管道基础大数据平台系统开发-【后端】-Server
12
13693261870
2023-07-31 c8e5656bd1d02f66b9e6e159da56804f7c7da112
12
已修改4个文件
86 ■■■■ 文件已修改
src/main/java/com/lf/server/controller/data/TaskController.java 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/mapper/data/TaskMapper.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/data/TaskService.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/data/TaskMapper.xml 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/controller/data/TaskController.java
@@ -39,78 +39,28 @@
    PublishService publishService;
    @SysLog()
    @ApiOperation(value = "查询记录数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "任务名称", dataType = "String", paramType = "query", required = false, example = "")
    })
    @GetMapping({"/selectCount"})
    public ResponseMsg<Integer> selectCount(String name) {
        try {
            int count = taskService.selectCount(name);
            return success(count);
        } catch (Exception ex) {
            return fail(ex, -1);
        }
    }
    @SysLog()
    @ApiOperation(value = "分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "任务名称", dataType = "String", paramType = "query", example = ""),
            @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<List<TaskEntity>> selectByPage(String name, Integer pageSize, Integer pageIndex) {
        try {
            if (pageSize < 1 || pageIndex < 1) {
                return fail("每页页数或分页数小于1", null);
            }
            List<TaskEntity> rs = taskService.selectByPage(name, pageSize, pageSize * (pageIndex - 1));
            return success(rs);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
    @SysLog()
    @ApiOperation(value = "分页查询并返回记录数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "任务名称", dataType = "String", paramType = "query", example = ""),
            @ApiImplicitParam(name = "status", value = "任务状态", dataType = "Integer", paramType = "query", example = "1"),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "Integer", paramType = "query", example = "10"),
            @ApiImplicitParam(name = "pageIndex", value = "分页数(从1开始)", dataType = "Integer", paramType = "query", example = "1")
    })
    @GetMapping(value = "/selectByPageAndCount")
    public ResponseMsg<List<TaskEntity>> selectByPageAndCount(String name, Integer pageSize, Integer pageIndex) {
    public ResponseMsg<List<TaskEntity>> selectByPageAndCount(String name, Integer status, Integer pageSize, Integer pageIndex) {
        try {
            if (pageSize < 1 || pageIndex < 1) {
                return fail("每页页数或分页数小于1", null);
            }
            int count = taskService.selectCount(name);
            int count = taskService.selectCount(name, status);
            if (count == 0) {
                return success(0, null);
            }
            List<TaskEntity> rs = taskService.selectByPage(name, pageSize, pageSize * (pageIndex - 1));
            List<TaskEntity> rs = taskService.selectByPage(name, status, pageSize, pageSize * (pageIndex - 1));
            return success(count, rs);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
    @SysLog()
    @ApiOperation(value = "查询所有")
    @GetMapping(value = "/selectAll")
    public ResponseMsg<List<TaskEntity>> selectAll() {
        try {
            List<TaskEntity> list = taskService.selectAll();
            return success(list);
        } catch (Exception ex) {
            return fail(ex, null);
        }
src/main/java/com/lf/server/mapper/data/TaskMapper.java
@@ -16,20 +16,22 @@
    /**
     * 查询记录数
     *
     * @param name 任务名称
     * @param name   任务名称
     * @param status 任务状态
     * @return 记录数
     */
    public Integer selectCount(String name);
    public Integer selectCount(String name, Integer status);
    /**
     * 分页查询
     *
     * @param name   任务名称
     * @param status 任务状态
     * @param limit  记录数
     * @param offset 偏移量
     * @return 列表
     */
    public List<TaskEntity> selectByPage(String name, Integer limit, Integer offset);
    public List<TaskEntity> selectByPage(String name, Integer status, Integer limit, Integer offset);
    /**
     * 查询所有
src/main/java/com/lf/server/service/data/TaskService.java
@@ -18,17 +18,17 @@
    TaskMapper taskMapper;
    @Override
    public Integer selectCount(String name) {
    public Integer selectCount(String name, Integer status) {
        name = StringHelper.getLikeUpperStr(name);
        return taskMapper.selectCount(name);
        return taskMapper.selectCount(name, status);
    }
    @Override
    public List<TaskEntity> selectByPage(String name, Integer limit, Integer offset) {
    public List<TaskEntity> selectByPage(String name, Integer status, Integer limit, Integer offset) {
        name = StringHelper.getLikeUpperStr(name);
        return taskMapper.selectByPage(name, limit, offset);
        return taskMapper.selectByPage(name, status, limit, offset);
    }
    @Override
src/main/resources/mapper/data/TaskMapper.xml
@@ -4,8 +4,12 @@
    <select id="selectCount" resultType="java.lang.Integer">
        select count(*) from lf.sys_task
        <where>
            1 = 1
            <if test="name != null">
                upper(name) like #{name}
                and upper(name) like #{name}
            </if>
            <if test="status != null">
                and status = #{status}
            </if>
        </where>
    </select>
@@ -14,8 +18,12 @@
        select a.*, fn_get_fullname(a.depcode, 1) depName, fn_get_fullname(a.dircode, 2) dirName, fn_uname(create_user) createName, fn_uname(update_user) updateName
        from lf.sys_task a
        <where>
            1 = 1
            <if test="name != null">
                upper(name) like #{name}
                and upper(name) like #{name}
            </if>
            <if test="status != null">
                and status = #{status}
            </if>
        </where>
        order by a.update_time desc, a.create_time desc