src/main/java/com/xcong/excoin/common/response/PageConvert.java | ●●●●● patch | view | raw | blame | history | |
src/main/java/com/xcong/excoin/modules/test/controller/TestUserController.java | ●●●●● patch | view | raw | blame | history | |
src/main/java/com/xcong/excoin/modules/test/mapper/TestUserEntityMapper.java | ●●●●● patch | view | raw | blame | history |
src/main/java/com/xcong/excoin/common/response/PageConvert.java
New file @@ -0,0 +1,11 @@ package com.xcong.excoin.common.response; import com.baomidou.mybatisplus.core.metadata.IPage; /** * @author wzy * @date 2020-05-13 **/ public class PageConvert { } src/main/java/com/xcong/excoin/modules/test/controller/TestUserController.java
@@ -17,6 +17,7 @@ import io.swagger.annotations.ApiResponses; import lombok.extern.slf4j.Slf4j; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -40,13 +41,14 @@ @PostMapping(value = "/findUserInPage") public Result findUserInPage(@RequestParam(value = "pageSize", defaultValue = "10") int pageSize, @RequestParam(value = "pageNum", defaultValue = "1") int pageNum, @RequestBody @Valid TestUserDto testUserDto, @UserAuth MemberEntity memberEntity) { @RequestBody @Validated TestUserDto testUserDto, @UserAuth MemberEntity memberEntity) { log.info("--->{}",SecurityContextHolder.getContext().getAuthentication()); log.info("----->{}", memberEntity); Page<TestUserEntity> page = new Page<>(pageNum, pageSize); log.info(testUserDto.getName()); IPage<TestUserEntity> list = testUserService.page(page); return Result.ok(MessageSourceUtils.getString("111"), list); IPage<TestUserVo> aa = TestUserEntityMapper.INSTANCE.pageEntityToPageVO(list); return Result.ok(MessageSourceUtils.getString("111"), aa); } src/main/java/com/xcong/excoin/modules/test/mapper/TestUserEntityMapper.java
@@ -1,10 +1,17 @@ package com.xcong.excoin.modules.test.mapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.xcong.excoin.modules.test.dto.TestUserDto; import com.xcong.excoin.modules.test.entity.TestUserEntity; import com.xcong.excoin.modules.test.vo.TestUserVo; import com.xcong.excoin.modules.test.vo.TestVo; import org.mapstruct.InheritInverseConfiguration; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; import java.util.List; /** * @author wzy @@ -16,5 +23,14 @@ public abstract TestUserEntity dtoToEntity(TestUserDto testUserDto); @Mapping(source = "name", target = "name") @Mapping(source = "password", target = "pwd") public abstract TestVo entityToTestVo(TestUserEntity testUserEntity); @Mapping(source = "name", target = "userName") public abstract TestUserVo entityToVo(TestUserEntity testUserEntity); public abstract List<TestUserVo> entityListToVoList(List<TestUserEntity> testUserEntities); public abstract Page<TestUserVo> pageEntityToPageVO(IPage<TestUserEntity> list); }