接口融合

This commit is contained in:
dylanmay 2025-01-04 20:12:17 +08:00
parent b49339d08b
commit da92b5a582
4 changed files with 17 additions and 23 deletions

View File

@ -47,7 +47,9 @@ public class ImMessageController {
@GetMapping("/list")
@Operation(summary = "消息列表-根据接收人和发送时间进行分页查询")
public CommonResult<List<ImMessageRespVO>> getMessageList(@Valid ImMessageListReqVO listReqVO) {
List<ImMessageDO> messagePage = imMessageService.getMessageList(listReqVO);
Long loginUserId = getLoginUserId();
List<ImMessageDO> messagePage = imMessageService.getMessageList(listReqVO, loginUserId);
return success(BeanUtils.toBean(messagePage, ImMessageRespVO.class));
}

View File

@ -107,13 +107,13 @@ public class ImConversationServiceImpl implements ImConversationService {
conversation = insertConversation(no, loginUserId, createReqVO.getTargetId(), createReqVO.getType());
}
// TODO @dylan这个是不是不用 push 对于发送端它自己肯定知道对于接收端貌似收到 message 的时候再创建更合理一点
// 发送打开会话的通知并推送会话实体
// 给自己发送创建会话成功的通知
// 给自己发送创建会话成功的通知 方便多端登录的时候保持会话同时更新
webSocketMessageSender.sendObject(UserTypeEnum.ADMIN.getValue(), getLoginUserId(),
IM_CONVERSATION_ADD, conversation);
// 给接受者发送创建会话的通知
// TODO[dylan] 接受者在接收到消息的时候本地发现没有回话就按照会话编号创建一个因此可以不需要发送这个通知
webSocketMessageSender.sendObject(UserTypeEnum.ADMIN.getValue(), createReqVO.getTargetId(),
IM_CONVERSATION_ADD, conversation);
return conversation;

View File

@ -20,7 +20,7 @@ public interface ImMessageService {
* @param listReqVO 分页查询
* @return 消息分页
*/
List<ImMessageDO> getMessageList(ImMessageListReqVO listReqVO);
List<ImMessageDO> getMessageList(ImMessageListReqVO listReqVO, Long loginUserId);
/**
* 获得历史消息

View File

@ -116,31 +116,23 @@ public class UserController {
return success(UserConvert.INSTANCE.convertList(result, deptMap));
}
// TODO @dylan融合到 getSimpleUserList 接口允许传递 deptId 筛选
@GetMapping("/listByDept")
@Operation(summary = "获得部门用户列表")
@PreAuthorize("@ss.hasPermission('system:user:list')")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
public CommonResult<List<UserRespVO>> getDeptUsers(@RequestParam("id") Long id) {
List<Long> ids = new ArrayList<>();
ids.add(id);
List<AdminUserDO> result = userService.getDeptUsers(ids);
if (CollUtil.isEmpty(result)) {
return success(null);
}
// 拼接数据
Map<Long, DeptDO> deptMap = deptService.getDeptMap(
convertList(result, AdminUserDO::getDeptId));
return success(UserConvert.INSTANCE.convertList(result, deptMap));
}
@GetMapping({"/list-all-simple", "/simple-list"})
@Operation(summary = "获取用户精简信息列表", description = "只包含被开启的用户,主要用于前端的下拉选项")
public CommonResult<List<UserSimpleRespVO>> getSimpleUserList() {
List<AdminUserDO> list = userService.getUserListByStatus(CommonStatusEnum.ENABLE.getStatus());
public CommonResult<List<UserSimpleRespVO>> getSimpleUserList(@RequestParam("id") Long deptId) {
List<AdminUserDO> list;
if (deptId != null) {
List<Long> deptIds = Collections.singletonList(deptId);
list = userService.getDeptUsers(deptIds);
} else {
list = userService.getUserListByStatus(CommonStatusEnum.ENABLE.getStatus());
}
// 拼接数据
Map<Long, DeptDO> deptMap = deptService.getDeptMap(
convertList(list, AdminUserDO::getDeptId));
return success(UserConvert.INSTANCE.convertSimpleList(list, deptMap));
}