原则:让IPage接收从数据库查处的记录
@Autowaire private UserMapper userMapper; public PageDTO<UserVO> pageUser(UserPageQuery query) { IPage<UserVO> page = new Page<>(query.getPageNo(),2); page = userMapper.PageAndXml(query,page); List<UserVO> list = page.getRecords(); return PageDTO.of((Page<?>) page,list); }
- Mapper
-
IPage<UserVO> PageAndXml(@Param("query") UserPageQuery query,@Param("page") IPage<UserVO> page);
-
<select id="PageAndXml" resultType="com.hmall.user.domain.vo.UserVO"> SELECT <include refid="hmUser"/> FROM `hm-user`.`user` hu LEFT JOIN `hm-risk`.`risk_status` hr ON hu.id = hr.user_id LEFT JOIN `hm-user`.`user_role` hro ON hu.id = hro.user_id LEFT JOIN `hm-user`.`role` r ON hro.user_id = r.id <where> <if test="query.riskStatus != null and query.riskStatus!=''"> hr.status = #{query.riskStatus} </if> <if test="query.status != null and query.status!=''"> hu.status=#{query.status}; </if> </where> </select>
附录优质文章:
https://blog.csdn.net/m0_62317155/article/details/134256473
https://blog.csdn.net/qq_33807380/article/details/136848053