mybatis plus分页联表查询

@GetMapping(value = "/list/{size}/{current}")
public ResponseMessage<IPage<VO>> list(@PathVariable @Min(1) Integer current,
                                                        @PathVariable @Range(min = 1, max = 100) Integer size) {
    return ResponseMessage.success(this.sService.listPage(current, size));
}

service

IPage<VO> listPage(@NonNull Integer current, @NonNull Integer size);

serviceImpl

@Override
public IPage<VO> listPage(@NonNull Integer current, @NonNull Integer size) {
	return this.sMapper.listPage(new Page<>(current, size));
}

mapper

IPage<VO> listPage(@Param("page") Page<VO> page);

mapper.xml

<select id="listPage" resultType="VO">
        SELECT
            pb.*, sb.*
        FROM
            b pb, s sb
        WHERE
            pb.id = sb.id
   select>

如果有其他条件,也可以在serviceImpl 中的 listPage(new Page<>(current, size), wrapper),加个wrapper条件**

limit

List<Carousel> carousels =
                this.carouselMapper.selectList(Wrappers.<Carousel>lambdaQuery().eq(Carousel::getDeleted, 0).last(
                        "limit " + number));

你可能感兴趣的:(mybatis,plus)