管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-12-25 1def68140023fe6edb8ce47df21fe1ed0ae871e0
1
已修改5个文件
97 ■■■■ 文件已修改
src/main/java/com/lf/server/controller/show/ApplyController.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/entity/show/ApplyEntity.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/mapper/show/ApplyMapper.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/show/ApplyService.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/show/ApplyMapper.xml 45 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/controller/show/ApplyController.java
@@ -78,25 +78,26 @@
    @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) {
src/main/java/com/lf/server/entity/show/ApplyEntity.java
@@ -38,6 +38,10 @@
    private Timestamp updateTime;
    private String uname;
    private Boolean isVerify;
    public ApplyEntity() {
    }
@@ -152,4 +156,20 @@
    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;
    }
}
src/main/java/com/lf/server/mapper/show/ApplyMapper.java
@@ -5,6 +5,7 @@
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import java.sql.Timestamp;
import java.util.List;
/**
@@ -17,20 +18,27 @@
    /**
     * 查询记录数
     *
     * @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);
    /**
     * 查询所有
src/main/java/com/lf/server/service/show/ApplyService.java
@@ -10,6 +10,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
@@ -26,13 +27,13 @@
    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
src/main/resources/mapper/show/ApplyMapper.xml
@@ -2,22 +2,53 @@
<!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 &gt;= #{start}
            </if>
            <if test="end != null">
                and a.create_time &lt;= #{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 &gt;= #{start}
            </if>
            <if test="end != null">
                and a.create_time &lt;= #{end}
            </if>
        </where>
        order by id
        order by a.id
        limit #{limit} offset #{offset}
    </select>