Commit da92b5a582c4ce6177cf1db9961f2f44b4d5f5f2
1 parent
b49339d0
接口融合
Showing
4 changed files
with
17 additions
and
23 deletions
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/controller/admin/message/ImMessageController.java
| @@ -47,7 +47,9 @@ public class ImMessageController { | @@ -47,7 +47,9 @@ public class ImMessageController { | ||
| 47 | @GetMapping("/list") | 47 | @GetMapping("/list") |
| 48 | @Operation(summary = "消息列表-根据接收人和发送时间进行分页查询") | 48 | @Operation(summary = "消息列表-根据接收人和发送时间进行分页查询") |
| 49 | public CommonResult<List<ImMessageRespVO>> getMessageList(@Valid ImMessageListReqVO listReqVO) { | 49 | public CommonResult<List<ImMessageRespVO>> getMessageList(@Valid ImMessageListReqVO listReqVO) { |
| 50 | - List<ImMessageDO> messagePage = imMessageService.getMessageList(listReqVO); | 50 | + |
| 51 | + Long loginUserId = getLoginUserId(); | ||
| 52 | + List<ImMessageDO> messagePage = imMessageService.getMessageList(listReqVO, loginUserId); | ||
| 51 | return success(BeanUtils.toBean(messagePage, ImMessageRespVO.class)); | 53 | return success(BeanUtils.toBean(messagePage, ImMessageRespVO.class)); |
| 52 | } | 54 | } |
| 53 | 55 |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/service/conversation/ImConversationServiceImpl.java
| @@ -107,13 +107,13 @@ public class ImConversationServiceImpl implements ImConversationService { | @@ -107,13 +107,13 @@ public class ImConversationServiceImpl implements ImConversationService { | ||
| 107 | conversation = insertConversation(no, loginUserId, createReqVO.getTargetId(), createReqVO.getType()); | 107 | conversation = insertConversation(no, loginUserId, createReqVO.getTargetId(), createReqVO.getType()); |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | - // TODO @dylan:这个是不是不用 push 呀。对于发送端,它自己肯定知道;对于接收端,貌似收到 message 的时候,再创建更合理一点。 | ||
| 111 | // 发送打开会话的通知,并推送会话实体 | 110 | // 发送打开会话的通知,并推送会话实体 |
| 112 | - // 给自己发送创建会话成功的通知 | 111 | + // 给自己发送创建会话成功的通知, 方便多端登录的时候保持会话同时更新 |
| 113 | webSocketMessageSender.sendObject(UserTypeEnum.ADMIN.getValue(), getLoginUserId(), | 112 | webSocketMessageSender.sendObject(UserTypeEnum.ADMIN.getValue(), getLoginUserId(), |
| 114 | IM_CONVERSATION_ADD, conversation); | 113 | IM_CONVERSATION_ADD, conversation); |
| 115 | 114 | ||
| 116 | // 给接受者发送创建会话的通知 | 115 | // 给接受者发送创建会话的通知 |
| 116 | + // TODO:[dylan] 接受者,在接收到消息的时候本地发现没有回话,就按照会话编号创建一个,因此可以不需要发送这个通知 | ||
| 117 | webSocketMessageSender.sendObject(UserTypeEnum.ADMIN.getValue(), createReqVO.getTargetId(), | 117 | webSocketMessageSender.sendObject(UserTypeEnum.ADMIN.getValue(), createReqVO.getTargetId(), |
| 118 | IM_CONVERSATION_ADD, conversation); | 118 | IM_CONVERSATION_ADD, conversation); |
| 119 | return conversation; | 119 | return conversation; |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/service/message/ImMessageService.java
| @@ -20,7 +20,7 @@ public interface ImMessageService { | @@ -20,7 +20,7 @@ public interface ImMessageService { | ||
| 20 | * @param listReqVO 分页查询 | 20 | * @param listReqVO 分页查询 |
| 21 | * @return 消息分页 | 21 | * @return 消息分页 |
| 22 | */ | 22 | */ |
| 23 | - List<ImMessageDO> getMessageList(ImMessageListReqVO listReqVO); | 23 | + List<ImMessageDO> getMessageList(ImMessageListReqVO listReqVO, Long loginUserId); |
| 24 | 24 | ||
| 25 | /** | 25 | /** |
| 26 | * 获得历史消息 | 26 | * 获得历史消息 |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java
| @@ -116,31 +116,23 @@ public class UserController { | @@ -116,31 +116,23 @@ public class UserController { | ||
| 116 | return success(UserConvert.INSTANCE.convertList(result, deptMap)); | 116 | return success(UserConvert.INSTANCE.convertList(result, deptMap)); |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | - // TODO @dylan:融合到 getSimpleUserList 接口,允许传递 deptId 筛选 | ||
| 120 | - @GetMapping("/listByDept") | ||
| 121 | - @Operation(summary = "获得部门用户列表") | ||
| 122 | - @PreAuthorize("@ss.hasPermission('system:user:list')") | ||
| 123 | - @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 124 | - public CommonResult<List<UserRespVO>> getDeptUsers(@RequestParam("id") Long id) { | ||
| 125 | - List<Long> ids = new ArrayList<>(); | ||
| 126 | - ids.add(id); | ||
| 127 | - List<AdminUserDO> result = userService.getDeptUsers(ids); | ||
| 128 | - if (CollUtil.isEmpty(result)) { | ||
| 129 | - return success(null); | ||
| 130 | - } | ||
| 131 | - // 拼接数据 | ||
| 132 | - Map<Long, DeptDO> deptMap = deptService.getDeptMap( | ||
| 133 | - convertList(result, AdminUserDO::getDeptId)); | ||
| 134 | - return success(UserConvert.INSTANCE.convertList(result, deptMap)); | ||
| 135 | - } | ||
| 136 | 119 | ||
| 137 | @GetMapping({"/list-all-simple", "/simple-list"}) | 120 | @GetMapping({"/list-all-simple", "/simple-list"}) |
| 138 | @Operation(summary = "获取用户精简信息列表", description = "只包含被开启的用户,主要用于前端的下拉选项") | 121 | @Operation(summary = "获取用户精简信息列表", description = "只包含被开启的用户,主要用于前端的下拉选项") |
| 139 | - public CommonResult<List<UserSimpleRespVO>> getSimpleUserList() { | ||
| 140 | - List<AdminUserDO> list = userService.getUserListByStatus(CommonStatusEnum.ENABLE.getStatus()); | 122 | + public CommonResult<List<UserSimpleRespVO>> getSimpleUserList(@RequestParam("id") Long deptId) { |
| 123 | + List<AdminUserDO> list; | ||
| 124 | + | ||
| 125 | + if (deptId != null) { | ||
| 126 | + List<Long> deptIds = Collections.singletonList(deptId); | ||
| 127 | + list = userService.getDeptUsers(deptIds); | ||
| 128 | + } else { | ||
| 129 | + list = userService.getUserListByStatus(CommonStatusEnum.ENABLE.getStatus()); | ||
| 130 | + } | ||
| 131 | + | ||
| 141 | // 拼接数据 | 132 | // 拼接数据 |
| 142 | Map<Long, DeptDO> deptMap = deptService.getDeptMap( | 133 | Map<Long, DeptDO> deptMap = deptService.getDeptMap( |
| 143 | convertList(list, AdminUserDO::getDeptId)); | 134 | convertList(list, AdminUserDO::getDeptId)); |
| 135 | + | ||
| 144 | return success(UserConvert.INSTANCE.convertSimpleList(list, deptMap)); | 136 | return success(UserConvert.INSTANCE.convertSimpleList(list, deptMap)); |
| 145 | } | 137 | } |
| 146 | 138 |