|
|
|
|
@ -1,6 +1,7 @@ |
|
|
|
|
|
|
|
|
|
package org.springblade.plugin.operation.task.controller; |
|
|
|
|
|
|
|
|
|
import com.alibaba.nacos.common.utils.CollectionUtils; |
|
|
|
|
import com.alibaba.nacos.common.utils.StringUtils; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
@ -42,115 +43,131 @@ import java.util.List; |
|
|
|
|
@Api(value = "接口权限", tags = "接口权限") |
|
|
|
|
public class TaskInfoController extends BladeController { |
|
|
|
|
|
|
|
|
|
private final ITaskInfoService taskInfoService; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 详情 |
|
|
|
|
*/ |
|
|
|
|
@GetMapping("/detail") |
|
|
|
|
@ApiOperationSupport(order = 1) |
|
|
|
|
@ApiOperation(value = "详情", notes = "传入dataScope") |
|
|
|
|
public R<TaskInfo> detail(TaskInfo taskInfo) { |
|
|
|
|
TaskInfo detail = taskInfoService.getOne(Condition.getQueryWrapper(taskInfo)); |
|
|
|
|
return R.data(detail); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 分页 |
|
|
|
|
*/ |
|
|
|
|
@GetMapping("/list") |
|
|
|
|
@ApiOperationSupport(order = 2) |
|
|
|
|
@ApiOperation(value = "分页", notes = "传入dataScope") |
|
|
|
|
public R<IPage<TaskInfo>> list(TaskInfo taskInfo, Query query) { |
|
|
|
|
LambdaQueryWrapper<TaskInfo> wrapper = new LambdaQueryWrapper<>(taskInfo); |
|
|
|
|
// 创建人模糊查
|
|
|
|
|
if (StringUtils.isNotBlank(taskInfo.getCreateUserName())) { |
|
|
|
|
wrapper.like(TaskInfo::getCreateUserName, taskInfo.getCreateUserName()); |
|
|
|
|
} |
|
|
|
|
// 创建时间
|
|
|
|
|
if (taskInfo.getStartTime() != null && taskInfo.getEndTime() != null) { |
|
|
|
|
wrapper.between(TaskInfo::getCreateTime, taskInfo.getStartTime(), taskInfo.getEndTime()); |
|
|
|
|
} |
|
|
|
|
// 倒序
|
|
|
|
|
wrapper.orderByDesc(TaskInfo::getCreateTime); |
|
|
|
|
IPage<TaskInfo> pages = taskInfoService.page(Condition.getPage(query), wrapper); |
|
|
|
|
return R.data(pages); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 新增 |
|
|
|
|
*/ |
|
|
|
|
@ApiLog("数据运维-新增任务种类") |
|
|
|
|
@PostMapping("/save") |
|
|
|
|
@ApiOperationSupport(order = 3) |
|
|
|
|
@ApiOperation(value = "新增", notes = "传入dataScope") |
|
|
|
|
public R save(@Valid @RequestBody TaskInfo taskInfo) { |
|
|
|
|
taskInfo.setCreateUserName(AuthUtil.getNickName()); |
|
|
|
|
return R.status(taskInfoService.save(taskInfo)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 修改 |
|
|
|
|
*/ |
|
|
|
|
@ApiLog("数据运维-修改任务种类") |
|
|
|
|
@PostMapping("/update") |
|
|
|
|
@ApiOperationSupport(order = 4) |
|
|
|
|
@ApiOperation(value = "修改", notes = "传入dataScope") |
|
|
|
|
public R update(@Valid @RequestBody TaskInfo taskInfo) { |
|
|
|
|
return R.status(taskInfoService.updateById(taskInfo)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 新增或修改 |
|
|
|
|
*/ |
|
|
|
|
@PostMapping("/submit") |
|
|
|
|
@ApiOperationSupport(order = 5) |
|
|
|
|
@ApiOperation(value = "新增或修改", notes = "传入dataScope") |
|
|
|
|
public R submit(@Valid @RequestBody TaskInfo taskInfo) { |
|
|
|
|
return R.status(taskInfoService.saveOrUpdate(taskInfo)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 删除 |
|
|
|
|
*/ |
|
|
|
|
@ApiLog("数据运维-删除任务种类") |
|
|
|
|
@PostMapping("/remove") |
|
|
|
|
@ApiOperationSupport(order = 6) |
|
|
|
|
@ApiOperation(value = "逻辑删除", notes = "传入ids") |
|
|
|
|
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
|
|
|
|
return R.status(taskInfoService.deleteLogic(Func.toLongList(ids))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 任务种类去重返回 |
|
|
|
|
*/ |
|
|
|
|
@GetMapping("/taskTypeData") |
|
|
|
|
public R taskTypeData(String parentId) { |
|
|
|
|
QueryWrapper<TaskInfo> wrapper = new QueryWrapper<>(); |
|
|
|
|
if (StringUtils.isNotBlank(parentId)) { |
|
|
|
|
wrapper.eq("task_parent_id", parentId); |
|
|
|
|
private final ITaskInfoService taskInfoService; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 详情 |
|
|
|
|
*/ |
|
|
|
|
@GetMapping("/detail") |
|
|
|
|
@ApiOperationSupport(order = 1) |
|
|
|
|
@ApiOperation(value = "详情", notes = "传入dataScope") |
|
|
|
|
public R<TaskInfo> detail(TaskInfo taskInfo) { |
|
|
|
|
TaskInfo detail = taskInfoService.getOne(Condition.getQueryWrapper(taskInfo)); |
|
|
|
|
return R.data(detail); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 分页 |
|
|
|
|
*/ |
|
|
|
|
@GetMapping("/list") |
|
|
|
|
@ApiOperationSupport(order = 2) |
|
|
|
|
@ApiOperation(value = "分页", notes = "传入dataScope") |
|
|
|
|
public R<IPage<TaskInfo>> list(TaskInfo taskInfo, Query query) { |
|
|
|
|
LambdaQueryWrapper<TaskInfo> wrapper = new LambdaQueryWrapper<>(taskInfo); |
|
|
|
|
// 创建人模糊查
|
|
|
|
|
if (StringUtils.isNotBlank(taskInfo.getCreateUserName())) { |
|
|
|
|
wrapper.like(TaskInfo::getCreateUserName, taskInfo.getCreateUserName()); |
|
|
|
|
} |
|
|
|
|
// 创建时间
|
|
|
|
|
if (taskInfo.getStartTime() != null && taskInfo.getEndTime() != null) { |
|
|
|
|
wrapper.between(TaskInfo::getCreateTime, taskInfo.getStartTime(), taskInfo.getEndTime()); |
|
|
|
|
} |
|
|
|
|
// 倒序
|
|
|
|
|
wrapper.orderByDesc(TaskInfo::getCreateTime); |
|
|
|
|
IPage<TaskInfo> pages = taskInfoService.page(Condition.getPage(query), wrapper); |
|
|
|
|
return R.data(pages); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 新增 |
|
|
|
|
*/ |
|
|
|
|
@ApiLog("数据运维-新增任务种类") |
|
|
|
|
@PostMapping("/save") |
|
|
|
|
@ApiOperationSupport(order = 3) |
|
|
|
|
@ApiOperation(value = "新增", notes = "传入dataScope") |
|
|
|
|
public R save(@Valid @RequestBody TaskInfo taskInfo) throws Exception { |
|
|
|
|
LambdaQueryWrapper<TaskInfo> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
wrapper.eq(TaskInfo::getTaskTypeName, taskInfo.getTaskTypeName()); |
|
|
|
|
wrapper.eq(TaskInfo::getTaskParentId, taskInfo.getTaskParentId()); |
|
|
|
|
int count = taskInfoService.count(wrapper); |
|
|
|
|
if (count > 0) { |
|
|
|
|
throw new Exception("数据重复!"); |
|
|
|
|
} else { |
|
|
|
|
wrapper.select("DISTINCT task_type_name"); |
|
|
|
|
taskInfo.setCreateUserName(AuthUtil.getNickName()); |
|
|
|
|
return R.status(taskInfoService.save(taskInfo)); |
|
|
|
|
} |
|
|
|
|
return R.data(taskInfoService.list(wrapper)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 任务等级 |
|
|
|
|
*/ |
|
|
|
|
@GetMapping("/taskLevel") |
|
|
|
|
public R taskParent() { |
|
|
|
|
List<DictBiz> taskParent = DictBizCache.getList("task_level"); |
|
|
|
|
if ("运维公司".equals(AuthUtil.getUser().getRoleName())) { |
|
|
|
|
return R.data(taskParent); |
|
|
|
|
} |
|
|
|
|
List<DictBiz> taskParents = new ArrayList<>(); |
|
|
|
|
for (DictBiz dictBiz : taskParent) { |
|
|
|
|
if (!"3".equals(dictBiz.getDictKey())) { |
|
|
|
|
taskParents.add(dictBiz); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 修改 |
|
|
|
|
*/ |
|
|
|
|
@ApiLog("数据运维-修改任务种类") |
|
|
|
|
@PostMapping("/update") |
|
|
|
|
@ApiOperationSupport(order = 4) |
|
|
|
|
@ApiOperation(value = "修改", notes = "传入dataScope") |
|
|
|
|
public R update(@Valid @RequestBody TaskInfo taskInfo) throws Exception { |
|
|
|
|
LambdaQueryWrapper<TaskInfo> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
wrapper.eq(TaskInfo::getTaskTypeName, taskInfo.getTaskTypeName()); |
|
|
|
|
wrapper.eq(TaskInfo::getTaskParentId, taskInfo.getTaskParentId()); |
|
|
|
|
TaskInfo info = taskInfoService.getOne(wrapper); |
|
|
|
|
if (info != null && !taskInfo.getId().equals(info.getId())) { |
|
|
|
|
throw new Exception("数据重复!"); |
|
|
|
|
} else { |
|
|
|
|
return R.status(taskInfoService.updateById(taskInfo)); |
|
|
|
|
} |
|
|
|
|
return R.data(taskParents); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 新增或修改 |
|
|
|
|
*/ |
|
|
|
|
@PostMapping("/submit") |
|
|
|
|
@ApiOperationSupport(order = 5) |
|
|
|
|
@ApiOperation(value = "新增或修改", notes = "传入dataScope") |
|
|
|
|
public R submit(@Valid @RequestBody TaskInfo taskInfo) { |
|
|
|
|
return R.status(taskInfoService.saveOrUpdate(taskInfo)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 删除 |
|
|
|
|
*/ |
|
|
|
|
@ApiLog("数据运维-删除任务种类") |
|
|
|
|
@PostMapping("/remove") |
|
|
|
|
@ApiOperationSupport(order = 6) |
|
|
|
|
@ApiOperation(value = "逻辑删除", notes = "传入ids") |
|
|
|
|
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { |
|
|
|
|
return R.status(taskInfoService.deleteLogic(Func.toLongList(ids))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 任务种类去重返回 |
|
|
|
|
*/ |
|
|
|
|
@GetMapping("/taskTypeData") |
|
|
|
|
public R taskTypeData(String parentId) { |
|
|
|
|
QueryWrapper<TaskInfo> wrapper = new QueryWrapper<>(); |
|
|
|
|
if (StringUtils.isNotBlank(parentId)) { |
|
|
|
|
wrapper.eq("task_parent_id", parentId); |
|
|
|
|
} else { |
|
|
|
|
wrapper.select("DISTINCT task_type_name"); |
|
|
|
|
} |
|
|
|
|
return R.data(taskInfoService.list(wrapper)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 任务等级 |
|
|
|
|
*/ |
|
|
|
|
@GetMapping("/taskLevel") |
|
|
|
|
public R taskParent() { |
|
|
|
|
List<DictBiz> taskParent = DictBizCache.getList("task_level"); |
|
|
|
|
if ("运维公司".equals(AuthUtil.getUser().getRoleName())) { |
|
|
|
|
return R.data(taskParent); |
|
|
|
|
} |
|
|
|
|
List<DictBiz> taskParents = new ArrayList<>(); |
|
|
|
|
for (DictBiz dictBiz : taskParent) { |
|
|
|
|
if (!"3".equals(dictBiz.getDictKey())) { |
|
|
|
|
taskParents.add(dictBiz); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return R.data(taskParents); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|