使用分页查询员工数据
EmpBasicController

  1. @GetMapping("/")
  2. public RespPageBean getEmployeeByPage(
  3. @RequestParam(defaultValue = "1") Integer page,
  4. @RequestParam(defaultValue = "10") Integer size,
  5. Employee employee, Date[] beginDateScope) {
  6. return employeeService.getEmployeeByPage(page, size, employee, beginDateScope);
  7. }

EmployService

  1. public RespPageBean getEmployeeByPage(Integer page, Integer size,
  2. Employee employee, Date[] beginDateScope) {
  3. if (page != null && size != null) {
  4. page = (page - 1) * size;
  5. }
  6. List<Employee> data = employeeMapper.getEmployeeByPage(page, size, employee, beginDateScope);
  7. Long total = employeeMapper.getTotal(employee, beginDateScope);
  8. RespPageBean bean = new RespPageBean();
  9. bean.setData(data);
  10. bean.setTotal(total);
  11. return bean;
  12. }

Mapper

  1. select e.*,p.`id` as pid,p.`name` as pname,n.`id` as nid,n.`name` as nname,d.`id` as did,
  2. d.`name` as dname,j.`id` as jid,j.`name` as jname,pos.`id` as posid,pos.`name` as posname
  3. from employee e,nation n,politicsstatus p,department d,joblevel j,position pos
  4. where e.`nationId`=n.`id` and e.`politicId`=p.`id` and e.`departmentId`=d.`id`
  5. and e.`jobLevelId`=j.`id` and e.`posId`=pos.`id`
  6. limit 2,10
<select id="getEmployeeByPage" resultMap="AllEmployeeInfo">
  select e.*,p.`id` as pid,p.`name` as pname,n.`id` as nid,n.`name` as nname,d.`id` as did,d.`name` as
  dname,j.`id` as jid,j.`name` as jname,pos.`id` as posid,pos.`name` as posname 
  from employee e,nation
  n,politicsstatus p,department d,joblevel j,position pos where e.`nationId`=n.`id` and e.`politicId`=p.`id` and
  e.`departmentId`=d.`id` and e.`jobLevelId`=j.`id` and e.`posId`=pos.`id`
  <if test="emp.name !=null and emp.name!=''">
    and e.name like concat('%',#{emp.name},'%')
  </if>
  <if test="emp.politicId !=null">
    and e.politicId =#{emp.politicId}
  </if>
  <if test="emp.nationId !=null">
    and e.nationId =#{emp.nationId}
  </if>
  <if test="emp.departmentId !=null">
    and e.departmentId =#{emp.departmentId}
  </if>
  <if test="emp.jobLevelId !=null">
    and e.jobLevelId =#{emp.jobLevelId}
  </if>
  <if test="emp.engageForm !=null and emp.engageForm!=''">
    and e.engageForm =#{emp.engageForm}
  </if>
  <if test="emp.posId !=null">
    and e.posId =#{emp.posId}
  </if>
  <if test="beginDateScope !=null">
    and e.beginDate between #{beginDateScope[0]} and #{beginDateScope[1]}
  </if>
  <if test="page !=null and size!=null">
    limit #{page},#{size}
  </if>
</select>

前端

前端是个表。
所以如果以后用到表的时候,再来这里看吧。

别忘了实现日期的格式过滤
image.pngimage.png