管道基础大数据平台系统开发-【后端】-Server
12
13693261870
2023-07-31 c8e5656bd1d02f66b9e6e159da56804f7c7da112
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);
        }