custom page sql
-
xml
<select id="selectPages" resultType="com.example.domain.vo.UserVo"> select u.user_name, u.real_real from user u ${ew.customSqlSegment} order by u.sort_num desc </select>
-
mapper
public interface UserMapper extends BaseMapper<User> {
IPage<UserVo> selectPages(IPage<UserVo> page,@Param(Constants.WRAPPER) Wrapper<User> ex);
}
- service
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
@Override
public IPage<UserVo> pages(UserPageDto dto){
QueryWrapper<User> query = new QueryWrapper<>();
query.eq(StringUtils.hasText(dto.getUserName()), "u.user_name",dto.getUserName());
query.like(StringUtils.hasText(dto.getRealName()), "u.real_name",dto.getRealName());
Page<User> page = new Page(1,10);
IPage<UserVo> result = this.getBaseMapper().selectPages(page, query);
return result;
}
}