Spring boot、mysql分页

第一种:

实现层:

@Override
public PageData inviteLogPage(Map params) {
params.put(“corpId”,SecurityUser.getUser().getCorpId());
params.put(“page”, (Long.valueOf(params.get(“page”).toString()) - 1) * Long.valueOf(params.get(“limit”).toString()));
List pageList = lhTlCorpInviteDao.selectInviteLogPageList(params);
long total = lhTlCorpInviteDao.getInviteLogCount(params);
Page page = new Page(Long.valueOf(params.get(“page”).toString()), Long.valueOf(params.get(“limit”).toString()));
page.setRecords(pageList);
page.setTotal(total);
return getPageData(page, CorpInviteDto.class);
}

Mapper层:

/**
*
* @return
*/
List selectInviteLogPageList(@Param(“params”) Map params);

Mapper.xml:

select distinct inv.id,res.RESUME_NAME as resumeName,stu.STUDENT_NAME as stuName,inv.id as id, inv.IS_VIEWED as isViewed,inv.IS_ACCEPT as isAccept,inv.IS_COMPLITE as isComplite,inv.INTERVIEW_DATE as interviewDate,tj.JOB_NAME as jobName,tj.id as jobId from lh_tl_corp_invite inv LEFT JOIN lh_tm_jobs tj ON tj.`ID` = inv.`JOB_ID` LEFT JOIN lh_tm_stu_resume res ON inv.RESUME_ID = res.ID LEFT JOIN lh_tm_student stu ON res.STUDENT_ID = stu.ID where 1=1 and inv.DEL_FLAG = 0 and inv.CORP_ID = #{params.corpId} and stu.STUDENT_NAME like CONCAT('%',#{params.name},'%') LIMIT ${params.page},${params.limit}

第二种:

实现层:

/**
* 列表
* @param params
* @return
/
@Override
public PageResult findList(Map params){
Map map = new HashMap<>();
map.put(“page”,((Integer.parseInt(params.get(“page”).toString()))-1)
(Integer.parseInt(params.get(“limit”).toString())));
map.put(“limit”,(Integer.parseInt(params.get(“limit”).toString())));
List list = baseMapper.findList(map, params);
//获取数据总条数
Long count = baseMapper.getTotal(params);
return PageResult.builder().data(list).code(0).count(count).build();
}

Mapper层:

*/
List findList(@Param(“pageParam”)Map page, @Param(“p”) Map params);

Mapper.xml

select t.*,ts.speciality_name as specialityName from t_module_detail_code t left join t_speciality ts on t.speciality_id = ts.id where 1=1 and t.detail_code like concat(concat('%',#{p.detailCode}),'%') limit #{pageParam.page}, #{pageParam.limit}

Mapper.xml


    
        1=1
        
            and t.test_catagory_id = #{p.testCatagoryId}
        
        
            and ttc.id = #{p.testItemId}
        
        and t.test_catagory_id in (select category_id from t_test_item)
    





你可能感兴趣的:(Spring,Boot,mysql)