Commit 9cee1b3ceb53906f64da446493a975fb81a20c39
1 parent
f6948254
新增:群聊发送
Showing
32 changed files
with
1322 additions
and
70 deletions
yudao-module-im/yudao-module-im-api/src/main/java/cn/iocoder/yudao/module/im/enums/ErrorCodeConstants.java
| @@ -17,4 +17,10 @@ public interface ErrorCodeConstants { | @@ -17,4 +17,10 @@ public interface ErrorCodeConstants { | ||
| 17 | 17 | ||
| 18 | // ========== 消息 (1-040-300-000) ========== | 18 | // ========== 消息 (1-040-300-000) ========== |
| 19 | ErrorCode MESSAGE_NOT_EXISTS = new ErrorCode(1_040_300_000, "消息不存在"); | 19 | ErrorCode MESSAGE_NOT_EXISTS = new ErrorCode(1_040_300_000, "消息不存在"); |
| 20 | + | ||
| 21 | + // ========== 群 (1-040-400-000) ========== | ||
| 22 | + ErrorCode GROUP_NOT_EXISTS = new ErrorCode(1_040_400_000, "群不存在"); | ||
| 23 | + | ||
| 24 | + // ========== 群成员 (1-040-500-000) ========== | ||
| 25 | + ErrorCode GROUP_MEMBER_NOT_EXISTS = new ErrorCode(1_040_500_000, "群成员不存在"); | ||
| 20 | } | 26 | } |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/controller/admin/group/ImGroupController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.im.controller.admin.group; | ||
| 2 | + | ||
| 3 | +import org.springframework.web.bind.annotation.*; | ||
| 4 | +import jakarta.annotation.Resource; | ||
| 5 | +import org.springframework.validation.annotation.Validated; | ||
| 6 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 7 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 8 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 9 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 10 | + | ||
| 11 | +import jakarta.validation.*; | ||
| 12 | +import jakarta.servlet.http.*; | ||
| 13 | +import java.util.*; | ||
| 14 | +import java.io.IOException; | ||
| 15 | + | ||
| 16 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 17 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 18 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 19 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 20 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 21 | + | ||
| 22 | +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||
| 23 | + | ||
| 24 | +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||
| 25 | +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; | ||
| 26 | + | ||
| 27 | +import cn.iocoder.yudao.module.im.controller.admin.group.vo.*; | ||
| 28 | +import cn.iocoder.yudao.module.im.dal.dataobject.group.ImGroupDO; | ||
| 29 | +import cn.iocoder.yudao.module.im.service.group.ImGroupService; | ||
| 30 | + | ||
| 31 | +@Tag(name = "管理后台 - 群") | ||
| 32 | +@RestController | ||
| 33 | +@RequestMapping("/im/group") | ||
| 34 | +@Validated | ||
| 35 | +public class ImGroupController { | ||
| 36 | + | ||
| 37 | + @Resource | ||
| 38 | + private ImGroupService imGroupService; | ||
| 39 | + | ||
| 40 | + @PostMapping("/create") | ||
| 41 | + @Operation(summary = "创建群") | ||
| 42 | + @PreAuthorize("@ss.hasPermission('im:group:create')") | ||
| 43 | + public CommonResult<Long> createGroup(@Valid @RequestBody ImGroupSaveReqVO createReqVO) { | ||
| 44 | + return success(imGroupService.createGroup(createReqVO)); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + @PutMapping("/update") | ||
| 48 | + @Operation(summary = "更新群") | ||
| 49 | + @PreAuthorize("@ss.hasPermission('im:group:update')") | ||
| 50 | + public CommonResult<Boolean> updateGroup(@Valid @RequestBody ImGroupSaveReqVO updateReqVO) { | ||
| 51 | + imGroupService.updateGroup(updateReqVO); | ||
| 52 | + return success(true); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + @DeleteMapping("/delete") | ||
| 56 | + @Operation(summary = "删除群") | ||
| 57 | + @Parameter(name = "id", description = "编号", required = true) | ||
| 58 | + @PreAuthorize("@ss.hasPermission('im:group:delete')") | ||
| 59 | + public CommonResult<Boolean> deleteGroup(@RequestParam("id") Long id) { | ||
| 60 | + imGroupService.deleteGroup(id); | ||
| 61 | + return success(true); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + @GetMapping("/get") | ||
| 65 | + @Operation(summary = "获得群") | ||
| 66 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 67 | + @PreAuthorize("@ss.hasPermission('im:group:query')") | ||
| 68 | + public CommonResult<ImGroupRespVO> getGroup(@RequestParam("id") Long id) { | ||
| 69 | + ImGroupDO group = imGroupService.getGroup(id); | ||
| 70 | + return success(BeanUtils.toBean(group, ImGroupRespVO.class)); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + @GetMapping("/page") | ||
| 74 | + @Operation(summary = "获得群分页") | ||
| 75 | + @PreAuthorize("@ss.hasPermission('im:group:query')") | ||
| 76 | + public CommonResult<PageResult<ImGroupRespVO>> getGroupPage(@Valid ImGroupPageReqVO pageReqVO) { | ||
| 77 | + PageResult<ImGroupDO> pageResult = imGroupService.getGroupPage(pageReqVO); | ||
| 78 | + return success(BeanUtils.toBean(pageResult, ImGroupRespVO.class)); | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + @GetMapping("/export-excel") | ||
| 82 | + @Operation(summary = "导出群 Excel") | ||
| 83 | + @PreAuthorize("@ss.hasPermission('im:group:export')") | ||
| 84 | + @OperateLog(type = EXPORT) | ||
| 85 | + public void exportGroupExcel(@Valid ImGroupPageReqVO pageReqVO, | ||
| 86 | + HttpServletResponse response) throws IOException { | ||
| 87 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | ||
| 88 | + List<ImGroupDO> list = imGroupService.getGroupPage(pageReqVO).getList(); | ||
| 89 | + // 导出 Excel | ||
| 90 | + ExcelUtils.write(response, "群.xls", "数据", ImGroupRespVO.class, | ||
| 91 | + BeanUtils.toBean(list, ImGroupRespVO.class)); | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | +} | ||
| 0 | \ No newline at end of file | 95 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/controller/admin/group/vo/ImGroupPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.im.controller.admin.group.vo; | ||
| 2 | + | ||
| 3 | +import lombok.*; | ||
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||
| 6 | +import org.springframework.format.annotation.DateTimeFormat; | ||
| 7 | +import java.time.LocalDateTime; | ||
| 8 | + | ||
| 9 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||
| 10 | + | ||
| 11 | +@Schema(description = "管理后台 - 群分页 Request VO") | ||
| 12 | +@Data | ||
| 13 | +@EqualsAndHashCode(callSuper = true) | ||
| 14 | +@ToString(callSuper = true) | ||
| 15 | +public class ImGroupPageReqVO extends PageParam { | ||
| 16 | + | ||
| 17 | + @Schema(description = "群名字", example = "芋艿") | ||
| 18 | + private String groupName; | ||
| 19 | + | ||
| 20 | + @Schema(description = "群主id", example = "31460") | ||
| 21 | + private Long ownerId; | ||
| 22 | + | ||
| 23 | + @Schema(description = "群头像") | ||
| 24 | + private String headImage; | ||
| 25 | + | ||
| 26 | + @Schema(description = "群头像缩略图") | ||
| 27 | + private String headImageThumb; | ||
| 28 | + | ||
| 29 | + @Schema(description = "群公告") | ||
| 30 | + private String notice; | ||
| 31 | + | ||
| 32 | + @Schema(description = "群备注", example = "你说的对") | ||
| 33 | + private String remark; | ||
| 34 | + | ||
| 35 | + @Schema(description = "创建时间") | ||
| 36 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 37 | + private LocalDateTime[] createTime; | ||
| 38 | + | ||
| 39 | +} | ||
| 0 | \ No newline at end of file | 40 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/controller/admin/group/vo/ImGroupRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.im.controller.admin.group.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.*; | ||
| 5 | + | ||
| 6 | +import java.time.LocalDateTime; | ||
| 7 | +import com.alibaba.excel.annotation.*; | ||
| 8 | + | ||
| 9 | +@Schema(description = "管理后台 - 群 Response VO") | ||
| 10 | +@Data | ||
| 11 | +@ExcelIgnoreUnannotated | ||
| 12 | +public class ImGroupRespVO { | ||
| 13 | + | ||
| 14 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1003") | ||
| 15 | + @ExcelProperty("编号") | ||
| 16 | + private Long id; | ||
| 17 | + | ||
| 18 | + @Schema(description = "群名字", example = "芋艿") | ||
| 19 | + @ExcelProperty("群名字") | ||
| 20 | + private String groupName; | ||
| 21 | + | ||
| 22 | + @Schema(description = "群主id", requiredMode = Schema.RequiredMode.REQUIRED, example = "31460") | ||
| 23 | + @ExcelProperty("群主id") | ||
| 24 | + private Long ownerId; | ||
| 25 | + | ||
| 26 | + @Schema(description = "群头像") | ||
| 27 | + @ExcelProperty("群头像") | ||
| 28 | + private String headImage; | ||
| 29 | + | ||
| 30 | + @Schema(description = "群头像缩略图") | ||
| 31 | + @ExcelProperty("群头像缩略图") | ||
| 32 | + private String headImageThumb; | ||
| 33 | + | ||
| 34 | + @Schema(description = "群公告") | ||
| 35 | + @ExcelProperty("群公告") | ||
| 36 | + private String notice; | ||
| 37 | + | ||
| 38 | + @Schema(description = "群备注", example = "你说的对") | ||
| 39 | + @ExcelProperty("群备注") | ||
| 40 | + private String remark; | ||
| 41 | + | ||
| 42 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 43 | + @ExcelProperty("创建时间") | ||
| 44 | + private LocalDateTime createTime; | ||
| 45 | + | ||
| 46 | +} | ||
| 0 | \ No newline at end of file | 47 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/controller/admin/group/vo/ImGroupSaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.im.controller.admin.group.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.*; | ||
| 5 | +import jakarta.validation.constraints.*; | ||
| 6 | + | ||
| 7 | +@Schema(description = "管理后台 - 群新增/修改 Request VO") | ||
| 8 | +@Data | ||
| 9 | +public class ImGroupSaveReqVO { | ||
| 10 | + | ||
| 11 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1003") | ||
| 12 | + private Long id; | ||
| 13 | + | ||
| 14 | + @Schema(description = "群名字", example = "芋艿") | ||
| 15 | + private String groupName; | ||
| 16 | + | ||
| 17 | + @Schema(description = "群主id", requiredMode = Schema.RequiredMode.REQUIRED, example = "31460") | ||
| 18 | + @NotNull(message = "群主id不能为空") | ||
| 19 | + private Long ownerId; | ||
| 20 | + | ||
| 21 | + @Schema(description = "群头像") | ||
| 22 | + private String headImage; | ||
| 23 | + | ||
| 24 | + @Schema(description = "群头像缩略图") | ||
| 25 | + private String headImageThumb; | ||
| 26 | + | ||
| 27 | + @Schema(description = "群公告") | ||
| 28 | + private String notice; | ||
| 29 | + | ||
| 30 | + @Schema(description = "群备注", example = "你说的对") | ||
| 31 | + private String remark; | ||
| 32 | + | ||
| 33 | +} | ||
| 0 | \ No newline at end of file | 34 | \ 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
0 → 100644
| 1 | +package cn.iocoder.yudao.module.im.controller.admin.groupmember; | ||
| 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.groupmember.vo.ImGroupMemberPageReqVO; | ||
| 10 | +import cn.iocoder.yudao.module.im.controller.admin.groupmember.vo.ImGroupMemberRespVO; | ||
| 11 | +import cn.iocoder.yudao.module.im.controller.admin.groupmember.vo.ImGroupMemberSaveReqVO; | ||
| 12 | +import cn.iocoder.yudao.module.im.dal.dataobject.groupmember.GroupMemberDO; | ||
| 13 | +import cn.iocoder.yudao.module.im.service.groupmember.ImGroupMemberService; | ||
| 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/group-member") | ||
| 33 | +@Validated | ||
| 34 | +public class ImGroupMemberController { | ||
| 35 | + | ||
| 36 | + @Resource | ||
| 37 | + private ImGroupMemberService imGroupMemberService; | ||
| 38 | + | ||
| 39 | + @PostMapping("/create") | ||
| 40 | + @Operation(summary = "创建群成员") | ||
| 41 | + @PreAuthorize("@ss.hasPermission('im:group-member:create')") | ||
| 42 | + public CommonResult<Long> createGroupMember(@Valid @RequestBody ImGroupMemberSaveReqVO createReqVO) { | ||
| 43 | + return success(imGroupMemberService.createGroupMember(createReqVO)); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + @PutMapping("/update") | ||
| 47 | + @Operation(summary = "更新群成员") | ||
| 48 | + @PreAuthorize("@ss.hasPermission('im:group-member:update')") | ||
| 49 | + public CommonResult<Boolean> updateGroupMember(@Valid @RequestBody ImGroupMemberSaveReqVO updateReqVO) { | ||
| 50 | + imGroupMemberService.updateGroupMember(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:group-member:delete')") | ||
| 58 | + public CommonResult<Boolean> deleteGroupMember(@RequestParam("id") Long id) { | ||
| 59 | + imGroupMemberService.deleteGroupMember(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:group-member:query')") | ||
| 67 | + public CommonResult<ImGroupMemberRespVO> getGroupMember(@RequestParam("id") Long id) { | ||
| 68 | + GroupMemberDO groupMember = imGroupMemberService.getGroupMember(id); | ||
| 69 | + return success(BeanUtils.toBean(groupMember, ImGroupMemberRespVO.class)); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + @GetMapping("/page") | ||
| 73 | + @Operation(summary = "获得群成员分页") | ||
| 74 | + @PreAuthorize("@ss.hasPermission('im:group-member:query')") | ||
| 75 | + public CommonResult<PageResult<ImGroupMemberRespVO>> getGroupMemberPage(@Valid ImGroupMemberPageReqVO pageReqVO) { | ||
| 76 | + PageResult<GroupMemberDO> pageResult = imGroupMemberService.getGroupMemberPage(pageReqVO); | ||
| 77 | + return success(BeanUtils.toBean(pageResult, ImGroupMemberRespVO.class)); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + @GetMapping("/export-excel") | ||
| 81 | + @Operation(summary = "导出群成员 Excel") | ||
| 82 | + @PreAuthorize("@ss.hasPermission('im:group-member:export')") | ||
| 83 | + @OperateLog(type = EXPORT) | ||
| 84 | + public void exportGroupMemberExcel(@Valid ImGroupMemberPageReqVO pageReqVO, | ||
| 85 | + HttpServletResponse response) throws IOException { | ||
| 86 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | ||
| 87 | + List<GroupMemberDO> list = imGroupMemberService.getGroupMemberPage(pageReqVO).getList(); | ||
| 88 | + // 导出 Excel | ||
| 89 | + ExcelUtils.write(response, "群成员.xls", "数据", ImGroupMemberRespVO.class, | ||
| 90 | + BeanUtils.toBean(list, ImGroupMemberRespVO.class)); | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | +} | ||
| 0 | \ No newline at end of file | 94 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/controller/admin/groupmember/vo/ImGroupMemberPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.im.controller.admin.groupmember.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 | +@Schema(description = "管理后台 - 群成员分页 Request VO") | ||
| 15 | +@Data | ||
| 16 | +@EqualsAndHashCode(callSuper = true) | ||
| 17 | +@ToString(callSuper = true) | ||
| 18 | +public class ImGroupMemberPageReqVO extends PageParam { | ||
| 19 | + | ||
| 20 | + @Schema(description = "群 id", example = "13279") | ||
| 21 | + private Long groupId; | ||
| 22 | + | ||
| 23 | + @Schema(description = "用户id", example = "21730") | ||
| 24 | + private Long userId; | ||
| 25 | + | ||
| 26 | + @Schema(description = "昵称", example = "芋艿") | ||
| 27 | + private String nickname; | ||
| 28 | + | ||
| 29 | + @Schema(description = "头像") | ||
| 30 | + private String avatar; | ||
| 31 | + | ||
| 32 | + @Schema(description = "组内显示名称", example = "芋艿") | ||
| 33 | + private String aliasName; | ||
| 34 | + | ||
| 35 | + @Schema(description = "备注", example = "你说的对") | ||
| 36 | + private String remark; | ||
| 37 | + | ||
| 38 | + @Schema(description = "创建时间") | ||
| 39 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 40 | + private LocalDateTime[] createTime; | ||
| 41 | + | ||
| 42 | +} | ||
| 0 | \ No newline at end of file | 43 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/controller/admin/groupmember/vo/ImGroupMemberRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.im.controller.admin.groupmember.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 | +@Schema(description = "管理后台 - 群成员 Response VO") | ||
| 11 | +@Data | ||
| 12 | +@ExcelIgnoreUnannotated | ||
| 13 | +public class ImGroupMemberRespVO { | ||
| 14 | + | ||
| 15 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17071") | ||
| 16 | + @ExcelProperty("编号") | ||
| 17 | + private Long id; | ||
| 18 | + | ||
| 19 | + @Schema(description = "群 id", example = "13279") | ||
| 20 | + @ExcelProperty("群 id") | ||
| 21 | + private Long groupId; | ||
| 22 | + | ||
| 23 | + @Schema(description = "用户id", requiredMode = Schema.RequiredMode.REQUIRED, example = "21730") | ||
| 24 | + @ExcelProperty("用户id") | ||
| 25 | + private Long userId; | ||
| 26 | + | ||
| 27 | + @Schema(description = "昵称", example = "芋艿") | ||
| 28 | + @ExcelProperty("昵称") | ||
| 29 | + private String nickname; | ||
| 30 | + | ||
| 31 | + @Schema(description = "头像") | ||
| 32 | + @ExcelProperty("头像") | ||
| 33 | + private String avatar; | ||
| 34 | + | ||
| 35 | + @Schema(description = "组内显示名称", example = "芋艿") | ||
| 36 | + @ExcelProperty("组内显示名称") | ||
| 37 | + private String aliasName; | ||
| 38 | + | ||
| 39 | + @Schema(description = "备注", example = "你说的对") | ||
| 40 | + @ExcelProperty("备注") | ||
| 41 | + private String remark; | ||
| 42 | + | ||
| 43 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 44 | + @ExcelProperty("创建时间") | ||
| 45 | + private LocalDateTime createTime; | ||
| 46 | + | ||
| 47 | +} | ||
| 0 | \ No newline at end of file | 48 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/controller/admin/groupmember/vo/ImGroupMemberSaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.im.controller.admin.groupmember.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import jakarta.validation.constraints.NotNull; | ||
| 5 | +import lombok.Data; | ||
| 6 | + | ||
| 7 | +@Schema(description = "管理后台 - 群成员新增/修改 Request VO") | ||
| 8 | +@Data | ||
| 9 | +public class ImGroupMemberSaveReqVO { | ||
| 10 | + | ||
| 11 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17071") | ||
| 12 | + private Long id; | ||
| 13 | + | ||
| 14 | + @Schema(description = "群 id", example = "13279") | ||
| 15 | + private Long groupId; | ||
| 16 | + | ||
| 17 | + @Schema(description = "用户id", requiredMode = Schema.RequiredMode.REQUIRED, example = "21730") | ||
| 18 | + @NotNull(message = "用户id不能为空") | ||
| 19 | + private Long userId; | ||
| 20 | + | ||
| 21 | + @Schema(description = "昵称", example = "芋艿") | ||
| 22 | + private String nickname; | ||
| 23 | + | ||
| 24 | + @Schema(description = "头像") | ||
| 25 | + private String avatar; | ||
| 26 | + | ||
| 27 | + @Schema(description = "组内显示名称", example = "芋艿") | ||
| 28 | + private String aliasName; | ||
| 29 | + | ||
| 30 | + @Schema(description = "备注", example = "你说的对") | ||
| 31 | + private String remark; | ||
| 32 | + | ||
| 33 | +} | ||
| 0 | \ No newline at end of file | 34 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/dal/dataobject/group/ImGroupDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.im.dal.dataobject.group; | ||
| 2 | + | ||
| 3 | +import lombok.*; | ||
| 4 | +import com.baomidou.mybatisplus.annotation.*; | ||
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * 群 DO | ||
| 9 | + * | ||
| 10 | + * @author 芋道源码 | ||
| 11 | + */ | ||
| 12 | +@TableName("im_group") | ||
| 13 | +@KeySequence("im_group_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||
| 14 | +@Data | ||
| 15 | +@EqualsAndHashCode(callSuper = true) | ||
| 16 | +@ToString(callSuper = true) | ||
| 17 | +@Builder | ||
| 18 | +@NoArgsConstructor | ||
| 19 | +@AllArgsConstructor | ||
| 20 | +public class ImGroupDO extends BaseDO { | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * 编号 | ||
| 24 | + */ | ||
| 25 | + @TableId | ||
| 26 | + private Long id; | ||
| 27 | + /** | ||
| 28 | + * 群名字 | ||
| 29 | + */ | ||
| 30 | + private String groupName; | ||
| 31 | + /** | ||
| 32 | + * 群主id | ||
| 33 | + */ | ||
| 34 | + private Long ownerId; | ||
| 35 | + /** | ||
| 36 | + * 群头像 | ||
| 37 | + */ | ||
| 38 | + private String headImage; | ||
| 39 | + /** | ||
| 40 | + * 群头像缩略图 | ||
| 41 | + */ | ||
| 42 | + private String headImageThumb; | ||
| 43 | + /** | ||
| 44 | + * 群公告 | ||
| 45 | + */ | ||
| 46 | + private String notice; | ||
| 47 | + /** | ||
| 48 | + * 群备注 | ||
| 49 | + */ | ||
| 50 | + private String remark; | ||
| 51 | + | ||
| 52 | +} | ||
| 0 | \ No newline at end of file | 53 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/dal/dataobject/groupmember/GroupMemberDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.im.dal.dataobject.groupmember; | ||
| 2 | + | ||
| 3 | +import lombok.*; | ||
| 4 | +import java.util.*; | ||
| 5 | +import java.time.LocalDateTime; | ||
| 6 | +import java.time.LocalDateTime; | ||
| 7 | +import com.baomidou.mybatisplus.annotation.*; | ||
| 8 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 群成员 DO | ||
| 12 | + * | ||
| 13 | + * @author 芋道源码 | ||
| 14 | + */ | ||
| 15 | +@TableName("im_group_member") | ||
| 16 | +@KeySequence("im_group_member_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||
| 17 | +@Data | ||
| 18 | +@EqualsAndHashCode(callSuper = true) | ||
| 19 | +@ToString(callSuper = true) | ||
| 20 | +@Builder | ||
| 21 | +@NoArgsConstructor | ||
| 22 | +@AllArgsConstructor | ||
| 23 | +public class GroupMemberDO extends BaseDO { | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 编号 | ||
| 27 | + */ | ||
| 28 | + @TableId | ||
| 29 | + private Long id; | ||
| 30 | + /** | ||
| 31 | + * 群 id | ||
| 32 | + */ | ||
| 33 | + private Long groupId; | ||
| 34 | + /** | ||
| 35 | + * 用户id | ||
| 36 | + */ | ||
| 37 | + private Long userId; | ||
| 38 | + /** | ||
| 39 | + * 昵称 | ||
| 40 | + */ | ||
| 41 | + private String nickname; | ||
| 42 | + /** | ||
| 43 | + * 头像 | ||
| 44 | + */ | ||
| 45 | + private String avatar; | ||
| 46 | + /** | ||
| 47 | + * 组内显示名称 | ||
| 48 | + */ | ||
| 49 | + private String aliasName; | ||
| 50 | + /** | ||
| 51 | + * 备注 | ||
| 52 | + */ | ||
| 53 | + private String remark; | ||
| 54 | + | ||
| 55 | +} | ||
| 0 | \ No newline at end of file | 56 | \ 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 renamed to yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/dal/mysql/conversation/ImConversationMapper.java
| @@ -7,13 +7,15 @@ import cn.iocoder.yudao.module.im.controller.admin.conversation.vo.ImConversatio | @@ -7,13 +7,15 @@ import cn.iocoder.yudao.module.im.controller.admin.conversation.vo.ImConversatio | ||
| 7 | import cn.iocoder.yudao.module.im.dal.dataobject.conversation.ImConversationDO; | 7 | import cn.iocoder.yudao.module.im.dal.dataobject.conversation.ImConversationDO; |
| 8 | import org.apache.ibatis.annotations.Mapper; | 8 | import org.apache.ibatis.annotations.Mapper; |
| 9 | 9 | ||
| 10 | +import java.util.Optional; | ||
| 11 | + | ||
| 10 | /** | 12 | /** |
| 11 | * 会话 Mapper | 13 | * 会话 Mapper |
| 12 | * | 14 | * |
| 13 | * @author 芋道源码 | 15 | * @author 芋道源码 |
| 14 | */ | 16 | */ |
| 15 | @Mapper | 17 | @Mapper |
| 16 | -public interface ConversationMapper extends BaseMapperX<ImConversationDO> { | 18 | +public interface ImConversationMapper extends BaseMapperX<ImConversationDO> { |
| 17 | 19 | ||
| 18 | default PageResult<ImConversationDO> selectPage(ImConversationPageReqVO reqVO) { | 20 | default PageResult<ImConversationDO> selectPage(ImConversationPageReqVO reqVO) { |
| 19 | return selectPage(reqVO, new LambdaQueryWrapperX<ImConversationDO>() | 21 | return selectPage(reqVO, new LambdaQueryWrapperX<ImConversationDO>() |
| @@ -27,4 +29,7 @@ public interface ConversationMapper extends BaseMapperX<ImConversationDO> { | @@ -27,4 +29,7 @@ public interface ConversationMapper extends BaseMapperX<ImConversationDO> { | ||
| 27 | .orderByDesc(ImConversationDO::getId)); | 29 | .orderByDesc(ImConversationDO::getId)); |
| 28 | } | 30 | } |
| 29 | 31 | ||
| 32 | + default ImConversationDO selectByNo(String no){ | ||
| 33 | + return selectOne(new LambdaQueryWrapperX<ImConversationDO>().eq(ImConversationDO::getNo, no)); | ||
| 34 | + } | ||
| 30 | } | 35 | } |
| 31 | \ No newline at end of file | 36 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/dal/mysql/group/ImGroupMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.im.dal.mysql.group; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 6 | +import cn.iocoder.yudao.module.im.dal.dataobject.group.ImGroupDO; | ||
| 7 | +import org.apache.ibatis.annotations.Mapper; | ||
| 8 | +import cn.iocoder.yudao.module.im.controller.admin.group.vo.*; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 群 Mapper | ||
| 12 | + * | ||
| 13 | + * @author 芋道源码 | ||
| 14 | + */ | ||
| 15 | +@Mapper | ||
| 16 | +public interface ImGroupMapper extends BaseMapperX<ImGroupDO> { | ||
| 17 | + | ||
| 18 | + default PageResult<ImGroupDO> selectPage(ImGroupPageReqVO reqVO) { | ||
| 19 | + return selectPage(reqVO, new LambdaQueryWrapperX<ImGroupDO>() | ||
| 20 | + .likeIfPresent(ImGroupDO::getGroupName, reqVO.getGroupName()) | ||
| 21 | + .eqIfPresent(ImGroupDO::getOwnerId, reqVO.getOwnerId()) | ||
| 22 | + .eqIfPresent(ImGroupDO::getHeadImage, reqVO.getHeadImage()) | ||
| 23 | + .eqIfPresent(ImGroupDO::getHeadImageThumb, reqVO.getHeadImageThumb()) | ||
| 24 | + .eqIfPresent(ImGroupDO::getNotice, reqVO.getNotice()) | ||
| 25 | + .eqIfPresent(ImGroupDO::getRemark, reqVO.getRemark()) | ||
| 26 | + .betweenIfPresent(ImGroupDO::getCreateTime, reqVO.getCreateTime()) | ||
| 27 | + .orderByDesc(ImGroupDO::getId)); | ||
| 28 | + } | ||
| 29 | + | ||
| 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/dal/mysql/groupmember/ImGroupMemberMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.im.dal.mysql.groupmember; | ||
| 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.groupmember.vo.ImGroupMemberPageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.im.dal.dataobject.groupmember.GroupMemberDO; | ||
| 8 | +import org.apache.ibatis.annotations.Mapper; | ||
| 9 | + | ||
| 10 | +import java.util.List; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * 群成员 Mapper | ||
| 14 | + * | ||
| 15 | + * @author 芋道源码 | ||
| 16 | + */ | ||
| 17 | +@Mapper | ||
| 18 | +public interface ImGroupMemberMapper extends BaseMapperX<GroupMemberDO> { | ||
| 19 | + | ||
| 20 | + default PageResult<GroupMemberDO> selectPage(ImGroupMemberPageReqVO reqVO) { | ||
| 21 | + return selectPage(reqVO, new LambdaQueryWrapperX<GroupMemberDO>() | ||
| 22 | + .eqIfPresent(GroupMemberDO::getGroupId, reqVO.getGroupId()) | ||
| 23 | + .eqIfPresent(GroupMemberDO::getUserId, reqVO.getUserId()) | ||
| 24 | + .likeIfPresent(GroupMemberDO::getNickname, reqVO.getNickname()) | ||
| 25 | + .eqIfPresent(GroupMemberDO::getAvatar, reqVO.getAvatar()) | ||
| 26 | + .likeIfPresent(GroupMemberDO::getAliasName, reqVO.getAliasName()) | ||
| 27 | + .eqIfPresent(GroupMemberDO::getRemark, reqVO.getRemark()) | ||
| 28 | + .betweenIfPresent(GroupMemberDO::getCreateTime, reqVO.getCreateTime()) | ||
| 29 | + .orderByDesc(GroupMemberDO::getId)); | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + default List<GroupMemberDO> selectListByGroupId(Long groupId) { | ||
| 33 | + return selectList(new LambdaQueryWrapperX<GroupMemberDO>().eq(GroupMemberDO::getGroupId, groupId)); | ||
| 34 | + } | ||
| 35 | +} | ||
| 0 | \ No newline at end of file | 36 | \ 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 renamed to yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/dal/mysql/inbox/ImInboxMapper.java
| @@ -13,7 +13,7 @@ import org.apache.ibatis.annotations.Mapper; | @@ -13,7 +13,7 @@ import org.apache.ibatis.annotations.Mapper; | ||
| 13 | * @author 芋道源码 | 13 | * @author 芋道源码 |
| 14 | */ | 14 | */ |
| 15 | @Mapper | 15 | @Mapper |
| 16 | -public interface InboxMapper extends BaseMapperX<ImInboxDO> { | 16 | +public interface ImInboxMapper extends BaseMapperX<ImInboxDO> { |
| 17 | 17 | ||
| 18 | default PageResult<ImInboxDO> selectPage(ImInboxPageReqVO reqVO) { | 18 | default PageResult<ImInboxDO> selectPage(ImInboxPageReqVO reqVO) { |
| 19 | return selectPage(reqVO, new LambdaQueryWrapperX<ImInboxDO>() | 19 | return selectPage(reqVO, new LambdaQueryWrapperX<ImInboxDO>() |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/service/conversation/ImConversationServiceImpl.java
| @@ -5,9 +5,8 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | @@ -5,9 +5,8 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 5 | import cn.iocoder.yudao.module.im.controller.admin.conversation.vo.ImConversationPageReqVO; | 5 | import cn.iocoder.yudao.module.im.controller.admin.conversation.vo.ImConversationPageReqVO; |
| 6 | import cn.iocoder.yudao.module.im.controller.admin.conversation.vo.ImConversationSaveReqVO; | 6 | import cn.iocoder.yudao.module.im.controller.admin.conversation.vo.ImConversationSaveReqVO; |
| 7 | import cn.iocoder.yudao.module.im.dal.dataobject.conversation.ImConversationDO; | 7 | import cn.iocoder.yudao.module.im.dal.dataobject.conversation.ImConversationDO; |
| 8 | -import cn.iocoder.yudao.module.im.dal.mysql.conversation.ConversationMapper; | 8 | +import cn.iocoder.yudao.module.im.dal.mysql.conversation.ImConversationMapper; |
| 9 | import cn.iocoder.yudao.module.im.enums.conversation.ImConversationTypeEnum; | 9 | import cn.iocoder.yudao.module.im.enums.conversation.ImConversationTypeEnum; |
| 10 | -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||
| 11 | import jakarta.annotation.Resource; | 10 | import jakarta.annotation.Resource; |
| 12 | import org.springframework.stereotype.Service; | 11 | import org.springframework.stereotype.Service; |
| 13 | import org.springframework.validation.annotation.Validated; | 12 | import org.springframework.validation.annotation.Validated; |
| @@ -25,13 +24,13 @@ import static cn.iocoder.yudao.module.im.enums.ErrorCodeConstants.CONVERSATION_N | @@ -25,13 +24,13 @@ import static cn.iocoder.yudao.module.im.enums.ErrorCodeConstants.CONVERSATION_N | ||
| 25 | public class ImConversationServiceImpl implements ImConversationService { | 24 | public class ImConversationServiceImpl implements ImConversationService { |
| 26 | 25 | ||
| 27 | @Resource | 26 | @Resource |
| 28 | - private ConversationMapper conversationMapper; | 27 | + private ImConversationMapper imConversationMapper; |
| 29 | 28 | ||
| 30 | @Override | 29 | @Override |
| 31 | public Long createConversation(ImConversationSaveReqVO createReqVO) { | 30 | public Long createConversation(ImConversationSaveReqVO createReqVO) { |
| 32 | // 插入 | 31 | // 插入 |
| 33 | ImConversationDO conversation = BeanUtils.toBean(createReqVO, ImConversationDO.class); | 32 | ImConversationDO conversation = BeanUtils.toBean(createReqVO, ImConversationDO.class); |
| 34 | - conversationMapper.insert(conversation); | 33 | + imConversationMapper.insert(conversation); |
| 35 | // 返回 | 34 | // 返回 |
| 36 | return conversation.getId(); | 35 | return conversation.getId(); |
| 37 | } | 36 | } |
| @@ -42,7 +41,7 @@ public class ImConversationServiceImpl implements ImConversationService { | @@ -42,7 +41,7 @@ public class ImConversationServiceImpl implements ImConversationService { | ||
| 42 | validateConversationExists(updateReqVO.getId()); | 41 | validateConversationExists(updateReqVO.getId()); |
| 43 | // 更新 | 42 | // 更新 |
| 44 | ImConversationDO updateObj = BeanUtils.toBean(updateReqVO, ImConversationDO.class); | 43 | ImConversationDO updateObj = BeanUtils.toBean(updateReqVO, ImConversationDO.class); |
| 45 | - conversationMapper.updateById(updateObj); | 44 | + imConversationMapper.updateById(updateObj); |
| 46 | } | 45 | } |
| 47 | 46 | ||
| 48 | @Override | 47 | @Override |
| @@ -50,23 +49,23 @@ public class ImConversationServiceImpl implements ImConversationService { | @@ -50,23 +49,23 @@ public class ImConversationServiceImpl implements ImConversationService { | ||
| 50 | // 校验存在 | 49 | // 校验存在 |
| 51 | validateConversationExists(id); | 50 | validateConversationExists(id); |
| 52 | // 删除 | 51 | // 删除 |
| 53 | - conversationMapper.deleteById(id); | 52 | + imConversationMapper.deleteById(id); |
| 54 | } | 53 | } |
| 55 | 54 | ||
| 56 | private void validateConversationExists(Long id) { | 55 | private void validateConversationExists(Long id) { |
| 57 | - if (conversationMapper.selectById(id) == null) { | 56 | + if (imConversationMapper.selectById(id) == null) { |
| 58 | throw exception(CONVERSATION_NOT_EXISTS); | 57 | throw exception(CONVERSATION_NOT_EXISTS); |
| 59 | } | 58 | } |
| 60 | } | 59 | } |
| 61 | 60 | ||
| 62 | @Override | 61 | @Override |
| 63 | public ImConversationDO getConversation(Long id) { | 62 | public ImConversationDO getConversation(Long id) { |
| 64 | - return conversationMapper.selectById(id); | 63 | + return imConversationMapper.selectById(id); |
| 65 | } | 64 | } |
| 66 | 65 | ||
| 67 | @Override | 66 | @Override |
| 68 | public PageResult<ImConversationDO> getConversationPage(ImConversationPageReqVO pageReqVO) { | 67 | public PageResult<ImConversationDO> getConversationPage(ImConversationPageReqVO pageReqVO) { |
| 69 | - return conversationMapper.selectPage(pageReqVO); | 68 | + return imConversationMapper.selectPage(pageReqVO); |
| 70 | } | 69 | } |
| 71 | 70 | ||
| 72 | @Override | 71 | @Override |
| @@ -86,10 +85,9 @@ public class ImConversationServiceImpl implements ImConversationService { | @@ -86,10 +85,9 @@ public class ImConversationServiceImpl implements ImConversationService { | ||
| 86 | conversation.setPinned(false); | 85 | conversation.setPinned(false); |
| 87 | 86 | ||
| 88 | // 根据 no 查询是否存在,不存在则新增 | 87 | // 根据 no 查询是否存在,不存在则新增 |
| 89 | - QueryWrapper<ImConversationDO> queryWrapper = new QueryWrapper<>(); | ||
| 90 | - queryWrapper.eq("no", conversation.getNo()); | ||
| 91 | - if (conversationMapper.selectOne(queryWrapper) == null) { | ||
| 92 | - conversationMapper.insert(conversation); | 88 | + ImConversationDO imConversationDO = imConversationMapper.selectByNo(conversation.getNo()); |
| 89 | + if (imConversationDO == null) { | ||
| 90 | + imConversationMapper.insert(conversation); | ||
| 93 | } | 91 | } |
| 94 | } | 92 | } |
| 95 | 93 |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/service/group/ImGroupService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.im.service.group; | ||
| 2 | + | ||
| 3 | +import jakarta.validation.*; | ||
| 4 | +import cn.iocoder.yudao.module.im.controller.admin.group.vo.*; | ||
| 5 | +import cn.iocoder.yudao.module.im.dal.dataobject.group.ImGroupDO; | ||
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * 群 Service 接口 | ||
| 10 | + * | ||
| 11 | + * @author 芋道源码 | ||
| 12 | + */ | ||
| 13 | +public interface ImGroupService { | ||
| 14 | + | ||
| 15 | + /** | ||
| 16 | + * 创建群 | ||
| 17 | + * | ||
| 18 | + * @param createReqVO 创建信息 | ||
| 19 | + * @return 编号 | ||
| 20 | + */ | ||
| 21 | + Long createGroup(@Valid ImGroupSaveReqVO createReqVO); | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * 更新群 | ||
| 25 | + * | ||
| 26 | + * @param updateReqVO 更新信息 | ||
| 27 | + */ | ||
| 28 | + void updateGroup(@Valid ImGroupSaveReqVO updateReqVO); | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * 删除群 | ||
| 32 | + * | ||
| 33 | + * @param id 编号 | ||
| 34 | + */ | ||
| 35 | + void deleteGroup(Long id); | ||
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * 获得群 | ||
| 39 | + * | ||
| 40 | + * @param id 编号 | ||
| 41 | + * @return 群 | ||
| 42 | + */ | ||
| 43 | + ImGroupDO getGroup(Long id); | ||
| 44 | + | ||
| 45 | + /** | ||
| 46 | + * 获得群分页 | ||
| 47 | + * | ||
| 48 | + * @param pageReqVO 分页查询 | ||
| 49 | + * @return 群分页 | ||
| 50 | + */ | ||
| 51 | + PageResult<ImGroupDO> getGroupPage(ImGroupPageReqVO pageReqVO); | ||
| 52 | + | ||
| 53 | +} | ||
| 0 | \ No newline at end of file | 54 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/service/group/ImGroupServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.im.service.group; | ||
| 2 | + | ||
| 3 | +import org.springframework.stereotype.Service; | ||
| 4 | +import jakarta.annotation.Resource; | ||
| 5 | +import org.springframework.validation.annotation.Validated; | ||
| 6 | + | ||
| 7 | +import cn.iocoder.yudao.module.im.controller.admin.group.vo.*; | ||
| 8 | +import cn.iocoder.yudao.module.im.dal.dataobject.group.ImGroupDO; | ||
| 9 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 10 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 11 | + | ||
| 12 | +import cn.iocoder.yudao.module.im.dal.mysql.group.ImGroupMapper; | ||
| 13 | + | ||
| 14 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 15 | +import static cn.iocoder.yudao.module.im.enums.ErrorCodeConstants.*; | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * 群 Service 实现类 | ||
| 19 | + * | ||
| 20 | + * @author 芋道源码 | ||
| 21 | + */ | ||
| 22 | +@Service | ||
| 23 | +@Validated | ||
| 24 | +public class ImGroupServiceImpl implements ImGroupService { | ||
| 25 | + | ||
| 26 | + @Resource | ||
| 27 | + private ImGroupMapper imGroupMapper; | ||
| 28 | + | ||
| 29 | + @Override | ||
| 30 | + public Long createGroup(ImGroupSaveReqVO createReqVO) { | ||
| 31 | + // 插入 | ||
| 32 | + ImGroupDO group = BeanUtils.toBean(createReqVO, ImGroupDO.class); | ||
| 33 | + imGroupMapper.insert(group); | ||
| 34 | + // 返回 | ||
| 35 | + return group.getId(); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + @Override | ||
| 39 | + public void updateGroup(ImGroupSaveReqVO updateReqVO) { | ||
| 40 | + // 校验存在 | ||
| 41 | + validateGroupExists(updateReqVO.getId()); | ||
| 42 | + // 更新 | ||
| 43 | + ImGroupDO updateObj = BeanUtils.toBean(updateReqVO, ImGroupDO.class); | ||
| 44 | + imGroupMapper.updateById(updateObj); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + @Override | ||
| 48 | + public void deleteGroup(Long id) { | ||
| 49 | + // 校验存在 | ||
| 50 | + validateGroupExists(id); | ||
| 51 | + // 删除 | ||
| 52 | + imGroupMapper.deleteById(id); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + private void validateGroupExists(Long id) { | ||
| 56 | + if (imGroupMapper.selectById(id) == null) { | ||
| 57 | + throw exception(GROUP_NOT_EXISTS); | ||
| 58 | + } | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + @Override | ||
| 62 | + public ImGroupDO getGroup(Long id) { | ||
| 63 | + return imGroupMapper.selectById(id); | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + @Override | ||
| 67 | + public PageResult<ImGroupDO> getGroupPage(ImGroupPageReqVO pageReqVO) { | ||
| 68 | + return imGroupMapper.selectPage(pageReqVO); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | +} | ||
| 0 | \ No newline at end of file | 72 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/service/groupmember/ImGroupMemberService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.im.service.groupmember; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.module.im.controller.admin.groupmember.vo.ImGroupMemberPageReqVO; | ||
| 5 | +import cn.iocoder.yudao.module.im.controller.admin.groupmember.vo.ImGroupMemberSaveReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.im.dal.dataobject.groupmember.GroupMemberDO; | ||
| 7 | +import jakarta.validation.Valid; | ||
| 8 | + | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * 群成员 Service 接口 | ||
| 13 | + * | ||
| 14 | + * @author 芋道源码 | ||
| 15 | + */ | ||
| 16 | +public interface ImGroupMemberService { | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * 创建群成员 | ||
| 20 | + * | ||
| 21 | + * @param createReqVO 创建信息 | ||
| 22 | + * @return 编号 | ||
| 23 | + */ | ||
| 24 | + Long createGroupMember(@Valid ImGroupMemberSaveReqVO createReqVO); | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 更新群成员 | ||
| 28 | + * | ||
| 29 | + * @param updateReqVO 更新信息 | ||
| 30 | + */ | ||
| 31 | + void updateGroupMember(@Valid ImGroupMemberSaveReqVO updateReqVO); | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * 删除群成员 | ||
| 35 | + * | ||
| 36 | + * @param id 编号 | ||
| 37 | + */ | ||
| 38 | + void deleteGroupMember(Long id); | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * 获得群成员 | ||
| 42 | + * | ||
| 43 | + * @param id 编号 | ||
| 44 | + * @return 群成员 | ||
| 45 | + */ | ||
| 46 | + GroupMemberDO getGroupMember(Long id); | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * 获得群成员分页 | ||
| 50 | + * | ||
| 51 | + * @param pageReqVO 分页查询 | ||
| 52 | + * @return 群成员分页 | ||
| 53 | + */ | ||
| 54 | + PageResult<GroupMemberDO> getGroupMemberPage(ImGroupMemberPageReqVO pageReqVO); | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * 根据群组id查询群成员 | ||
| 58 | + * | ||
| 59 | + * @param groupId 群组id | ||
| 60 | + * @return 群成员列表 | ||
| 61 | + */ | ||
| 62 | + List<GroupMemberDO> selectByGroupId(Long groupId); | ||
| 63 | +} | ||
| 0 | \ No newline at end of file | 64 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/service/groupmember/ImGroupMemberServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.im.service.groupmember; | ||
| 2 | + | ||
| 3 | +import org.springframework.stereotype.Service; | ||
| 4 | +import jakarta.annotation.Resource; | ||
| 5 | +import org.springframework.validation.annotation.Validated; | ||
| 6 | + | ||
| 7 | +import cn.iocoder.yudao.module.im.controller.admin.groupmember.vo.*; | ||
| 8 | +import cn.iocoder.yudao.module.im.dal.dataobject.groupmember.GroupMemberDO; | ||
| 9 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 10 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 11 | + | ||
| 12 | +import cn.iocoder.yudao.module.im.dal.mysql.groupmember.ImGroupMemberMapper; | ||
| 13 | + | ||
| 14 | +import java.util.List; | ||
| 15 | + | ||
| 16 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 17 | +import static cn.iocoder.yudao.module.im.enums.ErrorCodeConstants.*; | ||
| 18 | + | ||
| 19 | +/** | ||
| 20 | + * 群成员 Service 实现类 | ||
| 21 | + * | ||
| 22 | + * @author 芋道源码 | ||
| 23 | + */ | ||
| 24 | +@Service | ||
| 25 | +@Validated | ||
| 26 | +public class ImGroupMemberServiceImpl implements ImGroupMemberService { | ||
| 27 | + | ||
| 28 | + @Resource | ||
| 29 | + private ImGroupMemberMapper imGroupMemberMapper; | ||
| 30 | + | ||
| 31 | + @Override | ||
| 32 | + public Long createGroupMember(ImGroupMemberSaveReqVO createReqVO) { | ||
| 33 | + // 插入 | ||
| 34 | + GroupMemberDO groupMember = BeanUtils.toBean(createReqVO, GroupMemberDO.class); | ||
| 35 | + imGroupMemberMapper.insert(groupMember); | ||
| 36 | + // 返回 | ||
| 37 | + return groupMember.getId(); | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + @Override | ||
| 41 | + public void updateGroupMember(ImGroupMemberSaveReqVO updateReqVO) { | ||
| 42 | + // 校验存在 | ||
| 43 | + validateGroupMemberExists(updateReqVO.getId()); | ||
| 44 | + // 更新 | ||
| 45 | + GroupMemberDO updateObj = BeanUtils.toBean(updateReqVO, GroupMemberDO.class); | ||
| 46 | + imGroupMemberMapper.updateById(updateObj); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + @Override | ||
| 50 | + public void deleteGroupMember(Long id) { | ||
| 51 | + // 校验存在 | ||
| 52 | + validateGroupMemberExists(id); | ||
| 53 | + // 删除 | ||
| 54 | + imGroupMemberMapper.deleteById(id); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + private void validateGroupMemberExists(Long id) { | ||
| 58 | + if (imGroupMemberMapper.selectById(id) == null) { | ||
| 59 | + throw exception(GROUP_MEMBER_NOT_EXISTS); | ||
| 60 | + } | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + @Override | ||
| 64 | + public GroupMemberDO getGroupMember(Long id) { | ||
| 65 | + return imGroupMemberMapper.selectById(id); | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + @Override | ||
| 69 | + public PageResult<GroupMemberDO> getGroupMemberPage(ImGroupMemberPageReqVO pageReqVO) { | ||
| 70 | + return imGroupMemberMapper.selectPage(pageReqVO); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + @Override | ||
| 74 | + public List<GroupMemberDO> selectByGroupId(Long groupId) { | ||
| 75 | + return imGroupMemberMapper.selectListByGroupId(groupId); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | +} | ||
| 0 | \ No newline at end of file | 79 | \ 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
| @@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | @@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 5 | import cn.iocoder.yudao.module.im.controller.admin.inbox.vo.ImInboxPageReqVO; | 5 | import cn.iocoder.yudao.module.im.controller.admin.inbox.vo.ImInboxPageReqVO; |
| 6 | import cn.iocoder.yudao.module.im.controller.admin.inbox.vo.ImInboxSaveReqVO; | 6 | import cn.iocoder.yudao.module.im.controller.admin.inbox.vo.ImInboxSaveReqVO; |
| 7 | import cn.iocoder.yudao.module.im.dal.dataobject.inbox.ImInboxDO; | 7 | import cn.iocoder.yudao.module.im.dal.dataobject.inbox.ImInboxDO; |
| 8 | -import cn.iocoder.yudao.module.im.dal.mysql.inbox.InboxMapper; | 8 | +import cn.iocoder.yudao.module.im.dal.mysql.inbox.ImInboxMapper; |
| 9 | import jakarta.annotation.Resource; | 9 | import jakarta.annotation.Resource; |
| 10 | import org.springframework.stereotype.Service; | 10 | import org.springframework.stereotype.Service; |
| 11 | import org.springframework.validation.annotation.Validated; | 11 | import org.springframework.validation.annotation.Validated; |
| @@ -23,13 +23,13 @@ import static cn.iocoder.yudao.module.im.enums.ErrorCodeConstants.INBOX_NOT_EXIS | @@ -23,13 +23,13 @@ import static cn.iocoder.yudao.module.im.enums.ErrorCodeConstants.INBOX_NOT_EXIS | ||
| 23 | public class ImInboxServiceImpl implements ImInboxService { | 23 | public class ImInboxServiceImpl implements ImInboxService { |
| 24 | 24 | ||
| 25 | @Resource | 25 | @Resource |
| 26 | - private InboxMapper inboxMapper; | 26 | + private ImInboxMapper imInboxMapper; |
| 27 | 27 | ||
| 28 | @Override | 28 | @Override |
| 29 | public Long createInbox(ImInboxSaveReqVO createReqVO) { | 29 | public Long createInbox(ImInboxSaveReqVO createReqVO) { |
| 30 | // 插入 | 30 | // 插入 |
| 31 | ImInboxDO inbox = BeanUtils.toBean(createReqVO, ImInboxDO.class); | 31 | ImInboxDO inbox = BeanUtils.toBean(createReqVO, ImInboxDO.class); |
| 32 | - inboxMapper.insert(inbox); | 32 | + imInboxMapper.insert(inbox); |
| 33 | // 返回 | 33 | // 返回 |
| 34 | return inbox.getId(); | 34 | return inbox.getId(); |
| 35 | } | 35 | } |
| @@ -40,7 +40,7 @@ public class ImInboxServiceImpl implements ImInboxService { | @@ -40,7 +40,7 @@ public class ImInboxServiceImpl implements ImInboxService { | ||
| 40 | validateInboxExists(updateReqVO.getId()); | 40 | validateInboxExists(updateReqVO.getId()); |
| 41 | // 更新 | 41 | // 更新 |
| 42 | ImInboxDO updateObj = BeanUtils.toBean(updateReqVO, ImInboxDO.class); | 42 | ImInboxDO updateObj = BeanUtils.toBean(updateReqVO, ImInboxDO.class); |
| 43 | - inboxMapper.updateById(updateObj); | 43 | + imInboxMapper.updateById(updateObj); |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | @Override | 46 | @Override |
| @@ -48,23 +48,23 @@ public class ImInboxServiceImpl implements ImInboxService { | @@ -48,23 +48,23 @@ public class ImInboxServiceImpl implements ImInboxService { | ||
| 48 | // 校验存在 | 48 | // 校验存在 |
| 49 | validateInboxExists(id); | 49 | validateInboxExists(id); |
| 50 | // 删除 | 50 | // 删除 |
| 51 | - inboxMapper.deleteById(id); | 51 | + imInboxMapper.deleteById(id); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | private void validateInboxExists(Long id) { | 54 | private void validateInboxExists(Long id) { |
| 55 | - if (inboxMapper.selectById(id) == null) { | 55 | + if (imInboxMapper.selectById(id) == null) { |
| 56 | throw exception(INBOX_NOT_EXISTS); | 56 | throw exception(INBOX_NOT_EXISTS); |
| 57 | } | 57 | } |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | @Override | 60 | @Override |
| 61 | public ImInboxDO getInbox(Long id) { | 61 | public ImInboxDO getInbox(Long id) { |
| 62 | - return inboxMapper.selectById(id); | 62 | + return imInboxMapper.selectById(id); |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | @Override | 65 | @Override |
| 66 | public PageResult<ImInboxDO> getInboxPage(ImInboxPageReqVO pageReqVO) { | 66 | public PageResult<ImInboxDO> getInboxPage(ImInboxPageReqVO pageReqVO) { |
| 67 | - return inboxMapper.selectPage(pageReqVO); | 67 | + return imInboxMapper.selectPage(pageReqVO); |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | } | 70 | } |
| 71 | \ No newline at end of file | 71 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/service/message/ImMessageService.java
| @@ -69,4 +69,12 @@ public interface ImMessageService { | @@ -69,4 +69,12 @@ public interface ImMessageService { | ||
| 69 | * @param messageStatus 消息状态 | 69 | * @param messageStatus 消息状态 |
| 70 | */ | 70 | */ |
| 71 | void updateMessageStatus(Long messageId, Integer messageStatus); | 71 | void updateMessageStatus(Long messageId, Integer messageStatus); |
| 72 | + | ||
| 73 | + /** | ||
| 74 | + * 保存群聊消息 | ||
| 75 | + * @param message 消息 | ||
| 76 | + * @param fromUserId 发送者用户ID | ||
| 77 | + * @return id | ||
| 78 | + */ | ||
| 79 | + ImMessageDO saveGroupMessage(ImSendMessage message, Long fromUserId); | ||
| 72 | } | 80 | } |
| 73 | \ No newline at end of file | 81 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/service/message/ImMessageServiceImpl.java
| @@ -76,18 +76,22 @@ public class ImMessageServiceImpl implements ImMessageService { | @@ -76,18 +76,22 @@ public class ImMessageServiceImpl implements ImMessageService { | ||
| 76 | 76 | ||
| 77 | 77 | ||
| 78 | @Override | 78 | @Override |
| 79 | - public ImMessageDO savePrivateMessage(ImSendMessage message, Long senderId) { | 79 | + public ImMessageDO savePrivateMessage(ImSendMessage message, Long fromUserId) { |
| 80 | + return saveImMessageDO(message, fromUserId); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + private ImMessageDO saveImMessageDO(ImSendMessage message, Long fromUserId) { | ||
| 80 | ImMessageDO imMessageDO = new ImMessageDO(); | 84 | ImMessageDO imMessageDO = new ImMessageDO(); |
| 81 | imMessageDO.setClientMessageId(message.getClientMessageId()); | 85 | imMessageDO.setClientMessageId(message.getClientMessageId()); |
| 82 | - imMessageDO.setSenderId(senderId); | 86 | + imMessageDO.setSenderId(fromUserId); |
| 83 | imMessageDO.setReceiverId(message.getReceiverId()); | 87 | imMessageDO.setReceiverId(message.getReceiverId()); |
| 84 | //查询发送人昵称和发送人头像 | 88 | //查询发送人昵称和发送人头像 |
| 85 | - AdminUserRespDTO user = adminUserApi.getUser(senderId); | 89 | + AdminUserRespDTO user = adminUserApi.getUser(fromUserId); |
| 86 | imMessageDO.setSenderNickname(user.getNickname()); | 90 | imMessageDO.setSenderNickname(user.getNickname()); |
| 87 | imMessageDO.setSenderAvatar(user.getAvatar()); | 91 | imMessageDO.setSenderAvatar(user.getAvatar()); |
| 88 | imMessageDO.setConversationType(message.getConversationType()); | 92 | imMessageDO.setConversationType(message.getConversationType()); |
| 89 | imMessageDO.setContentType(message.getContentType()); | 93 | imMessageDO.setContentType(message.getContentType()); |
| 90 | - imMessageDO.setConversationNo(senderId + "_" + message.getReceiverId()); | 94 | + imMessageDO.setConversationNo(fromUserId + "_" + message.getReceiverId()); |
| 91 | imMessageDO.setContent(message.getContent()); | 95 | imMessageDO.setContent(message.getContent()); |
| 92 | //消息来源 100-用户发送;200-系统发送(一般是通知);不能为空 | 96 | //消息来源 100-用户发送;200-系统发送(一般是通知);不能为空 |
| 93 | imMessageDO.setSendFrom(100); | 97 | imMessageDO.setSendFrom(100); |
| @@ -108,4 +112,9 @@ public class ImMessageServiceImpl implements ImMessageService { | @@ -108,4 +112,9 @@ public class ImMessageServiceImpl implements ImMessageService { | ||
| 108 | imMessageMapper.updateById(imMessageDO); | 112 | imMessageMapper.updateById(imMessageDO); |
| 109 | } | 113 | } |
| 110 | 114 | ||
| 115 | + @Override | ||
| 116 | + public ImMessageDO saveGroupMessage(ImSendMessage message, Long fromUserId) { | ||
| 117 | + return saveImMessageDO(message, fromUserId); | ||
| 118 | + } | ||
| 119 | + | ||
| 111 | } | 120 | } |
| 112 | \ No newline at end of file | 121 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/java/cn/iocoder/yudao/module/im/websocket/ImWebSocketMessageListener.java
| @@ -5,11 +5,13 @@ import cn.iocoder.yudao.framework.websocket.core.listener.WebSocketMessageListen | @@ -5,11 +5,13 @@ import cn.iocoder.yudao.framework.websocket.core.listener.WebSocketMessageListen | ||
| 5 | import cn.iocoder.yudao.framework.websocket.core.sender.WebSocketMessageSender; | 5 | import cn.iocoder.yudao.framework.websocket.core.sender.WebSocketMessageSender; |
| 6 | import cn.iocoder.yudao.framework.websocket.core.util.WebSocketFrameworkUtils; | 6 | import cn.iocoder.yudao.framework.websocket.core.util.WebSocketFrameworkUtils; |
| 7 | import cn.iocoder.yudao.module.im.controller.admin.inbox.vo.ImInboxSaveReqVO; | 7 | import cn.iocoder.yudao.module.im.controller.admin.inbox.vo.ImInboxSaveReqVO; |
| 8 | +import cn.iocoder.yudao.module.im.dal.dataobject.groupmember.GroupMemberDO; | ||
| 8 | import cn.iocoder.yudao.module.im.dal.dataobject.message.ImMessageDO; | 9 | import cn.iocoder.yudao.module.im.dal.dataobject.message.ImMessageDO; |
| 9 | import cn.iocoder.yudao.module.im.dal.redis.inbox.SequenceGeneratorRedisDao; | 10 | import cn.iocoder.yudao.module.im.dal.redis.inbox.SequenceGeneratorRedisDao; |
| 10 | import cn.iocoder.yudao.module.im.enums.conversation.ImConversationTypeEnum; | 11 | import cn.iocoder.yudao.module.im.enums.conversation.ImConversationTypeEnum; |
| 11 | import cn.iocoder.yudao.module.im.enums.message.ImMessageStatusEnum; | 12 | import cn.iocoder.yudao.module.im.enums.message.ImMessageStatusEnum; |
| 12 | import cn.iocoder.yudao.module.im.service.conversation.ImConversationService; | 13 | import cn.iocoder.yudao.module.im.service.conversation.ImConversationService; |
| 14 | +import cn.iocoder.yudao.module.im.service.groupmember.ImGroupMemberService; | ||
| 13 | import cn.iocoder.yudao.module.im.service.inbox.ImInboxService; | 15 | import cn.iocoder.yudao.module.im.service.inbox.ImInboxService; |
| 14 | import cn.iocoder.yudao.module.im.service.message.ImMessageService; | 16 | import cn.iocoder.yudao.module.im.service.message.ImMessageService; |
| 15 | import cn.iocoder.yudao.module.im.websocket.message.ImReceiveMessage; | 17 | import cn.iocoder.yudao.module.im.websocket.message.ImReceiveMessage; |
| @@ -19,6 +21,8 @@ import lombok.extern.slf4j.Slf4j; | @@ -19,6 +21,8 @@ import lombok.extern.slf4j.Slf4j; | ||
| 19 | import org.springframework.stereotype.Component; | 21 | import org.springframework.stereotype.Component; |
| 20 | import org.springframework.web.socket.WebSocketSession; | 22 | import org.springframework.web.socket.WebSocketSession; |
| 21 | 23 | ||
| 24 | +import java.util.List; | ||
| 25 | + | ||
| 22 | /** | 26 | /** |
| 23 | * WebSocket im | 27 | * WebSocket im |
| 24 | * | 28 | * |
| @@ -28,6 +32,7 @@ import org.springframework.web.socket.WebSocketSession; | @@ -28,6 +32,7 @@ import org.springframework.web.socket.WebSocketSession; | ||
| 28 | @Slf4j | 32 | @Slf4j |
| 29 | public class ImWebSocketMessageListener implements WebSocketMessageListener<ImSendMessage> { | 33 | public class ImWebSocketMessageListener implements WebSocketMessageListener<ImSendMessage> { |
| 30 | 34 | ||
| 35 | + public static final String IM_MESSAGE_RECEIVE = "im-message-receive"; | ||
| 31 | @Resource | 36 | @Resource |
| 32 | private WebSocketMessageSender webSocketMessageSender; // WebSocket消息发送器 | 37 | private WebSocketMessageSender webSocketMessageSender; // WebSocket消息发送器 |
| 33 | @Resource | 38 | @Resource |
| @@ -37,6 +42,8 @@ public class ImWebSocketMessageListener implements WebSocketMessageListener<ImSe | @@ -37,6 +42,8 @@ public class ImWebSocketMessageListener implements WebSocketMessageListener<ImSe | ||
| 37 | @Resource | 42 | @Resource |
| 38 | private ImInboxService imInboxService; // IM收件箱服务 | 43 | private ImInboxService imInboxService; // IM收件箱服务 |
| 39 | @Resource | 44 | @Resource |
| 45 | + private ImGroupMemberService imGroupMemberService; // 群成员服务 | ||
| 46 | + @Resource | ||
| 40 | private SequenceGeneratorRedisDao sequenceGeneratorRedisDao; // 序列生成器Redis DAO | 47 | private SequenceGeneratorRedisDao sequenceGeneratorRedisDao; // 序列生成器Redis DAO |
| 41 | 48 | ||
| 42 | /** | 49 | /** |
| @@ -51,32 +58,70 @@ public class ImWebSocketMessageListener implements WebSocketMessageListener<ImSe | @@ -51,32 +58,70 @@ public class ImWebSocketMessageListener implements WebSocketMessageListener<ImSe | ||
| 51 | 58 | ||
| 52 | // 如果是私人消息,处理私人消息 | 59 | // 如果是私人消息,处理私人消息 |
| 53 | if (message.getConversationType().equals(ImConversationTypeEnum.PRIVATE.getType())) { | 60 | if (message.getConversationType().equals(ImConversationTypeEnum.PRIVATE.getType())) { |
| 54 | - ImMessageDO imMessageDO = imMessageService.savePrivateMessage(message, fromUserId); // 保存私人消息 | ||
| 55 | - handlePrivateMessage(fromUserId, imMessageDO, message); | 61 | + handlePrivateMessage(fromUserId, message); |
| 62 | + } else if (message.getConversationType().equals(ImConversationTypeEnum.GROUP.getType())) { | ||
| 63 | + //处理群聊消息 | ||
| 64 | + handleGroupMessage(fromUserId, message); | ||
| 65 | + } else { | ||
| 66 | + log.error("[onMessage][消息类型({}) 未支持]", message.getConversationType()); | ||
| 56 | } | 67 | } |
| 57 | } | 68 | } |
| 58 | 69 | ||
| 59 | /** | 70 | /** |
| 71 | + * 处理群聊消息 | ||
| 72 | + * | ||
| 73 | + * @param fromUserId 发送者用户ID | ||
| 74 | + * @param message 发送的IM消息 | ||
| 75 | + */ | ||
| 76 | + private void handleGroupMessage(Long fromUserId, ImSendMessage message) { | ||
| 77 | + ImMessageDO imMessageDO = imMessageService.saveGroupMessage(message, fromUserId); // 保存群聊消息 | ||
| 78 | + Long groupId = message.getReceiverId(); | ||
| 79 | + | ||
| 80 | + // 发送消息给群聊成员 | ||
| 81 | + List<GroupMemberDO> groupMemberDOList = imGroupMemberService.selectByGroupId(groupId); | ||
| 82 | + groupMemberDOList.forEach(groupMemberDO -> { | ||
| 83 | + //过滤掉自己 | ||
| 84 | + if (groupMemberDO.getUserId().equals(fromUserId)) { | ||
| 85 | + return; | ||
| 86 | + } | ||
| 87 | + Long receiverSequence = sequenceGeneratorRedisDao.generateSequence(groupMemberDO.getUserId()); // 生成接收者序列 | ||
| 88 | + Long receiverInboxId = createAndSaveInbox(groupMemberDO.getUserId(), imMessageDO.getId(), receiverSequence); // 创建并保存接收者收件箱 | ||
| 89 | + sendMessage(groupMemberDO.getUserId(), receiverInboxId, imMessageDO, message, receiverSequence); | ||
| 90 | + }); | ||
| 91 | + | ||
| 92 | + Long fromUserSequence = sequenceGeneratorRedisDao.generateSequence(fromUserId); // 生成发送者序列 | ||
| 93 | + Long fromUserInboxId = createAndSaveInbox(fromUserId, imMessageDO.getId(), fromUserSequence); // 创建并保存发送者收件箱 | ||
| 94 | + | ||
| 95 | + // 发送消息给发送者 | ||
| 96 | + sendMessage(fromUserId, fromUserInboxId, imMessageDO, message, fromUserSequence); | ||
| 97 | + | ||
| 98 | + // 更新消息状态为成功 | ||
| 99 | + imMessageService.updateMessageStatus(imMessageDO.getId(), ImMessageStatusEnum.SUCCESS.getStatus()); | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + /** | ||
| 60 | * 处理私人消息 | 103 | * 处理私人消息 |
| 61 | * | 104 | * |
| 62 | - * @param fromUserId 发送者用户ID | ||
| 63 | - * @param imMessageDO IM消息数据对象 | ||
| 64 | - * @param message 发送的IM消息 | 105 | + * @param fromUserId 发送者用户ID |
| 106 | + * @param message 发送的IM消息 | ||
| 65 | */ | 107 | */ |
| 66 | - private void handlePrivateMessage(Long fromUserId, ImMessageDO imMessageDO, ImSendMessage message) { | 108 | + private void handlePrivateMessage(Long fromUserId, ImSendMessage message) { |
| 109 | + ImMessageDO imMessageDO = imMessageService.savePrivateMessage(message, fromUserId); // 保存私人消息 | ||
| 110 | + Long receiverId = message.getReceiverId(); | ||
| 111 | + | ||
| 67 | Long fromUserSequence = sequenceGeneratorRedisDao.generateSequence(fromUserId); // 生成发送者序列 | 112 | Long fromUserSequence = sequenceGeneratorRedisDao.generateSequence(fromUserId); // 生成发送者序列 |
| 68 | Long fromUserInboxId = createAndSaveInbox(fromUserId, imMessageDO.getId(), fromUserSequence); // 创建并保存发送者收件箱 | 113 | Long fromUserInboxId = createAndSaveInbox(fromUserId, imMessageDO.getId(), fromUserSequence); // 创建并保存发送者收件箱 |
| 69 | - Long receiverSequence = sequenceGeneratorRedisDao.generateSequence(fromUserId); // 生成接收者序列 | 114 | + Long receiverSequence = sequenceGeneratorRedisDao.generateSequence(message.getReceiverId()); // 生成接收者序列 |
| 70 | Long receiverInboxId = createAndSaveInbox(message.getReceiverId(), imMessageDO.getId(), receiverSequence); // 创建并保存接收者收件箱 | 115 | Long receiverInboxId = createAndSaveInbox(message.getReceiverId(), imMessageDO.getId(), receiverSequence); // 创建并保存接收者收件箱 |
| 71 | 116 | ||
| 72 | // 发送消息给接收者和发送者 | 117 | // 发送消息给接收者和发送者 |
| 73 | - sendMessage(fromUserId, receiverInboxId, imMessageDO, message, "im-message-receive", fromUserSequence); | ||
| 74 | - sendMessage(fromUserId, fromUserInboxId, imMessageDO, message, "im-message-receive", receiverSequence); | 118 | + sendMessage(fromUserId, fromUserInboxId, imMessageDO, message, fromUserSequence); |
| 119 | + sendMessage(receiverId, receiverInboxId, imMessageDO, message, receiverSequence); | ||
| 75 | 120 | ||
| 76 | // 更新消息状态为成功 | 121 | // 更新消息状态为成功 |
| 77 | imMessageService.updateMessageStatus(imMessageDO.getId(), ImMessageStatusEnum.SUCCESS.getStatus()); | 122 | imMessageService.updateMessageStatus(imMessageDO.getId(), ImMessageStatusEnum.SUCCESS.getStatus()); |
| 78 | // 保存私人会话,只有在 client 操作会话(已读、置顶)时,才会延迟创建 | 123 | // 保存私人会话,只有在 client 操作会话(已读、置顶)时,才会延迟创建 |
| 79 | - //imConversationService.savePrivateConversation(fromUserId, message.getReceiverId()); | 124 | + //imConversationService.savePrivateConversation(fromUserId, receiverId); |
| 80 | } | 125 | } |
| 81 | 126 | ||
| 82 | /** | 127 | /** |
| @@ -99,20 +144,19 @@ public class ImWebSocketMessageListener implements WebSocketMessageListener<ImSe | @@ -99,20 +144,19 @@ public class ImWebSocketMessageListener implements WebSocketMessageListener<ImSe | ||
| 99 | * @param inboxId 收件箱ID | 144 | * @param inboxId 收件箱ID |
| 100 | * @param imMessageDO IM消息数据对象 | 145 | * @param imMessageDO IM消息数据对象 |
| 101 | * @param message 发送的IM消息 | 146 | * @param message 发送的IM消息 |
| 102 | - * @param messageType 消息类型 | ||
| 103 | * @param sequence 序列 | 147 | * @param sequence 序列 |
| 104 | */ | 148 | */ |
| 105 | - private void sendMessage(Long fromUserId, Long inboxId, ImMessageDO imMessageDO, ImSendMessage message, String messageType, Long sequence) { | 149 | + private void sendMessage(Long fromUserId, Long inboxId, ImMessageDO imMessageDO, ImSendMessage message, Long sequence) { |
| 106 | ImReceiveMessage receiveMessage = new ImReceiveMessage(); // 创建接收消息 | 150 | ImReceiveMessage receiveMessage = new ImReceiveMessage(); // 创建接收消息 |
| 107 | receiveMessage.setFromId(fromUserId); // 设置发送者ID | 151 | receiveMessage.setFromId(fromUserId); // 设置发送者ID |
| 108 | - receiveMessage.setConversationType(ImConversationTypeEnum.PRIVATE.getType()); // 设置会话类型为私人 | 152 | + receiveMessage.setConversationType(message.getConversationType()); // 设置会话类型 |
| 109 | receiveMessage.setContentType(message.getContentType()); // 设置内容类型 | 153 | receiveMessage.setContentType(message.getContentType()); // 设置内容类型 |
| 110 | receiveMessage.setContent(message.getContent()); // 设置内容 | 154 | receiveMessage.setContent(message.getContent()); // 设置内容 |
| 111 | receiveMessage.setMessageId(imMessageDO.getId()); // 设置消息ID | 155 | receiveMessage.setMessageId(imMessageDO.getId()); // 设置消息ID |
| 112 | receiveMessage.setInboxId(inboxId); // 设置收件箱ID | 156 | receiveMessage.setInboxId(inboxId); // 设置收件箱ID |
| 113 | receiveMessage.setSendTime(imMessageDO.getSendTime()); // 设置发送时间 | 157 | receiveMessage.setSendTime(imMessageDO.getSendTime()); // 设置发送时间 |
| 114 | receiveMessage.setSequence(sequence); // 设置序列 | 158 | receiveMessage.setSequence(sequence); // 设置序列 |
| 115 | - webSocketMessageSender.sendObject(UserTypeEnum.ADMIN.getValue(), fromUserId, messageType, receiveMessage); // 发送消息 | 159 | + webSocketMessageSender.sendObject(UserTypeEnum.ADMIN.getValue(), fromUserId, ImWebSocketMessageListener.IM_MESSAGE_RECEIVE, receiveMessage); // 发送消息 |
| 116 | } | 160 | } |
| 117 | 161 | ||
| 118 | /** | 162 | /** |
yudao-module-im/yudao-module-im-biz/src/main/resources/mapper/conversation/ImConversationMapper.xml
0 → 100755
| 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"> | ||
| 3 | +<mapper namespace="cn.iocoder.yudao.module.im.dal.mysql.conversation.ImConversationMapper"> | ||
| 4 | + | ||
| 5 | + <!-- | ||
| 6 | + 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 | ||
| 7 | + 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。 | ||
| 8 | + 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 | ||
| 9 | + 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ | ||
| 10 | + --> | ||
| 11 | + | ||
| 12 | +</mapper> | ||
| 0 | \ No newline at end of file | 13 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/resources/mapper/inbox/InboxMapper.xml renamed to yudao-module-im/yudao-module-im-biz/src/main/resources/mapper/group/ImGroupMapper.xml
100755 → 100644
| 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.InboxMapper"> | 3 | +<mapper namespace="cn.iocoder.yudao.module.im.dal.mysql.group.ImGroupMapper"> |
| 4 | 4 | ||
| 5 | <!-- | 5 | <!-- |
| 6 | 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 | 6 | 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 |
yudao-module-im/yudao-module-im-biz/src/main/resources/mapper/groupmember/ImGroupMemberMapper.xml
0 → 100644
| 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"> | ||
| 3 | +<mapper namespace="cn.iocoder.yudao.module.im.dal.mysql.groupmember.ImGroupMemberMapper"> | ||
| 4 | + | ||
| 5 | + <!-- | ||
| 6 | + 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 | ||
| 7 | + 无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。 | ||
| 8 | + 代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。 | ||
| 9 | + 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ | ||
| 10 | + --> | ||
| 11 | + | ||
| 12 | +</mapper> | ||
| 0 | \ No newline at end of file | 13 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/main/resources/mapper/conversation/ConversationMapper.xml renamed to yudao-module-im/yudao-module-im-biz/src/main/resources/mapper/inbox/ImInboxMapper.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.conversation.ConversationMapper"> | 3 | +<mapper namespace="cn.iocoder.yudao.module.im.dal.mysql.inbox.ImInboxMapper"> |
| 4 | 4 | ||
| 5 | <!-- | 5 | <!-- |
| 6 | 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 | 6 | 一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。 |
yudao-module-im/yudao-module-im-biz/src/test/java/cn/iocoder/yudao/module/im/service/conversation/ImConversationServiceImplTest.java
| @@ -9,7 +9,7 @@ import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | @@ -9,7 +9,7 @@ import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | ||
| 9 | 9 | ||
| 10 | import cn.iocoder.yudao.module.im.controller.admin.conversation.vo.*; | 10 | import cn.iocoder.yudao.module.im.controller.admin.conversation.vo.*; |
| 11 | import cn.iocoder.yudao.module.im.dal.dataobject.conversation.ImConversationDO; | 11 | import cn.iocoder.yudao.module.im.dal.dataobject.conversation.ImConversationDO; |
| 12 | -import cn.iocoder.yudao.module.im.dal.mysql.conversation.ConversationMapper; | 12 | +import cn.iocoder.yudao.module.im.dal.mysql.conversation.ImConversationMapper; |
| 13 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 13 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 14 | 14 | ||
| 15 | import org.springframework.context.annotation.Import; | 15 | import org.springframework.context.annotation.Import; |
| @@ -33,7 +33,7 @@ public class ImConversationServiceImplTest extends BaseDbUnitTest { | @@ -33,7 +33,7 @@ public class ImConversationServiceImplTest extends BaseDbUnitTest { | ||
| 33 | private ImConversationServiceImpl conversationService; | 33 | private ImConversationServiceImpl conversationService; |
| 34 | 34 | ||
| 35 | @Resource | 35 | @Resource |
| 36 | - private ConversationMapper conversationMapper; | 36 | + private ImConversationMapper imConversationMapper; |
| 37 | 37 | ||
| 38 | @Test | 38 | @Test |
| 39 | public void testCreateConversation_success() { | 39 | public void testCreateConversation_success() { |
| @@ -45,7 +45,7 @@ public class ImConversationServiceImplTest extends BaseDbUnitTest { | @@ -45,7 +45,7 @@ public class ImConversationServiceImplTest extends BaseDbUnitTest { | ||
| 45 | // 断言 | 45 | // 断言 |
| 46 | assertNotNull(conversationId); | 46 | assertNotNull(conversationId); |
| 47 | // 校验记录的属性是否正确 | 47 | // 校验记录的属性是否正确 |
| 48 | - ImConversationDO conversation = conversationMapper.selectById(conversationId); | 48 | + ImConversationDO conversation = imConversationMapper.selectById(conversationId); |
| 49 | assertPojoEquals(createReqVO, conversation, "id"); | 49 | assertPojoEquals(createReqVO, conversation, "id"); |
| 50 | } | 50 | } |
| 51 | 51 | ||
| @@ -53,7 +53,7 @@ public class ImConversationServiceImplTest extends BaseDbUnitTest { | @@ -53,7 +53,7 @@ public class ImConversationServiceImplTest extends BaseDbUnitTest { | ||
| 53 | public void testUpdateConversation_success() { | 53 | public void testUpdateConversation_success() { |
| 54 | // mock 数据 | 54 | // mock 数据 |
| 55 | ImConversationDO dbConversation = randomPojo(ImConversationDO.class); | 55 | ImConversationDO dbConversation = randomPojo(ImConversationDO.class); |
| 56 | - conversationMapper.insert(dbConversation);// @Sql: 先插入出一条存在的数据 | 56 | + imConversationMapper.insert(dbConversation);// @Sql: 先插入出一条存在的数据 |
| 57 | // 准备参数 | 57 | // 准备参数 |
| 58 | ImConversationSaveReqVO updateReqVO = randomPojo(ImConversationSaveReqVO.class, o -> { | 58 | ImConversationSaveReqVO updateReqVO = randomPojo(ImConversationSaveReqVO.class, o -> { |
| 59 | o.setId(dbConversation.getId()); // 设置更新的 ID | 59 | o.setId(dbConversation.getId()); // 设置更新的 ID |
| @@ -62,7 +62,7 @@ public class ImConversationServiceImplTest extends BaseDbUnitTest { | @@ -62,7 +62,7 @@ public class ImConversationServiceImplTest extends BaseDbUnitTest { | ||
| 62 | // 调用 | 62 | // 调用 |
| 63 | conversationService.updateConversation(updateReqVO); | 63 | conversationService.updateConversation(updateReqVO); |
| 64 | // 校验是否更新正确 | 64 | // 校验是否更新正确 |
| 65 | - ImConversationDO conversation = conversationMapper.selectById(updateReqVO.getId()); // 获取最新的 | 65 | + ImConversationDO conversation = imConversationMapper.selectById(updateReqVO.getId()); // 获取最新的 |
| 66 | assertPojoEquals(updateReqVO, conversation); | 66 | assertPojoEquals(updateReqVO, conversation); |
| 67 | } | 67 | } |
| 68 | 68 | ||
| @@ -79,14 +79,14 @@ public class ImConversationServiceImplTest extends BaseDbUnitTest { | @@ -79,14 +79,14 @@ public class ImConversationServiceImplTest extends BaseDbUnitTest { | ||
| 79 | public void testDeleteConversation_success() { | 79 | public void testDeleteConversation_success() { |
| 80 | // mock 数据 | 80 | // mock 数据 |
| 81 | ImConversationDO dbConversation = randomPojo(ImConversationDO.class); | 81 | ImConversationDO dbConversation = randomPojo(ImConversationDO.class); |
| 82 | - conversationMapper.insert(dbConversation);// @Sql: 先插入出一条存在的数据 | 82 | + imConversationMapper.insert(dbConversation);// @Sql: 先插入出一条存在的数据 |
| 83 | // 准备参数 | 83 | // 准备参数 |
| 84 | Long id = dbConversation.getId(); | 84 | Long id = dbConversation.getId(); |
| 85 | 85 | ||
| 86 | // 调用 | 86 | // 调用 |
| 87 | conversationService.deleteConversation(id); | 87 | conversationService.deleteConversation(id); |
| 88 | // 校验数据不存在了 | 88 | // 校验数据不存在了 |
| 89 | - assertNull(conversationMapper.selectById(id)); | 89 | + assertNull(imConversationMapper.selectById(id)); |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | @Test | 92 | @Test |
| @@ -111,21 +111,21 @@ public class ImConversationServiceImplTest extends BaseDbUnitTest { | @@ -111,21 +111,21 @@ public class ImConversationServiceImplTest extends BaseDbUnitTest { | ||
| 111 | o.setLastReadTime(null); | 111 | o.setLastReadTime(null); |
| 112 | o.setCreateTime(null); | 112 | o.setCreateTime(null); |
| 113 | }); | 113 | }); |
| 114 | - conversationMapper.insert(dbConversation); | 114 | + imConversationMapper.insert(dbConversation); |
| 115 | // 测试 userId 不匹配 | 115 | // 测试 userId 不匹配 |
| 116 | - conversationMapper.insert(cloneIgnoreId(dbConversation, o -> o.setUserId(null))); | 116 | + imConversationMapper.insert(cloneIgnoreId(dbConversation, o -> o.setUserId(null))); |
| 117 | // 测试 conversationType 不匹配 | 117 | // 测试 conversationType 不匹配 |
| 118 | - conversationMapper.insert(cloneIgnoreId(dbConversation, o -> o.setConversationType(null))); | 118 | + imConversationMapper.insert(cloneIgnoreId(dbConversation, o -> o.setConversationType(null))); |
| 119 | // 测试 targetId 不匹配 | 119 | // 测试 targetId 不匹配 |
| 120 | - conversationMapper.insert(cloneIgnoreId(dbConversation, o -> o.setTargetId(null))); | 120 | + imConversationMapper.insert(cloneIgnoreId(dbConversation, o -> o.setTargetId(null))); |
| 121 | // 测试 no 不匹配 | 121 | // 测试 no 不匹配 |
| 122 | - conversationMapper.insert(cloneIgnoreId(dbConversation, o -> o.setNo(null))); | 122 | + imConversationMapper.insert(cloneIgnoreId(dbConversation, o -> o.setNo(null))); |
| 123 | // 测试 pinned 不匹配 | 123 | // 测试 pinned 不匹配 |
| 124 | - conversationMapper.insert(cloneIgnoreId(dbConversation, o -> o.setPinned(null))); | 124 | + imConversationMapper.insert(cloneIgnoreId(dbConversation, o -> o.setPinned(null))); |
| 125 | // 测试 lastReadTime 不匹配 | 125 | // 测试 lastReadTime 不匹配 |
| 126 | - conversationMapper.insert(cloneIgnoreId(dbConversation, o -> o.setLastReadTime(null))); | 126 | + imConversationMapper.insert(cloneIgnoreId(dbConversation, o -> o.setLastReadTime(null))); |
| 127 | // 测试 createTime 不匹配 | 127 | // 测试 createTime 不匹配 |
| 128 | - conversationMapper.insert(cloneIgnoreId(dbConversation, o -> o.setCreateTime(null))); | 128 | + imConversationMapper.insert(cloneIgnoreId(dbConversation, o -> o.setCreateTime(null))); |
| 129 | // 准备参数 | 129 | // 准备参数 |
| 130 | ImConversationPageReqVO reqVO = new ImConversationPageReqVO(); | 130 | ImConversationPageReqVO reqVO = new ImConversationPageReqVO(); |
| 131 | reqVO.setUserId(null); | 131 | reqVO.setUserId(null); |
yudao-module-im/yudao-module-im-biz/src/test/java/cn/iocoder/yudao/module/im/service/group/ImGroupServiceImplTest.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.im.service.group; | ||
| 2 | + | ||
| 3 | +import org.junit.jupiter.api.Disabled; | ||
| 4 | +import org.junit.jupiter.api.Test; | ||
| 5 | + | ||
| 6 | +import jakarta.annotation.Resource; | ||
| 7 | + | ||
| 8 | +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | ||
| 9 | + | ||
| 10 | +import cn.iocoder.yudao.module.im.controller.admin.group.vo.*; | ||
| 11 | +import cn.iocoder.yudao.module.im.dal.dataobject.group.ImGroupDO; | ||
| 12 | +import cn.iocoder.yudao.module.im.dal.mysql.group.ImGroupMapper; | ||
| 13 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 14 | + | ||
| 15 | +import org.springframework.context.annotation.Import; | ||
| 16 | + | ||
| 17 | +import static cn.iocoder.yudao.module.im.enums.ErrorCodeConstants.*; | ||
| 18 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; | ||
| 19 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; | ||
| 20 | +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; | ||
| 21 | +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; | ||
| 22 | +import static org.junit.jupiter.api.Assertions.*; | ||
| 23 | + | ||
| 24 | +/** | ||
| 25 | + * {@link ImGroupServiceImpl} 的单元测试类 | ||
| 26 | + * | ||
| 27 | + * @author 芋道源码 | ||
| 28 | + */ | ||
| 29 | +@Import(ImGroupServiceImpl.class) | ||
| 30 | +public class ImGroupServiceImplTest extends BaseDbUnitTest { | ||
| 31 | + | ||
| 32 | + @Resource | ||
| 33 | + private ImGroupServiceImpl groupService; | ||
| 34 | + | ||
| 35 | + @Resource | ||
| 36 | + private ImGroupMapper imGroupMapper; | ||
| 37 | + | ||
| 38 | + @Test | ||
| 39 | + public void testCreateGroup_success() { | ||
| 40 | + // 准备参数 | ||
| 41 | + ImGroupSaveReqVO createReqVO = randomPojo(ImGroupSaveReqVO.class).setId(null); | ||
| 42 | + | ||
| 43 | + // 调用 | ||
| 44 | + Long groupId = groupService.createGroup(createReqVO); | ||
| 45 | + // 断言 | ||
| 46 | + assertNotNull(groupId); | ||
| 47 | + // 校验记录的属性是否正确 | ||
| 48 | + ImGroupDO group = imGroupMapper.selectById(groupId); | ||
| 49 | + assertPojoEquals(createReqVO, group, "id"); | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + @Test | ||
| 53 | + public void testUpdateGroup_success() { | ||
| 54 | + // mock 数据 | ||
| 55 | + ImGroupDO dbGroup = randomPojo(ImGroupDO.class); | ||
| 56 | + imGroupMapper.insert(dbGroup);// @Sql: 先插入出一条存在的数据 | ||
| 57 | + // 准备参数 | ||
| 58 | + ImGroupSaveReqVO updateReqVO = randomPojo(ImGroupSaveReqVO.class, o -> { | ||
| 59 | + o.setId(dbGroup.getId()); // 设置更新的 ID | ||
| 60 | + }); | ||
| 61 | + | ||
| 62 | + // 调用 | ||
| 63 | + groupService.updateGroup(updateReqVO); | ||
| 64 | + // 校验是否更新正确 | ||
| 65 | + ImGroupDO group = imGroupMapper.selectById(updateReqVO.getId()); // 获取最新的 | ||
| 66 | + assertPojoEquals(updateReqVO, group); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + @Test | ||
| 70 | + public void testUpdateGroup_notExists() { | ||
| 71 | + // 准备参数 | ||
| 72 | + ImGroupSaveReqVO updateReqVO = randomPojo(ImGroupSaveReqVO.class); | ||
| 73 | + | ||
| 74 | + // 调用, 并断言异常 | ||
| 75 | + assertServiceException(() -> groupService.updateGroup(updateReqVO), GROUP_NOT_EXISTS); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + @Test | ||
| 79 | + public void testDeleteGroup_success() { | ||
| 80 | + // mock 数据 | ||
| 81 | + ImGroupDO dbGroup = randomPojo(ImGroupDO.class); | ||
| 82 | + imGroupMapper.insert(dbGroup);// @Sql: 先插入出一条存在的数据 | ||
| 83 | + // 准备参数 | ||
| 84 | + Long id = dbGroup.getId(); | ||
| 85 | + | ||
| 86 | + // 调用 | ||
| 87 | + groupService.deleteGroup(id); | ||
| 88 | + // 校验数据不存在了 | ||
| 89 | + assertNull(imGroupMapper.selectById(id)); | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + @Test | ||
| 93 | + public void testDeleteGroup_notExists() { | ||
| 94 | + // 准备参数 | ||
| 95 | + Long id = randomLongId(); | ||
| 96 | + | ||
| 97 | + // 调用, 并断言异常 | ||
| 98 | + assertServiceException(() -> groupService.deleteGroup(id), GROUP_NOT_EXISTS); | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + @Test | ||
| 102 | + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | ||
| 103 | + public void testGetGroupPage() { | ||
| 104 | + // mock 数据 | ||
| 105 | + ImGroupDO dbGroup = randomPojo(ImGroupDO.class, o -> { // 等会查询到 | ||
| 106 | + o.setGroupName(null); | ||
| 107 | + o.setOwnerId(null); | ||
| 108 | + o.setHeadImage(null); | ||
| 109 | + o.setHeadImageThumb(null); | ||
| 110 | + o.setNotice(null); | ||
| 111 | + o.setRemark(null); | ||
| 112 | + o.setCreateTime(null); | ||
| 113 | + }); | ||
| 114 | + imGroupMapper.insert(dbGroup); | ||
| 115 | + // 测试 groupName 不匹配 | ||
| 116 | + imGroupMapper.insert(cloneIgnoreId(dbGroup, o -> o.setGroupName(null))); | ||
| 117 | + // 测试 ownerId 不匹配 | ||
| 118 | + imGroupMapper.insert(cloneIgnoreId(dbGroup, o -> o.setOwnerId(null))); | ||
| 119 | + // 测试 headImage 不匹配 | ||
| 120 | + imGroupMapper.insert(cloneIgnoreId(dbGroup, o -> o.setHeadImage(null))); | ||
| 121 | + // 测试 headImageThumb 不匹配 | ||
| 122 | + imGroupMapper.insert(cloneIgnoreId(dbGroup, o -> o.setHeadImageThumb(null))); | ||
| 123 | + // 测试 notice 不匹配 | ||
| 124 | + imGroupMapper.insert(cloneIgnoreId(dbGroup, o -> o.setNotice(null))); | ||
| 125 | + // 测试 remark 不匹配 | ||
| 126 | + imGroupMapper.insert(cloneIgnoreId(dbGroup, o -> o.setRemark(null))); | ||
| 127 | + // 测试 createTime 不匹配 | ||
| 128 | + imGroupMapper.insert(cloneIgnoreId(dbGroup, o -> o.setCreateTime(null))); | ||
| 129 | + // 准备参数 | ||
| 130 | + ImGroupPageReqVO reqVO = new ImGroupPageReqVO(); | ||
| 131 | + reqVO.setGroupName(null); | ||
| 132 | + reqVO.setOwnerId(null); | ||
| 133 | + reqVO.setHeadImage(null); | ||
| 134 | + reqVO.setHeadImageThumb(null); | ||
| 135 | + reqVO.setNotice(null); | ||
| 136 | + reqVO.setRemark(null); | ||
| 137 | + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | ||
| 138 | + | ||
| 139 | + // 调用 | ||
| 140 | + PageResult<ImGroupDO> pageResult = groupService.getGroupPage(reqVO); | ||
| 141 | + // 断言 | ||
| 142 | + assertEquals(1, pageResult.getTotal()); | ||
| 143 | + assertEquals(1, pageResult.getList().size()); | ||
| 144 | + assertPojoEquals(dbGroup, pageResult.getList().get(0)); | ||
| 145 | + } | ||
| 146 | + | ||
| 147 | +} | ||
| 0 | \ No newline at end of file | 148 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/test/java/cn/iocoder/yudao/module/im/service/groupmember/ImGroupMemberServiceImplTest.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.im.service.groupmember; | ||
| 2 | + | ||
| 3 | +import org.junit.jupiter.api.Disabled; | ||
| 4 | +import org.junit.jupiter.api.Test; | ||
| 5 | + | ||
| 6 | +import jakarta.annotation.Resource; | ||
| 7 | + | ||
| 8 | +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | ||
| 9 | + | ||
| 10 | +import cn.iocoder.yudao.module.im.controller.admin.groupmember.vo.*; | ||
| 11 | +import cn.iocoder.yudao.module.im.dal.dataobject.groupmember.GroupMemberDO; | ||
| 12 | +import cn.iocoder.yudao.module.im.dal.mysql.groupmember.ImGroupMemberMapper; | ||
| 13 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 14 | + | ||
| 15 | +import org.springframework.context.annotation.Import; | ||
| 16 | + | ||
| 17 | +import static cn.iocoder.yudao.module.im.enums.ErrorCodeConstants.*; | ||
| 18 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; | ||
| 19 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; | ||
| 20 | +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; | ||
| 21 | +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; | ||
| 22 | +import static org.junit.jupiter.api.Assertions.*; | ||
| 23 | + | ||
| 24 | +/** | ||
| 25 | + * {@link ImGroupMemberServiceImpl} 的单元测试类 | ||
| 26 | + * | ||
| 27 | + * @author 芋道源码 | ||
| 28 | + */ | ||
| 29 | +@Import(ImGroupMemberServiceImpl.class) | ||
| 30 | +public class ImGroupMemberServiceImplTest extends BaseDbUnitTest { | ||
| 31 | + | ||
| 32 | + @Resource | ||
| 33 | + private ImGroupMemberServiceImpl groupMemberService; | ||
| 34 | + | ||
| 35 | + @Resource | ||
| 36 | + private ImGroupMemberMapper imGroupMemberMapper; | ||
| 37 | + | ||
| 38 | + @Test | ||
| 39 | + public void testCreateGroupMember_success() { | ||
| 40 | + // 准备参数 | ||
| 41 | + ImGroupMemberSaveReqVO createReqVO = randomPojo(ImGroupMemberSaveReqVO.class).setId(null); | ||
| 42 | + | ||
| 43 | + // 调用 | ||
| 44 | + Long groupMemberId = groupMemberService.createGroupMember(createReqVO); | ||
| 45 | + // 断言 | ||
| 46 | + assertNotNull(groupMemberId); | ||
| 47 | + // 校验记录的属性是否正确 | ||
| 48 | + GroupMemberDO groupMember = imGroupMemberMapper.selectById(groupMemberId); | ||
| 49 | + assertPojoEquals(createReqVO, groupMember, "id"); | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + @Test | ||
| 53 | + public void testUpdateGroupMember_success() { | ||
| 54 | + // mock 数据 | ||
| 55 | + GroupMemberDO dbGroupMember = randomPojo(GroupMemberDO.class); | ||
| 56 | + imGroupMemberMapper.insert(dbGroupMember);// @Sql: 先插入出一条存在的数据 | ||
| 57 | + // 准备参数 | ||
| 58 | + ImGroupMemberSaveReqVO updateReqVO = randomPojo(ImGroupMemberSaveReqVO.class, o -> { | ||
| 59 | + o.setId(dbGroupMember.getId()); // 设置更新的 ID | ||
| 60 | + }); | ||
| 61 | + | ||
| 62 | + // 调用 | ||
| 63 | + groupMemberService.updateGroupMember(updateReqVO); | ||
| 64 | + // 校验是否更新正确 | ||
| 65 | + GroupMemberDO groupMember = imGroupMemberMapper.selectById(updateReqVO.getId()); // 获取最新的 | ||
| 66 | + assertPojoEquals(updateReqVO, groupMember); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + @Test | ||
| 70 | + public void testUpdateGroupMember_notExists() { | ||
| 71 | + // 准备参数 | ||
| 72 | + ImGroupMemberSaveReqVO updateReqVO = randomPojo(ImGroupMemberSaveReqVO.class); | ||
| 73 | + | ||
| 74 | + // 调用, 并断言异常 | ||
| 75 | + assertServiceException(() -> groupMemberService.updateGroupMember(updateReqVO), GROUP_MEMBER_NOT_EXISTS); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + @Test | ||
| 79 | + public void testDeleteGroupMember_success() { | ||
| 80 | + // mock 数据 | ||
| 81 | + GroupMemberDO dbGroupMember = randomPojo(GroupMemberDO.class); | ||
| 82 | + imGroupMemberMapper.insert(dbGroupMember);// @Sql: 先插入出一条存在的数据 | ||
| 83 | + // 准备参数 | ||
| 84 | + Long id = dbGroupMember.getId(); | ||
| 85 | + | ||
| 86 | + // 调用 | ||
| 87 | + groupMemberService.deleteGroupMember(id); | ||
| 88 | + // 校验数据不存在了 | ||
| 89 | + assertNull(imGroupMemberMapper.selectById(id)); | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + @Test | ||
| 93 | + public void testDeleteGroupMember_notExists() { | ||
| 94 | + // 准备参数 | ||
| 95 | + Long id = randomLongId(); | ||
| 96 | + | ||
| 97 | + // 调用, 并断言异常 | ||
| 98 | + assertServiceException(() -> groupMemberService.deleteGroupMember(id), GROUP_MEMBER_NOT_EXISTS); | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + @Test | ||
| 102 | + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | ||
| 103 | + public void testGetGroupMemberPage() { | ||
| 104 | + // mock 数据 | ||
| 105 | + GroupMemberDO dbGroupMember = randomPojo(GroupMemberDO.class, o -> { // 等会查询到 | ||
| 106 | + o.setGroupId(null); | ||
| 107 | + o.setUserId(null); | ||
| 108 | + o.setNickname(null); | ||
| 109 | + o.setAvatar(null); | ||
| 110 | + o.setAliasName(null); | ||
| 111 | + o.setRemark(null); | ||
| 112 | + o.setCreateTime(null); | ||
| 113 | + }); | ||
| 114 | + imGroupMemberMapper.insert(dbGroupMember); | ||
| 115 | + // 测试 groupId 不匹配 | ||
| 116 | + imGroupMemberMapper.insert(cloneIgnoreId(dbGroupMember, o -> o.setGroupId(null))); | ||
| 117 | + // 测试 userId 不匹配 | ||
| 118 | + imGroupMemberMapper.insert(cloneIgnoreId(dbGroupMember, o -> o.setUserId(null))); | ||
| 119 | + // 测试 nickname 不匹配 | ||
| 120 | + imGroupMemberMapper.insert(cloneIgnoreId(dbGroupMember, o -> o.setNickname(null))); | ||
| 121 | + // 测试 avatar 不匹配 | ||
| 122 | + imGroupMemberMapper.insert(cloneIgnoreId(dbGroupMember, o -> o.setAvatar(null))); | ||
| 123 | + // 测试 aliasName 不匹配 | ||
| 124 | + imGroupMemberMapper.insert(cloneIgnoreId(dbGroupMember, o -> o.setAliasName(null))); | ||
| 125 | + // 测试 remark 不匹配 | ||
| 126 | + imGroupMemberMapper.insert(cloneIgnoreId(dbGroupMember, o -> o.setRemark(null))); | ||
| 127 | + // 测试 createTime 不匹配 | ||
| 128 | + imGroupMemberMapper.insert(cloneIgnoreId(dbGroupMember, o -> o.setCreateTime(null))); | ||
| 129 | + // 准备参数 | ||
| 130 | + ImGroupMemberPageReqVO reqVO = new ImGroupMemberPageReqVO(); | ||
| 131 | + reqVO.setGroupId(null); | ||
| 132 | + reqVO.setUserId(null); | ||
| 133 | + reqVO.setNickname(null); | ||
| 134 | + reqVO.setAvatar(null); | ||
| 135 | + reqVO.setAliasName(null); | ||
| 136 | + reqVO.setRemark(null); | ||
| 137 | + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | ||
| 138 | + | ||
| 139 | + // 调用 | ||
| 140 | + PageResult<GroupMemberDO> pageResult = groupMemberService.getGroupMemberPage(reqVO); | ||
| 141 | + // 断言 | ||
| 142 | + assertEquals(1, pageResult.getTotal()); | ||
| 143 | + assertEquals(1, pageResult.getList().size()); | ||
| 144 | + assertPojoEquals(dbGroupMember, pageResult.getList().get(0)); | ||
| 145 | + } | ||
| 146 | + | ||
| 147 | +} | ||
| 0 | \ No newline at end of file | 148 | \ No newline at end of file |
yudao-module-im/yudao-module-im-biz/src/test/java/cn/iocoder/yudao/module/im/service/inbox/ImInboxServiceImplTest.java
| @@ -9,7 +9,7 @@ import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | @@ -9,7 +9,7 @@ import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | ||
| 9 | 9 | ||
| 10 | import cn.iocoder.yudao.module.im.controller.admin.inbox.vo.*; | 10 | import cn.iocoder.yudao.module.im.controller.admin.inbox.vo.*; |
| 11 | import cn.iocoder.yudao.module.im.dal.dataobject.inbox.ImInboxDO; | 11 | import cn.iocoder.yudao.module.im.dal.dataobject.inbox.ImInboxDO; |
| 12 | -import cn.iocoder.yudao.module.im.dal.mysql.inbox.InboxMapper; | 12 | +import cn.iocoder.yudao.module.im.dal.mysql.inbox.ImInboxMapper; |
| 13 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 13 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 14 | 14 | ||
| 15 | import org.springframework.context.annotation.Import; | 15 | import org.springframework.context.annotation.Import; |
| @@ -33,7 +33,7 @@ public class ImInboxServiceImplTest extends BaseDbUnitTest { | @@ -33,7 +33,7 @@ public class ImInboxServiceImplTest extends BaseDbUnitTest { | ||
| 33 | private ImInboxServiceImpl inboxService; | 33 | private ImInboxServiceImpl inboxService; |
| 34 | 34 | ||
| 35 | @Resource | 35 | @Resource |
| 36 | - private InboxMapper inboxMapper; | 36 | + private ImInboxMapper imInboxMapper; |
| 37 | 37 | ||
| 38 | @Test | 38 | @Test |
| 39 | public void testCreateInbox_success() { | 39 | public void testCreateInbox_success() { |
| @@ -45,7 +45,7 @@ public class ImInboxServiceImplTest extends BaseDbUnitTest { | @@ -45,7 +45,7 @@ public class ImInboxServiceImplTest extends BaseDbUnitTest { | ||
| 45 | // 断言 | 45 | // 断言 |
| 46 | assertNotNull(inboxId); | 46 | assertNotNull(inboxId); |
| 47 | // 校验记录的属性是否正确 | 47 | // 校验记录的属性是否正确 |
| 48 | - ImInboxDO inbox = inboxMapper.selectById(inboxId); | 48 | + ImInboxDO inbox = imInboxMapper.selectById(inboxId); |
| 49 | assertPojoEquals(createReqVO, inbox, "id"); | 49 | assertPojoEquals(createReqVO, inbox, "id"); |
| 50 | } | 50 | } |
| 51 | 51 | ||
| @@ -53,7 +53,7 @@ public class ImInboxServiceImplTest extends BaseDbUnitTest { | @@ -53,7 +53,7 @@ public class ImInboxServiceImplTest extends BaseDbUnitTest { | ||
| 53 | public void testUpdateInbox_success() { | 53 | public void testUpdateInbox_success() { |
| 54 | // mock 数据 | 54 | // mock 数据 |
| 55 | ImInboxDO dbInbox = randomPojo(ImInboxDO.class); | 55 | ImInboxDO dbInbox = randomPojo(ImInboxDO.class); |
| 56 | - inboxMapper.insert(dbInbox);// @Sql: 先插入出一条存在的数据 | 56 | + imInboxMapper.insert(dbInbox);// @Sql: 先插入出一条存在的数据 |
| 57 | // 准备参数 | 57 | // 准备参数 |
| 58 | ImInboxSaveReqVO updateReqVO = randomPojo(ImInboxSaveReqVO.class, o -> { | 58 | ImInboxSaveReqVO updateReqVO = randomPojo(ImInboxSaveReqVO.class, o -> { |
| 59 | o.setId(dbInbox.getId()); // 设置更新的 ID | 59 | o.setId(dbInbox.getId()); // 设置更新的 ID |
| @@ -62,7 +62,7 @@ public class ImInboxServiceImplTest extends BaseDbUnitTest { | @@ -62,7 +62,7 @@ public class ImInboxServiceImplTest extends BaseDbUnitTest { | ||
| 62 | // 调用 | 62 | // 调用 |
| 63 | inboxService.updateInbox(updateReqVO); | 63 | inboxService.updateInbox(updateReqVO); |
| 64 | // 校验是否更新正确 | 64 | // 校验是否更新正确 |
| 65 | - ImInboxDO inbox = inboxMapper.selectById(updateReqVO.getId()); // 获取最新的 | 65 | + ImInboxDO inbox = imInboxMapper.selectById(updateReqVO.getId()); // 获取最新的 |
| 66 | assertPojoEquals(updateReqVO, inbox); | 66 | assertPojoEquals(updateReqVO, inbox); |
| 67 | } | 67 | } |
| 68 | 68 | ||
| @@ -79,14 +79,14 @@ public class ImInboxServiceImplTest extends BaseDbUnitTest { | @@ -79,14 +79,14 @@ public class ImInboxServiceImplTest extends BaseDbUnitTest { | ||
| 79 | public void testDeleteInbox_success() { | 79 | public void testDeleteInbox_success() { |
| 80 | // mock 数据 | 80 | // mock 数据 |
| 81 | ImInboxDO dbInbox = randomPojo(ImInboxDO.class); | 81 | ImInboxDO dbInbox = randomPojo(ImInboxDO.class); |
| 82 | - inboxMapper.insert(dbInbox);// @Sql: 先插入出一条存在的数据 | 82 | + imInboxMapper.insert(dbInbox);// @Sql: 先插入出一条存在的数据 |
| 83 | // 准备参数 | 83 | // 准备参数 |
| 84 | Long id = dbInbox.getId(); | 84 | Long id = dbInbox.getId(); |
| 85 | 85 | ||
| 86 | // 调用 | 86 | // 调用 |
| 87 | inboxService.deleteInbox(id); | 87 | inboxService.deleteInbox(id); |
| 88 | // 校验数据不存在了 | 88 | // 校验数据不存在了 |
| 89 | - assertNull(inboxMapper.selectById(id)); | 89 | + assertNull(imInboxMapper.selectById(id)); |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | @Test | 92 | @Test |
| @@ -108,15 +108,15 @@ public class ImInboxServiceImplTest extends BaseDbUnitTest { | @@ -108,15 +108,15 @@ public class ImInboxServiceImplTest extends BaseDbUnitTest { | ||
| 108 | o.setSequence(null); | 108 | o.setSequence(null); |
| 109 | o.setCreateTime(null); | 109 | o.setCreateTime(null); |
| 110 | }); | 110 | }); |
| 111 | - inboxMapper.insert(dbInbox); | 111 | + imInboxMapper.insert(dbInbox); |
| 112 | // 测试 userId 不匹配 | 112 | // 测试 userId 不匹配 |
| 113 | - inboxMapper.insert(cloneIgnoreId(dbInbox, o -> o.setUserId(null))); | 113 | + imInboxMapper.insert(cloneIgnoreId(dbInbox, o -> o.setUserId(null))); |
| 114 | // 测试 messageId 不匹配 | 114 | // 测试 messageId 不匹配 |
| 115 | - inboxMapper.insert(cloneIgnoreId(dbInbox, o -> o.setMessageId(null))); | 115 | + imInboxMapper.insert(cloneIgnoreId(dbInbox, o -> o.setMessageId(null))); |
| 116 | // 测试 sequence 不匹配 | 116 | // 测试 sequence 不匹配 |
| 117 | - inboxMapper.insert(cloneIgnoreId(dbInbox, o -> o.setSequence(null))); | 117 | + imInboxMapper.insert(cloneIgnoreId(dbInbox, o -> o.setSequence(null))); |
| 118 | // 测试 createTime 不匹配 | 118 | // 测试 createTime 不匹配 |
| 119 | - inboxMapper.insert(cloneIgnoreId(dbInbox, o -> o.setCreateTime(null))); | 119 | + imInboxMapper.insert(cloneIgnoreId(dbInbox, o -> o.setCreateTime(null))); |
| 120 | // 准备参数 | 120 | // 准备参数 |
| 121 | ImInboxPageReqVO reqVO = new ImInboxPageReqVO(); | 121 | ImInboxPageReqVO reqVO = new ImInboxPageReqVO(); |
| 122 | reqVO.setUserId(null); | 122 | reqVO.setUserId(null); |