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