Commit 51e724fc906f387ce5e392a6b3531433451fd0db
1 parent
4015b2f2
修改:置顶会话和更新最后已读时间
Showing
30 changed files
with
278 additions
and
746 deletions
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/controller/admin/conversation/ConversationController.java
| @@ -2,15 +2,15 @@ package cn.iocoder.yudao.module.im.controller.admin.conversation; | @@ -2,15 +2,15 @@ package cn.iocoder.yudao.module.im.controller.admin.conversation; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 4 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 5 | +import cn.iocoder.yudao.module.im.controller.admin.conversation.vo.ConversationLastTimeReqVO; | ||
| 5 | import cn.iocoder.yudao.module.im.controller.admin.conversation.vo.ImConversationRespVO; | 6 | import cn.iocoder.yudao.module.im.controller.admin.conversation.vo.ImConversationRespVO; |
| 6 | -import cn.iocoder.yudao.module.im.controller.admin.conversation.vo.ImConversationSaveReqVO; | 7 | +import cn.iocoder.yudao.module.im.controller.admin.conversation.vo.ConversationPinnedReqVO; |
| 7 | import cn.iocoder.yudao.module.im.dal.dataobject.conversation.ConversationDO; | 8 | import cn.iocoder.yudao.module.im.dal.dataobject.conversation.ConversationDO; |
| 8 | import cn.iocoder.yudao.module.im.service.conversation.ConversationService; | 9 | import cn.iocoder.yudao.module.im.service.conversation.ConversationService; |
| 9 | import io.swagger.v3.oas.annotations.Operation; | 10 | import io.swagger.v3.oas.annotations.Operation; |
| 10 | import io.swagger.v3.oas.annotations.tags.Tag; | 11 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 11 | import jakarta.annotation.Resource; | 12 | import jakarta.annotation.Resource; |
| 12 | import jakarta.validation.Valid; | 13 | import jakarta.validation.Valid; |
| 13 | -import org.springframework.security.access.prepost.PreAuthorize; | ||
| 14 | import org.springframework.validation.annotation.Validated; | 14 | import org.springframework.validation.annotation.Validated; |
| 15 | import org.springframework.web.bind.annotation.*; | 15 | import org.springframework.web.bind.annotation.*; |
| 16 | 16 | ||
| @@ -18,33 +18,27 @@ import java.util.List; | @@ -18,33 +18,27 @@ import java.util.List; | ||
| 18 | 18 | ||
| 19 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 19 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 20 | 20 | ||
| 21 | -// TODO @hao: 管理后台 - IM 会话 | ||
| 22 | @Tag(name = "管理后台 - IM 会话") | 21 | @Tag(name = "管理后台 - IM 会话") |
| 23 | @RestController | 22 | @RestController |
| 24 | @RequestMapping("/im/conversation") | 23 | @RequestMapping("/im/conversation") |
| 25 | @Validated | 24 | @Validated |
| 26 | public class ConversationController { | 25 | public class ConversationController { |
| 27 | 26 | ||
| 28 | - // TODO @hao: conversationService 即可 | ||
| 29 | @Resource | 27 | @Resource |
| 30 | private ConversationService conversationService; | 28 | private ConversationService conversationService; |
| 31 | 29 | ||
| 32 | - // TODO @hao:/list 会话列表;一般 get 是给单个对象,或者 get-count 这种;然后 conversation 已经是模块名了,所以可以简化 | ||
| 33 | - @GetMapping("/get-conversation") | 30 | + @GetMapping("/list") |
| 34 | @Operation(summary = "获得用户的会话列表") | 31 | @Operation(summary = "获得用户的会话列表") |
| 35 | - @PreAuthorize("hasAuthority('im:conversation:query')") // TODO @hao:不用权限哈 | ||
| 36 | public CommonResult<List<ImConversationRespVO>> getConversationList() { | 32 | public CommonResult<List<ImConversationRespVO>> getConversationList() { |
| 37 | List<ConversationDO> conversationList = conversationService.getConversationList(); | 33 | List<ConversationDO> conversationList = conversationService.getConversationList(); |
| 38 | return success(BeanUtils.toBean(conversationList, ImConversationRespVO.class)); | 34 | return success(BeanUtils.toBean(conversationList, ImConversationRespVO.class)); |
| 39 | } | 35 | } |
| 40 | 36 | ||
| 41 | - // TODO @hao:/update-pinned 保持和 db 字段一致哈; | ||
| 42 | // TODO @hao:这个接口,需要单独的 VO 哈; | 37 | // TODO @hao:这个接口,需要单独的 VO 哈; |
| 43 | - @PostMapping("/update-top") | 38 | + @PostMapping("/update-pinned") |
| 44 | @Operation(summary = "置顶会话") | 39 | @Operation(summary = "置顶会话") |
| 45 | - @PreAuthorize("hasAuthority('im:conversation:update')") // TODO @hao:不用权限哈;因为肯定会判断是不是自己的 | ||
| 46 | - public CommonResult<Boolean> updateTop(@Valid @RequestBody ImConversationSaveReqVO updateReqVO) { | ||
| 47 | - conversationService.updateTop(updateReqVO); | 40 | + public CommonResult<Boolean> updatePinned(@Valid @RequestBody ConversationPinnedReqVO updateReqVO) { |
| 41 | + conversationService.updatePinned(updateReqVO); | ||
| 48 | return success(true); | 42 | return success(true); |
| 49 | } | 43 | } |
| 50 | 44 | ||
| @@ -52,8 +46,7 @@ public class ConversationController { | @@ -52,8 +46,7 @@ public class ConversationController { | ||
| 52 | // TODO @hao:这个接口,需要单独的 VO 哈; | 46 | // TODO @hao:这个接口,需要单独的 VO 哈; |
| 53 | @PostMapping("/update-last-read-time") | 47 | @PostMapping("/update-last-read-time") |
| 54 | @Operation(summary = "更新最后已读时间") | 48 | @Operation(summary = "更新最后已读时间") |
| 55 | - @PreAuthorize("hasAuthority('im:conversation:update')") // TODO @hao:不用权限哈;因为肯定会判断是不是自己的 | ||
| 56 | - public CommonResult<Boolean> updateLastReadTime(@Valid @RequestBody ImConversationSaveReqVO updateReqVO) { | 49 | + public CommonResult<Boolean> updateLastReadTime(@Valid @RequestBody ConversationLastTimeReqVO updateReqVO) { |
| 57 | conversationService.updateLastReadTime(updateReqVO); | 50 | conversationService.updateLastReadTime(updateReqVO); |
| 58 | return success(true); | 51 | return success(true); |
| 59 | } | 52 | } |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/controller/admin/conversation/vo/ConversationLastTimeReqVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.im.controller.admin.conversation.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import jakarta.validation.constraints.NotEmpty; | ||
| 5 | +import jakarta.validation.constraints.NotNull; | ||
| 6 | +import lombok.Data; | ||
| 7 | + | ||
| 8 | +import java.time.LocalDateTime; | ||
| 9 | + | ||
| 10 | +@Schema(description = "管理后台 - 会话最后已读时间 Request VO") | ||
| 11 | +@Data | ||
| 12 | +public class ConversationLastTimeReqVO { | ||
| 13 | + | ||
| 14 | + @Schema(description = "会话标志", requiredMode = Schema.RequiredMode.REQUIRED, example = "s_1_2") | ||
| 15 | + @NotEmpty(message = "会话标志不能为空") | ||
| 16 | + private String no; | ||
| 17 | + | ||
| 18 | + @Schema(description = "最后已读时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-03-01 00:00:00") | ||
| 19 | + @NotNull(message = "最后已读时间不能为空") | ||
| 20 | + private LocalDateTime lastReadTime; | ||
| 21 | + | ||
| 22 | + @Schema(description = "所属用户", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 23 | + private Long userId; | ||
| 24 | + | ||
| 25 | + @Schema(description = "聊天对象编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | ||
| 26 | + private Long targetId; | ||
| 27 | + | ||
| 28 | + @Schema(description = "会话类型",requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 29 | + private Integer type; //枚举 ConversationTypeEnum | ||
| 30 | + | ||
| 31 | +} | ||
| 0 | \ No newline at end of file | 32 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/controller/admin/conversation/vo/ConversationPinnedReqVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.im.controller.admin.conversation.vo; | ||
| 2 | + | ||
| 3 | +import com.alibaba.excel.annotation.ExcelProperty; | ||
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | +import jakarta.validation.constraints.NotEmpty; | ||
| 6 | +import jakarta.validation.constraints.NotNull; | ||
| 7 | +import lombok.Data; | ||
| 8 | + | ||
| 9 | +import java.time.LocalDateTime; | ||
| 10 | + | ||
| 11 | +@Schema(description = "管理后台 - 会话置顶 Request VO") | ||
| 12 | +@Data | ||
| 13 | +public class ConversationPinnedReqVO { | ||
| 14 | + | ||
| 15 | + @Schema(description = "会话标志", requiredMode = Schema.RequiredMode.REQUIRED, example = "s_1_2") | ||
| 16 | + @NotEmpty(message = "会话标志不能为空") | ||
| 17 | + private String no; | ||
| 18 | + | ||
| 19 | + @Schema(description = "是否置顶", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 20 | + @NotNull(message = "是否置顶不能为空") | ||
| 21 | + private Boolean pinned; | ||
| 22 | + | ||
| 23 | + @Schema(description = "所属用户", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 24 | + private Long userId; | ||
| 25 | + | ||
| 26 | + @Schema(description = "聊天对象编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | ||
| 27 | + private Long targetId; | ||
| 28 | + | ||
| 29 | + @Schema(description = "会话类型",requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 30 | + private Integer type; //枚举 ConversationTypeEnum | ||
| 31 | + | ||
| 32 | + | ||
| 33 | + | ||
| 34 | +} | ||
| 0 | \ No newline at end of file | 35 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/controller/admin/conversation/vo/ImConversationPageReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.im.controller.admin.conversation.vo; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 4 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | -import lombok.Data; | ||
| 6 | -import lombok.EqualsAndHashCode; | ||
| 7 | -import lombok.ToString; | ||
| 8 | -import org.springframework.format.annotation.DateTimeFormat; | ||
| 9 | - | ||
| 10 | -import java.time.LocalDateTime; | ||
| 11 | - | ||
| 12 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 13 | - | ||
| 14 | -// TODO @hao:这个貌似业务上,暂时用不到,可以考虑删除哈。 | ||
| 15 | -@Schema(description = "管理后台 - IM 会话分页 Request VO") | ||
| 16 | -@Data | ||
| 17 | -@EqualsAndHashCode(callSuper = true) | ||
| 18 | -@ToString(callSuper = true) | ||
| 19 | -public class ImConversationPageReqVO extends PageParam { | ||
| 20 | - | ||
| 21 | - @Schema(description = "所属用户", example = "11545") | ||
| 22 | - private Long userId; | ||
| 23 | - | ||
| 24 | - @Schema(description = "类型:1 单聊;2 群聊;4 通知会话(预留)", example = "1") | ||
| 25 | - private Integer type; | ||
| 26 | - | ||
| 27 | - @Schema(description = "单聊时,用户编号;群聊时,群编号", example = "21454") | ||
| 28 | - private Long targetId; | ||
| 29 | - | ||
| 30 | - @Schema(description = "会话标志 单聊:s_{userId}_{targetId},需要排序 userId 和 targetId 群聊:g_groupId") | ||
| 31 | - private String no; | ||
| 32 | - | ||
| 33 | - @Schema(description = "是否置顶 0否 1是") | ||
| 34 | - private Boolean pinned; | ||
| 35 | - | ||
| 36 | - @Schema(description = "最后已读时间") | ||
| 37 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 38 | - private LocalDateTime[] lastReadTime; | ||
| 39 | - | ||
| 40 | - @Schema(description = "创建时间") | ||
| 41 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 42 | - private LocalDateTime[] createTime; | ||
| 43 | - | ||
| 44 | -} | ||
| 45 | \ No newline at end of file | 0 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/controller/admin/conversation/vo/ImConversationRespVO.java
| @@ -9,45 +9,30 @@ import java.time.LocalDateTime; | @@ -9,45 +9,30 @@ import java.time.LocalDateTime; | ||
| 9 | 9 | ||
| 10 | @Schema(description = "管理后台 - 会话 Response VO") | 10 | @Schema(description = "管理后台 - 会话 Response VO") |
| 11 | @Data | 11 | @Data |
| 12 | -@ExcelIgnoreUnannotated // TODO @hao:excel 的注解可以先删除 | ||
| 13 | public class ImConversationRespVO { | 12 | public class ImConversationRespVO { |
| 14 | 13 | ||
| 15 | - // TODO @hao:example 都写下 | ||
| 16 | - | ||
| 17 | @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13905") | 14 | @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13905") |
| 18 | - @ExcelProperty("编号") | ||
| 19 | private Long id; | 15 | private Long id; |
| 20 | 16 | ||
| 21 | - @Schema(description = "所属用户", requiredMode = Schema.RequiredMode.REQUIRED, example = "11545") | ||
| 22 | - @ExcelProperty("所属用户") | 17 | + @Schema(description = "所属用户", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| 23 | private Long userId; | 18 | private Long userId; |
| 24 | 19 | ||
| 25 | - // TODO @hao:@Schema 可以改成“会话类型”,不用把具体的数字写在上面哈。这样后续改动,会比较难改 | ||
| 26 | - @Schema(description = "类型:1 单聊;2 群聊;4 通知会话(预留)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 27 | - @ExcelProperty("类型:1 单聊;2 群聊;4 通知会话(预留)") | 20 | + @Schema(description = "会话类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| 28 | private Integer conversationType; | 21 | private Integer conversationType; |
| 29 | 22 | ||
| 30 | - // TODO @hao:只写,聊天对象编号 | ||
| 31 | - @Schema(description = "单聊时,用户编号;群聊时,群编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "21454") | ||
| 32 | - @ExcelProperty("单聊时,用户编号;群聊时,群编号") | 23 | + @Schema(description = "聊天对象编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") |
| 33 | private Long targetId; | 24 | private Long targetId; |
| 34 | 25 | ||
| 35 | - // TODO @hao:只写 no 即可。 | ||
| 36 | - @Schema(description = "会话标志 单聊:s_{userId}_{targetId},需要排序 userId 和 targetId 群聊:g_groupId", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 37 | - @ExcelProperty("会话标志 单聊:s_{userId}_{targetId},需要排序 userId 和 targetId 群聊:g_groupId") | 26 | + @Schema(description = "会话标志", requiredMode = Schema.RequiredMode.REQUIRED, example = "s_1_2") |
| 38 | private String no; | 27 | private String no; |
| 39 | 28 | ||
| 40 | - // TODO @hao:只写 是否置顶;0 1 是数据库的结果哈; | ||
| 41 | - @Schema(description = "是否置顶 0否 1是", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 42 | - @ExcelProperty("是否置顶 0否 1是") | 29 | + @Schema(description = "是否置顶", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| 43 | private Boolean pinned; | 30 | private Boolean pinned; |
| 44 | 31 | ||
| 45 | - @Schema(description = "最后已读时间") | ||
| 46 | - @ExcelProperty("最后已读时间") | 32 | + @Schema(description = "最后已读时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-03-01 00:00:00") |
| 47 | private LocalDateTime lastReadTime; | 33 | private LocalDateTime lastReadTime; |
| 48 | 34 | ||
| 49 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | 35 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 50 | - @ExcelProperty("创建时间") | ||
| 51 | private LocalDateTime createTime; | 36 | private LocalDateTime createTime; |
| 52 | 37 | ||
| 53 | } | 38 | } |
| 54 | \ No newline at end of file | 39 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/controller/admin/conversation/vo/ImConversationSaveReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.im.controller.admin.conversation.vo; | ||
| 2 | - | ||
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | -import jakarta.validation.constraints.NotEmpty; | ||
| 5 | -import jakarta.validation.constraints.NotNull; | ||
| 6 | -import lombok.Data; | ||
| 7 | - | ||
| 8 | -import java.time.LocalDateTime; | ||
| 9 | - | ||
| 10 | -// TODO @hao:这个貌似业务上,暂时用不到,可以考虑删除哈。 | ||
| 11 | -@Schema(description = "管理后台 - 会话新增/修改 Request VO") | ||
| 12 | -@Data | ||
| 13 | -public class ImConversationSaveReqVO { | ||
| 14 | - | ||
| 15 | - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13905") | ||
| 16 | - private Long id; | ||
| 17 | - | ||
| 18 | - @Schema(description = "所属用户", requiredMode = Schema.RequiredMode.REQUIRED, example = "11545") | ||
| 19 | - @NotNull(message = "所属用户不能为空") | ||
| 20 | - private Long userId; | ||
| 21 | - | ||
| 22 | - @Schema(description = "类型:1 单聊;2 群聊;4 通知会话(预留)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 23 | - @NotNull(message = "类型:1 单聊;2 群聊;4 通知会话(预留)不能为空") | ||
| 24 | - private Integer type; | ||
| 25 | - | ||
| 26 | - @Schema(description = "单聊时,用户编号;群聊时,群编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "21454") | ||
| 27 | - @NotEmpty(message = "单聊时,用户编号;群聊时,群编号不能为空") | ||
| 28 | - private Long targetId; | ||
| 29 | - | ||
| 30 | - @Schema(description = "会话标志 单聊:s_{userId}_{targetId},需要排序 userId 和 targetId 群聊:g_groupId", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 31 | - @NotEmpty(message = "会话标志 单聊:s_{userId}_{targetId},需要排序 userId 和 targetId 群聊:g_groupId不能为空") | ||
| 32 | - private String no; | ||
| 33 | - | ||
| 34 | - @Schema(description = "是否置顶 0否 1是", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 35 | - @NotNull(message = "是否置顶 0否 1是不能为空") | ||
| 36 | - private Boolean pinned; | ||
| 37 | - | ||
| 38 | - @Schema(description = "最后已读时间") | ||
| 39 | - private LocalDateTime lastReadTime; | ||
| 40 | - | ||
| 41 | -} | ||
| 42 | \ No newline at end of file | 0 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/controller/admin/groupmember/ImGroupMemberController.java
| @@ -10,7 +10,7 @@ import cn.iocoder.yudao.module.im.controller.admin.groupmember.vo.ImGroupMemberP | @@ -10,7 +10,7 @@ import cn.iocoder.yudao.module.im.controller.admin.groupmember.vo.ImGroupMemberP | ||
| 10 | import cn.iocoder.yudao.module.im.controller.admin.groupmember.vo.ImGroupMemberRespVO; | 10 | import cn.iocoder.yudao.module.im.controller.admin.groupmember.vo.ImGroupMemberRespVO; |
| 11 | import cn.iocoder.yudao.module.im.controller.admin.groupmember.vo.ImGroupMemberSaveReqVO; | 11 | import cn.iocoder.yudao.module.im.controller.admin.groupmember.vo.ImGroupMemberSaveReqVO; |
| 12 | import cn.iocoder.yudao.module.im.dal.dataobject.group.GroupMemberDO; | 12 | import cn.iocoder.yudao.module.im.dal.dataobject.group.GroupMemberDO; |
| 13 | -import cn.iocoder.yudao.module.im.service.groupmember.ImGroupMemberService; | 13 | +import cn.iocoder.yudao.module.im.service.groupmember.GroupMemberService; |
| 14 | import io.swagger.v3.oas.annotations.Operation; | 14 | import io.swagger.v3.oas.annotations.Operation; |
| 15 | import io.swagger.v3.oas.annotations.Parameter; | 15 | import io.swagger.v3.oas.annotations.Parameter; |
| 16 | import io.swagger.v3.oas.annotations.tags.Tag; | 16 | import io.swagger.v3.oas.annotations.tags.Tag; |
| @@ -34,20 +34,20 @@ import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.E | @@ -34,20 +34,20 @@ import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.E | ||
| 34 | public class ImGroupMemberController { | 34 | public class ImGroupMemberController { |
| 35 | 35 | ||
| 36 | @Resource | 36 | @Resource |
| 37 | - private ImGroupMemberService imGroupMemberService; | 37 | + private GroupMemberService groupMemberService; |
| 38 | 38 | ||
| 39 | @PostMapping("/create") | 39 | @PostMapping("/create") |
| 40 | @Operation(summary = "创建群成员") | 40 | @Operation(summary = "创建群成员") |
| 41 | @PreAuthorize("@ss.hasPermission('im:group-member:create')") | 41 | @PreAuthorize("@ss.hasPermission('im:group-member:create')") |
| 42 | public CommonResult<Long> createGroupMember(@Valid @RequestBody ImGroupMemberSaveReqVO createReqVO) { | 42 | public CommonResult<Long> createGroupMember(@Valid @RequestBody ImGroupMemberSaveReqVO createReqVO) { |
| 43 | - return success(imGroupMemberService.createGroupMember(createReqVO)); | 43 | + return success(groupMemberService.createGroupMember(createReqVO)); |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | @PutMapping("/update") | 46 | @PutMapping("/update") |
| 47 | @Operation(summary = "更新群成员") | 47 | @Operation(summary = "更新群成员") |
| 48 | @PreAuthorize("@ss.hasPermission('im:group-member:update')") | 48 | @PreAuthorize("@ss.hasPermission('im:group-member:update')") |
| 49 | public CommonResult<Boolean> updateGroupMember(@Valid @RequestBody ImGroupMemberSaveReqVO updateReqVO) { | 49 | public CommonResult<Boolean> updateGroupMember(@Valid @RequestBody ImGroupMemberSaveReqVO updateReqVO) { |
| 50 | - imGroupMemberService.updateGroupMember(updateReqVO); | 50 | + groupMemberService.updateGroupMember(updateReqVO); |
| 51 | return success(true); | 51 | return success(true); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| @@ -56,7 +56,7 @@ public class ImGroupMemberController { | @@ -56,7 +56,7 @@ public class ImGroupMemberController { | ||
| 56 | @Parameter(name = "id", description = "编号", required = true) | 56 | @Parameter(name = "id", description = "编号", required = true) |
| 57 | @PreAuthorize("@ss.hasPermission('im:group-member:delete')") | 57 | @PreAuthorize("@ss.hasPermission('im:group-member:delete')") |
| 58 | public CommonResult<Boolean> deleteGroupMember(@RequestParam("id") Long id) { | 58 | public CommonResult<Boolean> deleteGroupMember(@RequestParam("id") Long id) { |
| 59 | - imGroupMemberService.deleteGroupMember(id); | 59 | + groupMemberService.deleteGroupMember(id); |
| 60 | return success(true); | 60 | return success(true); |
| 61 | } | 61 | } |
| 62 | 62 | ||
| @@ -65,7 +65,7 @@ public class ImGroupMemberController { | @@ -65,7 +65,7 @@ public class ImGroupMemberController { | ||
| 65 | @Parameter(name = "id", description = "编号", required = true, example = "1024") | 65 | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| 66 | @PreAuthorize("@ss.hasPermission('im:group-member:query')") | 66 | @PreAuthorize("@ss.hasPermission('im:group-member:query')") |
| 67 | public CommonResult<ImGroupMemberRespVO> getGroupMember(@RequestParam("id") Long id) { | 67 | public CommonResult<ImGroupMemberRespVO> getGroupMember(@RequestParam("id") Long id) { |
| 68 | - GroupMemberDO groupMember = imGroupMemberService.getGroupMember(id); | 68 | + GroupMemberDO groupMember = groupMemberService.getGroupMember(id); |
| 69 | return success(BeanUtils.toBean(groupMember, ImGroupMemberRespVO.class)); | 69 | return success(BeanUtils.toBean(groupMember, ImGroupMemberRespVO.class)); |
| 70 | } | 70 | } |
| 71 | 71 | ||
| @@ -73,7 +73,7 @@ public class ImGroupMemberController { | @@ -73,7 +73,7 @@ public class ImGroupMemberController { | ||
| 73 | @Operation(summary = "获得群成员分页") | 73 | @Operation(summary = "获得群成员分页") |
| 74 | @PreAuthorize("@ss.hasPermission('im:group-member:query')") | 74 | @PreAuthorize("@ss.hasPermission('im:group-member:query')") |
| 75 | public CommonResult<PageResult<ImGroupMemberRespVO>> getGroupMemberPage(@Valid ImGroupMemberPageReqVO pageReqVO) { | 75 | public CommonResult<PageResult<ImGroupMemberRespVO>> getGroupMemberPage(@Valid ImGroupMemberPageReqVO pageReqVO) { |
| 76 | - PageResult<GroupMemberDO> pageResult = imGroupMemberService.getGroupMemberPage(pageReqVO); | 76 | + PageResult<GroupMemberDO> pageResult = groupMemberService.getGroupMemberPage(pageReqVO); |
| 77 | return success(BeanUtils.toBean(pageResult, ImGroupMemberRespVO.class)); | 77 | return success(BeanUtils.toBean(pageResult, ImGroupMemberRespVO.class)); |
| 78 | } | 78 | } |
| 79 | 79 | ||
| @@ -84,7 +84,7 @@ public class ImGroupMemberController { | @@ -84,7 +84,7 @@ public class ImGroupMemberController { | ||
| 84 | public void exportGroupMemberExcel(@Valid ImGroupMemberPageReqVO pageReqVO, | 84 | public void exportGroupMemberExcel(@Valid ImGroupMemberPageReqVO pageReqVO, |
| 85 | HttpServletResponse response) throws IOException { | 85 | HttpServletResponse response) throws IOException { |
| 86 | pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | 86 | pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); |
| 87 | - List<GroupMemberDO> list = imGroupMemberService.getGroupMemberPage(pageReqVO).getList(); | 87 | + List<GroupMemberDO> list = groupMemberService.getGroupMemberPage(pageReqVO).getList(); |
| 88 | // 导出 Excel | 88 | // 导出 Excel |
| 89 | ExcelUtils.write(response, "群成员.xls", "数据", ImGroupMemberRespVO.class, | 89 | ExcelUtils.write(response, "群成员.xls", "数据", ImGroupMemberRespVO.class, |
| 90 | BeanUtils.toBean(list, ImGroupMemberRespVO.class)); | 90 | BeanUtils.toBean(list, ImGroupMemberRespVO.class)); |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/controller/admin/inbox/ImInboxController.java deleted
| 1 | -package cn.iocoder.yudao.module.im.controller.admin.inbox; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 4 | -import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 5 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 6 | -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 7 | -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||
| 8 | -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||
| 9 | -import cn.iocoder.yudao.module.im.controller.admin.inbox.vo.ImInboxPageReqVO; | ||
| 10 | -import cn.iocoder.yudao.module.im.controller.admin.inbox.vo.ImInboxRespVO; | ||
| 11 | -import cn.iocoder.yudao.module.im.controller.admin.inbox.vo.InboxSaveReqVO; | ||
| 12 | -import cn.iocoder.yudao.module.im.dal.dataobject.inbox.InboxDO; | ||
| 13 | -import cn.iocoder.yudao.module.im.service.inbox.ImInboxService; | ||
| 14 | -import io.swagger.v3.oas.annotations.Operation; | ||
| 15 | -import io.swagger.v3.oas.annotations.Parameter; | ||
| 16 | -import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 17 | -import jakarta.annotation.Resource; | ||
| 18 | -import jakarta.servlet.http.HttpServletResponse; | ||
| 19 | -import jakarta.validation.Valid; | ||
| 20 | -import org.springframework.security.access.prepost.PreAuthorize; | ||
| 21 | -import org.springframework.validation.annotation.Validated; | ||
| 22 | -import org.springframework.web.bind.annotation.*; | ||
| 23 | - | ||
| 24 | -import java.io.IOException; | ||
| 25 | -import java.util.List; | ||
| 26 | - | ||
| 27 | -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 28 | -import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | ||
| 29 | - | ||
| 30 | -@Tag(name = "管理后台 - 收件箱") | ||
| 31 | -@RestController | ||
| 32 | -@RequestMapping("/im/inbox") | ||
| 33 | -@Validated | ||
| 34 | -public class ImInboxController { | ||
| 35 | - | ||
| 36 | - @Resource | ||
| 37 | - private ImInboxService imInboxService; | ||
| 38 | - | ||
| 39 | - @PostMapping("/create") | ||
| 40 | - @Operation(summary = "创建收件箱") | ||
| 41 | - @PreAuthorize("@ss.hasPermission('im:inbox:create')") | ||
| 42 | - public CommonResult<Long> createInbox(@Valid @RequestBody InboxSaveReqVO createReqVO) { | ||
| 43 | - return success(imInboxService.createInbox(createReqVO)); | ||
| 44 | - } | ||
| 45 | - | ||
| 46 | - @PutMapping("/update") | ||
| 47 | - @Operation(summary = "更新收件箱") | ||
| 48 | - @PreAuthorize("@ss.hasPermission('im:inbox:update')") | ||
| 49 | - public CommonResult<Boolean> updateInbox(@Valid @RequestBody InboxSaveReqVO updateReqVO) { | ||
| 50 | - imInboxService.updateInbox(updateReqVO); | ||
| 51 | - return success(true); | ||
| 52 | - } | ||
| 53 | - | ||
| 54 | - @DeleteMapping("/delete") | ||
| 55 | - @Operation(summary = "删除收件箱") | ||
| 56 | - @Parameter(name = "id", description = "编号", required = true) | ||
| 57 | - @PreAuthorize("@ss.hasPermission('im:inbox:delete')") | ||
| 58 | - public CommonResult<Boolean> deleteInbox(@RequestParam("id") Long id) { | ||
| 59 | - imInboxService.deleteInbox(id); | ||
| 60 | - return success(true); | ||
| 61 | - } | ||
| 62 | - | ||
| 63 | - @GetMapping("/get") | ||
| 64 | - @Operation(summary = "获得收件箱") | ||
| 65 | - @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 66 | - @PreAuthorize("@ss.hasPermission('im:inbox:query')") | ||
| 67 | - public CommonResult<ImInboxRespVO> getInbox(@RequestParam("id") Long id) { | ||
| 68 | - InboxDO inbox = imInboxService.getInbox(id); | ||
| 69 | - return success(BeanUtils.toBean(inbox, ImInboxRespVO.class)); | ||
| 70 | - } | ||
| 71 | - | ||
| 72 | - @GetMapping("/page") | ||
| 73 | - @Operation(summary = "获得收件箱分页") | ||
| 74 | - @PreAuthorize("@ss.hasPermission('im:inbox:query')") | ||
| 75 | - public CommonResult<PageResult<ImInboxRespVO>> getInboxPage(@Valid ImInboxPageReqVO pageReqVO) { | ||
| 76 | - PageResult<InboxDO> pageResult = imInboxService.getInboxPage(pageReqVO); | ||
| 77 | - return success(BeanUtils.toBean(pageResult, ImInboxRespVO.class)); | ||
| 78 | - } | ||
| 79 | - | ||
| 80 | - @GetMapping("/export-excel") | ||
| 81 | - @Operation(summary = "导出收件箱 Excel") | ||
| 82 | - @PreAuthorize("@ss.hasPermission('im:inbox:export')") | ||
| 83 | - @OperateLog(type = EXPORT) | ||
| 84 | - public void exportInboxExcel(@Valid ImInboxPageReqVO pageReqVO, | ||
| 85 | - HttpServletResponse response) throws IOException { | ||
| 86 | - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | ||
| 87 | - List<InboxDO> list = imInboxService.getInboxPage(pageReqVO).getList(); | ||
| 88 | - // 导出 Excel | ||
| 89 | - ExcelUtils.write(response, "收件箱.xls", "数据", ImInboxRespVO.class, | ||
| 90 | - BeanUtils.toBean(list, ImInboxRespVO.class)); | ||
| 91 | - } | ||
| 92 | - | ||
| 93 | -} | ||
| 94 | \ No newline at end of file | 0 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/controller/admin/inbox/package-info.java
0 → 100644
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/controller/admin/inbox/vo/ImInboxPageReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.im.controller.admin.inbox.vo; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 4 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | -import lombok.Data; | ||
| 6 | -import lombok.EqualsAndHashCode; | ||
| 7 | -import lombok.ToString; | ||
| 8 | -import org.springframework.format.annotation.DateTimeFormat; | ||
| 9 | - | ||
| 10 | -import java.time.LocalDateTime; | ||
| 11 | - | ||
| 12 | -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 13 | - | ||
| 14 | -// TODO @hao:这个是不是删除掉,应该不会有这个 VO 哈 | ||
| 15 | -@Schema(description = "管理后台 - 收件箱分页 Request VO") | ||
| 16 | -@Data | ||
| 17 | -@EqualsAndHashCode(callSuper = true) | ||
| 18 | -@ToString(callSuper = true) | ||
| 19 | -public class ImInboxPageReqVO extends PageParam { | ||
| 20 | - | ||
| 21 | - @Schema(description = "用户编号", example = "3979") | ||
| 22 | - private Long userId; | ||
| 23 | - | ||
| 24 | - @Schema(description = "消息编号", example = "12454") | ||
| 25 | - private Long messageId; | ||
| 26 | - | ||
| 27 | - @Schema(description = "序号,按照 user 递增") | ||
| 28 | - private Long sequence; | ||
| 29 | - | ||
| 30 | - @Schema(description = "创建时间") | ||
| 31 | - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 32 | - private LocalDateTime[] createTime; | ||
| 33 | - | ||
| 34 | -} | ||
| 35 | \ No newline at end of file | 0 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/controller/admin/inbox/vo/ImInboxRespVO.java deleted
| 1 | -package cn.iocoder.yudao.module.im.controller.admin.inbox.vo; | ||
| 2 | - | ||
| 3 | -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | ||
| 4 | -import com.alibaba.excel.annotation.ExcelProperty; | ||
| 5 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 6 | -import lombok.Data; | ||
| 7 | - | ||
| 8 | -import java.time.LocalDateTime; | ||
| 9 | - | ||
| 10 | -// TODO @hao:这个是不是删除掉,应该不会有这个 VO 哈;应该给前端的,是要屏蔽掉这个表,最终返回的都是 Message 哈;说白了,这个 inbox 是后端的内部实现 | ||
| 11 | -@Schema(description = "管理后台 - 收件箱 Response VO") | ||
| 12 | -@Data | ||
| 13 | -@ExcelIgnoreUnannotated | ||
| 14 | -public class ImInboxRespVO { | ||
| 15 | - | ||
| 16 | - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18389") | ||
| 17 | - @ExcelProperty("编号") | ||
| 18 | - private Long id; | ||
| 19 | - | ||
| 20 | - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3979") | ||
| 21 | - @ExcelProperty("用户编号") | ||
| 22 | - private Long userId; | ||
| 23 | - | ||
| 24 | - @Schema(description = "消息编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "12454") | ||
| 25 | - @ExcelProperty("消息编号") | ||
| 26 | - private Long messageId; | ||
| 27 | - | ||
| 28 | - @Schema(description = "序号,按照 user 递增", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 29 | - @ExcelProperty("序号,按照 user 递增") | ||
| 30 | - private Long sequence; | ||
| 31 | - | ||
| 32 | - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 33 | - @ExcelProperty("创建时间") | ||
| 34 | - private LocalDateTime createTime; | ||
| 35 | - | ||
| 36 | -} | ||
| 37 | \ No newline at end of file | 0 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/controller/admin/inbox/vo/InboxSaveReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.im.controller.admin.inbox.vo; | ||
| 2 | - | ||
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | -import jakarta.validation.constraints.NotNull; | ||
| 5 | -import lombok.AllArgsConstructor; | ||
| 6 | -import lombok.Data; | ||
| 7 | -import lombok.NoArgsConstructor; | ||
| 8 | - | ||
| 9 | -// TODO @hao:这个是不是删除掉,应该不会有这个 VO 哈 | ||
| 10 | -@Schema(description = "管理后台 - 收件箱新增/修改 Request VO") | ||
| 11 | -@Data | ||
| 12 | -@AllArgsConstructor | ||
| 13 | -@NoArgsConstructor | ||
| 14 | -public class InboxSaveReqVO { | ||
| 15 | - | ||
| 16 | - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18389") | ||
| 17 | - private Long id; | ||
| 18 | - | ||
| 19 | - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3979") | ||
| 20 | - @NotNull(message = "用户编号不能为空") | ||
| 21 | - private Long userId; | ||
| 22 | - | ||
| 23 | - @Schema(description = "消息编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "12454") | ||
| 24 | - @NotNull(message = "消息编号不能为空") | ||
| 25 | - private Long messageId; | ||
| 26 | - | ||
| 27 | - @Schema(description = "序号,按照 user 递增", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 28 | - @NotNull(message = "序号,按照 user 递增不能为空") | ||
| 29 | - private Long sequence; | ||
| 30 | - | ||
| 31 | - public InboxSaveReqVO(Long userId, Long messageId, Long sequence) { | ||
| 32 | - this.userId = userId; | ||
| 33 | - this.messageId = messageId; | ||
| 34 | - this.sequence = sequence; | ||
| 35 | - } | ||
| 36 | - | ||
| 37 | -} | ||
| 38 | \ No newline at end of file | 0 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/controller/admin/message/MessageController.java
| @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.im.controller.admin.message; | @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.im.controller.admin.message; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 4 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 5 | import cn.iocoder.yudao.module.im.controller.admin.message.vo.MessagePageReqVO; | 5 | import cn.iocoder.yudao.module.im.controller.admin.message.vo.MessagePageReqVO; |
| 6 | -import cn.iocoder.yudao.module.im.controller.admin.message.vo.ImMessageReqVO; | 6 | +import cn.iocoder.yudao.module.im.controller.admin.message.vo.MessageReqVO; |
| 7 | import cn.iocoder.yudao.module.im.controller.admin.message.vo.SendMessageReqVO; | 7 | import cn.iocoder.yudao.module.im.controller.admin.message.vo.SendMessageReqVO; |
| 8 | import cn.iocoder.yudao.module.im.controller.admin.message.vo.SendMessageRespVO; | 8 | import cn.iocoder.yudao.module.im.controller.admin.message.vo.SendMessageRespVO; |
| 9 | import cn.iocoder.yudao.module.im.dal.dataobject.message.MessageDO; | 9 | import cn.iocoder.yudao.module.im.dal.dataobject.message.MessageDO; |
| @@ -40,18 +40,18 @@ public class MessageController { | @@ -40,18 +40,18 @@ public class MessageController { | ||
| 40 | @Operation(summary = "拉取大于 sequence 的消息列表") | 40 | @Operation(summary = "拉取大于 sequence 的消息列表") |
| 41 | @Parameter(name = "sequence", description = "序号", required = true, example = "1") | 41 | @Parameter(name = "sequence", description = "序号", required = true, example = "1") |
| 42 | @Parameter(name = "size", description = "条数", required = true, example = "10") | 42 | @Parameter(name = "size", description = "条数", required = true, example = "10") |
| 43 | - public CommonResult<List<ImMessageReqVO>> loadMessage(@RequestParam("sequence") Long sequence, | ||
| 44 | - @RequestParam("size") Integer size) { | 43 | + public CommonResult<List<MessageReqVO>> getMessageListBySequence(@RequestParam("sequence") Long sequence, |
| 44 | + @RequestParam("size") Integer size) { | ||
| 45 | List<MessageDO> messages = messageService.getMessageListBySequence(getLoginUserId(), sequence, size); | 45 | List<MessageDO> messages = messageService.getMessageListBySequence(getLoginUserId(), sequence, size); |
| 46 | - return success(BeanUtils.toBean(messages, ImMessageReqVO.class)); | 46 | + return success(BeanUtils.toBean(messages, MessageReqVO.class)); |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | - @GetMapping("/page") | ||
| 50 | - @Operation(summary = "查询聊天记录-分页") | ||
| 51 | - public CommonResult<List<ImMessageReqVO>> getMessagePage(@Valid MessagePageReqVO pageReqVO) { | 49 | + @GetMapping("/history") |
| 50 | + @Operation(summary = "查询聊天记录-根据会话标志和发送时间进行分页查询") | ||
| 51 | + public CommonResult<List<MessageReqVO>> getHistoryMessage(@Valid MessagePageReqVO pageReqVO) { | ||
| 52 | //根据会话标志和发送时间进行分页查询 | 52 | //根据会话标志和发送时间进行分页查询 |
| 53 | - List<MessageDO> messagePage = messageService.getMessagePage(pageReqVO); | ||
| 54 | - return success(BeanUtils.toBean(messagePage, ImMessageReqVO.class)); | 53 | + List<MessageDO> messagePage = messageService.getHistoryMessage(pageReqVO); |
| 54 | + return success(BeanUtils.toBean(messagePage, MessageReqVO.class)); | ||
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | } | 57 | } |
| 58 | \ No newline at end of file | 58 | \ 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/ImMessageReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.im.controller.admin.message.vo; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.validation.InEnum; | ||
| 4 | -import cn.iocoder.yudao.module.im.enums.message.MessageContentTypeEnum; | ||
| 5 | -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | ||
| 6 | -import com.alibaba.excel.annotation.ExcelProperty; | ||
| 7 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 8 | -import lombok.Data; | ||
| 9 | - | ||
| 10 | -@Schema(description = "管理后台 - 消息 Request VO") | ||
| 11 | -@Data | ||
| 12 | -@ExcelIgnoreUnannotated | ||
| 13 | -public class ImMessageReqVO { | ||
| 14 | - | ||
| 15 | - @Schema(description = "客户端消息编号 uuid,用于排重", requiredMode = Schema.RequiredMode.REQUIRED, example = "3331") | ||
| 16 | - @ExcelProperty("客户端消息编号 uuid,用于排重") | ||
| 17 | - private String clientMessageId; | ||
| 18 | - | ||
| 19 | - @Schema(description = "接收人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "32494") | ||
| 20 | - @ExcelProperty("接收人编号") | ||
| 21 | - private Long receiverId; | ||
| 22 | - | ||
| 23 | - @Schema(description = "会话类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | ||
| 24 | - @ExcelProperty("会话类型") | ||
| 25 | - private Integer conversationType; | ||
| 26 | - | ||
| 27 | - @Schema(description = "消息类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 28 | - @ExcelProperty("消息类型") | ||
| 29 | - @InEnum(MessageContentTypeEnum.class) | ||
| 30 | - private Integer contentType; | ||
| 31 | - | ||
| 32 | - @Schema(description = "消息内容", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 33 | - @ExcelProperty("消息内容") | ||
| 34 | - private String content; | ||
| 35 | - | ||
| 36 | -} | ||
| 37 | \ No newline at end of file | 0 | \ 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/ImMessageSaveReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.im.controller.admin.message.vo; | ||
| 2 | - | ||
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | -import jakarta.validation.constraints.NotEmpty; | ||
| 5 | -import jakarta.validation.constraints.NotNull; | ||
| 6 | -import lombok.Data; | ||
| 7 | - | ||
| 8 | -import java.time.LocalDateTime; | ||
| 9 | - | ||
| 10 | -@Schema(description = "管理后台 - 消息新增/修改 Request VO") | ||
| 11 | -@Data | ||
| 12 | -public class ImMessageSaveReqVO { | ||
| 13 | - | ||
| 14 | - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30713") | ||
| 15 | - private Long id; | ||
| 16 | - | ||
| 17 | - @Schema(description = "客户端消息编号 uuid,用于排重", requiredMode = Schema.RequiredMode.REQUIRED, example = "3331") | ||
| 18 | - @NotEmpty(message = "客户端消息编号 uuid,用于排重不能为空") | ||
| 19 | - private String clientMessageId; | ||
| 20 | - | ||
| 21 | - @Schema(description = "发送人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23239") | ||
| 22 | - @NotNull(message = "发送人编号不能为空") | ||
| 23 | - private Long senderId; | ||
| 24 | - | ||
| 25 | - @Schema(description = "接收人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "32494") | ||
| 26 | - @NotNull(message = "接收人编号不能为空") | ||
| 27 | - private Long receiverId; | ||
| 28 | - | ||
| 29 | - @Schema(description = "发送人昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") | ||
| 30 | - @NotEmpty(message = "发送人昵称不能为空") | ||
| 31 | - private String senderNickname; | ||
| 32 | - | ||
| 33 | - @Schema(description = "发送人头像", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 34 | - @NotEmpty(message = "发送人头像不能为空") | ||
| 35 | - private String senderAvatar; | ||
| 36 | - | ||
| 37 | - @Schema(description = "会话类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | ||
| 38 | - @NotNull(message = "会话类型不能为空") | ||
| 39 | - private Integer conversationType; | ||
| 40 | - | ||
| 41 | - @Schema(description = "会话标志 conversation_no = a_b", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 42 | - @NotEmpty(message = "会话标志不能为空") | ||
| 43 | - private String conversationNo; | ||
| 44 | - | ||
| 45 | - @Schema(description = "消息类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 46 | - @NotNull(message = "消息类型不能为空") | ||
| 47 | - private Integer contentType; | ||
| 48 | - | ||
| 49 | - @Schema(description = "消息内容", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 50 | - @NotEmpty(message = "消息内容不能为空") | ||
| 51 | - private String content; | ||
| 52 | - | ||
| 53 | - @Schema(description = "发送时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 54 | - private LocalDateTime sendTime; | ||
| 55 | - | ||
| 56 | - @Schema(description = "消息来源 100-用户发送;200-系统发送(一般是通知);", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 57 | - @NotNull(message = "消息来源 100-用户发送;200-系统发送(一般是通知);不能为空") | ||
| 58 | - private Integer sendFrom; | ||
| 59 | - | ||
| 60 | - @Schema(description = "消息状态 1 发送中、2 发送成功、3 发送失败、4 已删除、5 已撤回", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 61 | - @NotNull(message = "消息状态不能为空") | ||
| 62 | - private Integer messageStatus; | ||
| 63 | -} | ||
| 64 | \ No newline at end of file | 0 | \ 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/MessageReqVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.im.controller.admin.message.vo; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | ||
| 4 | +import cn.iocoder.yudao.module.im.enums.message.MessageContentTypeEnum; | ||
| 5 | +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | ||
| 6 | +import com.alibaba.excel.annotation.ExcelProperty; | ||
| 7 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 8 | +import lombok.Data; | ||
| 9 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 10 | + | ||
| 11 | +import java.time.LocalDateTime; | ||
| 12 | + | ||
| 13 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 14 | + | ||
| 15 | +@Schema(description = "管理后台 - 消息 Request VO") | ||
| 16 | +@Data | ||
| 17 | +public class MessageReqVO { | ||
| 18 | + | ||
| 19 | + @Schema(description = "消息编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "12454") | ||
| 20 | + private Long id; | ||
| 21 | + | ||
| 22 | + @Schema(description = "会话类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 23 | + private Integer conversationType; // 对应 ImConversationTypeEnum 枚举 | ||
| 24 | + | ||
| 25 | + @Schema(description = "发送人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 26 | + private Long fromId; // 根据 conversationType 区分 | ||
| 27 | + | ||
| 28 | + @Schema(description = "发送人昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") | ||
| 29 | + private String senderNickname; | ||
| 30 | + | ||
| 31 | + @Schema(description = "发送人头像", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 32 | + private String senderAvatar; | ||
| 33 | + | ||
| 34 | + @Schema(description = "接收人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "32494") | ||
| 35 | + private Long receiverId; | ||
| 36 | + | ||
| 37 | + @Schema(description = "内容类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 38 | + private Integer contentType; // 参见 ImMessageTypeEnum 枚举 | ||
| 39 | + | ||
| 40 | + @Schema(description = "消息内容", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 41 | + private String content; | ||
| 42 | + | ||
| 43 | + @Schema(description = "发送时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 44 | + private LocalDateTime sendTime; | ||
| 45 | + | ||
| 46 | + @Schema(description = "序号", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 47 | + private Long sequence; | ||
| 48 | + | ||
| 49 | +} | ||
| 0 | \ No newline at end of file | 50 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/dal/mysql/conversation/ConversationMapper.java
| 1 | package cn.iocoder.yudao.module.im.dal.mysql.conversation; | 1 | package cn.iocoder.yudao.module.im.dal.mysql.conversation; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | 4 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 6 | -import cn.iocoder.yudao.module.im.controller.admin.conversation.vo.ImConversationPageReqVO; | ||
| 7 | import cn.iocoder.yudao.module.im.dal.dataobject.conversation.ConversationDO; | 5 | import cn.iocoder.yudao.module.im.dal.dataobject.conversation.ConversationDO; |
| 8 | import org.apache.ibatis.annotations.Mapper; | 6 | import org.apache.ibatis.annotations.Mapper; |
| 9 | 7 | ||
| @@ -15,20 +13,7 @@ import org.apache.ibatis.annotations.Mapper; | @@ -15,20 +13,7 @@ import org.apache.ibatis.annotations.Mapper; | ||
| 15 | @Mapper | 13 | @Mapper |
| 16 | public interface ConversationMapper extends BaseMapperX<ConversationDO> { | 14 | public interface ConversationMapper extends BaseMapperX<ConversationDO> { |
| 17 | 15 | ||
| 18 | - default PageResult<ConversationDO> selectPage(ImConversationPageReqVO reqVO) { | ||
| 19 | - return selectPage(reqVO, new LambdaQueryWrapperX<ConversationDO>() | ||
| 20 | - .eqIfPresent(ConversationDO::getUserId, reqVO.getUserId()) | ||
| 21 | - .eqIfPresent(ConversationDO::getType, reqVO.getType()) | ||
| 22 | - .eqIfPresent(ConversationDO::getTargetId, reqVO.getTargetId()) | ||
| 23 | - .eqIfPresent(ConversationDO::getNo, reqVO.getNo()) | ||
| 24 | - .eqIfPresent(ConversationDO::getPinned, reqVO.getPinned()) | ||
| 25 | - .betweenIfPresent(ConversationDO::getLastReadTime, reqVO.getLastReadTime()) | ||
| 26 | - .betweenIfPresent(ConversationDO::getCreateTime, reqVO.getCreateTime()) | ||
| 27 | - .orderByDesc(ConversationDO::getId)); | ||
| 28 | - } | ||
| 29 | - | ||
| 30 | - // TODO @hao:1)no) {,要有空格哈;2)可以直接 selectOne(ImConversationDO::getNo, no) 父类做了封装 | ||
| 31 | default ConversationDO selectByNo(String no){ | 16 | default ConversationDO selectByNo(String no){ |
| 32 | - return selectOne(new LambdaQueryWrapperX<ConversationDO>().eq(ConversationDO::getNo, no)); | 17 | + return selectOne(ConversationDO::getNo, no); |
| 33 | } | 18 | } |
| 34 | } | 19 | } |
| 35 | \ No newline at end of file | 20 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/dal/mysql/inbox/ImInboxMapper.java deleted
| 1 | -package cn.iocoder.yudao.module.im.dal.mysql.inbox; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | -import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 5 | -import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 6 | -import cn.iocoder.yudao.module.im.controller.admin.inbox.vo.ImInboxPageReqVO; | ||
| 7 | -import cn.iocoder.yudao.module.im.dal.dataobject.inbox.InboxDO; | ||
| 8 | -import org.apache.ibatis.annotations.Mapper; | ||
| 9 | - | ||
| 10 | -/** | ||
| 11 | - * IM 收件箱 Mapper | ||
| 12 | - * | ||
| 13 | - * @author 芋道源码 | ||
| 14 | - */ | ||
| 15 | -@Mapper | ||
| 16 | -public interface ImInboxMapper extends BaseMapperX<InboxDO> { | ||
| 17 | - | ||
| 18 | - default PageResult<InboxDO> selectPage(ImInboxPageReqVO reqVO) { | ||
| 19 | - return selectPage(reqVO, new LambdaQueryWrapperX<InboxDO>() | ||
| 20 | - .eqIfPresent(InboxDO::getUserId, reqVO.getUserId()) | ||
| 21 | - .eqIfPresent(InboxDO::getMessageId, reqVO.getMessageId()) | ||
| 22 | - .eqIfPresent(InboxDO::getSequence, reqVO.getSequence()) | ||
| 23 | - .betweenIfPresent(InboxDO::getCreateTime, reqVO.getCreateTime()) | ||
| 24 | - .orderByDesc(InboxDO::getId)); | ||
| 25 | - } | ||
| 26 | - | ||
| 27 | -} | ||
| 28 | \ No newline at end of file | 0 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/dal/mysql/inbox/InboxMapper.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.im.dal.mysql.inbox; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 5 | +import cn.iocoder.yudao.module.im.dal.dataobject.inbox.InboxDO; | ||
| 6 | +import org.apache.ibatis.annotations.Mapper; | ||
| 7 | + | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * IM 收件箱 Mapper | ||
| 12 | + * | ||
| 13 | + * @author 芋道源码 | ||
| 14 | + */ | ||
| 15 | +@Mapper | ||
| 16 | +public interface InboxMapper extends BaseMapperX<InboxDO> { | ||
| 17 | + | ||
| 18 | + default List<Long> selectMessageIdsByUserIdAndSequence(Long userId, Long sequence, Integer size) { | ||
| 19 | + return selectList(new LambdaQueryWrapperX<InboxDO>() | ||
| 20 | + .gt(InboxDO::getUserId, userId) | ||
| 21 | + .gt(InboxDO::getSequence, sequence) | ||
| 22 | + .orderByAsc(InboxDO::getSequence) | ||
| 23 | + .last("limit 0," + size)) | ||
| 24 | + .stream() | ||
| 25 | + .map(InboxDO::getMessageId) | ||
| 26 | + .toList(); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | +// default PageResult<InboxDO> selectPage(ImInboxPageReqVO reqVO) { | ||
| 30 | +// return selectPage(reqVO, new LambdaQueryWrapperX<InboxDO>() | ||
| 31 | +// .eqIfPresent(InboxDO::getUserId, reqVO.getUserId()) | ||
| 32 | +// .eqIfPresent(InboxDO::getMessageId, reqVO.getMessageId()) | ||
| 33 | +// .eqIfPresent(InboxDO::getSequence, reqVO.getSequence()) | ||
| 34 | +// .betweenIfPresent(InboxDO::getCreateTime, reqVO.getCreateTime()) | ||
| 35 | +// .orderByDesc(InboxDO::getId)); | ||
| 36 | +// } | ||
| 37 | + | ||
| 38 | +} | ||
| 0 | \ No newline at end of file | 39 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/dal/mysql/message/MessageMapper.java
| @@ -18,30 +18,7 @@ import java.util.List; | @@ -18,30 +18,7 @@ import java.util.List; | ||
| 18 | @Mapper | 18 | @Mapper |
| 19 | public interface MessageMapper extends BaseMapperX<MessageDO> { | 19 | public interface MessageMapper extends BaseMapperX<MessageDO> { |
| 20 | 20 | ||
| 21 | - // TODO @hao:不链表哈;先从 ImInboxDO 查询出 messageId,然后再到 ImMessageDO 里 IN | ||
| 22 | - default List<MessageDO> getGreaterThanSequenceMessage(Long userId, Long sequence, Integer size) { | ||
| 23 | - //查询 inbox 表中,大于 sequence 的消息,关联 message 表,按照 inbox 表 sequence 升序 | ||
| 24 | - return selectJoinList(MessageDO.class, new MPJLambdaWrapper<MessageDO>() | ||
| 25 | - .selectAll(MessageDO.class) | ||
| 26 | - .innerJoin(InboxDO.class, InboxDO::getMessageId, MessageDO::getId) | ||
| 27 | - .eq(InboxDO::getUserId, userId) | ||
| 28 | - .gt(InboxDO::getSequence, sequence) | ||
| 29 | - .orderByAsc(InboxDO::getSequence) | ||
| 30 | - .last("limit 0," + size)); | ||
| 31 | - } | ||
| 32 | - | ||
| 33 | - // TODO @hao:在 dao 里,使用 selectListByUserId,查询用 select,条件用 by,这个算是 spring data 的 method dsl | ||
| 34 | - default List<MessageDO> getAllMessage(Long userId, Integer size) { | ||
| 35 | - //查询 inbox 表中,100条消息,关联 message 表,按照 inbox 表 sequence 降序 | ||
| 36 | - return selectJoinList(MessageDO.class, new MPJLambdaWrapper<MessageDO>() | ||
| 37 | - .selectAll(MessageDO.class) | ||
| 38 | - .innerJoin(InboxDO.class, InboxDO::getMessageId, MessageDO::getId) | ||
| 39 | - .eq(InboxDO::getUserId, userId) | ||
| 40 | - .orderByDesc(InboxDO::getSequence) | ||
| 41 | - .last("limit 0," + size)); | ||
| 42 | - } | ||
| 43 | - | ||
| 44 | - default List<MessageDO> getMessagePage(MessagePageReqVO pageReqVO) { | 21 | + default List<MessageDO> getHistoryMessage(MessagePageReqVO pageReqVO) { |
| 45 | return selectList(new LambdaQueryWrapperX<MessageDO>() | 22 | return selectList(new LambdaQueryWrapperX<MessageDO>() |
| 46 | .eqIfPresent(MessageDO::getConversationNo, pageReqVO.getConversationNo()) | 23 | .eqIfPresent(MessageDO::getConversationNo, pageReqVO.getConversationNo()) |
| 47 | .betweenIfPresent(MessageDO::getSendTime, pageReqVO.getSendTime()) | 24 | .betweenIfPresent(MessageDO::getSendTime, pageReqVO.getSendTime()) |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/service/conversation/ConversationService.java
| 1 | package cn.iocoder.yudao.module.im.service.conversation; | 1 | package cn.iocoder.yudao.module.im.service.conversation; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | -import cn.iocoder.yudao.module.im.controller.admin.conversation.vo.ImConversationPageReqVO; | ||
| 5 | -import cn.iocoder.yudao.module.im.controller.admin.conversation.vo.ImConversationSaveReqVO; | 3 | +import cn.iocoder.yudao.module.im.controller.admin.conversation.vo.ConversationLastTimeReqVO; |
| 4 | +import cn.iocoder.yudao.module.im.controller.admin.conversation.vo.ConversationPinnedReqVO; | ||
| 6 | import cn.iocoder.yudao.module.im.dal.dataobject.conversation.ConversationDO; | 5 | import cn.iocoder.yudao.module.im.dal.dataobject.conversation.ConversationDO; |
| 7 | -import jakarta.validation.Valid; | ||
| 8 | 6 | ||
| 9 | import java.util.List; | 7 | import java.util.List; |
| 10 | 8 | ||
| @@ -16,45 +14,6 @@ import java.util.List; | @@ -16,45 +14,6 @@ import java.util.List; | ||
| 16 | public interface ConversationService { | 14 | public interface ConversationService { |
| 17 | 15 | ||
| 18 | /** | 16 | /** |
| 19 | - * 创建会话 | ||
| 20 | - * | ||
| 21 | - * @param createReqVO 创建信息 | ||
| 22 | - * @return 编号 | ||
| 23 | - */ | ||
| 24 | - Long createConversation(@Valid ImConversationSaveReqVO createReqVO); | ||
| 25 | - | ||
| 26 | - /** | ||
| 27 | - * 更新会话 | ||
| 28 | - * | ||
| 29 | - * @param updateReqVO 更新信息 | ||
| 30 | - */ | ||
| 31 | - void updateConversation(@Valid ImConversationSaveReqVO updateReqVO); | ||
| 32 | - | ||
| 33 | - /** | ||
| 34 | - * 删除会话 | ||
| 35 | - * | ||
| 36 | - * @param id 编号 | ||
| 37 | - */ | ||
| 38 | - void deleteConversation(Long id); | ||
| 39 | - | ||
| 40 | - /** | ||
| 41 | - * 获得会话 | ||
| 42 | - * | ||
| 43 | - * @param id 编号 | ||
| 44 | - * @return 会话 | ||
| 45 | - */ | ||
| 46 | - ConversationDO getConversation(Long id); | ||
| 47 | - | ||
| 48 | - /** | ||
| 49 | - * 获得会话分页 | ||
| 50 | - * | ||
| 51 | - * @param pageReqVO 分页查询 | ||
| 52 | - * @return 会话分页 | ||
| 53 | - */ | ||
| 54 | - PageResult<ConversationDO> getConversationPage(ImConversationPageReqVO pageReqVO); | ||
| 55 | - | ||
| 56 | - | ||
| 57 | - /** | ||
| 58 | * 获得用户的会话列表 | 17 | * 获得用户的会话列表 |
| 59 | * | 18 | * |
| 60 | * @return 会话列表 | 19 | * @return 会话列表 |
| @@ -66,13 +25,13 @@ public interface ConversationService { | @@ -66,13 +25,13 @@ public interface ConversationService { | ||
| 66 | * | 25 | * |
| 67 | * @param updateReqVO 更新信息 | 26 | * @param updateReqVO 更新信息 |
| 68 | */ | 27 | */ |
| 69 | - void updateTop(ImConversationSaveReqVO updateReqVO); | 28 | + void updatePinned(ConversationPinnedReqVO updateReqVO); |
| 70 | 29 | ||
| 71 | /** | 30 | /** |
| 72 | * 更新最后已读时间 | 31 | * 更新最后已读时间 |
| 73 | * | 32 | * |
| 74 | * @param updateReqVO 更新信息 | 33 | * @param updateReqVO 更新信息 |
| 75 | */ | 34 | */ |
| 76 | - void updateLastReadTime(ImConversationSaveReqVO updateReqVO); | 35 | + void updateLastReadTime(ConversationLastTimeReqVO updateReqVO); |
| 77 | 36 | ||
| 78 | } | 37 | } |
| 79 | \ No newline at end of file | 38 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/service/conversation/ConversationServiceImpl.java
| 1 | package cn.iocoder.yudao.module.im.service.conversation; | 1 | package cn.iocoder.yudao.module.im.service.conversation; |
| 2 | 2 | ||
| 3 | -import cn.hutool.core.date.DateUtil; | ||
| 4 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 3 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 6 | -import cn.iocoder.yudao.module.im.controller.admin.conversation.vo.ImConversationPageReqVO; | ||
| 7 | -import cn.iocoder.yudao.module.im.controller.admin.conversation.vo.ImConversationSaveReqVO; | 4 | +import cn.iocoder.yudao.module.im.controller.admin.conversation.vo.ConversationLastTimeReqVO; |
| 5 | +import cn.iocoder.yudao.module.im.controller.admin.conversation.vo.ConversationPinnedReqVO; | ||
| 8 | import cn.iocoder.yudao.module.im.dal.dataobject.conversation.ConversationDO; | 6 | import cn.iocoder.yudao.module.im.dal.dataobject.conversation.ConversationDO; |
| 9 | import cn.iocoder.yudao.module.im.dal.mysql.conversation.ConversationMapper; | 7 | import cn.iocoder.yudao.module.im.dal.mysql.conversation.ConversationMapper; |
| 8 | +import cn.iocoder.yudao.module.im.service.inbox.InboxService; | ||
| 10 | import jakarta.annotation.Resource; | 9 | import jakarta.annotation.Resource; |
| 11 | import org.springframework.stereotype.Service; | 10 | import org.springframework.stereotype.Service; |
| 12 | import org.springframework.validation.annotation.Validated; | 11 | import org.springframework.validation.annotation.Validated; |
| 13 | 12 | ||
| 14 | -import java.util.Date; | ||
| 15 | import java.util.List; | 13 | import java.util.List; |
| 16 | 14 | ||
| 17 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 15 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 18 | -import static cn.iocoder.yudao.module.im.enums.ErrorCodeConstants.CONVERSATION_NOT_EXISTS; | ||
| 19 | 16 | ||
| 20 | /** | 17 | /** |
| 21 | * IM 会话 Service 实现类 | 18 | * IM 会话 Service 实现类 |
| @@ -26,52 +23,10 @@ import static cn.iocoder.yudao.module.im.enums.ErrorCodeConstants.CONVERSATION_N | @@ -26,52 +23,10 @@ import static cn.iocoder.yudao.module.im.enums.ErrorCodeConstants.CONVERSATION_N | ||
| 26 | @Validated | 23 | @Validated |
| 27 | public class ConversationServiceImpl implements ConversationService { | 24 | public class ConversationServiceImpl implements ConversationService { |
| 28 | 25 | ||
| 29 | - // TODO @hao: 自己模块的注入,不用带 im 前缀哈; | ||
| 30 | @Resource | 26 | @Resource |
| 31 | private ConversationMapper conversationMapper; | 27 | private ConversationMapper conversationMapper; |
| 32 | - | ||
| 33 | - // TODO @hao: 这个方法,是不是不需要哈 | ||
| 34 | - @Override | ||
| 35 | - public Long createConversation(ImConversationSaveReqVO createReqVO) { | ||
| 36 | - ConversationDO conversation = BeanUtils.toBean(createReqVO, ConversationDO.class); | ||
| 37 | - conversationMapper.insert(conversation); | ||
| 38 | - return conversation.getId(); | ||
| 39 | - } | ||
| 40 | - | ||
| 41 | - // TODO @hao: 这个方法,是不是不需要哈 | ||
| 42 | - @Override | ||
| 43 | - public void updateConversation(ImConversationSaveReqVO updateReqVO) { | ||
| 44 | - // 校验存在 | ||
| 45 | - validateConversationExists(updateReqVO.getId()); | ||
| 46 | - // 更新 | ||
| 47 | - ConversationDO updateObj = BeanUtils.toBean(updateReqVO, ConversationDO.class); | ||
| 48 | - conversationMapper.updateById(updateObj); | ||
| 49 | - } | ||
| 50 | - | ||
| 51 | - // TODO @hao: 考虑到可能和端上不同步,可以不校验是不是存储。另外,不基于 id 删除。要基于 no + userId 删除哈。说白了,对端上要屏蔽 id 字段 | ||
| 52 | - @Override | ||
| 53 | - public void deleteConversation(Long id) { | ||
| 54 | - // 校验存在 | ||
| 55 | - validateConversationExists(id); | ||
| 56 | - // 删除 | ||
| 57 | - conversationMapper.deleteById(id); | ||
| 58 | - } | ||
| 59 | - | ||
| 60 | - private void validateConversationExists(Long id) { | ||
| 61 | - if (conversationMapper.selectById(id) == null) { | ||
| 62 | - throw exception(CONVERSATION_NOT_EXISTS); | ||
| 63 | - } | ||
| 64 | - } | ||
| 65 | - | ||
| 66 | - @Override | ||
| 67 | - public ConversationDO getConversation(Long id) { | ||
| 68 | - return conversationMapper.selectById(id); | ||
| 69 | - } | ||
| 70 | - | ||
| 71 | - @Override | ||
| 72 | - public PageResult<ConversationDO> getConversationPage(ImConversationPageReqVO pageReqVO) { | ||
| 73 | - return conversationMapper.selectPage(pageReqVO); | ||
| 74 | - } | 28 | + @Resource |
| 29 | + private InboxService inboxService; | ||
| 75 | 30 | ||
| 76 | @Override | 31 | @Override |
| 77 | public List<ConversationDO> getConversationList() { | 32 | public List<ConversationDO> getConversationList() { |
| @@ -79,31 +34,39 @@ public class ConversationServiceImpl implements ConversationService { | @@ -79,31 +34,39 @@ public class ConversationServiceImpl implements ConversationService { | ||
| 79 | } | 34 | } |
| 80 | 35 | ||
| 81 | @Override | 36 | @Override |
| 82 | - public void updateTop(ImConversationSaveReqVO updateReqVO) { | ||
| 83 | - createOrUpdateConversation(updateReqVO); | ||
| 84 | - } | 37 | + public void updatePinned(ConversationPinnedReqVO updateReqVO) { |
| 38 | + // TODO @hao:updateTop 和 updateLastReadTime 使用独立的逻辑实现,不使用统一的 ImConversationSaveReqVO; | ||
| 39 | + // TODO 大体步骤建议: | ||
| 40 | + // 1. 先 getOrderCreateConversation,查询会话,不存在则插入; | ||
| 41 | + // 2. 更新对应的字段 | ||
| 42 | + // 3. 做对应更新的 notify 推送 | ||
| 43 | + ConversationDO conversation = conversationMapper.selectByNo(updateReqVO.getNo()); | ||
| 44 | + if (conversation == null) { | ||
| 45 | + ConversationDO conversationDO = new ConversationDO(); | ||
| 46 | + conversationDO.setNo(updateReqVO.getNo()); | ||
| 47 | + conversationDO.setPinned(updateReqVO.getPinned()); | ||
| 48 | + conversationDO.setUserId(updateReqVO.getUserId()); | ||
| 49 | + conversationDO.setTargetId(updateReqVO.getTargetId()); | ||
| 50 | + conversationDO.setType(updateReqVO.getType()); | ||
| 51 | + conversationMapper.insert(conversationDO); | ||
| 52 | + } else { | ||
| 53 | + // 更新 | ||
| 54 | + ConversationDO updateObj = BeanUtils.toBean(updateReqVO, ConversationDO.class); | ||
| 55 | + conversationMapper.updateById(updateObj); | ||
| 56 | + } | ||
| 85 | 57 | ||
| 86 | - @Override | ||
| 87 | - public void updateLastReadTime(ImConversationSaveReqVO updateReqVO) { | ||
| 88 | - createOrUpdateConversation(updateReqVO); | ||
| 89 | } | 58 | } |
| 90 | 59 | ||
| 91 | - // TODO @hao:updateTop 和 updateLastReadTime 使用独立的逻辑实现,不使用统一的 ImConversationSaveReqVO; | ||
| 92 | - // TODO 大体步骤建议: | ||
| 93 | - // 1. 先 getOrderCreateConversation,查询会话,不存在则插入; | ||
| 94 | - // 2. 更新对应的字段 | ||
| 95 | - // 3. 做对应更新的 notify 推送 | ||
| 96 | - private void createOrUpdateConversation(ImConversationSaveReqVO updateReqVO) { | ||
| 97 | - // 操作会话(已读、置顶)时,才会延迟创建,要先判断是否存在,根据 no 查询是否存在,不存在则新增 | 60 | + @Override |
| 61 | + public void updateLastReadTime(ConversationLastTimeReqVO updateReqVO) { | ||
| 98 | ConversationDO conversation = conversationMapper.selectByNo(updateReqVO.getNo()); | 62 | ConversationDO conversation = conversationMapper.selectByNo(updateReqVO.getNo()); |
| 99 | if (conversation == null) { | 63 | if (conversation == null) { |
| 100 | ConversationDO conversationDO = new ConversationDO(); | 64 | ConversationDO conversationDO = new ConversationDO(); |
| 101 | conversationDO.setNo(updateReqVO.getNo()); | 65 | conversationDO.setNo(updateReqVO.getNo()); |
| 66 | + conversationDO.setLastReadTime(updateReqVO.getLastReadTime()); | ||
| 102 | conversationDO.setUserId(updateReqVO.getUserId()); | 67 | conversationDO.setUserId(updateReqVO.getUserId()); |
| 103 | conversationDO.setTargetId(updateReqVO.getTargetId()); | 68 | conversationDO.setTargetId(updateReqVO.getTargetId()); |
| 104 | conversationDO.setType(updateReqVO.getType()); | 69 | conversationDO.setType(updateReqVO.getType()); |
| 105 | - conversationDO.setPinned(updateReqVO.getPinned()); | ||
| 106 | - conversationDO.setLastReadTime(DateUtil.toLocalDateTime(new Date())); | ||
| 107 | conversationMapper.insert(conversationDO); | 70 | conversationMapper.insert(conversationDO); |
| 108 | } else { | 71 | } else { |
| 109 | // 更新 | 72 | // 更新 |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/service/groupmember/ImGroupMemberService.java renamed to yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/service/groupmember/GroupMemberService.java
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/service/groupmember/ImGroupMemberServiceImpl.java renamed to yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/service/groupmember/GroupMemberServiceImpl.java
| @@ -23,7 +23,7 @@ import static cn.iocoder.yudao.module.im.enums.ErrorCodeConstants.*; | @@ -23,7 +23,7 @@ import static cn.iocoder.yudao.module.im.enums.ErrorCodeConstants.*; | ||
| 23 | */ | 23 | */ |
| 24 | @Service | 24 | @Service |
| 25 | @Validated | 25 | @Validated |
| 26 | -public class ImGroupMemberServiceImpl implements ImGroupMemberService { | 26 | +public class GroupMemberServiceImpl implements GroupMemberService { |
| 27 | 27 | ||
| 28 | @Resource | 28 | @Resource |
| 29 | private ImGroupMemberMapper imGroupMemberMapper; | 29 | private ImGroupMemberMapper imGroupMemberMapper; |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/service/inbox/ImInboxService.java deleted
| 1 | -package cn.iocoder.yudao.module.im.service.inbox; | ||
| 2 | - | ||
| 3 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | -import cn.iocoder.yudao.module.im.controller.admin.inbox.vo.ImInboxPageReqVO; | ||
| 5 | -import cn.iocoder.yudao.module.im.controller.admin.inbox.vo.InboxSaveReqVO; | ||
| 6 | -import cn.iocoder.yudao.module.im.controller.admin.inbox.vo.InboxSaveMessageReqVO; | ||
| 7 | -import cn.iocoder.yudao.module.im.dal.dataobject.inbox.InboxDO; | ||
| 8 | -import jakarta.validation.Valid; | ||
| 9 | - | ||
| 10 | -// TODO @hao:不用的方法,删除下哈; | ||
| 11 | -/** | ||
| 12 | - * IM 收件箱 Service 接口 | ||
| 13 | - * | ||
| 14 | - * @author 芋道源码 | ||
| 15 | - */ | ||
| 16 | -public interface ImInboxService { | ||
| 17 | - | ||
| 18 | - /** | ||
| 19 | - * 创建收件箱 | ||
| 20 | - * | ||
| 21 | - * @param createReqVO 创建信息 | ||
| 22 | - * @return 编号 | ||
| 23 | - */ | ||
| 24 | - Long createInbox(@Valid InboxSaveReqVO createReqVO); | ||
| 25 | - | ||
| 26 | - /** | ||
| 27 | - * 更新收件箱 | ||
| 28 | - * | ||
| 29 | - * @param updateReqVO 更新信息 | ||
| 30 | - */ | ||
| 31 | - void updateInbox(@Valid InboxSaveReqVO updateReqVO); | ||
| 32 | - | ||
| 33 | - /** | ||
| 34 | - * 删除收件箱 | ||
| 35 | - * | ||
| 36 | - * @param id 编号 | ||
| 37 | - */ | ||
| 38 | - void deleteInbox(Long id); | ||
| 39 | - | ||
| 40 | - /** | ||
| 41 | - * 获得收件箱 | ||
| 42 | - * | ||
| 43 | - * @param id 编号 | ||
| 44 | - * @return 收件箱 | ||
| 45 | - */ | ||
| 46 | - InboxDO getInbox(Long id); | ||
| 47 | - | ||
| 48 | - /** | ||
| 49 | - * 获得收件箱分页 | ||
| 50 | - * | ||
| 51 | - * @param pageReqVO 分页查询 | ||
| 52 | - * @return 收件箱分页 | ||
| 53 | - */ | ||
| 54 | - PageResult<InboxDO> getInboxPage(ImInboxPageReqVO pageReqVO); | ||
| 55 | - | ||
| 56 | - /** | ||
| 57 | - * 保存收件箱和发送消息 | ||
| 58 | - * @param inboxSaveMessageReqVO 收件箱保存消息 Request VO | ||
| 59 | - */ | ||
| 60 | - void saveInboxAndSendMessage(InboxSaveMessageReqVO inboxSaveMessageReqVO); | ||
| 61 | -} | ||
| 62 | \ No newline at end of file | 0 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/service/inbox/InboxService.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.im.service.inbox; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.module.im.controller.admin.inbox.vo.InboxSaveMessageReqVO; | ||
| 4 | + | ||
| 5 | +import java.util.List; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * IM 收件箱 Service 接口 | ||
| 9 | + * | ||
| 10 | + * @author 芋道源码 | ||
| 11 | + */ | ||
| 12 | +public interface InboxService { | ||
| 13 | + | ||
| 14 | + /** | ||
| 15 | + * 保存收件箱和发送消息 | ||
| 16 | + * | ||
| 17 | + * @param inboxSaveMessageReqVO 收件箱保存消息 Request VO | ||
| 18 | + */ | ||
| 19 | + void saveInboxAndSendMessage(InboxSaveMessageReqVO inboxSaveMessageReqVO); | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * 获得大于 sequence 的消息ids | ||
| 23 | + * | ||
| 24 | + * @param userId 用户编号 | ||
| 25 | + * @param sequence 序列号 | ||
| 26 | + * @param size 数量 | ||
| 27 | + * @return 消息编号列表 | ||
| 28 | + */ | ||
| 29 | + List<Long> selectMessageIdsByUserIdAndSequence(Long userId, Long sequence, Integer size); | ||
| 30 | +} | ||
| 0 | \ No newline at end of file | 31 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/service/inbox/ImInboxServiceImpl.java renamed to yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/service/inbox/InboxServiceImpl.java
| 1 | package cn.iocoder.yudao.module.im.service.inbox; | 1 | package cn.iocoder.yudao.module.im.service.inbox; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | 3 | import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; |
| 4 | -import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 4 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 6 | import cn.iocoder.yudao.framework.websocket.core.sender.WebSocketMessageSender; | 5 | import cn.iocoder.yudao.framework.websocket.core.sender.WebSocketMessageSender; |
| 7 | -import cn.iocoder.yudao.module.im.controller.admin.inbox.vo.ImInboxPageReqVO; | ||
| 8 | import cn.iocoder.yudao.module.im.controller.admin.inbox.vo.InboxSaveMessageReqVO; | 6 | import cn.iocoder.yudao.module.im.controller.admin.inbox.vo.InboxSaveMessageReqVO; |
| 9 | -import cn.iocoder.yudao.module.im.controller.admin.inbox.vo.InboxSaveReqVO; | ||
| 10 | import cn.iocoder.yudao.module.im.controller.admin.inbox.vo.InboxSendMessageReqVO; | 7 | import cn.iocoder.yudao.module.im.controller.admin.inbox.vo.InboxSendMessageReqVO; |
| 11 | import cn.iocoder.yudao.module.im.dal.dataobject.group.GroupMemberDO; | 8 | import cn.iocoder.yudao.module.im.dal.dataobject.group.GroupMemberDO; |
| 12 | import cn.iocoder.yudao.module.im.dal.dataobject.inbox.InboxDO; | 9 | import cn.iocoder.yudao.module.im.dal.dataobject.inbox.InboxDO; |
| 13 | -import cn.iocoder.yudao.module.im.dal.mysql.inbox.ImInboxMapper; | 10 | +import cn.iocoder.yudao.module.im.dal.mysql.inbox.InboxMapper; |
| 14 | import cn.iocoder.yudao.module.im.dal.redis.inbox.InboxLockRedisDAO; | 11 | import cn.iocoder.yudao.module.im.dal.redis.inbox.InboxLockRedisDAO; |
| 15 | import cn.iocoder.yudao.module.im.dal.redis.inbox.SequenceRedisDao; | 12 | import cn.iocoder.yudao.module.im.dal.redis.inbox.SequenceRedisDao; |
| 16 | import cn.iocoder.yudao.module.im.enums.conversation.ConversationTypeEnum; | 13 | import cn.iocoder.yudao.module.im.enums.conversation.ConversationTypeEnum; |
| 17 | -import cn.iocoder.yudao.module.im.service.groupmember.ImGroupMemberService; | 14 | +import cn.iocoder.yudao.module.im.service.groupmember.GroupMemberService; |
| 18 | import jakarta.annotation.Resource; | 15 | import jakarta.annotation.Resource; |
| 19 | import org.dromara.hutool.core.date.DateUnit; | 16 | import org.dromara.hutool.core.date.DateUnit; |
| 20 | import org.springframework.stereotype.Service; | 17 | import org.springframework.stereotype.Service; |
| @@ -22,9 +19,6 @@ import org.springframework.validation.annotation.Validated; | @@ -22,9 +19,6 @@ import org.springframework.validation.annotation.Validated; | ||
| 22 | 19 | ||
| 23 | import java.util.List; | 20 | import java.util.List; |
| 24 | 21 | ||
| 25 | -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 26 | -import static cn.iocoder.yudao.module.im.enums.ErrorCodeConstants.INBOX_NOT_EXISTS; | ||
| 27 | - | ||
| 28 | /** | 22 | /** |
| 29 | * 收件箱 Service 实现类 | 23 | * 收件箱 Service 实现类 |
| 30 | * | 24 | * |
| @@ -32,13 +26,13 @@ import static cn.iocoder.yudao.module.im.enums.ErrorCodeConstants.INBOX_NOT_EXIS | @@ -32,13 +26,13 @@ import static cn.iocoder.yudao.module.im.enums.ErrorCodeConstants.INBOX_NOT_EXIS | ||
| 32 | */ | 26 | */ |
| 33 | @Service | 27 | @Service |
| 34 | @Validated | 28 | @Validated |
| 35 | -public class ImInboxServiceImpl implements ImInboxService { | 29 | +public class InboxServiceImpl implements InboxService { |
| 36 | 30 | ||
| 37 | private static final Long INBOX_LOCK_TIMEOUT = 120 * DateUnit.SECOND.getMillis(); | 31 | private static final Long INBOX_LOCK_TIMEOUT = 120 * DateUnit.SECOND.getMillis(); |
| 38 | private static final String IM_MESSAGE_RECEIVE = "im-message-receive"; | 32 | private static final String IM_MESSAGE_RECEIVE = "im-message-receive"; |
| 39 | 33 | ||
| 40 | @Resource | 34 | @Resource |
| 41 | - private ImInboxMapper imInboxMapper; | 35 | + private InboxMapper inboxMapper; |
| 42 | @Resource | 36 | @Resource |
| 43 | private SequenceRedisDao sequenceRedisDao; // 序列生成器Redis DAO | 37 | private SequenceRedisDao sequenceRedisDao; // 序列生成器Redis DAO |
| 44 | @Resource | 38 | @Resource |
| @@ -46,47 +40,7 @@ public class ImInboxServiceImpl implements ImInboxService { | @@ -46,47 +40,7 @@ public class ImInboxServiceImpl implements ImInboxService { | ||
| 46 | @Resource | 40 | @Resource |
| 47 | private WebSocketMessageSender webSocketMessageSender; // WebSocket消息发送器 | 41 | private WebSocketMessageSender webSocketMessageSender; // WebSocket消息发送器 |
| 48 | @Resource | 42 | @Resource |
| 49 | - private ImGroupMemberService imGroupMemberService; | ||
| 50 | - | ||
| 51 | - @Override | ||
| 52 | - public Long createInbox(InboxSaveReqVO createReqVO) { | ||
| 53 | - InboxDO inbox = BeanUtils.toBean(createReqVO, InboxDO.class); | ||
| 54 | - imInboxMapper.insert(inbox); | ||
| 55 | - return inbox.getId(); | ||
| 56 | - } | ||
| 57 | - | ||
| 58 | - @Override | ||
| 59 | - public void updateInbox(InboxSaveReqVO updateReqVO) { | ||
| 60 | - // 校验存在 | ||
| 61 | - validateInboxExists(updateReqVO.getId()); | ||
| 62 | - // 更新 | ||
| 63 | - InboxDO updateObj = BeanUtils.toBean(updateReqVO, InboxDO.class); | ||
| 64 | - imInboxMapper.updateById(updateObj); | ||
| 65 | - } | ||
| 66 | - | ||
| 67 | - @Override | ||
| 68 | - public void deleteInbox(Long id) { | ||
| 69 | - // 校验存在 | ||
| 70 | - validateInboxExists(id); | ||
| 71 | - // 删除 | ||
| 72 | - imInboxMapper.deleteById(id); | ||
| 73 | - } | ||
| 74 | - | ||
| 75 | - private void validateInboxExists(Long id) { | ||
| 76 | - if (imInboxMapper.selectById(id) == null) { | ||
| 77 | - throw exception(INBOX_NOT_EXISTS); | ||
| 78 | - } | ||
| 79 | - } | ||
| 80 | - | ||
| 81 | - @Override | ||
| 82 | - public InboxDO getInbox(Long id) { | ||
| 83 | - return imInboxMapper.selectById(id); | ||
| 84 | - } | ||
| 85 | - | ||
| 86 | - @Override | ||
| 87 | - public PageResult<InboxDO> getInboxPage(ImInboxPageReqVO pageReqVO) { | ||
| 88 | - return imInboxMapper.selectPage(pageReqVO); | ||
| 89 | - } | 43 | + private GroupMemberService groupMemberService; |
| 90 | 44 | ||
| 91 | @Override | 45 | @Override |
| 92 | public void saveInboxAndSendMessage(InboxSaveMessageReqVO inboxSaveMessage) { | 46 | public void saveInboxAndSendMessage(InboxSaveMessageReqVO inboxSaveMessage) { |
| @@ -96,11 +50,16 @@ public class ImInboxServiceImpl implements ImInboxService { | @@ -96,11 +50,16 @@ public class ImInboxServiceImpl implements ImInboxService { | ||
| 96 | if (inboxSaveMessage.getConversationType().equals(ConversationTypeEnum.SINGLE.getType())) { | 50 | if (inboxSaveMessage.getConversationType().equals(ConversationTypeEnum.SINGLE.getType())) { |
| 97 | saveInboxAndSendMessageForUser(inboxSaveMessage.getReceiverId(), inboxSaveMessage); | 51 | saveInboxAndSendMessageForUser(inboxSaveMessage.getReceiverId(), inboxSaveMessage); |
| 98 | } else if (inboxSaveMessage.getConversationType().equals(ConversationTypeEnum.GROUP.getType())) { | 52 | } else if (inboxSaveMessage.getConversationType().equals(ConversationTypeEnum.GROUP.getType())) { |
| 99 | - List<GroupMemberDO> groupMembers = imGroupMemberService.selectByGroupId(inboxSaveMessage.getReceiverId()); | 53 | + List<GroupMemberDO> groupMembers = groupMemberService.selectByGroupId(inboxSaveMessage.getReceiverId()); |
| 100 | groupMembers.forEach(groupMemberDO -> saveInboxAndSendMessageForUser(groupMemberDO.getUserId(), inboxSaveMessage)); | 54 | groupMembers.forEach(groupMemberDO -> saveInboxAndSendMessageForUser(groupMemberDO.getUserId(), inboxSaveMessage)); |
| 101 | } | 55 | } |
| 102 | } | 56 | } |
| 103 | 57 | ||
| 58 | + @Override | ||
| 59 | + public List<Long> selectMessageIdsByUserIdAndSequence(Long userId, Long sequence, Integer size) { | ||
| 60 | + return inboxMapper.selectMessageIdsByUserIdAndSequence(userId, sequence, size); | ||
| 61 | + } | ||
| 62 | + | ||
| 104 | private void saveInboxAndSendMessageForUser(Long userId, InboxSaveMessageReqVO inboxSaveMessage) { | 63 | private void saveInboxAndSendMessageForUser(Long userId, InboxSaveMessageReqVO inboxSaveMessage) { |
| 105 | inboxLockRedisDAO.lock(userId, INBOX_LOCK_TIMEOUT, () -> { | 64 | inboxLockRedisDAO.lock(userId, INBOX_LOCK_TIMEOUT, () -> { |
| 106 | Long userSequence = sequenceRedisDao.generateSequence(userId); | 65 | Long userSequence = sequenceRedisDao.generateSequence(userId); |
| @@ -108,12 +67,8 @@ public class ImInboxServiceImpl implements ImInboxService { | @@ -108,12 +67,8 @@ public class ImInboxServiceImpl implements ImInboxService { | ||
| 108 | inbox.setUserId(userId); | 67 | inbox.setUserId(userId); |
| 109 | inbox.setMessageId(inboxSaveMessage.getMessageId()); | 68 | inbox.setMessageId(inboxSaveMessage.getMessageId()); |
| 110 | inbox.setSequence(userSequence); | 69 | inbox.setSequence(userSequence); |
| 111 | - imInboxMapper.insert(inbox); | 70 | + inboxMapper.insert(inbox); |
| 112 | 71 | ||
| 113 | - //是发送人不发送 | ||
| 114 | - if (userId.equals(inboxSaveMessage.getFromId())) { | ||
| 115 | - return; | ||
| 116 | - } | ||
| 117 | InboxSendMessageReqVO message = BeanUtils.toBean(inboxSaveMessage, InboxSendMessageReqVO.class); | 72 | InboxSendMessageReqVO message = BeanUtils.toBean(inboxSaveMessage, InboxSendMessageReqVO.class); |
| 118 | message.setSequence(userSequence); | 73 | message.setSequence(userSequence); |
| 119 | webSocketMessageSender.sendObject(UserTypeEnum.ADMIN.getValue(), userId, IM_MESSAGE_RECEIVE, message); | 74 | webSocketMessageSender.sendObject(UserTypeEnum.ADMIN.getValue(), userId, IM_MESSAGE_RECEIVE, message); |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/service/message/MessageService.java
| @@ -15,13 +15,12 @@ import java.util.List; | @@ -15,13 +15,12 @@ import java.util.List; | ||
| 15 | public interface MessageService { | 15 | public interface MessageService { |
| 16 | 16 | ||
| 17 | /** | 17 | /** |
| 18 | - * 获得消息分页 | 18 | + * 获得历史消息 |
| 19 | * | 19 | * |
| 20 | * @param pageReqVO 分页查询 | 20 | * @param pageReqVO 分页查询 |
| 21 | * @return 消息分页 | 21 | * @return 消息分页 |
| 22 | */ | 22 | */ |
| 23 | - List<MessageDO> getMessagePage(MessagePageReqVO pageReqVO); | ||
| 24 | - | 23 | + List<MessageDO> getHistoryMessage(MessagePageReqVO pageReqVO); |
| 25 | 24 | ||
| 26 | /** | 25 | /** |
| 27 | * 拉取消息-大于 seq 的消息 | 26 | * 拉取消息-大于 seq 的消息 |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/service/message/MessageServiceImpl.java
| @@ -10,8 +10,8 @@ import cn.iocoder.yudao.module.im.dal.mysql.message.MessageMapper; | @@ -10,8 +10,8 @@ import cn.iocoder.yudao.module.im.dal.mysql.message.MessageMapper; | ||
| 10 | import cn.iocoder.yudao.module.im.enums.conversation.ConversationTypeEnum; | 10 | import cn.iocoder.yudao.module.im.enums.conversation.ConversationTypeEnum; |
| 11 | import cn.iocoder.yudao.module.im.enums.message.MessageSourceEnum; | 11 | import cn.iocoder.yudao.module.im.enums.message.MessageSourceEnum; |
| 12 | import cn.iocoder.yudao.module.im.enums.message.MessageStatusEnum; | 12 | import cn.iocoder.yudao.module.im.enums.message.MessageStatusEnum; |
| 13 | -import cn.iocoder.yudao.module.im.service.groupmember.ImGroupMemberService; | ||
| 14 | -import cn.iocoder.yudao.module.im.service.inbox.ImInboxService; | 13 | +import cn.iocoder.yudao.module.im.service.groupmember.GroupMemberService; |
| 14 | +import cn.iocoder.yudao.module.im.service.inbox.InboxService; | ||
| 15 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | 15 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| 16 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | 16 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| 17 | import jakarta.annotation.Resource; | 17 | import jakarta.annotation.Resource; |
| @@ -38,20 +38,21 @@ public class MessageServiceImpl implements MessageService { | @@ -38,20 +38,21 @@ public class MessageServiceImpl implements MessageService { | ||
| 38 | @Resource | 38 | @Resource |
| 39 | private MessageMapper messageMapper; | 39 | private MessageMapper messageMapper; |
| 40 | @Resource | 40 | @Resource |
| 41 | - private ImInboxService imInboxService; // IM收件箱服务 | 41 | + private InboxService inboxService; |
| 42 | @Resource | 42 | @Resource |
| 43 | private AdminUserApi adminUserApi; | 43 | private AdminUserApi adminUserApi; |
| 44 | @Resource | 44 | @Resource |
| 45 | - private ImGroupMemberService imGroupMemberService; | 45 | + private GroupMemberService groupMemberService; |
| 46 | 46 | ||
| 47 | @Override | 47 | @Override |
| 48 | - public List<MessageDO> getMessagePage(MessagePageReqVO pageReqVO) { | ||
| 49 | - return messageMapper.getMessagePage(pageReqVO); | 48 | + public List<MessageDO> getHistoryMessage(MessagePageReqVO pageReqVO) { |
| 49 | + return messageMapper.getHistoryMessage(pageReqVO); | ||
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | @Override | 52 | @Override |
| 53 | public List<MessageDO> getMessageListBySequence(Long userId, Long sequence, Integer size) { | 53 | public List<MessageDO> getMessageListBySequence(Long userId, Long sequence, Integer size) { |
| 54 | - return messageMapper.getGreaterThanSequenceMessage(userId, sequence, size); | 54 | + List<Long> messageIds = inboxService.selectMessageIdsByUserIdAndSequence(userId, sequence, size); |
| 55 | + return messageMapper.selectBatchIds(messageIds); | ||
| 55 | } | 56 | } |
| 56 | 57 | ||
| 57 | @Override | 58 | @Override |
| @@ -61,7 +62,7 @@ public class MessageServiceImpl implements MessageService { | @@ -61,7 +62,7 @@ public class MessageServiceImpl implements MessageService { | ||
| 61 | SendMessageRespVO sendMessageRespVO = saveMessage(fromUserId, message, inboxSaveMessageReqVO); | 62 | SendMessageRespVO sendMessageRespVO = saveMessage(fromUserId, message, inboxSaveMessageReqVO); |
| 62 | 63 | ||
| 63 | // 保存收件箱 + 发送消息给用户 | 64 | // 保存收件箱 + 发送消息给用户 |
| 64 | - imInboxService.saveInboxAndSendMessage(inboxSaveMessageReqVO); | 65 | + inboxService.saveInboxAndSendMessage(inboxSaveMessageReqVO); |
| 65 | return sendMessageRespVO; | 66 | return sendMessageRespVO; |
| 66 | } | 67 | } |
| 67 | 68 | ||
| @@ -112,7 +113,7 @@ public class MessageServiceImpl implements MessageService { | @@ -112,7 +113,7 @@ public class MessageServiceImpl implements MessageService { | ||
| 112 | 113 | ||
| 113 | } else if (message.getConversationType().equals(ConversationTypeEnum.GROUP.getType())) { | 114 | } else if (message.getConversationType().equals(ConversationTypeEnum.GROUP.getType())) { |
| 114 | //校验群聊是否存在; | 115 | //校验群聊是否存在; |
| 115 | - List<GroupMemberDO> groupMemberDOS = imGroupMemberService.selectByGroupId(message.getReceiverId()); | 116 | + List<GroupMemberDO> groupMemberDOS = groupMemberService.selectByGroupId(message.getReceiverId()); |
| 116 | if (groupMemberDOS.isEmpty()) { | 117 | if (groupMemberDOS.isEmpty()) { |
| 117 | throw exception(MESSAGE_RECEIVER_NOT_EXISTS); | 118 | throw exception(MESSAGE_RECEIVER_NOT_EXISTS); |
| 118 | } | 119 | } |
yudao-module-im/yudao-module-im-biz/src/main/resources/mapper/inbox/ImInboxMapper.xml renamed to yudao-module-im/yudao-module-im-biz/src/main/resources/mapper/inbox/InboxMapper.xml
| 1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| 3 | -<mapper namespace="cn.iocoder.yudao.module.im.dal.mysql.inbox.ImInboxMapper"> | 3 | +<mapper namespace="cn.iocoder.yudao.module.im.dal.mysql.inbox.InboxMapper"> |
| 4 | 4 | ||
| 5 | <!-- | 5 | <!-- |
| 6 | 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 | 6 | 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 |