| | |
| | | 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); |
| | | } |
| | |
| | | /** |
| | | * 查询记录数 |
| | | * |
| | | * @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); |
| | | |
| | | /** |
| | | * 查询所有 |
| | |
| | | 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 |
| | |
| | | <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> |
| | |
| | | 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 |