update - REQ-2516-添加自动生成对外部暴露的接口代码
This commit is contained in:
parent
0744014f64
commit
85b305ba5e
11
pom.xml
11
pom.xml
@ -64,6 +64,11 @@
|
||||
<artifactId>workflow-engine-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>workflow-auto-gen</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>workflow-engine-server</artifactId>
|
||||
@ -125,6 +130,11 @@
|
||||
<artifactId>mapstruct-processor</artifactId>
|
||||
<version>${mapstruct.version}</version>
|
||||
</path>
|
||||
<path>
|
||||
<groupId>cn.axzo.workflow</groupId>
|
||||
<artifactId>workflow-auto-gen</artifactId>
|
||||
<version>${revision}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
@ -139,6 +149,7 @@
|
||||
</repository>
|
||||
</repositories>
|
||||
<modules>
|
||||
<module>workflow-auto-gen</module>
|
||||
<module>workflow-engine-api</module>
|
||||
<module>workflow-engine-common</module>
|
||||
<module>workflow-engine-core</module>
|
||||
|
||||
29
workflow-auto-gen/pom.xml
Normal file
29
workflow-auto-gen/pom.xml
Normal file
@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>cn.axzo.workflow</groupId>
|
||||
<artifactId>workflow-engine</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>workflow-auto-gen</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Workflow Auto Gen</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.auto.service</groupId>
|
||||
<artifactId>auto-service</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup</groupId>
|
||||
<artifactId>javapoet</artifactId>
|
||||
<version>1.13.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@ -0,0 +1,16 @@
|
||||
package cn.axzo.workflow.generate;
|
||||
|
||||
import javax.annotation.processing.RoundEnvironment;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
|
||||
public abstract class BaseCodeGenProcessor implements CodeGenProcessor {
|
||||
|
||||
public static final String PREFIX = "Base";
|
||||
|
||||
@Override
|
||||
public GenCodeInfo generate(TypeElement typeElement, RoundEnvironment roundEnvironment)
|
||||
throws Exception {
|
||||
//添加其他逻辑扩展
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package cn.axzo.workflow.generate;
|
||||
|
||||
import javax.annotation.processing.RoundEnvironment;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
public interface CodeGenProcessor {
|
||||
/**
|
||||
* 需要解析的类上的注解
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Class<? extends Annotation> getAnnotation();
|
||||
|
||||
/**
|
||||
* 获取生成的包名
|
||||
*
|
||||
* @param typeElement
|
||||
* @return
|
||||
*/
|
||||
String generatePackage(TypeElement typeElement);
|
||||
|
||||
/**
|
||||
* 代码生成逻辑.
|
||||
*
|
||||
* @param typeElement
|
||||
* @param roundEnvironment
|
||||
* @throws Exception
|
||||
*/
|
||||
GenCodeInfo generate(TypeElement typeElement, RoundEnvironment roundEnvironment) throws Exception;
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
package cn.axzo.workflow.generate;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.Map;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.Set;
|
||||
|
||||
public class CodeGenProcessorRegistry {
|
||||
private static Map<String, ? extends CodeGenProcessor> PROCESSORS;
|
||||
|
||||
private CodeGenProcessorRegistry() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* 注解处理器要处理的注解集合
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Set<String> getSupportedAnnotations() {
|
||||
return PROCESSORS.keySet();
|
||||
}
|
||||
|
||||
public static CodeGenProcessor find(String annotationClassName) {
|
||||
return PROCESSORS.get(annotationClassName);
|
||||
}
|
||||
|
||||
/**
|
||||
* spi 加载所有的processor
|
||||
*
|
||||
*/
|
||||
public static void initProcessors() {
|
||||
final Map<String, CodeGenProcessor> map = Maps.newLinkedHashMap();
|
||||
ServiceLoader<CodeGenProcessor> processors = ServiceLoader.load(CodeGenProcessor.class, CodeGenProcessor.class.getClassLoader());
|
||||
for (CodeGenProcessor next : processors) {
|
||||
Class<? extends Annotation> annotation = next.getAnnotation();
|
||||
map.put(annotation.getName(), next);
|
||||
}
|
||||
PROCESSORS = map;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
package cn.axzo.workflow.generate;
|
||||
|
||||
import com.squareup.javapoet.TypeSpec;
|
||||
|
||||
public class GenCodeInfo {
|
||||
private final TypeSpec typeSpec;
|
||||
private final String sourcePath;
|
||||
private final String packageName;
|
||||
private final String className;
|
||||
|
||||
public static GenCodeInfoBuilder builder() {
|
||||
return new GenCodeInfoBuilder();
|
||||
}
|
||||
|
||||
public TypeSpec getTypeSpec() {
|
||||
return typeSpec;
|
||||
}
|
||||
|
||||
public String getSourcePath() {
|
||||
return sourcePath;
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
return packageName;
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
private GenCodeInfo(GenCodeInfoBuilder builder) {
|
||||
this.typeSpec = builder.typeSpec;
|
||||
this.sourcePath = builder.sourcePath;
|
||||
this.packageName = builder.packageName;
|
||||
this.className = builder.className;
|
||||
}
|
||||
|
||||
public static class GenCodeInfoBuilder {
|
||||
private TypeSpec typeSpec;
|
||||
private String sourcePath;
|
||||
private String packageName;
|
||||
private String className;
|
||||
|
||||
public GenCodeInfoBuilder typeSpec(TypeSpec typeSpec) {
|
||||
this.typeSpec = typeSpec;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GenCodeInfoBuilder sourcePath(String sourcePath) {
|
||||
this.sourcePath = sourcePath;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GenCodeInfoBuilder packageName(String packageName) {
|
||||
this.packageName = packageName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GenCodeInfoBuilder className(String className) {
|
||||
this.className = className;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GenCodeInfo build() {
|
||||
return new GenCodeInfo(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
package cn.axzo.workflow.generate;
|
||||
|
||||
import com.squareup.javapoet.JavaFile;
|
||||
import com.squareup.javapoet.MethodSpec;
|
||||
import com.squareup.javapoet.TypeSpec;
|
||||
|
||||
import javax.lang.model.element.Modifier;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
|
||||
public class GenJavaSourceFileUtils {
|
||||
|
||||
public static void genJavaSourceFile(String pathStr, String packageName, String className, List<MethodSpec> methodSpecs) {
|
||||
TypeSpec typeSpec = TypeSpec
|
||||
.interfaceBuilder(className)
|
||||
.addModifiers(Modifier.PUBLIC)
|
||||
.addMethods(methodSpecs)
|
||||
.build();
|
||||
JavaFile javaFile = JavaFile.builder(packageName, typeSpec)
|
||||
.addFileComment("--auto generated by workflow auto-gen plugin--")
|
||||
.build();
|
||||
String javaFileName = typeSpec.name + ".java";
|
||||
try {
|
||||
Path path = Paths.get(pathStr);
|
||||
File packageFolder = new File(path.toFile().getAbsolutePath());
|
||||
if (!packageFolder.exists()) {
|
||||
System.out.println("package not exists:" + path);
|
||||
return;
|
||||
}
|
||||
String javaFilePath = path.toFile().getAbsolutePath() + File.separator + javaFileName;
|
||||
System.out.println("name:" + javaFilePath);
|
||||
File sourceFile = new File(javaFilePath);
|
||||
if (!sourceFile.exists()) {
|
||||
javaFile.writeTo(packageFolder);
|
||||
} else {
|
||||
javaFile.writeTo(packageFolder);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,87 @@
|
||||
package cn.axzo.workflow.generate;
|
||||
|
||||
import cn.axzo.workflow.generate.annotition.GenService;
|
||||
import cn.axzo.workflow.generate.annotition.Management;
|
||||
import com.google.auto.service.AutoService;
|
||||
import com.squareup.javapoet.AnnotationSpec;
|
||||
import com.squareup.javapoet.MethodSpec;
|
||||
import com.squareup.javapoet.ParameterSpec;
|
||||
import com.squareup.javapoet.TypeName;
|
||||
import com.squareup.javapoet.TypeSpec;
|
||||
|
||||
import javax.annotation.processing.RoundEnvironment;
|
||||
import javax.lang.model.element.AnnotationMirror;
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.ExecutableElement;
|
||||
import javax.lang.model.element.Modifier;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.lang.model.element.VariableElement;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@AutoService(CodeGenProcessor.class)
|
||||
public class GenServiceProcessor extends BaseCodeGenProcessor {
|
||||
|
||||
@Override
|
||||
public Class<? extends Annotation> getAnnotation() {
|
||||
return GenService.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generatePackage(TypeElement typeElement) {
|
||||
return typeElement.getAnnotation(GenService.class).genPkgName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenCodeInfo generate(TypeElement typeElement, RoundEnvironment roundEnvironment) throws Exception {
|
||||
String genPkgName = typeElement.getAnnotation(GenService.class).genPkgName();
|
||||
String sourcePath = typeElement.getAnnotation(GenService.class).genSourcePath();
|
||||
String genClassName = typeElement.getAnnotation(GenService.class).genClassName();
|
||||
List<? extends Element> enclosedElements = typeElement.getEnclosedElements();
|
||||
TypeSpec.Builder targetTypeSpec = TypeSpec.interfaceBuilder(genClassName)
|
||||
.addModifiers(typeElement.getModifiers().toArray(new Modifier[]{}));
|
||||
for (Element enclosedElement : enclosedElements) {
|
||||
if (enclosedElement instanceof ExecutableElement) {
|
||||
ExecutableElement executableElement = (ExecutableElement) enclosedElement;
|
||||
List<? extends AnnotationMirror> annotationMirrors = executableElement.getAnnotationMirrors();
|
||||
boolean add = true;
|
||||
for (AnnotationMirror annotationMirror : annotationMirrors) {
|
||||
if (annotationMirror.getAnnotationType().toString().equals(Management.class.getName())) {
|
||||
add = false;
|
||||
}
|
||||
}
|
||||
if (add) {
|
||||
List<ParameterSpec> parameterSpecs = new ArrayList<>();
|
||||
for (VariableElement variableElement : executableElement.getParameters()) {
|
||||
parameterSpecs.add(ParameterSpec.get(variableElement));
|
||||
}
|
||||
List<AnnotationSpec> annotationSpecs = new ArrayList<>();
|
||||
for (AnnotationMirror annotationMirror : annotationMirrors) {
|
||||
annotationSpecs.add(AnnotationSpec.get(annotationMirror));
|
||||
}
|
||||
List<TypeName> exceptions = new ArrayList<>();
|
||||
List<? extends TypeMirror> thrownTypes = executableElement.getThrownTypes();
|
||||
for (TypeMirror typeMirror : thrownTypes) {
|
||||
exceptions.add(TypeName.get(typeMirror));
|
||||
}
|
||||
MethodSpec main = MethodSpec.methodBuilder(enclosedElement.getSimpleName().toString())
|
||||
.addModifiers(enclosedElement.getModifiers())
|
||||
.returns(TypeName.get(executableElement.getReturnType()))
|
||||
.addParameters(parameterSpecs)
|
||||
.addAnnotations(annotationSpecs)
|
||||
.addExceptions(exceptions)
|
||||
.build();
|
||||
targetTypeSpec.addMethod(main);
|
||||
}
|
||||
}
|
||||
}
|
||||
return GenCodeInfo.builder()
|
||||
.className(genClassName)
|
||||
.packageName(genPkgName)
|
||||
.sourcePath(sourcePath)
|
||||
.typeSpec(targetTypeSpec.build())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package cn.axzo.workflow.generate;
|
||||
|
||||
import javax.annotation.processing.ProcessingEnvironment;
|
||||
|
||||
public final class ProcessingEnvironmentHolder {
|
||||
|
||||
public static final ThreadLocal<ProcessingEnvironment> environment = new ThreadLocal<>();
|
||||
|
||||
|
||||
public static void setEnvironment(ProcessingEnvironment pe) {
|
||||
environment.set(pe);
|
||||
}
|
||||
|
||||
public static ProcessingEnvironment getEnvironment() {
|
||||
return environment.get();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,128 @@
|
||||
package cn.axzo.workflow.generate;
|
||||
|
||||
import com.google.auto.service.AutoService;
|
||||
import com.squareup.javapoet.MethodSpec;
|
||||
|
||||
import javax.annotation.processing.AbstractProcessor;
|
||||
import javax.annotation.processing.ProcessingEnvironment;
|
||||
import javax.annotation.processing.Processor;
|
||||
import javax.annotation.processing.RoundEnvironment;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
import javax.lang.model.util.ElementFilter;
|
||||
import javax.tools.Diagnostic;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
@AutoService(Processor.class)
|
||||
public class WorkflowExposeApiGenProcessor extends AbstractProcessor {
|
||||
|
||||
@Override
|
||||
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
||||
List<GenCodeInfo> genCodeInfos = new ArrayList<>();
|
||||
annotations.forEach(an -> {
|
||||
Set<? extends Element> typeElements = roundEnv.getElementsAnnotatedWith(an);
|
||||
Set<TypeElement> types = ElementFilter.typesIn(typeElements);
|
||||
for (TypeElement typeElement : types) {
|
||||
CodeGenProcessor codeGenProcessor = CodeGenProcessorRegistry.find(an.getQualifiedName().toString());
|
||||
try {
|
||||
GenCodeInfo generate = codeGenProcessor.generate(typeElement, roundEnv);
|
||||
genCodeInfos.add(generate);
|
||||
} catch (Exception e) {
|
||||
ProcessingEnvironmentHolder.getEnvironment().getMessager().printMessage(Diagnostic.Kind.ERROR, "代码生成异常:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
if (!genCodeInfos.isEmpty()) {
|
||||
Map<Triplet<String, String, String>, List<GenCodeInfo>> apiGenMap = new HashMap<>();
|
||||
//进行分组
|
||||
for (GenCodeInfo genCodeInfo : genCodeInfos) {
|
||||
Triplet<String, String, String> triplet = Triplet.of(genCodeInfo.getSourcePath(), genCodeInfo.getPackageName(), genCodeInfo.getClassName());
|
||||
List<GenCodeInfo> codeInfos = apiGenMap.computeIfAbsent(triplet, k -> new ArrayList<>());
|
||||
codeInfos.add(genCodeInfo);
|
||||
}
|
||||
for (Map.Entry<Triplet<String, String, String>, List<GenCodeInfo>> entry : apiGenMap.entrySet()) {
|
||||
Triplet<String, String, String> triplet = entry.getKey();
|
||||
List<MethodSpec> methodSpecs = new ArrayList<>();
|
||||
List<GenCodeInfo> infos = entry.getValue();
|
||||
for (GenCodeInfo genCodeInfo : infos) {
|
||||
methodSpecs.addAll(genCodeInfo.getTypeSpec().methodSpecs);
|
||||
}
|
||||
GenJavaSourceFileUtils.genJavaSourceFile(triplet.getFirst(), triplet.getSecond(), triplet.getThird(), methodSpecs);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void init(ProcessingEnvironment processingEnv) {
|
||||
super.init(processingEnv);
|
||||
ProcessingEnvironmentHolder.setEnvironment(processingEnv);
|
||||
CodeGenProcessorRegistry.initProcessors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getSupportedAnnotationTypes() {
|
||||
return CodeGenProcessorRegistry.getSupportedAnnotations();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SourceVersion getSupportedSourceVersion() {
|
||||
return SourceVersion.latestSupported();
|
||||
}
|
||||
|
||||
public static final class Triplet<T, U, V> {
|
||||
private final T first;
|
||||
private final U second;
|
||||
private final V third;
|
||||
|
||||
public Triplet(T first, U second, V third) {
|
||||
this.first = first;
|
||||
this.second = second;
|
||||
this.third = third;
|
||||
}
|
||||
|
||||
public T getFirst() {
|
||||
return first;
|
||||
}
|
||||
|
||||
public U getSecond() {
|
||||
return second;
|
||||
}
|
||||
|
||||
public V getThird() {
|
||||
return third;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Triplet{" +
|
||||
"first=" + first +
|
||||
", second=" + second +
|
||||
", third=" + third +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Triplet<?, ?, ?> triplet = (Triplet<?, ?, ?>) o;
|
||||
return Objects.equals(first, triplet.first) && Objects.equals(second, triplet.second) && Objects.equals(third, triplet.third);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(first, second, third);
|
||||
}
|
||||
|
||||
public static <T, U, V> Triplet<T, U, V> of(T first, U second, V third) {
|
||||
return new Triplet<>(first, second, third);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
package cn.axzo.workflow.generate.annotition;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface GenService {
|
||||
|
||||
String genPkgName();
|
||||
|
||||
String genSourcePath() default "workflow-engine-spring-boot-starter/src/main/java";
|
||||
|
||||
String genClassName() default "WorkflowCoreService";
|
||||
|
||||
boolean overrideSource() default false;
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
package cn.axzo.workflow.generate.annotition;
|
||||
|
||||
/**
|
||||
* 控制接口是否调用受限,标记了注解的方法,表示受控,不允许暴露给客户端使用
|
||||
*
|
||||
* @author wangli
|
||||
* @since 2024/5/22 10:43
|
||||
*/
|
||||
public @interface Management {
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
cn.axzo.workflow.generate.WorkflowExposeApiGenProcessor
|
||||
@ -23,6 +23,11 @@
|
||||
<artifactId>workflow-engine-common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.workflow</groupId>
|
||||
<artifactId>workflow-auto-gen</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.openfeign</groupId>
|
||||
<artifactId>feign-httpclient</artifactId>
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
package cn.axzo.workflow.client.annotation;
|
||||
|
||||
/**
|
||||
* 控制接口是否调用受限
|
||||
*
|
||||
* @author wangli
|
||||
* @since 2024/5/22 10:43
|
||||
*/
|
||||
public @interface Management {
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
package cn.axzo.workflow.client.feign.bpmn;
|
||||
|
||||
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnActivitySetAssigneeDTO;
|
||||
import cn.axzo.workflow.generate.annotition.Management;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -24,6 +25,7 @@ public interface ProcessActivityApi {
|
||||
* 业务节点唤醒
|
||||
*/
|
||||
@GetMapping("/api/process/activity/trigger")
|
||||
@Management
|
||||
CommonResponse<Boolean> trigger(@NotBlank(message = "触发 ID 不能为空") @RequestParam String triggerId, @RequestParam Boolean async);
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package cn.axzo.workflow.client.feign.bpmn;
|
||||
|
||||
import cn.axzo.workflow.client.annotation.Management;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.definition.BpmnProcessDefinitionUpdateDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.model.BpmnModelUpdateDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.process.BpmnProcessDefinitionPageDTO;
|
||||
@ -23,7 +22,6 @@ import javax.validation.constraints.NotNull;
|
||||
* @author wangli
|
||||
* @since 2023/9/21 16:25
|
||||
*/
|
||||
@Management
|
||||
@FeignClient(name = "workflow-engine", url = "${axzo.service.workflow-engine:http://workflow-engine:8080}")
|
||||
public interface ProcessDefinitionApi {
|
||||
|
||||
|
||||
@ -15,6 +15,7 @@ import cn.axzo.workflow.common.model.response.bpmn.process.BpmnProcessInstanceAd
|
||||
import cn.axzo.workflow.common.model.response.bpmn.process.BpmnProcessInstancePageItemVO;
|
||||
import cn.axzo.workflow.common.model.response.bpmn.process.BpmnProcessInstanceVO;
|
||||
import cn.axzo.workflow.common.model.response.bpmn.process.ProcessNodeDetailVO;
|
||||
import cn.axzo.workflow.generate.annotition.GenService;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@ -40,6 +41,7 @@ import java.util.Map;
|
||||
* @since 2023/9/21 16:26
|
||||
*/
|
||||
@FeignClient(name = "workflow-engine", url = "${axzo.service.workflow-engine:http://workflow-engine:8080}")
|
||||
@GenService(genPkgName = "cn.axzo.workflow.starter.api")
|
||||
public interface ProcessInstanceApi {
|
||||
/**
|
||||
* 查询所有的审批流
|
||||
|
||||
@ -1,12 +1,10 @@
|
||||
package cn.axzo.workflow.client.feign.bpmn;
|
||||
|
||||
import cn.axzo.workflow.client.annotation.Management;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@Management
|
||||
@FeignClient(name = "workflow-engine", url = "${axzo.service.workflow-engine:http://workflow-engine:8080}")
|
||||
public interface ProcessJobApi {
|
||||
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package cn.axzo.workflow.client.feign.bpmn;
|
||||
|
||||
import cn.axzo.workflow.client.annotation.Management;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.model.BpmnModelCreateDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.model.BpmnModelSearchDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.model.BpmnModelUpdateDTO;
|
||||
@ -28,7 +27,6 @@ import java.util.List;
|
||||
* @author wangli
|
||||
* @since 2023/9/21 15:47
|
||||
*/
|
||||
@Management
|
||||
@FeignClient(name = "workflow-engine", url = "${axzo.service.workflow-engine:http://workflow-engine:8080}")
|
||||
public interface ProcessModelApi {
|
||||
|
||||
|
||||
@ -16,6 +16,7 @@ import cn.axzo.workflow.common.model.response.bpmn.task.BpmnHistoricTaskInstance
|
||||
import cn.axzo.workflow.common.model.response.bpmn.task.BpmnTaskDonePageItemVO;
|
||||
import cn.axzo.workflow.common.model.response.bpmn.task.BpmnTaskInstanceVO;
|
||||
import cn.axzo.workflow.common.model.response.bpmn.task.BpmnTaskTodoPageItemVO;
|
||||
import cn.axzo.workflow.generate.annotition.GenService;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
@ -39,6 +40,7 @@ import java.util.Map;
|
||||
* @since 2023/9/21 16:26
|
||||
*/
|
||||
@FeignClient(name = "workflow-engine", url = "${axzo.service.workflow-engine:http://workflow-engine:8080}")
|
||||
@GenService(genPkgName = "cn.axzo.workflow.starter.api")
|
||||
public interface ProcessTaskApi {
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package cn.axzo.workflow.client.feign.bpmn;
|
||||
|
||||
import cn.axzo.workflow.client.annotation.Management;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.RestBpmnProcessVariable;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
@ -16,7 +15,6 @@ import javax.validation.constraints.NotBlank;
|
||||
/**
|
||||
* 流程变量api
|
||||
*/
|
||||
@Management
|
||||
@FeignClient(name = "workflow-engine", url = "${axzo.service.workflow-engine:http://workflow-engine:8080}")
|
||||
public interface ProcessVariableApi {
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package cn.axzo.workflow.client.feign.manage;
|
||||
|
||||
import cn.axzo.workflow.client.annotation.Management;
|
||||
import cn.axzo.workflow.generate.annotition.Management;
|
||||
import cn.axzo.workflow.common.model.request.category.CategoryConfigCreateDTO;
|
||||
import cn.axzo.workflow.common.model.request.category.CategoryConfigSearchDTO;
|
||||
import cn.axzo.workflow.common.model.request.category.CategoryCreateDTO;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package cn.axzo.workflow.client.feign.manage;
|
||||
|
||||
import cn.axzo.workflow.client.annotation.Management;
|
||||
import cn.axzo.workflow.generate.annotition.Management;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.BpmnButtonMetaInfo;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
|
||||
@ -19,10 +19,33 @@
|
||||
<groupId>cn.axzo.workflow</groupId>
|
||||
<artifactId>workflow-engine-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.workflow</groupId>
|
||||
<artifactId>workflow-auto-gen</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.axzo.framework.rocketmq</groupId>
|
||||
<artifactId>axzo-common-rocketmq</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.10.1</version>
|
||||
<configuration>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>cn.axzo.workflow</groupId>
|
||||
<artifactId>workflow-auto-gen</artifactId>
|
||||
<version>${revision}</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
@ -1,14 +1,203 @@
|
||||
// --auto generated by workflow auto-gen plugin--
|
||||
package cn.axzo.workflow.starter.api;
|
||||
|
||||
import cn.axzo.workflow.common.model.request.bpmn.process.BpmnProcessInstanceAbortDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.process.BpmnProcessInstanceAdminPageReqVO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.process.BpmnProcessInstanceCancelDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.process.BpmnProcessInstanceCarbonCopyDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.process.BpmnProcessInstanceCheckApproverDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.process.BpmnProcessInstanceCreateDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.process.BpmnProcessInstanceCreateWithFormDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.process.BpmnProcessInstanceMyPageReqVO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.process.BpmnProcessInstanceQueryDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnRobotTaskCompleteDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnRobotTaskCreateDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskAttachmentDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskAuditDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskCommentDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskCountersignDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskPageSearchDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskRemindDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskTransferDTO;
|
||||
import cn.axzo.workflow.common.model.response.BpmPageResult;
|
||||
import cn.axzo.workflow.common.model.response.bpmn.BatchOperationResultVO;
|
||||
import cn.axzo.workflow.common.model.response.bpmn.process.BpmnProcessInstanceAdminPageItemVO;
|
||||
import cn.axzo.workflow.common.model.response.bpmn.process.BpmnProcessInstancePageItemVO;
|
||||
import cn.axzo.workflow.common.model.response.bpmn.process.BpmnProcessInstanceVO;
|
||||
import cn.axzo.workflow.common.model.response.bpmn.process.ProcessNodeDetailVO;
|
||||
import cn.axzo.workflow.common.model.response.bpmn.task.BpmnHistoricTaskInstanceGroupVO;
|
||||
import cn.axzo.workflow.common.model.response.bpmn.task.BpmnHistoricTaskInstanceVO;
|
||||
import cn.axzo.workflow.common.model.response.bpmn.task.BpmnTaskDonePageItemVO;
|
||||
import cn.axzo.workflow.common.model.response.bpmn.task.BpmnTaskInstanceVO;
|
||||
import cn.axzo.workflow.common.model.response.bpmn.task.BpmnTaskTodoPageItemVO;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import java.lang.Boolean;
|
||||
import java.lang.Integer;
|
||||
import java.lang.Object;
|
||||
import java.lang.String;
|
||||
import java.lang.Void;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
|
||||
/**
|
||||
* 模拟生成的受限访问的接口定义
|
||||
*
|
||||
* @author wangli
|
||||
* @since 2024/5/28 16:12
|
||||
*/
|
||||
public interface WorkflowCoreService {
|
||||
@GetMapping("/api/process/task/page/todo")
|
||||
CommonResponse<BpmPageResult<BpmnTaskTodoPageItemVO>> getTodoTaskPage(BpmnTaskPageSearchDTO dto);
|
||||
|
||||
String createProcessInstance(BpmnProcessInstanceCreateDTO dto);
|
||||
@GetMapping("/api/process/task/page/done")
|
||||
CommonResponse<BpmPageResult<BpmnTaskDonePageItemVO>> getDoneTaskPage(BpmnTaskPageSearchDTO dto);
|
||||
|
||||
@GetMapping("/api/process/task/list/flat")
|
||||
CommonResponse<List<BpmnHistoricTaskInstanceVO>> getTaskListFlatByProcessInstanceId(
|
||||
String processInstanceId, String tenantId);
|
||||
|
||||
@GetMapping("/api/process/task/list/group")
|
||||
CommonResponse<List<BpmnHistoricTaskInstanceGroupVO>> getTaskListGroupByProcessInstanceId(
|
||||
String processInstanceId, String tenantId);
|
||||
|
||||
@GetMapping("/api/process/task/active/list")
|
||||
CommonResponse<List<BpmnTaskInstanceVO>> getActiveTasksByProcessInstanceId(
|
||||
String processInstanceId, String tenantId);
|
||||
|
||||
@PostMapping("/api/process/task/approve")
|
||||
CommonResponse<Boolean> approveTask(BpmnTaskAuditDTO dto);
|
||||
|
||||
@PostMapping("/api/process/task/batch/approve")
|
||||
CommonResponse<BatchOperationResultVO> batchApproveTask(List<BpmnTaskAuditDTO> dtos);
|
||||
|
||||
@PostMapping("/api/process/task/reject")
|
||||
CommonResponse<Boolean> rejectTask(BpmnTaskAuditDTO dto);
|
||||
|
||||
@PostMapping("/api/process/task/batch/reject")
|
||||
CommonResponse<BatchOperationResultVO> batchRejectTask(List<BpmnTaskAuditDTO> dtos);
|
||||
|
||||
@Operation(
|
||||
summary = "直接修改审批任务的审批人"
|
||||
)
|
||||
@PostMapping("/api/process/task/transfer")
|
||||
CommonResponse<Boolean> transferTask(BpmnTaskTransferDTO dto);
|
||||
|
||||
@Operation(
|
||||
summary = "批量修改审批任务的审批人"
|
||||
)
|
||||
@PostMapping("/api/process/task/batch/transfer")
|
||||
CommonResponse<BatchOperationResultVO> batchTransferTask(List<BpmnTaskTransferDTO> dtos);
|
||||
|
||||
@Operation(
|
||||
summary = "审批流程评论"
|
||||
)
|
||||
@PostMapping("/api/process/task/comment")
|
||||
CommonResponse<Boolean> commentTask(BpmnTaskCommentDTO dto);
|
||||
|
||||
@Operation(
|
||||
summary = "添加附件"
|
||||
)
|
||||
@PostMapping("/api/process/task/attachment")
|
||||
CommonResponse<Void> addAttachment(BpmnTaskAttachmentDTO dto);
|
||||
|
||||
@Operation(
|
||||
summary = "审批流程加签"
|
||||
)
|
||||
@PostMapping("/api/process/task/countersign")
|
||||
CommonResponse<Boolean> countersignTask(BpmnTaskCountersignDTO dto);
|
||||
|
||||
@Operation(
|
||||
summary = "审批流程催办"
|
||||
)
|
||||
@PostMapping("/api/process/task/remind")
|
||||
CommonResponse<Boolean> remindTask(BpmnTaskRemindDTO dto);
|
||||
|
||||
@Operation(
|
||||
summary = "创建机器人节点, 暂停流程任务"
|
||||
)
|
||||
@PostMapping("/api/process/task/robot/create")
|
||||
CommonResponse<String> createRobotTask(BpmnRobotTaskCreateDTO dto);
|
||||
|
||||
@Operation(
|
||||
summary = "完成机器人节点, 继续流程任务"
|
||||
)
|
||||
@PostMapping("/api/process/task/robot/complete")
|
||||
CommonResponse<Boolean> completeRobotTask(BpmnRobotTaskCompleteDTO dto);
|
||||
|
||||
@Operation(
|
||||
summary = "根据实例 ID 和自然人 ID 查询对应待处理的任务 ID"
|
||||
)
|
||||
@GetMapping("/api/process/task/find")
|
||||
CommonResponse<String> findTaskIdByInstanceIdAndPersonId(String processInstanceId,
|
||||
String personId);
|
||||
|
||||
@Operation(
|
||||
summary = "根据实例 ID列表 和自然人 ID 查询对应待处理的任务 ID"
|
||||
)
|
||||
@GetMapping("/api/process/task/batch/find")
|
||||
CommonResponse<Map<String, String>> findTaskIdByInstanceIdsAndPersonId(
|
||||
List<String> processInstanceIds, String personId);
|
||||
|
||||
@PostMapping("/api/process/instance/page/all")
|
||||
CommonResponse<BpmPageResult<BpmnProcessInstanceAdminPageItemVO>> getAllProcessInstancePage(
|
||||
BpmnProcessInstanceAdminPageReqVO dto);
|
||||
|
||||
@PostMapping("/api/process/instance/page/my")
|
||||
CommonResponse<BpmPageResult<BpmnProcessInstancePageItemVO>> getMyProcessInstancePage(
|
||||
BpmnProcessInstanceMyPageReqVO dto);
|
||||
|
||||
@PostMapping("/api/process/instance/create")
|
||||
CommonResponse<String> createProcessInstance(BpmnProcessInstanceCreateDTO dto);
|
||||
|
||||
@PostMapping("/api/process/instance/form/create")
|
||||
CommonResponse<String> createProcessInstanceWith(BpmnProcessInstanceCreateWithFormDTO dto);
|
||||
|
||||
@DeleteMapping("/api/process/instance/cancel")
|
||||
CommonResponse<Boolean> cancelProcessInstance(BpmnProcessInstanceCancelDTO dto);
|
||||
|
||||
@DeleteMapping("/api/process/instance/abort")
|
||||
CommonResponse<Boolean> abortProcessInstance(BpmnProcessInstanceAbortDTO dto);
|
||||
|
||||
@DeleteMapping("/api/process/instance/batch/abort")
|
||||
CommonResponse<BatchOperationResultVO> batchAbortProcessInstance(
|
||||
List<BpmnProcessInstanceAbortDTO> dtos);
|
||||
|
||||
@PostMapping("/api/process/instance/carbon-copy")
|
||||
CommonResponse<Boolean> carbonCopyProcessInstance(BpmnProcessInstanceCarbonCopyDTO dto);
|
||||
|
||||
@GetMapping("/api/process/instance/get")
|
||||
CommonResponse<BpmnProcessInstanceVO> getProcessInstanceVO(BpmnProcessInstanceQueryDTO dto);
|
||||
|
||||
@Operation(
|
||||
summary = "更新指定流程定义的版本的状态, 处于 suspended 状态的流程模型将不能再发起实例"
|
||||
)
|
||||
@PutMapping("/api/process/instance/status/update")
|
||||
CommonResponse<Boolean> updateProcessStatus(String processDefinitionId, Integer status);
|
||||
|
||||
@GetMapping("/api/process/instance/graphical")
|
||||
CommonResponse<ObjectNode> processInstanceGraphical(String processInstanceId, String tenantId);
|
||||
|
||||
@GetMapping("/api/process/instance/node/forecasting")
|
||||
CommonResponse<List<ProcessNodeDetailVO>> processInstanceNodeForecast(String processInstanceId,
|
||||
String tenantId);
|
||||
|
||||
@GetMapping("/api/process/instance/node/filter/forecasting")
|
||||
CommonResponse<List<ProcessNodeDetailVO>> processInstanceFilterNodeForecast(
|
||||
String processInstanceId, String tenantId, Boolean allNode, List<String> nodeDefinitionKeys);
|
||||
|
||||
@GetMapping("/api/process/instance/cooperation-org")
|
||||
CommonResponse<Map<String, Object>> getProcessVariables(String processInstanceId,
|
||||
String tenantId);
|
||||
|
||||
@Operation(
|
||||
summary = "查询实例的租户集合"
|
||||
)
|
||||
@GetMapping("/api/process/instance/tenant/ids")
|
||||
CommonResponse<List<String>> getTenantIds();
|
||||
|
||||
@Operation(
|
||||
summary = "校验指定流程实例下,是否存在指定的审批人"
|
||||
)
|
||||
@PostMapping("/api/process/instance/check/approver")
|
||||
CommonResponse<Boolean> checkInstanceApprover(BpmnProcessInstanceCheckApproverDTO dto);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user