分页查询
第一步:在实体类VO和BO中创建
在实体类的VO中创建 “具体的内容与一页的数量”如“...PagingToGetDataVo” 在这里的分页查询里面创建
private List<Community> list;//内容实体类
private Integer count;//一页的数量
在实体类中BO中创建 “具体的分页分化”如“...PagingToGetDataVo” 在这里的分页查询里面创建
private String token;
private Long start;//开始坐标
private Integer size;//每页显示长度
private String 具体是谁的实体类;//标题
private Integer status;//内容分类
private Integer delFlag;//逻辑删除
第二步在Mapper中进行添加
在...Mapper中进行添加
/**
* @author zhuxinyu 2023-10-30
* 分页获取查询数据
* @param ...PagingToGetDataBo
* @return
*/
public List<需要返回的内容> ...PagingToGetData(...PagingToGetDataBo ...PagingToGetDataBo);
第三步在service中的service和service中的impl进行创建
在service中的...service进行创建
在service中
/**
* @author zhuxinyu 2023-10-28
* 分页获取数据
* @param ...PagingToGetDataBo
* @return ResponseVo.class
*/
public ResponseVo ...PagingToGetData(...PagingToGetDataBo ...PagingToGetDataBo);
在service中的impl中的...serviceImpl中进行创建
/**
* @author zhuxinyu 2023-10-29
* 分页获取数据
* @param ...PagingToGetDataBo
* @return ResponseVo.class
*/
@Override
public ResponseVo ...PagingToGetData(...PagingToGetDataBo ...PagingToGetDataBo) {
List < ... > list = ...Mapper. ...PagingToGetData(...PagingToGetDataBo);
...PagingToGetDataVo ...PagingToGetDataVo = new ...PagingToGetDataVo();
...PagingToGetDataVo.setList(list);
...PagingToGetDataVo.setCount(list.size());
return null;
}
第四步在controller中的控制器里进行创建
在controller中的控制器里进行创建。
/**
* @author zhuxinyu 2023-10-28
* 分页获取数据
* @param ...PagingToGetDataBo
* @return
*/
@ApiOperation("分页获取数据")
@PostMapping("/...pagingToGetData")
public String ...PagingToGetData(@RequestBody ...PagingToGetDataBo ...PagingToGetDataBo){
Map<String , String> map = ThreadLocalUtil.mapThreadLocal.get();
if (map.get("error") != null) {
return JSONArray.toJSONString(new ResponseVo<>(map.get("error"),null,map.get("code")));
}
return JSONArray.toJSONString(...Service. ...PagingToGetData(...PagingToGetDataBo));
}
第五步在resources中的mybatis中的mapper包下创建
在resources中的mybatis中的mapper包下的...Mapper.xml创建表
<!--
@author zhuxinyu 2023-10-30
分页获取用户数据集合
-->
<select id="...PagingToGetData" resultType="com.gsxy.core.pojo. ..."
parameterType="com.gsxy.core.pojo.bo. ...PagingToGetDataBo">
select
*
from
...
<where>
<if test="具体名称 != null and 具体名称 != ''">
具体名称 like concat('%',#{具体名称},'%') and
</if>
</where>
status = #{status} and
del_flag = #{delFlag}
limit
#{start},#{size}
</select>