会员: 会员等级取消分页功能

This commit is contained in:
owen 2023-08-23 10:12:21 +08:00
parent dc382d80bb
commit 4132cf1437
7 changed files with 23 additions and 35 deletions

View File

@ -1,7 +1,6 @@
package cn.iocoder.yudao.module.member.controller.admin.level; package cn.iocoder.yudao.module.member.controller.admin.level;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; 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.controller.admin.level.vo.level.*;
import cn.iocoder.yudao.module.member.convert.level.MemberLevelConvert; 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.level.MemberLevelDO;
@ -70,13 +69,12 @@ public class MemberLevelController {
return success(MemberLevelConvert.INSTANCE.convertSimpleList(list)); return success(MemberLevelConvert.INSTANCE.convertSimpleList(list));
} }
// TODO @疯狂是不是不做分页直接 list 就好啦返回的时候按照经验排序下哈 @GetMapping("/list")
@GetMapping("/page") @Operation(summary = "获得会员等级列表")
@Operation(summary = "获得会员等级分页")
@PreAuthorize("@ss.hasPermission('member:level:query')") @PreAuthorize("@ss.hasPermission('member:level:query')")
public CommonResult<PageResult<MemberLevelRespVO>> getLevelPage(@Valid MemberLevelPageReqVO pageVO) { public CommonResult<List<MemberLevelRespVO>> getLevelList(@Valid MemberLevelListReqVO pageVO) {
PageResult<MemberLevelDO> pageResult = levelService.getLevelPage(pageVO); List<MemberLevelDO> result = levelService.getLevelList(pageVO);
return success(MemberLevelConvert.INSTANCE.convertPage(pageResult)); return success(MemberLevelConvert.INSTANCE.convertList(result));
} }
} }

View File

@ -1,16 +1,13 @@
package cn.iocoder.yudao.module.member.controller.admin.level.vo.level; 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 io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString; import lombok.ToString;
@Schema(description = "管理后台 - 会员等级分页 Request VO") @Schema(description = "管理后台 - 会员等级分页 Request VO")
@Data @Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
public class MemberLevelPageReqVO extends PageParam { public class MemberLevelListReqVO {
@Schema(description = "等级名称", example = "芋艿") @Schema(description = "等级名称", example = "芋艿")
private String name; private String name;

View File

@ -1,6 +1,5 @@
package cn.iocoder.yudao.module.member.convert.level; 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.MemberLevelCreateReqVO;
import cn.iocoder.yudao.module.member.controller.admin.level.vo.level.MemberLevelRespVO; 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.MemberLevelSimpleRespVO;
@ -29,7 +28,5 @@ public interface MemberLevelConvert {
List<MemberLevelRespVO> convertList(List<MemberLevelDO> list); List<MemberLevelRespVO> convertList(List<MemberLevelDO> list);
PageResult<MemberLevelRespVO> convertPage(PageResult<MemberLevelDO> page);
List<MemberLevelSimpleRespVO> convertSimpleList(List<MemberLevelDO> list); List<MemberLevelSimpleRespVO> convertSimpleList(List<MemberLevelDO> list);
} }

View File

@ -1,9 +1,8 @@
package cn.iocoder.yudao.module.member.dal.mysql.level; 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.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; 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 cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -17,8 +16,8 @@ import java.util.List;
@Mapper @Mapper
public interface MemberLevelMapper extends BaseMapperX<MemberLevelDO> { public interface MemberLevelMapper extends BaseMapperX<MemberLevelDO> {
default PageResult<MemberLevelDO> selectPage(MemberLevelPageReqVO reqVO) { default List<MemberLevelDO> selectList(MemberLevelListReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<MemberLevelDO>() return selectList(new LambdaQueryWrapperX<MemberLevelDO>()
.likeIfPresent(MemberLevelDO::getName, reqVO.getName()) .likeIfPresent(MemberLevelDO::getName, reqVO.getName())
.eqIfPresent(MemberLevelDO::getStatus, reqVO.getStatus()) .eqIfPresent(MemberLevelDO::getStatus, reqVO.getStatus())
.orderByAsc(MemberLevelDO::getLevel)); .orderByAsc(MemberLevelDO::getLevel));

View File

@ -1,9 +1,8 @@
package cn.iocoder.yudao.module.member.service.level; package cn.iocoder.yudao.module.member.service.level;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; 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.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.level.vo.level.MemberLevelUpdateReqVO;
import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateLevelReqVO; import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateLevelReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO;
@ -59,12 +58,12 @@ public interface MemberLevelService {
List<MemberLevelDO> getLevelList(Collection<Long> ids); List<MemberLevelDO> getLevelList(Collection<Long> ids);
/** /**
* 获得会员等级分页 * 获得会员等级列表
* *
* @param pageReqVO 分页查询 * @param listReqVO 查询参数
* @return 会员等级分页 * @return 会员等级列表
*/ */
PageResult<MemberLevelDO> getLevelPage(MemberLevelPageReqVO pageReqVO); List<MemberLevelDO> getLevelList(MemberLevelListReqVO listReqVO);
/** /**

View File

@ -4,9 +4,8 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.ObjectUtil; 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.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.level.vo.level.MemberLevelUpdateReqVO;
import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateLevelReqVO; import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateLevelReqVO;
import cn.iocoder.yudao.module.member.convert.level.MemberLevelConvert; import cn.iocoder.yudao.module.member.convert.level.MemberLevelConvert;
@ -173,8 +172,8 @@ public class MemberLevelServiceImpl implements MemberLevelService {
} }
@Override @Override
public PageResult<MemberLevelDO> getLevelPage(MemberLevelPageReqVO pageReqVO) { public List<MemberLevelDO> getLevelList(MemberLevelListReqVO listReqVO) {
return levelMapper.selectPage(pageReqVO); return levelMapper.selectList(listReqVO);
} }
@Override @Override

View File

@ -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.common.util.collection.ArrayUtils;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; 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.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.level.vo.level.MemberLevelUpdateReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO;
import cn.iocoder.yudao.module.member.dal.mysql.level.MemberLevelMapper; import cn.iocoder.yudao.module.member.dal.mysql.level.MemberLevelMapper;
@ -121,7 +121,7 @@ public class MemberLevelServiceImplTest extends BaseDbUnitTest {
} }
@Test @Test
public void testGetLevelPage() { public void testGetLevelList() {
// mock 数据 // mock 数据
MemberLevelDO dbLevel = randomPojo(MemberLevelDO.class, o -> { // 等会查询到 MemberLevelDO dbLevel = randomPojo(MemberLevelDO.class, o -> { // 等会查询到
o.setName("黄金会员"); o.setName("黄金会员");
@ -133,16 +133,15 @@ public class MemberLevelServiceImplTest extends BaseDbUnitTest {
// 测试 status 不匹配 // 测试 status 不匹配
levelMapper.insert(cloneIgnoreId(dbLevel, o -> o.setStatus(0))); levelMapper.insert(cloneIgnoreId(dbLevel, o -> o.setStatus(0)));
// 准备参数 // 准备参数
MemberLevelPageReqVO reqVO = new MemberLevelPageReqVO(); MemberLevelListReqVO reqVO = new MemberLevelListReqVO();
reqVO.setName("黄金会员"); reqVO.setName("黄金会员");
reqVO.setStatus(1); reqVO.setStatus(1);
// 调用 // 调用
PageResult<MemberLevelDO> pageResult = levelService.getLevelPage(reqVO); List<MemberLevelDO> list = levelService.getLevelList(reqVO);
// 断言 // 断言
assertEquals(1, pageResult.getTotal()); assertEquals(1, list.size());
assertEquals(1, pageResult.getList().size()); assertPojoEquals(dbLevel, list.get(0));
assertPojoEquals(dbLevel, pageResult.getList().get(0));
} }
@Test @Test