From 4132cf14371289628375102955e588cb3c096898 Mon Sep 17 00:00:00 2001 From: owen Date: Wed, 23 Aug 2023 10:12:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=9A=E5=91=98:=20=E4=BC=9A=E5=91=98?= =?UTF-8?q?=E7=AD=89=E7=BA=A7=E5=8F=96=E6=B6=88=E5=88=86=E9=A1=B5=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/level/MemberLevelController.java | 12 +++++------- ...evelPageReqVO.java => MemberLevelListReqVO.java} | 5 +---- .../member/convert/level/MemberLevelConvert.java | 3 --- .../member/dal/mysql/level/MemberLevelMapper.java | 7 +++---- .../member/service/level/MemberLevelService.java | 11 +++++------ .../service/level/MemberLevelServiceImpl.java | 7 +++---- .../service/level/MemberLevelServiceImplTest.java | 13 ++++++------- 7 files changed, 23 insertions(+), 35 deletions(-) rename yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/{MemberLevelPageReqVO.java => MemberLevelListReqVO.java} (71%) 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 af4153b22f..5a031321ff 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 @@ -1,7 +1,6 @@ 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.level.*; import cn.iocoder.yudao.module.member.convert.level.MemberLevelConvert; import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; @@ -70,13 +69,12 @@ public class MemberLevelController { return success(MemberLevelConvert.INSTANCE.convertSimpleList(list)); } - // TODO @疯狂:是不是不做分页,直接 list 就好啦;返回的时候,按照经验排序下哈; - @GetMapping("/page") - @Operation(summary = "获得会员等级分页") + @GetMapping("/list") + @Operation(summary = "获得会员等级列表") @PreAuthorize("@ss.hasPermission('member:level:query')") - public CommonResult> getLevelPage(@Valid MemberLevelPageReqVO pageVO) { - PageResult pageResult = levelService.getLevelPage(pageVO); - return success(MemberLevelConvert.INSTANCE.convertPage(pageResult)); + public CommonResult> getLevelList(@Valid MemberLevelListReqVO pageVO) { + List result = levelService.getLevelList(pageVO); + return success(MemberLevelConvert.INSTANCE.convertList(result)); } } diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelPageReqVO.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelListReqVO.java similarity index 71% rename from yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelPageReqVO.java rename to yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelListReqVO.java index d9a6b5b666..87502b278a 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelPageReqVO.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/level/vo/level/MemberLevelListReqVO.java @@ -1,16 +1,13 @@ 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; import lombok.Data; -import lombok.EqualsAndHashCode; import lombok.ToString; @Schema(description = "管理后台 - 会员等级分页 Request VO") @Data -@EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) -public class MemberLevelPageReqVO extends PageParam { +public class MemberLevelListReqVO { @Schema(description = "等级名称", example = "芋艿") private String name; 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 ec2549462d..4788bf365e 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,6 +1,5 @@ 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.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; @@ -29,7 +28,5 @@ public interface MemberLevelConvert { List convertList(List list); - PageResult convertPage(PageResult page); - List convertSimpleList(List list); } 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 b0eb77d124..a7be2fd644 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 @@ -1,9 +1,8 @@ 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.level.MemberLevelPageReqVO; +import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelListReqVO; import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; import org.apache.ibatis.annotations.Mapper; @@ -17,8 +16,8 @@ import java.util.List; @Mapper public interface MemberLevelMapper extends BaseMapperX { - default PageResult selectPage(MemberLevelPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() + default List selectList(MemberLevelListReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() .likeIfPresent(MemberLevelDO::getName, reqVO.getName()) .eqIfPresent(MemberLevelDO::getStatus, reqVO.getStatus()) .orderByAsc(MemberLevelDO::getLevel)); 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 e59e205c9e..11c75cd65a 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 @@ -1,9 +1,8 @@ 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.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.MemberLevelListReqVO; import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelUpdateReqVO; import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateLevelReqVO; import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; @@ -59,12 +58,12 @@ public interface MemberLevelService { List getLevelList(Collection ids); /** - * 获得会员等级分页 + * 获得会员等级列表 * - * @param pageReqVO 分页查询 - * @return 会员等级分页 + * @param listReqVO 查询参数 + * @return 会员等级列表 */ - PageResult getLevelPage(MemberLevelPageReqVO pageReqVO); + List getLevelList(MemberLevelListReqVO listReqVO); /** 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 1cc7f474cc..6120b711a2 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 @@ -4,9 +4,8 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.framework.common.pojo.PageResult; 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.MemberLevelListReqVO; import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelUpdateReqVO; import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateLevelReqVO; import cn.iocoder.yudao.module.member.convert.level.MemberLevelConvert; @@ -173,8 +172,8 @@ public class MemberLevelServiceImpl implements MemberLevelService { } @Override - public PageResult getLevelPage(MemberLevelPageReqVO pageReqVO) { - return levelMapper.selectPage(pageReqVO); + public List getLevelList(MemberLevelListReqVO listReqVO) { + return levelMapper.selectList(listReqVO); } @Override 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 9763c2f6fe..abcf5ff8d7 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 @@ -5,7 +5,7 @@ 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.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.MemberLevelListReqVO; 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; @@ -121,7 +121,7 @@ public class MemberLevelServiceImplTest extends BaseDbUnitTest { } @Test - public void testGetLevelPage() { + public void testGetLevelList() { // mock 数据 MemberLevelDO dbLevel = randomPojo(MemberLevelDO.class, o -> { // 等会查询到 o.setName("黄金会员"); @@ -133,16 +133,15 @@ public class MemberLevelServiceImplTest extends BaseDbUnitTest { // 测试 status 不匹配 levelMapper.insert(cloneIgnoreId(dbLevel, o -> o.setStatus(0))); // 准备参数 - MemberLevelPageReqVO reqVO = new MemberLevelPageReqVO(); + MemberLevelListReqVO reqVO = new MemberLevelListReqVO(); reqVO.setName("黄金会员"); reqVO.setStatus(1); // 调用 - PageResult pageResult = levelService.getLevelPage(reqVO); + List list = levelService.getLevelList(reqVO); // 断言 - assertEquals(1, pageResult.getTotal()); - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbLevel, pageResult.getList().get(0)); + assertEquals(1, list.size()); + assertPojoEquals(dbLevel, list.get(0)); } @Test