From 800c44a46eede8d592a547d0ff82b99890cc7fc0 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Mon, 21 Aug 2023 23:18:04 +0800 Subject: [PATCH] =?UTF-8?q?code=20review=EF=BC=9A=E4=BC=9A=E5=91=98?= =?UTF-8?q?=E7=AD=89=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../level/MemberExperienceLogController.java | 7 ++++--- .../admin/level/MemberLevelController.java | 7 +++---- .../admin/level/MemberLevelLogController.java | 7 ++++--- .../vo/experience/MemberExperienceLogBaseVO.java | 2 +- .../level/vo/{ => level}/MemberLevelBaseVO.java | 15 +++++++++------ .../vo/{ => level}/MemberLevelCreateReqVO.java | 3 ++- .../vo/{ => level}/MemberLevelPageReqVO.java | 2 +- .../level/vo/{ => level}/MemberLevelRespVO.java | 2 +- .../vo/{ => level}/MemberLevelSimpleRespVO.java | 6 ++---- .../vo/{ => level}/MemberLevelUpdateReqVO.java | 2 +- .../controller/admin/tag/MemberTagController.java | 2 +- .../admin/user/MemberUserController.java | 3 +-- .../member/convert/level/MemberLevelConvert.java | 8 ++++---- .../member/convert/user/MemberUserConvert.java | 2 -- .../dal/dataobject/level/MemberLevelDO.java | 2 ++ .../dal/dataobject/level/MemberLevelLogDO.java | 2 ++ .../member/dal/dataobject/user/MemberUserDO.java | 4 +++- .../member/dal/mysql/level/MemberLevelMapper.java | 2 +- .../member/dal/mysql/user/MemberUserMapper.java | 1 + .../member/service/level/MemberLevelService.java | 6 +++--- .../service/level/MemberLevelServiceImpl.java | 7 ++++--- .../member/service/tag/MemberTagService.java | 3 ++- .../member/service/tag/MemberTagServiceImpl.java | 2 +- .../service/user/MemberUserServiceImpl.java | 3 ++- .../service/level/MemberLevelServiceImplTest.java | 7 ++++--- 25 files changed, 59 insertions(+), 48 deletions(-) rename yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/{ => level}/MemberLevelBaseVO.java (82%) rename yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/{ => level}/MemberLevelCreateReqVO.java (80%) rename yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/{ => level}/MemberLevelPageReqVO.java (98%) rename yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/{ => level}/MemberLevelRespVO.java (98%) rename yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/{ => level}/MemberLevelSimpleRespVO.java (91%) rename yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/{ => level}/MemberLevelUpdateReqVO.java (98%) diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberExperienceLogController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberExperienceLogController.java index 6683550d2..5b337fffa 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberExperienceLogController.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberExperienceLogController.java @@ -28,9 +28,7 @@ import java.util.List; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; -/** - * @author owen - */ +// TODO @疯狂:要不 Log 改成 Record,和 PointRecord 保持一致 @Tag(name = "管理后台 - 会员经验记录") @RestController @RequestMapping("/member/experience-log") @@ -40,6 +38,7 @@ public class MemberExperienceLogController { @Resource private MemberExperienceLogService experienceLogService; + // TODO @疯狂:不允许删除经验哈 @DeleteMapping("/delete") @Operation(summary = "删除会员经验记录") @Parameter(name = "id", description = "编号", required = true) @@ -58,6 +57,7 @@ public class MemberExperienceLogController { return success(MemberExperienceLogConvert.INSTANCE.convert(experienceLog)); } + // TODO @疯狂:这个接口可以删除哈,应该用不到 @GetMapping("/list") @Operation(summary = "获得会员经验记录列表") @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") @@ -75,6 +75,7 @@ public class MemberExperienceLogController { return success(MemberExperienceLogConvert.INSTANCE.convertPage(pageResult)); } + // TODO @疯狂:导出可以先不支持,场景不多 @GetMapping("/export-excel") @Operation(summary = "导出会员经验记录 Excel") @PreAuthorize("@ss.hasPermission('member:experience-log:export')") diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberLevelController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberLevelController.java index 753e38421..400d5d0f9 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberLevelController.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberLevelController.java @@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.member.controller.admin.level; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.*; +import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.*; import cn.iocoder.yudao.module.member.convert.level.MemberLevelConvert; import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; import cn.iocoder.yudao.module.member.service.level.MemberLevelService; @@ -20,9 +20,6 @@ import java.util.List; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -/** - * @author owen - */ @Tag(name = "管理后台 - 会员等级") @RestController @RequestMapping("/member/level") @@ -65,6 +62,7 @@ public class MemberLevelController { return success(MemberLevelConvert.INSTANCE.convert(level)); } + // TODO @疯狂:这个应该用不到哈 @GetMapping("/list") @Operation(summary = "获得会员等级列表") @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") @@ -83,6 +81,7 @@ public class MemberLevelController { return success(MemberLevelConvert.INSTANCE.convertSimpleList(list)); } + // TODO @疯狂:是不是不做分页,直接 list 就好啦;返回的时候,按照经验排序下哈; @GetMapping("/page") @Operation(summary = "获得会员等级分页") @PreAuthorize("@ss.hasPermission('member:level:query')") diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberLevelLogController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberLevelLogController.java index d47e3e9d1..5501b5f3b 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberLevelLogController.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/MemberLevelLogController.java @@ -28,9 +28,7 @@ import java.util.List; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; -/** - * @author owen - */ +// TODO @疯狂:是不是不用这个 controller;因为日志只是为了记录,db 可以查询、和审计即可,目前暂时不需要开放出来; @Tag(name = "管理后台 - 会员等级记录") @RestController @RequestMapping("/member/level-log") @@ -40,6 +38,7 @@ public class MemberLevelLogController { @Resource private MemberLevelLogService levelLogService; + // TODO @疯狂:这个不允许删除哈 @DeleteMapping("/delete") @Operation(summary = "删除会员等级记录") @Parameter(name = "id", description = "编号", required = true) @@ -58,6 +57,7 @@ public class MemberLevelLogController { return success(MemberLevelLogConvert.INSTANCE.convert(levelLog)); } + // TODO @疯狂:这个接口,应该没用 @GetMapping("/list") @Operation(summary = "获得会员等级记录列表") @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") @@ -75,6 +75,7 @@ public class MemberLevelLogController { return success(MemberLevelLogConvert.INSTANCE.convertPage(pageResult)); } + // TODO @疯狂:导出可以去掉先 @GetMapping("/export-excel") @Operation(summary = "导出会员等级记录 Excel") @PreAuthorize("@ss.hasPermission('member:level-log:export')") diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/experience/MemberExperienceLogBaseVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/experience/MemberExperienceLogBaseVO.java index e7faf1d6a..f58c588cb 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/experience/MemberExperienceLogBaseVO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/experience/MemberExperienceLogBaseVO.java @@ -38,7 +38,7 @@ public class MemberExperienceLogBaseVO { @NotNull(message = "变更后的经验不能为空") private Integer totalExperience; - @Schema(description = "描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "下单增加100经验") + @Schema(description = "描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "下单增加 100 经验") @NotNull(message = "描述不能为空") private String description; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/MemberLevelBaseVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelBaseVO.java similarity index 82% rename from yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/MemberLevelBaseVO.java rename to yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelBaseVO.java index e58d2551e..015bc7332 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/MemberLevelBaseVO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelBaseVO.java @@ -1,5 +1,7 @@ -package cn.iocoder.yudao.module.member.controller.admin.level.vo; +package cn.iocoder.yudao.module.member.controller.admin.level.vo.level; +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; +import cn.iocoder.yudao.framework.common.validation.InEnum; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import org.hibernate.validator.constraints.Range; @@ -24,29 +26,30 @@ public class MemberLevelBaseVO { @Schema(description = "升级经验", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") @NotNull(message = "升级经验不能为空") - @Positive(message = "升级经验必须大于0") + @Positive(message = "升级经验必须大于 0") private Integer experience; @Schema(description = "等级", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @NotNull(message = "等级不能为空") - @Positive(message = "等级必须大于0") + @Positive(message = "等级必须大于 0") private Integer level; @Schema(description = "享受折扣", requiredMode = Schema.RequiredMode.REQUIRED, example = "98") @NotNull(message = "享受折扣不能为空") - @Range(min = 0, max = 100, message = "享受折扣的范围为0-100") + @Range(min = 0, max = 100, message = "享受折扣的范围为 0-100") private Integer discount; @Schema(description = "等级图标", example = "https://www.iocoder.cn/yudao.jpg") - @URL(message = "等级图标 必须是 URL 格式") + @URL(message = "等级图标必须是 URL 格式") private String icon; @Schema(description = "等级背景图", example = "https://www.iocoder.cn/yudao.jpg") - @URL(message = "等级背景图 必须是 URL 格式") + @URL(message = "等级背景图必须是 URL 格式") private String backgroundUrl; @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @NotNull(message = "状态不能为空") + @InEnum(CommonStatusEnum.class) private Integer status; } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/MemberLevelCreateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelCreateReqVO.java similarity index 80% rename from yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/MemberLevelCreateReqVO.java rename to yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelCreateReqVO.java index 95eb1fc13..a67ebc8c4 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/MemberLevelCreateReqVO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelCreateReqVO.java @@ -1,10 +1,11 @@ -package cn.iocoder.yudao.module.member.controller.admin.level.vo; +package cn.iocoder.yudao.module.member.controller.admin.level.vo.level; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; +// TODO @疯狂:项目的 vo 和 controller 不写 author 信息哈,只写 swagger 注解 /** * @author owen */ diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/MemberLevelPageReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelPageReqVO.java similarity index 98% rename from yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/MemberLevelPageReqVO.java rename to yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelPageReqVO.java index c8c6de5a1..cc90a2b48 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/MemberLevelPageReqVO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelPageReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.member.controller.admin.level.vo; +package cn.iocoder.yudao.module.member.controller.admin.level.vo.level; import cn.iocoder.yudao.framework.common.pojo.PageParam; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/MemberLevelRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelRespVO.java similarity index 98% rename from yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/MemberLevelRespVO.java rename to yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelRespVO.java index 27451a870..db32e2ded 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/MemberLevelRespVO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelRespVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.member.controller.admin.level.vo; +package cn.iocoder.yudao.module.member.controller.admin.level.vo.level; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/MemberLevelSimpleRespVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelSimpleRespVO.java similarity index 91% rename from yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/MemberLevelSimpleRespVO.java rename to yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelSimpleRespVO.java index 4f928bb7f..57b52c107 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/MemberLevelSimpleRespVO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelSimpleRespVO.java @@ -1,13 +1,11 @@ -package cn.iocoder.yudao.module.member.controller.admin.level.vo; +package cn.iocoder.yudao.module.member.controller.admin.level.vo.level; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; -/** - * @author owen - */ +// TODO @疯狂:不需要继承 MemberLevelBaseVO @Schema(description = "管理后台 - 会员等级 Response VO") @Data @EqualsAndHashCode(callSuper = true) diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/MemberLevelUpdateReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelUpdateReqVO.java similarity index 98% rename from yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/MemberLevelUpdateReqVO.java rename to yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelUpdateReqVO.java index 155657350..9a5b2e089 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/MemberLevelUpdateReqVO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelUpdateReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.member.controller.admin.level.vo; +package cn.iocoder.yudao.module.member.controller.admin.level.vo.level; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/MemberTagController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/MemberTagController.java index c77a83e9d..34f3c20cc 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/MemberTagController.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/tag/MemberTagController.java @@ -69,7 +69,7 @@ public class MemberTagController { @Operation(summary = "获取会员标签精简信息列表", description = "只包含被开启的会员标签,主要用于前端的下拉选项") public CommonResult> getSimpleTagList() { // 获用户列表,只要开启状态的 - List list = tagService.getList(); + List list = tagService.getTagList(); // 排序后,返回给前端 return success(MemberTagConvert.INSTANCE.convertList(list)); } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/MemberUserController.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/MemberUserController.java index 04e991700..d1d5e8ffd 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/MemberUserController.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/user/MemberUserController.java @@ -76,10 +76,9 @@ public class MemberUserController { .flatMap(Collection::stream) .collect(Collectors.toSet()); List tags = memberTagService.getTagList(tagIds); - // 处理会员级别返显 List levels = memberLevelService.getEnableLevelList(); - + // 拼接 return success(MemberUserConvert.INSTANCE.convertPage(pageResult, tags, levels)); } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/level/MemberLevelConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/level/MemberLevelConvert.java index 704262c92..ec2549462 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/level/MemberLevelConvert.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/level/MemberLevelConvert.java @@ -1,10 +1,10 @@ package cn.iocoder.yudao.module.member.convert.level; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.MemberLevelCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.MemberLevelRespVO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.MemberLevelSimpleRespVO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.MemberLevelUpdateReqVO; +import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelCreateReqVO; +import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelRespVO; +import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelSimpleRespVO; +import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelUpdateReqVO; import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/user/MemberUserConvert.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/user/MemberUserConvert.java index 1acc1ecce..48166282f 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/user/MemberUserConvert.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/user/MemberUserConvert.java @@ -44,8 +44,6 @@ public interface MemberUserConvert { // 处理关联数据 Map tagMap = convertMap(tags, MemberTagDO::getId, MemberTagDO::getName); Map levelMap = convertMap(levels, MemberLevelDO::getId, MemberLevelDO::getName); - - // 填充关联数据 for (MemberUserRespVO vo : result.getList()) { vo.setTagNames(convertList(vo.getTagIds(), tagMap::get)); vo.setLevelName(MapUtil.getStr(levelMap, vo.getLevelId(), StrUtil.EMPTY)); diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/level/MemberLevelDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/level/MemberLevelDO.java index d8a67c04b..d504af055 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/level/MemberLevelDO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/level/MemberLevelDO.java @@ -10,6 +10,8 @@ import lombok.*; /** * 会员等级 DO * + * 配置每个等级需要的积分 + * * @author owen */ @TableName("member_level") diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/level/MemberLevelLogDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/level/MemberLevelLogDO.java index ab83f06a2..8ab63b18f 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/level/MemberLevelLogDO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/level/MemberLevelLogDO.java @@ -9,6 +9,8 @@ import lombok.*; /** * 会员等级记录 DO * + * 用户每次等级发生变更时,记录一条日志 + * * @author owen */ @TableName("member_level_log") diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/user/MemberUserDO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/user/MemberUserDO.java index 875fcd399..2d7c5086e 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/user/MemberUserDO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/user/MemberUserDO.java @@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.ip.core.Area; import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler; import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; +import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; import cn.iocoder.yudao.module.system.enums.common.SexEnum; import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableField; @@ -119,6 +120,8 @@ public class MemberUserDO extends TenantBaseDO { /** * 会员级别编号 + * + * 关联 {@link MemberLevelDO#getLevel()} 字段 */ private Long levelId; /** @@ -126,5 +129,4 @@ public class MemberUserDO extends TenantBaseDO { */ private Integer experience; - // TODO 积分等等 } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/level/MemberLevelMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/level/MemberLevelMapper.java index 239e096d3..b0eb77d12 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/level/MemberLevelMapper.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/level/MemberLevelMapper.java @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.member.dal.mysql.level; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.MemberLevelPageReqVO; +import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelPageReqVO; import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; import org.apache.ibatis.annotations.Mapper; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/user/MemberUserMapper.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/user/MemberUserMapper.java index 2315210cf..9af44ea9c 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/user/MemberUserMapper.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/user/MemberUserMapper.java @@ -49,6 +49,7 @@ public interface MemberUserMapper extends BaseMapperX { .orderByDesc(MemberUserDO::getId)); } + // TODO @疯狂:命名可以改成 updateUserLevelToNull;db 侧的操作,尽量无业务含义,更多是 select、update、insert 操作 /** * 取消会员的等级 * diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelService.java index c8fb5107d..a9f876071 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelService.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelService.java @@ -2,9 +2,9 @@ package cn.iocoder.yudao.module.member.service.level; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.MemberLevelCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.MemberLevelPageReqVO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.MemberLevelUpdateReqVO; +import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelCreateReqVO; +import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelPageReqVO; +import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelUpdateReqVO; import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelServiceImpl.java index b1bca4695..9ff169a23 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelServiceImpl.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/level/MemberLevelServiceImpl.java @@ -6,9 +6,9 @@ import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.MemberLevelCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.MemberLevelPageReqVO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.MemberLevelUpdateReqVO; +import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelCreateReqVO; +import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelPageReqVO; +import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelUpdateReqVO; import cn.iocoder.yudao.module.member.convert.level.MemberLevelConvert; import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; @@ -74,6 +74,7 @@ public class MemberLevelServiceImpl implements MemberLevelService { @Override public void deleteLevel(Long id) { + // TODO @疯狂:校验是否有用户使用该等级 // 校验存在 validateLevelExists(id); // 删除 diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/tag/MemberTagService.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/tag/MemberTagService.java index 5ecd1e244..5e3393394 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/tag/MemberTagService.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/tag/MemberTagService.java @@ -68,5 +68,6 @@ public interface MemberTagService { * * @return 标签列表 */ - List getList(); + List getTagList(); + } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/tag/MemberTagServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/tag/MemberTagServiceImpl.java index eb0ce11d0..2c11c55cb 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/tag/MemberTagServiceImpl.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/tag/MemberTagServiceImpl.java @@ -106,7 +106,7 @@ public class MemberTagServiceImpl implements MemberTagService { } @Override - public List getList() { + public List getTagList() { return tagMapper.selectList(); } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java index 3f299d067..880aa792b 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java @@ -184,8 +184,8 @@ public class MemberUserServiceImpl implements MemberUserService { return passwordEncoder.encode(password); } - @Transactional(rollbackFor = Exception.class) @Override + @Transactional(rollbackFor = Exception.class) public void updateUser(MemberUserUpdateReqVO updateReqVO) { // 校验存在 MemberUserDO user = validateUserExists(updateReqVO.getId()); @@ -197,6 +197,7 @@ public class MemberUserServiceImpl implements MemberUserService { memberUserMapper.updateById(updateObj); // 会员级别修改 + // TODO @疯狂:修改用户等级,要不要单独一个前端操作 + 接口;因为它是个相对严肃独立的动作 memberLevelService.updateUserLevel(user, updateReqVO.getLevelId(), updateReqVO.getLevelReason()); } diff --git a/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/level/MemberLevelServiceImplTest.java b/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/level/MemberLevelServiceImplTest.java index c85a62164..e05dde443 100644 --- a/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/level/MemberLevelServiceImplTest.java +++ b/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/level/MemberLevelServiceImplTest.java @@ -4,9 +4,9 @@ import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.MemberLevelCreateReqVO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.MemberLevelPageReqVO; -import cn.iocoder.yudao.module.member.controller.admin.level.vo.MemberLevelUpdateReqVO; +import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelCreateReqVO; +import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelPageReqVO; +import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelUpdateReqVO; import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; import cn.iocoder.yudao.module.member.dal.mysql.level.MemberLevelMapper; import org.junit.jupiter.api.Test; @@ -25,6 +25,7 @@ import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*; import static org.junit.jupiter.api.Assertions.*; +// TODO 芋艿:完全 review 完,在去 review 单测 /** * {@link MemberLevelServiceImpl} 的单元测试类 *