| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "name", value = "任务名称", dataType = "String", paramType = "query", example = ""), |
| | | @ApiImplicitParam(name = "status", value = "任务状态", dataType = "Integer", paramType = "query", example = "1"), |
| | | @ApiImplicitParam(name = "type", 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 = "/selectByPageAndCount") |
| | | public ResponseMsg<List<TaskEntity>> selectByPageAndCount(String name, Integer status, Integer pageSize, Integer pageIndex) { |
| | | public ResponseMsg<List<TaskEntity>> selectByPageAndCount(String name, Integer status, String type, Integer pageSize, Integer pageIndex) { |
| | | try { |
| | | if (pageSize < 1 || pageIndex < 1) { |
| | | return fail("每页页数或分页数小于1", null); |
| | | } |
| | | |
| | | int count = taskService.selectCount(name, status); |
| | | int count = taskService.selectCount(name, status, type); |
| | | if (count == 0) { |
| | | return success(0, null); |
| | | } |
| | | |
| | | List<TaskEntity> rs = taskService.selectByPage(name, status, pageSize, pageSize * (pageIndex - 1)); |
| | | List<TaskEntity> rs = taskService.selectByPage(name, status, type, pageSize, pageSize * (pageIndex - 1)); |
| | | |
| | | return success(count, rs); |
| | | } catch (Exception ex) { |
| | |
| | | public ResponseMsg<Object> deleteTask(int id, HttpServletRequest req) { |
| | | try { |
| | | TaskEntity task = taskService.selectById(id); |
| | | if (null == task) { |
| | | return fail("任务不存在", -1); |
| | | if (null == task || 1 != task.getStatus()) { |
| | | return fail("任务不存在或无需结束", -1); |
| | | } |
| | | |
| | | List<Integer> ids = new ArrayList<>(); |
| | |
| | | * |
| | | * @param name 任务名称 |
| | | * @param status 任务状态 |
| | | * @param type 任务类别 |
| | | * @return 记录数 |
| | | */ |
| | | public Integer selectCount(String name, Integer status); |
| | | public Integer selectCount(String name, Integer status, String type); |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param name 任务名称 |
| | | * @param status 任务状态 |
| | | * @param type 任务类别 |
| | | * @param limit 记录数 |
| | | * @param offset 偏移量 |
| | | * @return 列表 |
| | | */ |
| | | public List<TaskEntity> selectByPage(String name, Integer status, Integer limit, Integer offset); |
| | | public List<TaskEntity> selectByPage(String name, Integer status, String type, Integer limit, Integer offset); |
| | | |
| | | /** |
| | | * 查询所有 |
| | |
| | | TaskMapper taskMapper; |
| | | |
| | | @Override |
| | | public Integer selectCount(String name, Integer status) { |
| | | public Integer selectCount(String name, Integer status, String type) { |
| | | name = StringHelper.getLikeUpperStr(name); |
| | | |
| | | return taskMapper.selectCount(name, status); |
| | | return taskMapper.selectCount(name, status, type); |
| | | } |
| | | |
| | | @Override |
| | | public List<TaskEntity> selectByPage(String name, Integer status, Integer limit, Integer offset) { |
| | | public List<TaskEntity> selectByPage(String name, Integer status, String type, Integer limit, Integer offset) { |
| | | name = StringHelper.getLikeUpperStr(name); |
| | | |
| | | return taskMapper.selectByPage(name, status, limit, offset); |
| | | return taskMapper.selectByPage(name, status, type, limit, offset); |
| | | } |
| | | |
| | | @Override |