控制层
@RequestMapping("/list")
@RequiresPermissions("base:zhxtztgl:list")
public R list(@RequestParam Map<String, Object> params){
params.put("deptid", getDeptId());
PageUtils page = zhxtZtglService.queryPage2(params);
return R.ok().put("page", page);
}
服务层
@Override
public PageUtils queryPage2(Map<String, Object> params) {
Page<ZhxtZtglEntity> page = new Page<>(Integer.parseInt((String)params.get("page")), Integer.parseInt((String)params.get("limit")));
ZhxtZtglEntity zhxtZtglEntity=new ZhxtZtglEntity();
zhxtZtglEntity.setDeptId((Long) params.get("deptid"));
if(params.containsKey("queryDeptId")&&!"".equals(params.get("queryDeptId"))){
zhxtZtglEntity.setQueryDeptId(Long.parseLong(String.valueOf(params.get("queryDeptId"))));
}
List<ZhxtZtglEntity> list=zhxtZtglDao.getZtglPageList(page, zhxtZtglEntity);
return new PageUtils(list, page.getTotal(), page.getSize(), page.getCurrent());
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.vision.czzh.modules.base.dao.ZhxtZtglDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="com.vision.czzh.modules.base.entity.ZhxtZtglEntity" id="zhxtZtglMap">
<result property="id" column="id"/>
<result property="ztbm" column="ZTBM"/>
<result property="ztmc" column="ZTMC"/>
</resultMap>
<select id="getZtglPageList" parameterType="com.vision.czzh.modules.base.entity.ZhxtZtglEntity" resultType="com.vision.czzh.modules.base.entity.ZhxtZtglEntity">
select a.ID, a.ztbm,a.ztmc,a.dept_id deptId,b.name from zhxt_ztgl a,SYS_DEPT b where a.DEPT_ID=b.DEPT_ID and a.dept_id in (select dept_id from sys_dept where dept_id =#{zhxtZtglEntity.deptId} or parent_id=#{zhxtZtglEntity.deptId})
<if test="zhxtZtglEntity.queryDeptId!=null">
and a.dept_id =#{zhxtZtglEntity.queryDeptId}
</if>
order by a.dept_id,a.ztbm
</select>
</mapper>