标签:sid mod esper info response perm order by and entity
//Controller
@ResponseBody
@RequestMapping("/lightSplitBox")
@RequiresPermissions("zkgj:detail:list")
public R lightSplitBox(@RequestParam Map<String, Object> params){
PageUtils page = detailService.lightSplitBox(params);
String s=(String) params.get("params001");
return R.ok().put("page", page);
}
//Service接口
PageUtils lightSplitBox(Map<String, Object> params);//查询所有的分光想
//接口实现类
@Override
public PageUtils lightSplitBox(Map<String, Object> params) {
long page=Long.parseLong((String) params.get("page"));
long limit=Long.parseLong((String) params.get("limit"));
String order=(String) params.get("order");//获取排序方式
String sidx=(String) params.get("sidx");//获取排序的字段
DetailEntity detailEntity=new DetailEntity();
String opticalBoxName=(String)params.get("opticalBoxName");//获取查询参数
String opticalBoxType=(String)params.get("opticalBoxType");//获取查询参数
Page<DetailEntity> pagination = new Page<>(page,limit); //分页
List<DetailEntity> list = detailDao.lightSplitBox(pagination,order,sidx,opticalBoxType,opticalBoxName);
pagination.setRecords(list);
return new PageUtils(pagination);
}
//Dao层
List<DetailEntity> lightSplitBox(@Param("page") Page<DetailEntity> page,@Param("order") String order,@Param("sidx") String sidx,@Param("opticalBoxType") String opticalBoxType,@Param("opticalBoxName") String opticalBoxName);
//sql
<select id="getDetail" resultType="io.renren.modules.zkgj.entity.DetailEntity">
select
DATE_FORMAT(a.check_date,‘%Y-%m-%d‘) AS checkDateString,
a.id,
a.operator,
a.user_info,
a.check_date as checkDate,
COUNT(`operator`) AS sumPort
FROM tb_detail a
<where>
<if test="operator !=null and operator != ‘‘ ">
and a.operator like ‘%${operator}%‘
</if>
<if test="checkDateString !=null and checkDateString != ‘‘ ">
and DATE_FORMAT(a.check_date,‘%Y-%m-%d‘)=#{checkDateString}
</if>
<if test="params.sql_filter!=null">
and ${params.sql_filter}
</if>
</where>
GROUP BY DATE_FORMAT(a.check_date,‘%Y-%m-%d‘),a.operator
<choose>
<when test="sidx !=‘‘ and sidx != null">
ORDER BY a.${sidx} ${order}
</when>
<otherwise>
ORDER BY a.check_date desc
</otherwise>
</choose>
</select>
标签:sid mod esper info response perm order by and entity
原文地址:https://www.cnblogs.com/pureray-hui/p/12371453.html