feat: 2.6.0
1. 定义工作流模型
This commit is contained in:
parent
4a642ec296
commit
a70f941ad3
@ -446,7 +446,10 @@ CREATE TABLE `workflow`
|
||||
`namespace_id` varchar(64) NOT NULL DEFAULT '764d604ec6fc45f68cd92514c40e9e1a' COMMENT '命名空间id',
|
||||
`group_name` varchar(64) NOT NULL COMMENT '组名称',
|
||||
`workflow_status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '工作流状态 0、关闭、1、开启',
|
||||
`trigger_type` tinyint(4) NOT NULL COMMENT '触发类型 1.CRON 表达式 2. 固定时间',
|
||||
`trigger_interval` varchar(255) NOT NULL COMMENT '间隔时长',
|
||||
`execution_at` bigint(13) NOT NULL DEFAULT '0' COMMENT '任务执行时间',
|
||||
`executor_timeout` int(11) NOT NULL DEFAULT '0' COMMENT '任务执行超时时间,单位秒',
|
||||
`flow_info` JSON NOT NULL COMMENT '流程信息',
|
||||
`create_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_dt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
|
||||
|
@ -0,0 +1,19 @@
|
||||
package com.aizuda.easy.retry.template.datasource.persistence.mapper;
|
||||
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.po.Workflow;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 工作流 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xiaowoniu
|
||||
* @since 2023-12-12
|
||||
* @since : 2.6.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface WorkflowMapper extends BaseMapper<Workflow> {
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.aizuda.easy.retry.template.datasource.persistence.mapper;
|
||||
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.po.WorkflowNode;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 工作流节点 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xiaowoniu
|
||||
* @since 2023-12-12
|
||||
*/
|
||||
@Mapper
|
||||
public interface WorkflowNodeMapper extends BaseMapper<WorkflowNode> {
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.aizuda.easy.retry.template.datasource.persistence.mapper;
|
||||
|
||||
import com.aizuda.easy.retry.template.datasource.persistence.po.WorkflowTaskBatch;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 工作流批次 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xiaowoniu
|
||||
* @since 2023-12-12
|
||||
*/
|
||||
@Mapper
|
||||
public interface WorkflowTaskBatchMapper extends BaseMapper<WorkflowTaskBatch> {
|
||||
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package com.aizuda.easy.retry.template.datasource.persistence.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 工作流
|
||||
* </p>
|
||||
*
|
||||
* @author : xiaowoniu
|
||||
* @date : 2023-12-12
|
||||
* @since : 2.6.0
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("workflow")
|
||||
public class Workflow implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 命名空间id
|
||||
*/
|
||||
private String namespaceId;
|
||||
|
||||
/**
|
||||
* 组名称
|
||||
*/
|
||||
private String groupName;
|
||||
|
||||
/**
|
||||
* 工作流状态 0、关闭、1、开启
|
||||
*/
|
||||
private Byte workflowStatus;
|
||||
|
||||
/**
|
||||
* 任务执行时间
|
||||
*/
|
||||
private Long executionAt;
|
||||
|
||||
/**
|
||||
* 流程信息
|
||||
*/
|
||||
private String flowInfo;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createDt;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateDt;
|
||||
|
||||
/**
|
||||
* 逻辑删除 1、删除
|
||||
*/
|
||||
private Byte deleted;
|
||||
|
||||
/**
|
||||
* 扩展字段
|
||||
*/
|
||||
private String extAttrs;
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
package com.aizuda.easy.retry.template.datasource.persistence.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 工作流节点
|
||||
* </p>
|
||||
*
|
||||
* @author xiaowoniu
|
||||
* @since 2023-12-12
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("workflow_node")
|
||||
public class WorkflowNode implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 命名空间id
|
||||
*/
|
||||
private String namespaceId;
|
||||
|
||||
/**
|
||||
* 组名称
|
||||
*/
|
||||
private String groupName;
|
||||
|
||||
/**
|
||||
* 任务信息id
|
||||
*/
|
||||
private Long jobId;
|
||||
|
||||
/**
|
||||
* 1、任务节点 2、条件节点
|
||||
*/
|
||||
private Byte nodeType;
|
||||
|
||||
/**
|
||||
* 1、SpEl、2、Aviator 3、QL
|
||||
*/
|
||||
private Byte expressionType;
|
||||
|
||||
/**
|
||||
* 失败策略 1、跳过 2、阻塞
|
||||
*/
|
||||
private Byte failStrategy;
|
||||
|
||||
/**
|
||||
* 工作流节点状态 0、关闭、1、开启
|
||||
*/
|
||||
private Byte workflowNodeStatus;
|
||||
|
||||
/**
|
||||
* 节点表达式
|
||||
*/
|
||||
private String nodeExpression;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createDt;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateDt;
|
||||
|
||||
/**
|
||||
* 逻辑删除 1、删除
|
||||
*/
|
||||
private Byte deleted;
|
||||
|
||||
/**
|
||||
* 扩展字段
|
||||
*/
|
||||
private String extAttrs;
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package com.aizuda.easy.retry.template.datasource.persistence.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 工作流批次
|
||||
* </p>
|
||||
*
|
||||
* @author xiaowoniu
|
||||
* @since 2023-12-12
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("workflow_task_batch")
|
||||
public class WorkflowTaskBatch implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 命名空间id
|
||||
*/
|
||||
private String namespaceId;
|
||||
|
||||
/**
|
||||
* 组名称
|
||||
*/
|
||||
private String groupName;
|
||||
|
||||
/**
|
||||
* 工作流任务id
|
||||
*/
|
||||
private Long workflowId;
|
||||
|
||||
/**
|
||||
* 任务批次状态 0、失败 1、成功
|
||||
*/
|
||||
private Byte taskBatchStatus;
|
||||
|
||||
/**
|
||||
* 操作原因
|
||||
*/
|
||||
private Byte operationReason;
|
||||
|
||||
/**
|
||||
* 任务执行时间
|
||||
*/
|
||||
private Long executionAt;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createDt;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateDt;
|
||||
|
||||
/**
|
||||
* 逻辑删除 1、删除
|
||||
*/
|
||||
private Byte deleted;
|
||||
|
||||
/**
|
||||
* 扩展字段
|
||||
*/
|
||||
private String extAttrs;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.aizuda.easy.retry.template.datasource.persistence.mapper.WorkflowMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.aizuda.easy.retry.template.datasource.persistence.po.Workflow">
|
||||
<id column="id" property="id" />
|
||||
<result column="namespace_id" property="namespaceId" />
|
||||
<result column="group_name" property="groupName" />
|
||||
<result column="workflow_status" property="workflowStatus" />
|
||||
<result column="execution_at" property="executionAt" />
|
||||
<result column="flow_info" property="flowInfo" />
|
||||
<result column="create_dt" property="createDt" />
|
||||
<result column="update_dt" property="updateDt" />
|
||||
<result column="deleted" property="deleted" />
|
||||
<result column="ext_attrs" property="extAttrs" />
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.aizuda.easy.retry.template.datasource.persistence.mapper.WorkflowNodeMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.aizuda.easy.retry.template.datasource.persistence.po.WorkflowNode">
|
||||
<id column="id" property="id" />
|
||||
<result column="namespace_id" property="namespaceId" />
|
||||
<result column="group_name" property="groupName" />
|
||||
<result column="job_id" property="jobId" />
|
||||
<result column="node_type" property="nodeType" />
|
||||
<result column="expression_type" property="expressionType" />
|
||||
<result column="fail_strategy" property="failStrategy" />
|
||||
<result column="workflow_node_status" property="workflowNodeStatus" />
|
||||
<result column="node_expression" property="nodeExpression" />
|
||||
<result column="create_dt" property="createDt" />
|
||||
<result column="update_dt" property="updateDt" />
|
||||
<result column="deleted" property="deleted" />
|
||||
<result column="ext_attrs" property="extAttrs" />
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.aizuda.easy.retry.template.datasource.persistence.mapper.WorkflowTaskBatchMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="com.aizuda.easy.retry.template.datasource.persistence.po.WorkflowTaskBatch">
|
||||
<id column="id" property="id" />
|
||||
<result column="namespace_id" property="namespaceId" />
|
||||
<result column="group_name" property="groupName" />
|
||||
<result column="workflow_id" property="workflowId" />
|
||||
<result column="task_batch_status" property="taskBatchStatus" />
|
||||
<result column="operation_reason" property="operationReason" />
|
||||
<result column="execution_at" property="executionAt" />
|
||||
<result column="create_dt" property="createDt" />
|
||||
<result column="update_dt" property="updateDt" />
|
||||
<result column="deleted" property="deleted" />
|
||||
<result column="ext_attrs" property="extAttrs" />
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,56 @@
|
||||
package com.aizuda.easy.retry.server.web.controller;
|
||||
|
||||
import com.aizuda.easy.retry.server.web.model.request.WorkflowRequestVO;
|
||||
import com.aizuda.easy.retry.server.web.service.WorkflowService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @author xiaowoniu
|
||||
* @date 2023-12-12 21:50:46
|
||||
* @since 2.6.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/workflow")
|
||||
@RequiredArgsConstructor
|
||||
public class WorkflowController {
|
||||
|
||||
private final WorkflowService workflowService;
|
||||
|
||||
@Autowired
|
||||
@PostMapping
|
||||
public Boolean saveWorkflow(@RequestBody WorkflowRequestVO workflowRequestVO) {
|
||||
return workflowService.saveWorkflow(workflowRequestVO);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public void updateWorkflow() {
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/start")
|
||||
public void startWorkflow() {
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/stop")
|
||||
public void stopWorkflow() {
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/pause")
|
||||
public void pauseWorkflow() {
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/resume")
|
||||
public void resumeWorkflow() {
|
||||
|
||||
}
|
||||
|
||||
public void getWorkflowDetail() {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package com.aizuda.easy.retry.server.web.model.request;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xiaowoniu
|
||||
* @date 2023-12-12 21:53:17
|
||||
* @since 2.6.0
|
||||
*/
|
||||
@Data
|
||||
public class WorkflowRequestVO {
|
||||
|
||||
@NotBlank(message = "组名称不能为空")
|
||||
@Pattern(regexp = "^[A-Za-z0-9_]{1,64}$", message = "仅支持长度为1~64字符且类型为数字、字母和下划线")
|
||||
private String groupName;
|
||||
|
||||
@NotBlank(message = "触发类型不能为空")
|
||||
private Integer triggerType;
|
||||
|
||||
@NotBlank(message = "触发间隔不能为空")
|
||||
private String triggerInterval;
|
||||
|
||||
@NotNull(message = "执行超时时间不能为空")
|
||||
private Integer executorTimeout;
|
||||
|
||||
@NotEmpty(message = "执行超时时间不能为空")
|
||||
@Valid
|
||||
private List<NodeInfo> nodeInfos;
|
||||
|
||||
@Data
|
||||
public static class NodeInfo {
|
||||
|
||||
/**
|
||||
* 条件节点表达式
|
||||
*/
|
||||
private String nodeExpression;
|
||||
|
||||
@NotNull(message = "节点类型不能为空")
|
||||
private Integer nodeType;
|
||||
|
||||
@NotNull(message = "任务ID不能为空")
|
||||
private Long jobId;
|
||||
|
||||
@NotNull(message = "表达式类型不能为空")
|
||||
private Integer expressionType;
|
||||
|
||||
@NotNull(message = "失败策略不能为空")
|
||||
private Integer failStrategy;
|
||||
|
||||
/**
|
||||
* 子节点
|
||||
*/
|
||||
private List<NodeInfo> childrenList;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.aizuda.easy.retry.server.web.service;
|
||||
|
||||
import com.aizuda.easy.retry.server.web.model.request.WorkflowRequestVO;
|
||||
|
||||
/**
|
||||
* @author xiaowoniu
|
||||
* @date 2023-12-12 21:53:59
|
||||
* @since 2.6.0
|
||||
*/
|
||||
public interface WorkflowService {
|
||||
|
||||
boolean saveWorkflow(WorkflowRequestVO workflowRequestVO);
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.aizuda.easy.retry.server.web.service.impl;
|
||||
|
||||
import com.aizuda.easy.retry.server.web.model.request.WorkflowRequestVO;
|
||||
import com.aizuda.easy.retry.server.web.service.WorkflowService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author xiaowoniu
|
||||
* @date 2023-12-12 21:54:05
|
||||
* @since 2.6.0
|
||||
*/
|
||||
@Service
|
||||
public class WorkflowServiceImpl implements WorkflowService {
|
||||
|
||||
@Override
|
||||
public boolean saveWorkflow(WorkflowRequestVO workflowRequestVO) {
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user