第一种:
实现层:
@Override
public PageData inviteLogPage(Map<String, Object> 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<String, Object> 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<String, Object> params){
Map<String, Object> 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<String, Object> page, @Param(“p”) Map<String, Object> 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}<select id="getTotal" resultType="java.lang.Long">
select count(1) from t_module_detail_code t
left join t_speciality ts on t.speciality_id = ts.id
where 1=1
<if test="p.detailCode != null and p.detailCode != ''">
and t.detail_code like concat(concat('%',#{p.detailCode}),'%')
</if>
</select>
Mapper.xml
<sql id="where">
<where>
1=1
<if test="p.testCatagoryId != null and p.testCatagoryId !='' ">
and t.test_catagory_id = #{p.testCatagoryId}
</if>
<if test="p.testItemId != null and p.testItemId !='' ">
and ttc.id = #{p.testItemId}
</if>
and t.test_catagory_id in (select category_id from t_test_item)
</where>
</sql>
<select id="findList" resultType="com.central.test.strategy.model.TestPlan">
select t.*,ttc.categroy_name as categroyName,tti.item_name as detailInfo from t_test_plan t
left join t_test_category ttc on t.test_catagory_id = ttc.id
left join t_test_item tti on ttc.id = tti.category_id
<include refid="where"/>
limit #{pageParam.page}, #{pageParam.limit}
</select>
<select id="getTotal" resultType="java.lang.Long">
select count(1) from t_test_plan t
left join t_test_category ttc on t.test_catagory_id = ttc.id
left join t_test_item tti on ttc.id = tti.category_id
<include refid="where"/>
</select>