完成任务表+节点表+中间表的增删改查组合功能
parent
285c0ea258
commit
f8d52be51b
|
@ -1,6 +1,8 @@
|
|||
package com.muyu.quest.domain;
|
||||
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.validation.custom.IsSysApiState;
|
||||
import com.muyu.common.core.validation.custom.IsSysYesNo;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
@ -57,6 +59,7 @@ public class Node extends BaseEntity{
|
|||
|
||||
/** 启用状态 */
|
||||
@Excel(name = "启用状态")
|
||||
@IsSysYesNo
|
||||
private String state;
|
||||
|
||||
|
||||
|
|
|
@ -6,7 +6,9 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
|||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.validation.custom.IsSysYesNo;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
@ -55,71 +57,9 @@ public class Task extends BaseEntity {
|
|||
|
||||
/** 启用状态 */
|
||||
@Excel(name = "启用状态")
|
||||
@IsSysYesNo
|
||||
private String state;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
public void setTaskCode(String taskCode)
|
||||
{
|
||||
this.taskCode = taskCode;
|
||||
}
|
||||
|
||||
public String getTaskCode()
|
||||
{
|
||||
return taskCode;
|
||||
}
|
||||
public void setTaskName(String taskName)
|
||||
{
|
||||
this.taskName = taskName;
|
||||
}
|
||||
|
||||
public String getTaskName()
|
||||
{
|
||||
return taskName;
|
||||
}
|
||||
public void setTaskWebhook(String taskWebhook)
|
||||
{
|
||||
this.taskWebhook = taskWebhook;
|
||||
}
|
||||
|
||||
public String getTaskWebhook()
|
||||
{
|
||||
return taskWebhook;
|
||||
}
|
||||
public void setRuleCode(String ruleCode)
|
||||
{
|
||||
this.ruleCode = ruleCode;
|
||||
}
|
||||
|
||||
public String getRuleCode()
|
||||
{
|
||||
return ruleCode;
|
||||
}
|
||||
public void setTaskType(String taskType)
|
||||
{
|
||||
this.taskType = taskType;
|
||||
}
|
||||
|
||||
public String getTaskType()
|
||||
{
|
||||
return taskType;
|
||||
}
|
||||
public void setState(String state)
|
||||
{
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getState()
|
||||
{
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
package com.muyu.quest.domain;
|
||||
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
|
||||
/**
|
||||
* 任务结点中间表对象 task_node_middle
|
||||
*
|
||||
* @author 2112A
|
||||
* @date 2024-08-23
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Setter
|
||||
@Getter
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("task_node_middle")
|
||||
public class TaskNodeMiddle extends BaseEntity{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 自增主键 */
|
||||
@TableId( type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/** 任务编码 */
|
||||
@Excel(name = "任务编码")
|
||||
private String taskCode;
|
||||
|
||||
/** 节点编码 */
|
||||
@Excel(name = "节点编码")
|
||||
private String nodeCode;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("taskCode", getTaskCode())
|
||||
.append("nodeCode", getNodeCode())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package com.muyu.quest.req;
|
||||
|
||||
import com.muyu.common.core.validation.custom.IsSysYesNo;
|
||||
import lombok.*;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 节点管理对象 node_source
|
||||
*
|
||||
* @author 2112A
|
||||
* @date 2024-08-23
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class NodeReq{
|
||||
|
||||
|
||||
/** 节点名称 */
|
||||
private String nodeName;
|
||||
|
||||
/** 上一级节点 */
|
||||
private String nodePreCode;
|
||||
|
||||
/** 下一级节点 */
|
||||
private String nodeNextCode;
|
||||
|
||||
/** 启用状态 */
|
||||
@IsSysYesNo
|
||||
private String state;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("nodeName", getNodeName())
|
||||
.append("nodePreCode", getNodePreCode())
|
||||
.append("nodeNextCode", getNodeNextCode())
|
||||
.append("state", getState())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package com.muyu.quest.req;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.validation.custom.IsSysYesNo;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
|
||||
/**
|
||||
* 任务对象 task_source
|
||||
*
|
||||
* @author 2112A
|
||||
* @date 2024-08-22
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TaskReq{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/** 任务名称 */
|
||||
private String taskName;
|
||||
|
||||
/** 规则编码 */
|
||||
private String ruleCode;
|
||||
|
||||
/** 任务类型 */
|
||||
private String taskType;
|
||||
|
||||
/** 启用状态 */
|
||||
@IsSysYesNo
|
||||
private String state;
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("taskName", getTaskName())
|
||||
.append("ruleCode", getRuleCode())
|
||||
.append("taskType", getTaskType())
|
||||
.append("state", getState())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package com.muyu.quest.resp;
|
||||
|
||||
import com.muyu.common.core.enums.SysYesNo;
|
||||
import com.muyu.quest.domain.Node;
|
||||
import lombok.*;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 节点管理对象 node_source
|
||||
*
|
||||
* @author 2112A
|
||||
* @date 2024-08-23
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class NodeResp{
|
||||
|
||||
/** 自增主键 */
|
||||
private Long id;
|
||||
|
||||
/** 节点编码 */
|
||||
private String nodeCode;
|
||||
|
||||
/** 节点名称 */
|
||||
private String nodeName;
|
||||
|
||||
/** 节点入参 */
|
||||
private String nodeReq;
|
||||
|
||||
/** 节点出参 */
|
||||
private String nodeResp;
|
||||
|
||||
/** 上一级节点 */
|
||||
private String nodePreCode;
|
||||
|
||||
/** 下一级节点 */
|
||||
private String nodeNextCode;
|
||||
|
||||
/** 启用状态 */
|
||||
private String state;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("nodeCode", getNodeCode())
|
||||
.append("nodeName", getNodeName())
|
||||
.append("nodeReq", getNodeReq())
|
||||
.append("nodeResp", getNodeResp())
|
||||
.append("nodePreCode", getNodePreCode())
|
||||
.append("nodeNextCode", getNodeNextCode())
|
||||
.append("state", getState())
|
||||
.toString();
|
||||
}
|
||||
|
||||
public static NodeResp build(Node node) {
|
||||
return NodeResp.builder()
|
||||
.id(node.getId())
|
||||
.nodeCode(node.getNodeCode())
|
||||
.nodeName(node.getNodeName())
|
||||
.nodeReq(node.getNodeReq())
|
||||
.nodeResp(node.getNodeResp())
|
||||
.nodePreCode(node.getNodePreCode())
|
||||
.nodeNextCode(node.getNodeNextCode())
|
||||
.state(SysYesNo.getInfoByCode(node.getState()))
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package com.muyu.quest.resp;
|
||||
|
||||
|
||||
import com.muyu.common.core.enums.SysYesNo;
|
||||
import com.muyu.quest.domain.Task;
|
||||
import lombok.*;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
|
||||
/**
|
||||
* 任务对象 task_source
|
||||
*
|
||||
* @author 2112A
|
||||
* @date 2024-08-22
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TaskResp {
|
||||
|
||||
/** 自增主键 */
|
||||
private Long id;
|
||||
|
||||
/** 任务编码 */
|
||||
private String taskCode;
|
||||
|
||||
/** 任务名称 */
|
||||
private String taskName;
|
||||
|
||||
/** 任务触发器 */
|
||||
private String taskWebhook;
|
||||
|
||||
/** 规则编码 */
|
||||
private String ruleCode;
|
||||
|
||||
/** 任务类型 */
|
||||
private String taskType;
|
||||
|
||||
/** 启用状态 */
|
||||
private String state;
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("taskCode", getTaskCode())
|
||||
.append("taskName", getTaskName())
|
||||
.append("taskWebhook", getTaskWebhook())
|
||||
.append("ruleCode", getRuleCode())
|
||||
.append("taskType", getTaskType())
|
||||
.append("state", getState())
|
||||
.toString();
|
||||
}
|
||||
|
||||
public static TaskResp build(Task task) {
|
||||
return TaskResp.builder()
|
||||
.id(task.getId())
|
||||
.taskCode(task.getTaskCode())
|
||||
.taskName(task.getTaskName())
|
||||
.taskWebhook(task.getTaskWebhook())
|
||||
.ruleCode(task.getRuleCode())
|
||||
.taskType(task.getTaskType())
|
||||
.state(SysYesNo.getInfoByCode(task.getState()))
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -1,9 +1,18 @@
|
|||
package com.muyu.quest.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.muyu.quest.domain.TaskNodeMiddle;
|
||||
import com.muyu.quest.req.NodeReq;
|
||||
import com.muyu.quest.resp.NodeResp;
|
||||
import com.muyu.quest.service.ITaskNodeMiddleService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
|
@ -34,27 +43,32 @@ public class NodeController extends BaseController
|
|||
{
|
||||
@Resource
|
||||
private INodeService nodeService;
|
||||
@Resource
|
||||
private ITaskNodeMiddleService middleService;
|
||||
|
||||
/**
|
||||
* 查询节点管理列表
|
||||
*/
|
||||
@RequiresPermissions("quest:node:list")
|
||||
// @RequiresPermissions("quest:node:list")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<Node>> list(Node node)
|
||||
public Result<TableDataInfo<NodeResp>> list(NodeReq nodeReq)
|
||||
{
|
||||
startPage();
|
||||
List<Node> list = nodeService.selectNodeList(node);
|
||||
return getDataTable(list);
|
||||
List<Node> list = nodeService.selectNodeList(nodeReq);
|
||||
return getDataTable(list
|
||||
.stream()
|
||||
.map(NodeResp::build)
|
||||
.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出节点管理列表
|
||||
*/
|
||||
@RequiresPermissions("quest:node:export")
|
||||
// @RequiresPermissions("quest:node:export")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, Node node)
|
||||
public void export(HttpServletResponse response, NodeReq nodeReq)
|
||||
{
|
||||
List<Node> list = nodeService.selectNodeList(node);
|
||||
List<Node> list = nodeService.selectNodeList(nodeReq);
|
||||
ExcelUtil<Node> util = new ExcelUtil<Node>(Node.class);
|
||||
util.exportExcel(response, list, "节点管理数据");
|
||||
}
|
||||
|
@ -62,7 +76,7 @@ public class NodeController extends BaseController
|
|||
/**
|
||||
* 获取节点管理详细信息
|
||||
*/
|
||||
@RequiresPermissions("quest:node:query")
|
||||
// @RequiresPermissions("quest:node:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
public Result<List<Node>> getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
|
@ -72,22 +86,29 @@ public class NodeController extends BaseController
|
|||
/**
|
||||
* 新增节点管理
|
||||
*/
|
||||
@RequiresPermissions("quest:node:add")
|
||||
@PostMapping
|
||||
// @RequiresPermissions("quest:node:add")
|
||||
@PostMapping("/{taskCode}")
|
||||
@Transactional
|
||||
public Result<Integer> add(
|
||||
@Validated @RequestBody Node node)
|
||||
{
|
||||
@Validated @RequestBody Node node,@PathVariable("taskCode") String taskCode) {
|
||||
if (nodeService.checkIdUnique(node)) {
|
||||
return error("新增 节点管理 '" + node + "'失败,节点管理已存在");
|
||||
}
|
||||
String code = UUID.randomUUID().toString().replace("-","");
|
||||
node.setNodeCode(code);
|
||||
node.setCreateBy(SecurityUtils.getUsername());
|
||||
return toAjax(nodeService.save(node));
|
||||
boolean save = nodeService.save(node);
|
||||
if (save){
|
||||
// 新增任务节点中间表信息
|
||||
middleService.save(new TaskNodeMiddle(null,taskCode,code));
|
||||
}
|
||||
return toAjax(save);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改节点管理
|
||||
*/
|
||||
@RequiresPermissions("quest:node:edit")
|
||||
// @RequiresPermissions("quest:node:edit")
|
||||
@PutMapping
|
||||
public Result<Integer> edit(
|
||||
@Validated @RequestBody Node node)
|
||||
|
@ -102,10 +123,20 @@ public class NodeController extends BaseController
|
|||
/**
|
||||
* 删除节点管理
|
||||
*/
|
||||
@RequiresPermissions("quest:node:remove")
|
||||
@DeleteMapping("/{ids}")
|
||||
public Result<Integer> remove(@PathVariable("ids") Long[] ids)
|
||||
// @RequiresPermissions("quest:node:remove")
|
||||
@DeleteMapping("/{ids}/{taskCode}")
|
||||
@Transactional
|
||||
public Result<Integer> remove(@PathVariable("ids") Long[] ids,@PathVariable("taskCode") String taskCode)
|
||||
{
|
||||
// 节点id批量查询
|
||||
List<Node> list = nodeService.selectNodeByIds(ids);
|
||||
// 删除相关中间表信息信息
|
||||
list.forEach(node -> {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("node_code",node.getNodeCode());
|
||||
map.put("task_code",taskCode);
|
||||
middleService.removeByMap(map);
|
||||
});
|
||||
nodeService.removeBatchByIds(Arrays.asList(ids));
|
||||
return success();
|
||||
}
|
||||
|
|
|
@ -2,12 +2,15 @@ package com.muyu.quest.controller;
|
|||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.quest.domain.Task;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import com.muyu.quest.req.TaskReq;
|
||||
import com.muyu.quest.resp.TaskResp;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
@ -17,7 +20,6 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
|
||||
import com.muyu.quest.service.TaskService;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
|
@ -42,10 +44,10 @@ public class TaskController extends BaseController
|
|||
*/
|
||||
// @RequiresPermissions("quest:quest:list")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<Task>> list(Task task)
|
||||
public Result<TableDataInfo<TaskResp>> list(TaskReq taskReq)
|
||||
{
|
||||
startPage();
|
||||
List<Task> list = taskService.selectTaskList(task);
|
||||
List<TaskResp> list = taskService.selectTaskList(taskReq);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
@ -54,7 +56,7 @@ public class TaskController extends BaseController
|
|||
*/
|
||||
// @RequiresPermissions("quest:quest:query")
|
||||
@GetMapping(value = "/selectTaskByTaskCode/{taskCode}")
|
||||
public Result<List<Task>> getInfo(@PathVariable("taskCode") String taskCode) {
|
||||
public Result<Task> getInfo(@PathVariable("taskCode") String taskCode) {
|
||||
return success(taskService.selectTaskByTaskCode(taskCode));
|
||||
}
|
||||
|
||||
|
@ -63,7 +65,7 @@ public class TaskController extends BaseController
|
|||
*/
|
||||
// @RequiresPermissions("quest:quest:query")
|
||||
@GetMapping(value = "/selectTaskById/{id}")
|
||||
public Result<List<Task>> getInfo(@PathVariable("id") Long id) {
|
||||
public Result<Task> getInfo(@PathVariable("id") Long id) {
|
||||
return success(taskService.selectTaskById(id));
|
||||
}
|
||||
|
||||
|
@ -76,6 +78,7 @@ public class TaskController extends BaseController
|
|||
if (taskService.checkTaskCodeUnique(task)) {
|
||||
return error("新增参数'" + task.getTaskName() + "'失败,任务已存在");
|
||||
}
|
||||
task.setTaskCode(UUID.randomUUID().toString().replace("-",""));
|
||||
task.setCreateBy(SecurityUtils.getUsername());
|
||||
return toAjax(taskService.save(task));
|
||||
}
|
||||
|
@ -86,7 +89,7 @@ public class TaskController extends BaseController
|
|||
// @RequiresPermissions("quest:quest:quest")
|
||||
@PutMapping
|
||||
public Result edit (@Validated @RequestBody Task task) {
|
||||
if (!taskService.checkIdUnique(task)) {
|
||||
if (!taskService.checkTaskCodeUnique(task)) {
|
||||
return error("修改参数'" + task.getTaskName() + "'失败,任务不存在");
|
||||
}
|
||||
task.setUpdateBy(SecurityUtils.getUsername());
|
||||
|
|
|
@ -0,0 +1,112 @@
|
|||
package com.muyu.quest.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.quest.domain.TaskNodeMiddle;
|
||||
import com.muyu.quest.service.ITaskNodeMiddleService;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 任务结点中间表Controller
|
||||
*
|
||||
* @author 2112A
|
||||
* @date 2024-08-23
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/middle")
|
||||
public class TaskNodeMiddleController extends BaseController
|
||||
{
|
||||
@Resource
|
||||
private ITaskNodeMiddleService taskNodeMiddleService;
|
||||
|
||||
/**
|
||||
* 查询任务结点中间表列表
|
||||
*/
|
||||
// @RequiresPermissions("quest:middle:list")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<TaskNodeMiddle>> list(TaskNodeMiddle taskNodeMiddle)
|
||||
{
|
||||
startPage();
|
||||
List<TaskNodeMiddle> list = taskNodeMiddleService.selectTaskNodeMiddleList(taskNodeMiddle);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出任务结点中间表列表
|
||||
*/
|
||||
// @RequiresPermissions("quest:middle:export")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, TaskNodeMiddle taskNodeMiddle)
|
||||
{
|
||||
List<TaskNodeMiddle> list = taskNodeMiddleService.selectTaskNodeMiddleList(taskNodeMiddle);
|
||||
ExcelUtil<TaskNodeMiddle> util = new ExcelUtil<TaskNodeMiddle>(TaskNodeMiddle.class);
|
||||
util.exportExcel(response, list, "任务结点中间表数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取任务结点中间表详细信息
|
||||
*/
|
||||
// @RequiresPermissions("quest:middle:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
public Result<List<TaskNodeMiddle>> getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(taskNodeMiddleService.selectTaskNodeMiddleById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增任务结点中间表
|
||||
*/
|
||||
// @RequiresPermissions("quest:middle:add")
|
||||
@PostMapping
|
||||
public Result<Integer> add(
|
||||
@Validated @RequestBody TaskNodeMiddle taskNodeMiddle)
|
||||
{
|
||||
if (taskNodeMiddleService.checkIdUnique(taskNodeMiddle)) {
|
||||
return error("新增 任务结点中间表 '" + taskNodeMiddle + "'失败,任务结点中间表已存在");
|
||||
}
|
||||
taskNodeMiddle.setCreateBy(SecurityUtils.getUsername());
|
||||
return toAjax(taskNodeMiddleService.save(taskNodeMiddle));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改任务结点中间表
|
||||
*/
|
||||
// @RequiresPermissions("quest:middle:edit")
|
||||
@PutMapping
|
||||
public Result<Integer> edit(
|
||||
@Validated @RequestBody TaskNodeMiddle taskNodeMiddle)
|
||||
{
|
||||
if (!taskNodeMiddleService.checkIdUnique(taskNodeMiddle)) {
|
||||
return error("修改 任务结点中间表 '" + taskNodeMiddle + "'失败,任务结点中间表不存在");
|
||||
}
|
||||
taskNodeMiddle.setUpdateBy(SecurityUtils.getUsername());
|
||||
return toAjax(taskNodeMiddleService.updateById(taskNodeMiddle));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除任务结点中间表
|
||||
*/
|
||||
// @RequiresPermissions("quest:middle:remove")
|
||||
@DeleteMapping("/{ids}")
|
||||
public Result<Integer> remove(@PathVariable("ids") Long[] ids)
|
||||
{
|
||||
taskNodeMiddleService.removeBatchByIds(Arrays.asList(ids));
|
||||
return success();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.muyu.quest.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.muyu.quest.domain.TaskNodeMiddle;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 任务结点中间表Mapper接口
|
||||
*
|
||||
* @author 2112A
|
||||
* @date 2024-08-23
|
||||
*/
|
||||
@Mapper
|
||||
public interface TaskNodeMiddleMapper extends BaseMapper<TaskNodeMiddle>{
|
||||
|
||||
}
|
|
@ -3,6 +3,7 @@ package com.muyu.quest.service;
|
|||
import java.util.List;
|
||||
import com.muyu.quest.domain.Node;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.quest.req.NodeReq;
|
||||
|
||||
/**
|
||||
* 节点管理Service接口
|
||||
|
@ -22,10 +23,10 @@ public interface INodeService extends IService<Node> {
|
|||
/**
|
||||
* 查询节点管理列表
|
||||
*
|
||||
* @param node 节点管理
|
||||
* @param nodeReq 节点管理
|
||||
* @return 节点管理集合
|
||||
*/
|
||||
public List<Node> selectNodeList(Node node);
|
||||
public List<Node> selectNodeList(NodeReq nodeReq);
|
||||
|
||||
/**
|
||||
* 判断 节点管理 id是否唯一
|
||||
|
@ -34,4 +35,5 @@ public interface INodeService extends IService<Node> {
|
|||
*/
|
||||
Boolean checkIdUnique(Node node);
|
||||
|
||||
List<Node> selectNodeByIds(Long[] ids);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package com.muyu.quest.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.muyu.quest.domain.TaskNodeMiddle;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* 任务结点中间表Service接口
|
||||
*
|
||||
* @author 2112A
|
||||
* @date 2024-08-23
|
||||
*/
|
||||
public interface ITaskNodeMiddleService extends IService<TaskNodeMiddle> {
|
||||
/**
|
||||
* 精确查询任务结点中间表
|
||||
*
|
||||
* @param id 任务结点中间表主键
|
||||
* @return 任务结点中间表
|
||||
*/
|
||||
public TaskNodeMiddle selectTaskNodeMiddleById(Long id);
|
||||
|
||||
/**
|
||||
* 查询任务结点中间表列表
|
||||
*
|
||||
* @param taskNodeMiddle 任务结点中间表
|
||||
* @return 任务结点中间表集合
|
||||
*/
|
||||
public List<TaskNodeMiddle> selectTaskNodeMiddleList(TaskNodeMiddle taskNodeMiddle);
|
||||
|
||||
/**
|
||||
* 判断 任务结点中间表 id是否唯一
|
||||
* @param taskNodeMiddle 任务结点中间表
|
||||
* @return 结果
|
||||
*/
|
||||
Boolean checkIdUnique(TaskNodeMiddle taskNodeMiddle);
|
||||
|
||||
}
|
|
@ -4,6 +4,8 @@ import java.util.List;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.quest.domain.Task;
|
||||
import com.muyu.quest.req.TaskReq;
|
||||
import com.muyu.quest.resp.TaskResp;
|
||||
|
||||
/**
|
||||
* 任务Service接口
|
||||
|
@ -23,10 +25,10 @@ public interface TaskService extends IService<Task> {
|
|||
/**
|
||||
* 查询任务列表
|
||||
*
|
||||
* @param task 任务
|
||||
* @param taskReq 任务
|
||||
* @return 任务集合
|
||||
*/
|
||||
public List<Task> selectTaskList(Task task);
|
||||
public List<TaskResp> selectTaskList(TaskReq taskReq);
|
||||
|
||||
|
||||
Task selectTaskById(Long id);
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package com.muyu.quest.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.muyu.common.core.utils.DateUtils;
|
||||
|
||||
import com.muyu.quest.req.NodeReq;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.muyu.quest.mapper.NodeMapper;
|
||||
import com.muyu.quest.domain.Node;
|
||||
|
@ -41,18 +42,24 @@ public class NodeServiceImpl
|
|||
/**
|
||||
* 查询节点管理列表
|
||||
*
|
||||
* @param node 节点管理
|
||||
* @param nodeReq 节点管理
|
||||
* @return 节点管理
|
||||
*/
|
||||
@Override
|
||||
public List<Node> selectNodeList(Node node)
|
||||
public List<Node> selectNodeList(NodeReq nodeReq)
|
||||
{
|
||||
LambdaQueryWrapper<Node> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (StringUtils.isNotEmpty(node.getNodeName())){
|
||||
queryWrapper.like(Node::getNodeName, node.getNodeName());
|
||||
if (StringUtils.isNotEmpty(nodeReq.getNodeName())){
|
||||
queryWrapper.like(Node::getNodeName, nodeReq.getNodeName());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(node.getState())){
|
||||
queryWrapper.eq(Node::getState, node.getState());
|
||||
if (StringUtils.isNotEmpty(nodeReq.getNodePreCode())){
|
||||
queryWrapper.eq(Node::getNodePreCode, nodeReq.getNodePreCode());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(nodeReq.getNodeNextCode())){
|
||||
queryWrapper.eq(Node::getNodeNextCode, nodeReq.getNodeNextCode());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(nodeReq.getState())){
|
||||
queryWrapper.eq(Node::getState, nodeReq.getState());
|
||||
}
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
@ -69,4 +76,12 @@ public class NodeServiceImpl
|
|||
return this.count(queryWrapper) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Node> selectNodeByIds(Long[] ids) {
|
||||
LambdaQueryWrapper<Node> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(Node::getId, ids);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
package com.muyu.quest.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.muyu.common.core.utils.DateUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.muyu.quest.mapper.TaskNodeMiddleMapper;
|
||||
import com.muyu.quest.domain.TaskNodeMiddle;
|
||||
import com.muyu.quest.service.ITaskNodeMiddleService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* 任务结点中间表Service业务层处理
|
||||
*
|
||||
* @author 2112A
|
||||
* @date 2024-08-23
|
||||
*/
|
||||
@Service
|
||||
public class TaskNodeMiddleServiceImpl
|
||||
extends ServiceImpl<TaskNodeMiddleMapper, TaskNodeMiddle>
|
||||
implements ITaskNodeMiddleService {
|
||||
|
||||
/**
|
||||
* 精确查询任务结点中间表
|
||||
*
|
||||
* @param id 任务结点中间表主键
|
||||
* @return 任务结点中间表
|
||||
*/
|
||||
@Override
|
||||
public TaskNodeMiddle selectTaskNodeMiddleById(Long id)
|
||||
{
|
||||
LambdaQueryWrapper<TaskNodeMiddle> queryWrapper = new LambdaQueryWrapper<>();
|
||||
Assert.notNull(id, "id不可为空");
|
||||
queryWrapper.eq(TaskNodeMiddle::getId, id);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询任务结点中间表列表
|
||||
*
|
||||
* @param taskNodeMiddle 任务结点中间表
|
||||
* @return 任务结点中间表
|
||||
*/
|
||||
@Override
|
||||
public List<TaskNodeMiddle> selectTaskNodeMiddleList(TaskNodeMiddle taskNodeMiddle)
|
||||
{
|
||||
LambdaQueryWrapper<TaskNodeMiddle> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (StringUtils.isNotEmpty(taskNodeMiddle.getTaskCode())){
|
||||
queryWrapper.eq(TaskNodeMiddle::getTaskCode, taskNodeMiddle.getTaskCode());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(taskNodeMiddle.getNodeCode())){
|
||||
queryWrapper.eq(TaskNodeMiddle::getNodeCode, taskNodeMiddle.getNodeCode());
|
||||
}
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 唯一 判断
|
||||
* @param taskNodeMiddle 任务结点中间表
|
||||
* @return 任务结点中间表
|
||||
*/
|
||||
@Override
|
||||
public Boolean checkIdUnique(TaskNodeMiddle taskNodeMiddle) {
|
||||
LambdaQueryWrapper<TaskNodeMiddle> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(TaskNodeMiddle::getId, taskNodeMiddle.getId());
|
||||
return this.count(queryWrapper) > 0;
|
||||
}
|
||||
|
||||
}
|
|
@ -5,6 +5,8 @@ import java.util.List;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.quest.req.TaskReq;
|
||||
import com.muyu.quest.resp.TaskResp;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.muyu.quest.mapper.TaskMapper;
|
||||
import com.muyu.quest.domain.Task;
|
||||
|
@ -73,26 +75,29 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>
|
|||
/**
|
||||
* 查询任务列表
|
||||
*
|
||||
* @param task 任务
|
||||
* @param taskReq 任务
|
||||
* @return 任务
|
||||
*/
|
||||
@Override
|
||||
public List<Task> selectTaskList(Task task)
|
||||
public List<TaskResp> selectTaskList(TaskReq taskReq)
|
||||
{
|
||||
LambdaQueryWrapper<Task> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (StringUtils.isNotEmpty(task.getTaskName())){
|
||||
queryWrapper.like(Task::getTaskName, task.getTaskName());
|
||||
if (StringUtils.isNotEmpty(taskReq.getTaskName())){
|
||||
queryWrapper.like(Task::getTaskName, taskReq.getTaskName());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(task.getRuleCode())){
|
||||
queryWrapper.eq(Task::getRuleCode, task.getRuleCode());
|
||||
if (StringUtils.isNotEmpty(taskReq.getRuleCode())){
|
||||
queryWrapper.eq(Task::getRuleCode, taskReq.getRuleCode());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(task.getState())){
|
||||
queryWrapper.eq(Task::getState, task.getState());
|
||||
if (StringUtils.isNotEmpty(taskReq.getState())){
|
||||
queryWrapper.eq(Task::getState, taskReq.getState());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(task.getTaskType())){
|
||||
queryWrapper.eq(Task::getTaskType, task.getTaskType());
|
||||
if (StringUtils.isNotEmpty(taskReq.getTaskType())){
|
||||
queryWrapper.eq(Task::getTaskType, taskReq.getTaskType());
|
||||
}
|
||||
return this.list(queryWrapper);
|
||||
return this.list(queryWrapper)
|
||||
.stream()
|
||||
.map(TaskResp::build)
|
||||
.toList();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue