Commit 40be6ed727e97e690decdf4d5ad54691a2e05668
1 parent
788c24df
【代码评审】IM:会话、消息相关的接口
Showing
6 changed files
with
10 additions
and
8 deletions
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/controller/admin/conversation/ImConversationController.java
| ... | ... | @@ -46,6 +46,7 @@ public class ImConversationController { |
| 46 | 46 | public CommonResult<List<ImConversationRespVO>> getConversationList() { |
| 47 | 47 | List<ImConversationDO> conversationList = imConversationService.getConversationList(getLoginUserId()); |
| 48 | 48 | List<ImConversationRespVO> imConversationRespVOList = BeanUtils.toBean(conversationList, ImConversationRespVO.class); |
| 49 | + // TODO @dylan:这块,交给前端聚合哈。im 这块,我们重前端,后端更多解决消息的通信和存储。 | |
| 49 | 50 | imConversationRespVOList.forEach(item -> { |
| 50 | 51 | // 处理个人图像和昵称 |
| 51 | 52 | Long receiverId = item.getTargetId(); | ... | ... |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/controller/admin/conversation/vo/ImConversationRespVO.java
| 1 | 1 | package cn.iocoder.yudao.module.im.controller.admin.conversation.vo; |
| 2 | 2 | |
| 3 | -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | |
| 4 | -import com.alibaba.excel.annotation.ExcelProperty; | |
| 5 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 6 | 4 | import lombok.Data; |
| 7 | 5 | |
| ... | ... | @@ -35,6 +33,10 @@ public class ImConversationRespVO { |
| 35 | 33 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 36 | 34 | private LocalDateTime createTime; |
| 37 | 35 | |
| 36 | + // TODO @dylan:这块,交给前端聚合哈。im 这块,我们重前端,后端更多解决消息的通信和存储。 | |
| 37 | + // 1. 基础信息:根据会话类型,查询会话接受者的头像、昵称 | |
| 38 | + // 2. 未读信息:前端自己增量拉取,基于本地 db 查看 | |
| 39 | + | |
| 38 | 40 | @Schema(description = "会话接受者头像", requiredMode = Schema.RequiredMode.REQUIRED) |
| 39 | 41 | private String avatar; |
| 40 | 42 | ... | ... |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/controller/admin/message/vo/ImMessageListByNoReqVO.java
| 1 | 1 | package cn.iocoder.yudao.module.im.controller.admin.message.vo; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.framework.common.validation.InEnum; | |
| 4 | -import cn.iocoder.yudao.module.im.enums.conversation.ImConversationTypeEnum; | |
| 5 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 6 | 4 | import jakarta.validation.constraints.NotNull; |
| 7 | 5 | import lombok.Data; |
| ... | ... | @@ -12,6 +10,7 @@ import java.time.LocalDateTime; |
| 12 | 10 | |
| 13 | 11 | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; |
| 14 | 12 | |
| 13 | +// TODO @dylan:看看,是不是融合到 ImMessageListReqVO 里 | |
| 15 | 14 | @Schema(description = "管理后台 - 消息列表 Request VO") |
| 16 | 15 | @Data |
| 17 | 16 | @ToString(callSuper = true) | ... | ... |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/controller/admin/message/vo/ImMessageListReqVO.java
| ... | ... | @@ -5,7 +5,6 @@ import cn.iocoder.yudao.module.im.enums.conversation.ImConversationTypeEnum; |
| 5 | 5 | import io.swagger.v3.oas.annotations.media.Schema; |
| 6 | 6 | import jakarta.validation.constraints.NotNull; |
| 7 | 7 | import lombok.Data; |
| 8 | -import lombok.ToString; | |
| 9 | 8 | import org.springframework.format.annotation.DateTimeFormat; |
| 10 | 9 | |
| 11 | 10 | import java.time.LocalDateTime; |
| ... | ... | @@ -14,9 +13,9 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ |
| 14 | 13 | |
| 15 | 14 | @Schema(description = "管理后台 - 消息列表 Request VO") |
| 16 | 15 | @Data |
| 17 | -@ToString(callSuper = true) | |
| 18 | 16 | public class ImMessageListReqVO { |
| 19 | 17 | |
| 18 | + // TODO @dylan:是不是 receiverId 和 senderId 保留一个 receiverId 就行。这样,A + 自己(调用接口,从 getLoginUserId 拿),然后 conversationType,最终可以拼接出 conversationNo | |
| 20 | 19 | @Schema(description = "接收人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "32494") |
| 21 | 20 | @NotNull(message = "接收人编号不能为空") |
| 22 | 21 | private Long receiverId; |
| ... | ... | @@ -34,8 +33,9 @@ public class ImMessageListReqVO { |
| 34 | 33 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY) |
| 35 | 34 | private LocalDateTime sendTime; |
| 36 | 35 | |
| 36 | + // TODO @dylan:这个,可以根据 receiverId、senderId、conversationType 推导的,建议可以去掉。 | |
| 37 | 37 | @Schema(description = "会话编号编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "32494") |
| 38 | 38 | @NotNull(message = "会话编号不能为空") |
| 39 | - private String conversationNo ; | |
| 39 | + private String conversationNo; | |
| 40 | 40 | |
| 41 | 41 | } |
| 42 | 42 | \ No newline at end of file | ... | ... |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/controller/admin/message/vo/ImMessageSendReqVO.java
| ... | ... | @@ -24,6 +24,7 @@ public class ImMessageSendReqVO { |
| 24 | 24 | @NotNull(message = "会话类型不能为空") |
| 25 | 25 | private Integer conversationType; |
| 26 | 26 | |
| 27 | + // TODO @dylan:这个 conversationNo,直接计算哈。不用传递 | |
| 27 | 28 | @Schema(description = "会话编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") |
| 28 | 29 | @NotNull(message = "会话编号不能为空") |
| 29 | 30 | private String conversationNo; | ... | ... |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/service/message/ImMessageService.java