| | |
| | | @ApiOperation(value = "分页查询申请") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "uname", value = "用户名", dataType = "String", paramType = "query", example = "员"), |
| | | @ApiImplicitParam(name = "type", value = "类型", dataType = "Integer", paramType = "query", example = "3"), |
| | | @ApiImplicitParam(name = "status", value = "状态", dataType = "Integer", paramType = "query", example = "0"), |
| | | @ApiImplicitParam(name = "start", value = "开始时间", dataType = "Timestamp", paramType = "query", example = "2022-12-09 09:00:00"), |
| | | @ApiImplicitParam(name = "end", value = "结束时间", dataType = "Timestamp", paramType = "query", example = "2022-12-25 17:00:00"), |
| | | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"), |
| | | @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1") |
| | | }) |
| | | @GetMapping(value = "/selectByPage") |
| | | public ResponseMsg<Object> selectByPage(String uname, Integer type, Timestamp start, Timestamp end, Integer pageSize, Integer pageIndex) { |
| | | public ResponseMsg<Object> selectByPage(String uname, Integer status, Timestamp start, Timestamp end, Integer pageSize, Integer pageIndex, HttpServletRequest req) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("每页页数或分页数小于1", null); |
| | | } |
| | | |
| | | int count = applyService.selectCount(0); |
| | | int count = applyService.selectCount(uname, status, start, end); |
| | | if (count == 0) { |
| | | return success(0, null); |
| | | } |
| | | |
| | | List<ApplyEntity> rs = applyService.selectByPage(0, pageSize, pageSize * (pageIndex - 1)); |
| | | UserEntity ue = tokenService.getCurrentUser(req); |
| | | List<ApplyEntity> rs = applyService.selectByPage(ue.getId(), uname, status, start, end, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(count, rs); |
| | | } catch (Exception ex) { |
| | |
| | | |
| | | private Timestamp updateTime; |
| | | |
| | | private String uname; |
| | | |
| | | private Boolean isVerify; |
| | | |
| | | public ApplyEntity() { |
| | | } |
| | | |
| | |
| | | public void setUpdateTime(Timestamp updateTime) { |
| | | this.updateTime = updateTime; |
| | | } |
| | | |
| | | public String getUname() { |
| | | return uname; |
| | | } |
| | | |
| | | public void setUname(String uname) { |
| | | this.uname = uname; |
| | | } |
| | | |
| | | public Boolean getVerify() { |
| | | return isVerify; |
| | | } |
| | | |
| | | public void setVerify(Boolean verify) { |
| | | isVerify = verify; |
| | | } |
| | | } |
| | |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.sql.Timestamp; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 查询记录数 |
| | | * |
| | | * @param userid 用户ID |
| | | * @param uname 用户名 |
| | | * @param status 审核状态 |
| | | * @param start 开始时间 |
| | | * @param end 结束时间 |
| | | * @return 记录数 |
| | | */ |
| | | public Integer selectCount(Integer userid); |
| | | public Integer selectCount(String uname, Integer status, Timestamp start, Timestamp end); |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param userid 用户ID |
| | | * @param uname 用户名 |
| | | * @param status 审核状态 |
| | | * @param start 开始时间 |
| | | * @param end 结束时间 |
| | | * @param limit 记录数 |
| | | * @param offset 偏移量 |
| | | * @return 列表 |
| | | */ |
| | | public List<ApplyEntity> selectByPage(Integer userid, Integer limit, Integer offset); |
| | | public List<ApplyEntity> selectByPage(Integer userid, String uname, Integer status, Timestamp start, Timestamp end, Integer limit, Integer offset); |
| | | |
| | | /** |
| | | * 查询所有 |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.sql.Timestamp; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | |
| | | FlowService flowService; |
| | | |
| | | @Override |
| | | public Integer selectCount(Integer userid) { |
| | | return applyMapper.selectCount(userid); |
| | | public Integer selectCount(String uname, Integer status, Timestamp start, Timestamp end) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public List<ApplyEntity> selectByPage(Integer userid, Integer limit, Integer offset) { |
| | | return applyMapper.selectByPage(userid, limit, offset); |
| | | public List<ApplyEntity> selectByPage(Integer userid, String uname, Integer status, Timestamp start, Timestamp end, Integer limit, Integer offset) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.lf.server.mapper.show.ApplyMapper"> |
| | | <select id="selectCount" resultType="java.lang.Integer"> |
| | | select count(*) from lf.sys_apply |
| | | select count(*) from lf.sys_apply a inner join lf.sys_user b on a.userid = b.id |
| | | <where> |
| | | <if test="userid != null"> |
| | | userid = #{userid} |
| | | 1 = 1 |
| | | <if test="uname != null"> |
| | | and b.uname like #{uname} |
| | | </if> |
| | | <choose> |
| | | <when test="status == 1"> |
| | | and a.status between 1 and 9 |
| | | </when> |
| | | <otherwise> |
| | | and a.status = #{status} |
| | | </otherwise> |
| | | </choose> |
| | | <if test="start != null"> |
| | | and a.create_time >= #{start} |
| | | </if> |
| | | <if test="end != null"> |
| | | and a.create_time <= #{end} |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | <select id="selectByPage" resultType="com.lf.server.entity.show.ApplyEntity"> |
| | | select * from lf.sys_apply |
| | | select a.*, b.uname, (select count(*) from lf.sys_flow c where c.applyid = a.id and c.status = 0 and c.userid = #{userid}) isVerify |
| | | from lf.sys_apply a inner join lf.sys_user b on a.userid = b.id |
| | | <where> |
| | | <if test="userid != null"> |
| | | userid = #{userid} |
| | | 1 = 1 |
| | | <if test="uname != null"> |
| | | and b.uname like #{uname} |
| | | </if> |
| | | <choose> |
| | | <when test="status == 1"> |
| | | and a.status between 1 and 9 |
| | | </when> |
| | | <otherwise> |
| | | and a.status = #{status} |
| | | </otherwise> |
| | | </choose> |
| | | <if test="start != null"> |
| | | and a.create_time >= #{start} |
| | | </if> |
| | | <if test="end != null"> |
| | | and a.create_time <= #{end} |
| | | </if> |
| | | </where> |
| | | order by id |
| | | order by a.id |
| | | limit #{limit} offset #{offset} |
| | | </select> |
| | | |