一、mybatis plus IPage<实体>转 IPage
问题描述:使用mybatis plus时 通过crud接口获取iPage<实体> 但返回需要用iPage封装
/**
* 根据用户姓名分页查询用户
*
* @param walletLogQo
* @return
*/
@Override
public IPage<UserVo> selectPageAll(UserQo userQo) {
int page = userQo.getPage();
int limit = userQo.getLimit();
IPage<User> userIPage = cpWalletLogMapper.selectPage(new Page<>(page, limit),
new LambdaQueryWrapper<User>()
.like(User::getName, userQo.getUserName())
.orderByAsc(User::getId)
);
return userIPage .convert(User -> ConvertUtils.beanCopy(User, UserVo.class));
}
————————————————
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/weixin_44851436/article/details/108319816
Page page =this.lambdaQuery().eq(KtEvaluationItem::getSchoolId, portalUser.getSchoolId()).eq(KtEvaluationItem::getScope, "SCHOOL")
.or()
.eq(KtEvaluationItem::getSchoolId, portalUser.getSchoolId())
.eq(KtEvaluationItem::getScope, "CLASS")
.eq(KtEvaluationItem::getClassId, dto.getClassId())
.orderByDesc(KtEvaluationItem::getCreateTime)
.page(new Page<>(dto.getPageNo() !=null ? dto.getPageNo() :1, dto.getPageSize() !=null ? dto.getPageSize() :10));
IPage result = page.convert(item -> {
KtEvaluationItemVO vo =new KtEvaluationItemVO();
vo.setId(item.getId());
vo.setName(item.getName());
vo.setScope(item.getScope());
vo.setTeacherName(item.getTeacherName());
vo.setUpdateTime(item.getUpdateTime());
return vo;
});
return result;