可正常启动,工作流可以正常运行,增加了其他节点,但是还没运行过,编译无错。
This commit is contained in:
parent
ed0309f45c
commit
7991bde3ae
@ -3,6 +3,7 @@ package com.qqchen.deploy.backend.workflow.entity;
|
|||||||
import com.qqchen.deploy.backend.framework.annotation.LogicDelete;
|
import com.qqchen.deploy.backend.framework.annotation.LogicDelete;
|
||||||
import com.qqchen.deploy.backend.framework.domain.Entity;
|
import com.qqchen.deploy.backend.framework.domain.Entity;
|
||||||
import com.qqchen.deploy.backend.workflow.enums.VariableScopeEnum;
|
import com.qqchen.deploy.backend.workflow.enums.VariableScopeEnum;
|
||||||
|
import com.qqchen.deploy.backend.workflow.enums.VariableTypeEnum;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
@ -39,8 +40,9 @@ public class WorkflowVariable extends Entity<Long> {
|
|||||||
/**
|
/**
|
||||||
* 变量类型
|
* 变量类型
|
||||||
*/
|
*/
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private String type;
|
private VariableTypeEnum type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 变量作用域
|
* 变量作用域
|
||||||
|
|||||||
@ -0,0 +1,22 @@
|
|||||||
|
package com.qqchen.deploy.backend.workflow.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 变量类型枚举
|
||||||
|
*/
|
||||||
|
public enum VariableTypeEnum {
|
||||||
|
STRING("字符串"),
|
||||||
|
NUMBER("数字"),
|
||||||
|
BOOLEAN("布尔值"),
|
||||||
|
OBJECT("对象"),
|
||||||
|
ARRAY("数组");
|
||||||
|
|
||||||
|
private final String description;
|
||||||
|
|
||||||
|
VariableTypeEnum(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -9,6 +9,7 @@ import com.qqchen.deploy.backend.workflow.dto.WorkflowVariableDTO;
|
|||||||
import com.qqchen.deploy.backend.workflow.entity.WorkflowInstance;
|
import com.qqchen.deploy.backend.workflow.entity.WorkflowInstance;
|
||||||
import com.qqchen.deploy.backend.workflow.entity.WorkflowVariable;
|
import com.qqchen.deploy.backend.workflow.entity.WorkflowVariable;
|
||||||
import com.qqchen.deploy.backend.workflow.enums.VariableScopeEnum;
|
import com.qqchen.deploy.backend.workflow.enums.VariableScopeEnum;
|
||||||
|
import com.qqchen.deploy.backend.workflow.enums.VariableTypeEnum;
|
||||||
import com.qqchen.deploy.backend.workflow.repository.IWorkflowVariableRepository;
|
import com.qqchen.deploy.backend.workflow.repository.IWorkflowVariableRepository;
|
||||||
import com.qqchen.deploy.backend.workflow.service.IWorkflowVariableService;
|
import com.qqchen.deploy.backend.workflow.service.IWorkflowVariableService;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
@ -47,6 +48,24 @@ public class WorkflowVariableServiceImpl extends BaseServiceImpl<WorkflowVariabl
|
|||||||
variable.setWorkflowInstance(instance);
|
variable.setWorkflowInstance(instance);
|
||||||
variable.setName(key);
|
variable.setName(key);
|
||||||
variable.setValue(objectMapper.writeValueAsString(value));
|
variable.setValue(objectMapper.writeValueAsString(value));
|
||||||
|
|
||||||
|
// 推断变量类型
|
||||||
|
if (value == null) {
|
||||||
|
variable.setType(VariableTypeEnum.STRING); // 默认为字符串类型
|
||||||
|
} else if (value instanceof String) {
|
||||||
|
variable.setType(VariableTypeEnum.STRING);
|
||||||
|
} else if (value instanceof Number) {
|
||||||
|
variable.setType(VariableTypeEnum.NUMBER);
|
||||||
|
} else if (value instanceof Boolean) {
|
||||||
|
variable.setType(VariableTypeEnum.BOOLEAN);
|
||||||
|
} else if (value instanceof Map || value.getClass().isRecord()) {
|
||||||
|
variable.setType(VariableTypeEnum.OBJECT);
|
||||||
|
} else if (value instanceof Iterable || value.getClass().isArray()) {
|
||||||
|
variable.setType(VariableTypeEnum.ARRAY);
|
||||||
|
} else {
|
||||||
|
variable.setType(VariableTypeEnum.OBJECT);
|
||||||
|
}
|
||||||
|
|
||||||
variableRepository.save(variable);
|
variableRepository.save(variable);
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
throw new BusinessException(ResponseCode.WORKFLOW_VARIABLE_SERIALIZE_ERROR);
|
throw new BusinessException(ResponseCode.WORKFLOW_VARIABLE_SERIALIZE_ERROR);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user