update - 细化表单的 model 和 definition 两大类接口,并调整部分类型的目录

This commit is contained in:
wangli 2023-07-25 14:38:50 +08:00
parent 80a67df134
commit 7b7a36c34d
21 changed files with 509 additions and 167 deletions

View File

@ -21,5 +21,7 @@ public interface BpmConstants {
String START_EVENT_ID = "startEventNode";
String END_EVENT_ID = "endEventNode";
String BPM_MODEL_CATEGORY = "bpm_model_category";
String MODEL_META_INFO_PROCESS = "MODEL_PROCESS";
String MODEL_META_INFO_FORM = "MODEL_FORM";
String BPM_ALLOW_SKIP_USER_TASK = "_INTERNAL_SKIP_USER_TASK";
}

View File

@ -1,14 +1,9 @@
package cn.axzo.workflow.core.service;
import cn.axzo.workflow.core.service.dto.request.form.FormModelCreateDTO;
import cn.axzo.workflow.core.service.dto.request.form.FormModelSearchDTO;
import cn.axzo.workflow.core.service.dto.request.form.FormModelUpdateDTO;
import cn.axzo.workflow.core.service.dto.response.BpmPageResult;
import org.flowable.form.api.FormDeployment;
import org.flowable.form.api.FormInfo;
import cn.axzo.workflow.core.service.dto.request.form.definition.FormDefinitionUpdateDTO;
import cn.axzo.workflow.core.service.dto.response.form.definition.FormDefinitionVO;
import javax.annotation.Nullable;
import java.util.List;
/**
* 表单定义相关服务接口
@ -17,19 +12,13 @@ import java.util.List;
* @since 2023/7/19 16:46
*/
public interface BpmFormDefinitionService {
String createFormModel(FormModelCreateDTO dto);
void updateFormModel(FormModelUpdateDTO dto);
FormDefinitionVO get(String formModeId, @Nullable String tenantId);
void deleteFormModel(String formModelId, String tenantId);
void updateFormDefinition(FormDefinitionUpdateDTO dto);
String deployFormModelById(String formModelId, @Nullable String tenantId);
String deployFormModelByKey(String formModelKey, @Nullable String tenantId);
BpmPageResult<FormDeployment> listFormModel(FormModelSearchDTO dto);
List<FormInfo> get(String deploymentId, String tenantId);
}

View File

@ -1,10 +1,28 @@
package cn.axzo.workflow.core.service;
import cn.axzo.workflow.core.service.dto.request.form.model.FormModelCreateDTO;
import cn.axzo.workflow.core.service.dto.request.form.model.FormModelUpdateDTO;
import cn.axzo.workflow.core.service.dto.request.model.BpmModelBpmPageDTO;
import cn.axzo.workflow.core.service.dto.response.BpmPageResult;
import cn.axzo.workflow.core.service.dto.response.form.model.FormModelVO;
import javax.annotation.Nullable;
/**
* TODO
*
* @author wangli
* @sine 2023/7/24 23:47
* @since 2023/7/24 23:47
*/
public interface BpmFormModelService {
String createFormModel(FormModelCreateDTO dto);
void updateFormModel(FormModelUpdateDTO dto);
void deleteFormModel(String formModelId, @Nullable String tenantId);
BpmPageResult<FormModelVO> getModelPage(BpmModelBpmPageDTO dto);
FormModelVO get(String formModelId, @Nullable String tenantId);
}

View File

@ -4,7 +4,7 @@ import java.util.List;
public interface EntityConverter<V, E>{
V toVo(E var);
V toVo(E entity);
List<V> toVo(List<E> var);
List<V> toVos(List<E> entities);
}

View File

@ -0,0 +1,48 @@
package cn.axzo.workflow.core.service.converter;
import cn.axzo.workflow.core.service.dto.response.form.model.FormModelVO;
import org.flowable.engine.repository.Model;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static org.mapstruct.NullValueCheckStrategy.ALWAYS;
/**
* TODO
*
* @author wangli
* @since 2023/7/25 13:33
*/
@Mapper(
componentModel = "spring",
nullValueCheckStrategy = ALWAYS,
imports = Arrays.class
)
public interface FormModelConverter extends EntityConverter<FormModelVO, Model> {
@Mapping(target = "id", source = "entity.id")
@Mapping(target = "name", source = "entity.name")
@Mapping(target = "key", source = "entity.key")
@Mapping(target = "category", source = "entity.category")
@Mapping(target = "tenantId", source = "entity.tenantId")
@Mapping(target = "version", source = "entity.version")
@Mapping(target = "createAt", source = "entity.createTime")
@Mapping(target = "updateAt", source = "entity.lastUpdateTime")
FormModelVO toVo(Model entity);
@Override
default List<FormModelVO> toVos(List<Model> entities) {
if (CollectionUtils.isEmpty(entities)) {
return Collections.emptyList();
}
List<FormModelVO> result = new ArrayList<>();
entities.forEach(i -> result.add(toVo(i)));
return result;
}
}

View File

@ -1,5 +1,6 @@
package cn.axzo.workflow.core.service.dto.request.form;
import cn.axzo.workflow.core.service.dto.request.form.model.FormFieldsDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

View File

@ -0,0 +1,25 @@
package cn.axzo.workflow.core.service.dto.request.form.definition;
import cn.axzo.workflow.core.service.dto.request.form.FormDefinitionDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* TODO
*
* @author wangli
* @since 2023/7/25 14:21
*/
@Data
public class FormDefinitionUpdateDTO {
@ApiModelProperty("表单模型ID")
@NotBlank(message = "表单模型 ID 不能为空")
public String formModelId;
@ApiModelProperty(value = "表单定义内容")
private FormDefinitionDTO formDefinition;
}

View File

@ -1,4 +1,4 @@
package cn.axzo.workflow.core.service.dto.request.form;
package cn.axzo.workflow.core.service.dto.request.form.model;
/**
* 表单中的字段相关属性模型
@ -18,7 +18,7 @@ public class FormFieldsDTO {
@ApiModelProperty(value = "表单字段类型", hidden = true)
@NotBlank(message = "字段类型不能为空")
private String fieldType = "FormField";
private transient String fieldType = "FormField";
private String type;

View File

@ -1,4 +1,4 @@
package cn.axzo.workflow.core.service.dto.request.form;
package cn.axzo.workflow.core.service.dto.request.form.model;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package cn.axzo.workflow.core.service.dto.request.form;
package cn.axzo.workflow.core.service.dto.request.form.model;
import cn.axzo.workflow.core.service.dto.request.BpmPageParam;
import io.swagger.annotations.ApiModelProperty;

View File

@ -1,4 +1,4 @@
package cn.axzo.workflow.core.service.dto.request.form;
package cn.axzo.workflow.core.service.dto.request.form.model;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -18,6 +18,6 @@ public class FormModelUpdateDTO extends FormModelCreateDTO {
@NotBlank(message = "表单 ID 不能为空")
public String formModelId;
@ApiModelProperty(value = "表单定义内容", hidden = true)
private FormDefinitionDTO formDefinition;
// @ApiModelProperty(value = "表单定义内容", hidden = true)
// private FormDefinitionDTO formDefinition;
}

View File

@ -2,7 +2,9 @@ package cn.axzo.workflow.core.service.dto.request.model;
import cn.axzo.workflow.core.service.dto.request.BpmPageParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class BpmModelBpmPageDTO extends BpmPageParam {
/**

View File

@ -35,13 +35,12 @@ public class BpmModelCreateDTO {
/**
* MetaInfo 自定义数据可以放icon等任何
* */
@ApiModelProperty(value = "MetaInfo 自定义数据可以放icon等任何", example = "1")
private Object metaInfo;
// @ApiModelProperty(value = "MetaInfo 自定义数据可以放icon等任何", example = "1")
// private Object metaInfo;
/**
* 流程的Json 结构
*
* */
*/
@ApiModelProperty(value = "流程的Json 结构", example = "1")
private BpmJsonNode node;

View File

@ -0,0 +1,26 @@
package cn.axzo.workflow.core.service.dto.response.form.definition;
import cn.axzo.workflow.core.service.dto.request.form.model.FormFieldsDTO;
import lombok.Data;
import java.util.List;
/**
* TODO
*
* @author wangli
* @since 2023/7/25 14:00
*/
@Data
public class FormDefinitionVO {
private String name;
private String key;
private Integer version;
private String description;
private List<FormFieldsDTO> fields;
}

View File

@ -0,0 +1,32 @@
package cn.axzo.workflow.core.service.dto.response.form.model;
import lombok.Data;
import java.util.Date;
/**
* TODO
*
* @author wangli
* @since 2023/7/25 11:04
*/
@Data
public class FormModelVO {
private String id;
private String name;
private String key;
private String category;
private String tenantId;
private Integer version;
private Date createAt;
private Date updateAt;
}

View File

@ -3,11 +3,8 @@ package cn.axzo.workflow.core.service.impl;
import cn.axzo.workflow.core.common.exception.WorkflowEngineException;
import cn.axzo.workflow.core.service.BpmFormDefinitionService;
import cn.axzo.workflow.core.service.dto.request.form.FormDefinitionDTO;
import cn.axzo.workflow.core.service.dto.request.form.FormModelCreateDTO;
import cn.axzo.workflow.core.service.dto.request.form.FormModelSearchDTO;
import cn.axzo.workflow.core.service.dto.request.form.FormModelUpdateDTO;
import cn.axzo.workflow.core.service.dto.response.BpmPageResult;
import cn.hutool.core.collection.CollUtil;
import cn.axzo.workflow.core.service.dto.request.form.definition.FormDefinitionUpdateDTO;
import cn.axzo.workflow.core.service.dto.response.form.definition.FormDefinitionVO;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -15,15 +12,17 @@ import org.flowable.engine.RepositoryService;
import org.flowable.engine.TaskService;
import org.flowable.engine.repository.Model;
import org.flowable.engine.repository.ModelQuery;
import org.flowable.form.api.*;
import org.flowable.form.model.SimpleFormModel;
import org.flowable.form.api.FormDeployment;
import org.flowable.form.api.FormRepositoryService;
import org.flowable.form.api.FormService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.annotation.Nullable;
import javax.annotation.Resource;
import java.util.*;
import java.util.Arrays;
import java.util.Objects;
/**
* 表单定义 Service 实现
@ -48,48 +47,36 @@ public class BpmFormDefinitionServiceImpl implements BpmFormDefinitionService {
private TaskService taskService;
@Override
public String createFormModel(FormModelCreateDTO dto) {
Model persistModel = repositoryService.createModelQuery()
.modelKey(dto.getKey())
.modelTenantId(dto.getTenantId())
.singleResult();
if (Objects.nonNull(persistModel)) {
throw new WorkflowEngineException("存在指定 key 的表单模型");
public FormDefinitionVO get(String formModeId, @Nullable String tenantId) {
Model model = repositoryService.getModel(formModeId);
if (Objects.isNull(model)) {
throw new WorkflowEngineException("模型不存在");
}
Model model = repositoryService.newModel();
model.setKey(dto.getKey());
model.setCategory(dto.getCategory());
model.setName(dto.getName());
model.setTenantId(dto.getTenantId());
repositoryService.saveModel(model);
if (StringUtils.hasLength(tenantId) && !Objects.equals(model.getTenantId(), tenantId)) {
throw new WorkflowEngineException("模型不存在");
}
FormDefinitionVO formDefinitionVO = null;
try {
repositoryService.addModelEditorSource(model.getId(),
objectMapper.writeValueAsString(new SimpleFormModel()).getBytes());
formDefinitionVO = objectMapper.readValue(repositoryService.getModelEditorSource(model.getId()),
FormDefinitionVO.class);
} catch (Exception e) {
e.printStackTrace();
throw new WorkflowEngineException(e.getMessage());
throw new WorkflowEngineException("解析转换异常");
}
return model.getId();
return formDefinitionVO;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateFormModel(FormModelUpdateDTO dto) {
Model model = repositoryService.createModelQuery()
.modelId(dto.getFormModelId())
.modelTenantId(dto.getTenantId())
.singleResult();
if (Objects.isNull(model)) {
throw new WorkflowEngineException("表单模型不存在");
}
@Override
public void updateFormDefinition(FormDefinitionUpdateDTO dto) {
Model model = repositoryService.getModel(dto.getFormModelId());
if (Objects.isNull(model)) {
throw new WorkflowEngineException("模型不存在");
}
FormDefinitionDTO formDefinition = dto.getFormDefinition();
formDefinition.setKey(model.getKey());
formDefinition.setName(dto.getName());
model.setName(dto.getName());
model.setCategory(dto.getCategory());
formDefinition.setName(model.getName());
try {
repositoryService.addModelEditorSource(model.getId(),
@ -97,16 +84,6 @@ public class BpmFormDefinitionServiceImpl implements BpmFormDefinitionService {
} catch (Exception e) {
throw new WorkflowEngineException(e.getMessage());
}
repositoryService.saveModel(model);
}
@Override
public void deleteFormModel(String formModelId, String tenantId) {
Model model = repositoryService.getModel(formModelId);
if (Objects.isNull(model) || !Objects.equals(model.getTenantId(), tenantId)) {
throw new WorkflowEngineException("模型不存在");
}
repositoryService.deleteModel(formModelId);
}
@Override
@ -116,13 +93,8 @@ public class BpmFormDefinitionServiceImpl implements BpmFormDefinitionService {
if (Objects.isNull(model) || !Objects.equals(model.getTenantId(), tenantId)) {
throw new WorkflowEngineException("模型不存在");
}
FormDeployment deploy = formRepositoryService.createDeployment()
.addFormDefinition(model.getKey() + ".form",
Arrays.toString(repositoryService.getModelEditorSource(model.getId())))
.name(model.getName())
.category(model.getCategory())
.tenantId(model.getTenantId())
.deploy();
FormDeployment deploy = formRepositoryService.createDeployment().addFormDefinition(model.getKey() + ".form",
Arrays.toString(repositoryService.getModelEditorSource(model.getId()))).name(model.getName()).category(model.getCategory()).tenantId(model.getTenantId()).deploy();
return deploy.getId();
}
@ -130,8 +102,7 @@ public class BpmFormDefinitionServiceImpl implements BpmFormDefinitionService {
@Override
@Transactional(rollbackFor = Exception.class)
public String deployFormModelByKey(String formModelKey, String tenantId) {
ModelQuery modelQuery = repositoryService.createModelQuery()
.modelKey(formModelKey);
ModelQuery modelQuery = repositoryService.createModelQuery().modelKey(formModelKey);
if (StringUtils.hasLength(tenantId)) {
modelQuery.modelTenantId(tenantId);
}
@ -143,49 +114,50 @@ public class BpmFormDefinitionServiceImpl implements BpmFormDefinitionService {
return deployFormModelById(model.getId(), null);
}
@Override
public BpmPageResult<FormDeployment> listFormModel(FormModelSearchDTO dto) {
FormDeploymentQuery query = formRepositoryService.createDeploymentQuery();
if (StringUtils.hasLength(dto.getTenantId())) {
query.deploymentTenantId(dto.getTenantId());
}
if (StringUtils.hasLength(dto.getCategory())) {
query.deploymentCategory(dto.getCategory());
}
if (StringUtils.hasLength(dto.getName())) {
query.deploymentNameLike("%" + dto.getName() + "%");
}
List<FormDeployment> formDeployments = query.listPage((dto.getPageNo() - 1) * dto.getPageSize(),
dto.getPageSize());
if (CollUtil.isEmpty(formDeployments)) {
return BpmPageResult.empty(query.count());
}
return new BpmPageResult(formDeployments, query.count());
}
// @Override
// public BpmPageResult<FormDeployment> listFormModel(FormModelSearchDTO dto) {
// FormDeploymentQuery query = formRepositoryService.createDeploymentQuery();
// if (StringUtils.hasLength(dto.getTenantId())) {
// query.deploymentTenantId(dto.getTenantId());
// }
// if (StringUtils.hasLength(dto.getCategory())) {
// query.deploymentCategory(dto.getCategory());
// }
// if (StringUtils.hasLength(dto.getName())) {
// query.deploymentNameLike("%" + dto.getName() + "%");
// }
// List<FormDeployment> formDeployments = query.listPage((dto.getPageNo() - 1) * dto.getPageSize(),
// dto.getPageSize());
// if (CollUtil.isEmpty(formDeployments)) {
// return BpmPageResult.empty(query.count());
// }
// return new BpmPageResult(formDeployments, query.count());
// }
@Override
public List<FormInfo> get(String deploymentId, String tenantId) {
FormDefinitionQuery query = formRepositoryService.createFormDefinitionQuery();
if (StringUtils.hasLength(tenantId)) {
query.formTenantId(tenantId);
}
List<FormDefinition> list = query.deploymentId(deploymentId).list();
if (CollectionUtils.isEmpty(list)) {
return Collections.emptyList();
}
List<FormInfo> formInfos = new ArrayList<>();
list.forEach(i -> {
if (StringUtils.hasLength(tenantId)) {
formInfos.add(formRepositoryService.getFormModelByKeyAndParentDeploymentId(i.getKey(), deploymentId,
tenantId,
false));
} else {
formInfos.add(formRepositoryService.getFormModelByKey(i.getKey()));
}
});
return formInfos;
}
// @Override
// public List<FormInfo> get(String deploymentId, String tenantId) {
// FormDefinitionQuery query = formRepositoryService.createFormDefinitionQuery();
// if (StringUtils.hasLength(tenantId)) {
// query.formTenantId(tenantId);
// }
//
// List<FormDefinition> list = query.deploymentId(deploymentId).list();
// if (CollectionUtils.isEmpty(list)) {
// return Collections.emptyList();
// }
// List<FormInfo> formInfos = new ArrayList<>();
// list.forEach(i -> {
//
// if (StringUtils.hasLength(tenantId)) {
// formInfos.add(formRepositoryService.getFormModelByKeyAndParentDeploymentId(i.getKey(),
// deploymentId,
// tenantId,
// false));
// } else {
// formInfos.add(formRepositoryService.getFormModelByKey(i.getKey()));
// }
// });
// return formInfos;
// }
}

View File

@ -0,0 +1,173 @@
package cn.axzo.workflow.core.service.impl;
import cn.axzo.workflow.core.common.exception.WorkflowEngineException;
import cn.axzo.workflow.core.service.BpmFormModelService;
import cn.axzo.workflow.core.service.converter.FormModelConverter;
import cn.axzo.workflow.core.service.dto.request.form.model.FormModelCreateDTO;
import cn.axzo.workflow.core.service.dto.request.form.model.FormModelUpdateDTO;
import cn.axzo.workflow.core.service.dto.request.model.BpmModelBpmPageDTO;
import cn.axzo.workflow.core.service.dto.response.BpmPageResult;
import cn.axzo.workflow.core.service.dto.response.form.model.FormModelVO;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.flowable.content.api.ContentManagementService;
import org.flowable.engine.RepositoryService;
import org.flowable.engine.repository.Model;
import org.flowable.engine.repository.NativeModelQuery;
import org.flowable.form.api.FormRepositoryService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.annotation.Nullable;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import static cn.axzo.workflow.core.common.BpmConstants.MODEL_META_INFO_FORM;
/**
* TODO
*
* @author wangli
* @since 2023/7/25 10:13
*/
@Service
public class BpmFormModelServiceImpl implements BpmFormModelService {
@Resource
private FormRepositoryService formRepositoryService;
@Resource
private RepositoryService repositoryService;
@Resource
private ContentManagementService managementService;
@Resource
private ObjectMapper objectMapper;
@Resource
private FormModelConverter formModelConverter;
@Override
public String createFormModel(FormModelCreateDTO dto) {
Model persistModel = repositoryService.createModelQuery()
.modelKey(dto.getKey())
.modelTenantId(dto.getTenantId())
.singleResult();
if (Objects.nonNull(persistModel)) {
throw new WorkflowEngineException("存在指定 key 的表单模型");
}
Model model = repositoryService.newModel();
model.setKey(dto.getKey());
model.setCategory(dto.getCategory());
model.setName(dto.getName());
model.setTenantId(dto.getTenantId());
repositoryService.saveModel(model);
// try {
// repositoryService.addModelEditorSource(model.getId(),
// objectMapper.writeValueAsString(new SimpleFormModel()).getBytes());
// } catch (Exception e) {
// e.printStackTrace();
// throw new WorkflowEngineException(e.getMessage());
// }
return model.getId();
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateFormModel(FormModelUpdateDTO dto) {
Model model = repositoryService.createModelQuery()
.modelId(dto.getFormModelId())
.modelTenantId(dto.getTenantId())
.singleResult();
if (Objects.isNull(model)) {
throw new WorkflowEngineException("表单模型不存在");
}
// FormDefinitionDTO formDefinition = dto.getFormDefinition();
// formDefinition.setKey(model.getKey());
// formDefinition.setName(dto.getName());
//
// model.setName(dto.getName());
// model.setCategory(dto.getCategory());
//
// try {
// repositoryService.addModelEditorSource(model.getId(),
// objectMapper.writeValueAsString(formDefinition).getBytes());
// } catch (Exception e) {
// throw new WorkflowEngineException(e.getMessage());
// }
repositoryService.saveModel(model);
}
@Override
public void deleteFormModel(String formModelId, String tenantId) {
Model model = repositoryService.getModel(formModelId);
if (Objects.isNull(model)) {
throw new WorkflowEngineException("模型不存在");
}
if (StringUtils.hasLength(tenantId) && !Objects.equals(model.getTenantId(), tenantId)) {
throw new WorkflowEngineException("模型不存在");
}
repositoryService.deleteModel(formModelId);
}
@Override
public BpmPageResult<FormModelVO> getModelPage(BpmModelBpmPageDTO dto) {
String tableName = managementService.getTableName(Model.class);
StringBuilder baseQuerySql = new StringBuilder("SELECT * FROM ")
.append(tableName);
NativeModelQuery query = repositoryService.createNativeModelQuery();
if (StringUtils.hasLength(dto.getKey())) {
baseQuerySql.append(" where KEY_ = #{key}");
query.parameter("key", dto.getKey());
}
if (StringUtils.hasLength(dto.getName())) {
baseQuerySql.append(sqlConnectors(baseQuerySql))
.append(" NAME_ = #{name}");
query.parameter("name", dto.getName());
}
if (StringUtils.hasLength(dto.getCategory())) {
baseQuerySql.append(sqlConnectors(baseQuerySql))
.append(" CATEGORY_ = #{category}");
query.parameter("category", dto.getCategory());
}
if (StringUtils.hasLength(dto.getTenantId())) {
baseQuerySql.append(sqlConnectors(baseQuerySql))
.append(" TENANT_ID_ = #{tenantId}");
query.parameter("tenantId", dto.getTenantId());
}
baseQuerySql.append(sqlConnectors(baseQuerySql))
.append(" META_INFO_ = #{metaInfo}");
query.parameter("metaInfo", MODEL_META_INFO_FORM);
List<Model> models = query //.orderByLastUpdateTime()
.sql(baseQuerySql.append(" order by LAST_UPDATE_TIME_ desc").toString())
.listPage((dto.getPageNo() - 1) * dto.getPageSize(), dto.getPageSize());
if (CollectionUtils.isEmpty(models)) {
return new BpmPageResult<>(Collections.emptyList(), query.count());
}
return new BpmPageResult<>(formModelConverter.toVos(models), query.count());
}
@Override
public FormModelVO get(String formModelId, @Nullable String tenantId) {
Model model = repositoryService.getModel(formModelId);
if (Objects.isNull(model)) {
throw new WorkflowEngineException("模型不存在");
}
if (StringUtils.hasLength(tenantId) && !Objects.equals(model.getTenantId(), tenantId)) {
throw new WorkflowEngineException("模型不存在");
}
return formModelConverter.toVo(model);
}
private String sqlConnectors(StringBuilder stringBuilder) {
if (stringBuilder.indexOf("where") < 0) {
return " where";
}
return " and";
}
}

View File

@ -11,7 +11,6 @@ import cn.axzo.workflow.core.service.dto.request.model.BpmModelUpdateDTO;
import cn.axzo.workflow.core.service.dto.response.BpmPageResult;
import cn.axzo.workflow.core.service.dto.response.model.BpmModelDetailVO;
import cn.axzo.workflow.core.service.dto.response.model.BpmModelPageItemVO;
import com.alibaba.fastjson.JSON;
import org.flowable.common.engine.impl.db.SuspensionState;
import org.flowable.engine.RepositoryService;
import org.flowable.engine.repository.Deployment;
@ -28,6 +27,7 @@ import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Objects;
import static cn.axzo.workflow.core.common.BpmConstants.MODEL_META_INFO_PROCESS;
import static cn.axzo.workflow.core.common.enums.BpmErrorCode.*;
@Service
@ -58,7 +58,7 @@ public class BpmProcessModelServiceImpl implements BpmProcessModelService {
Model model = repositoryService.newModel();
model.setName(dto.getName());
model.setMetaInfo(JSON.toJSONString(dto.getMetaInfo()));
model.setMetaInfo(MODEL_META_INFO_PROCESS);
model.setCategory(dto.getCategory());
model.setKey(dto.getKey());
model.setTenantId(dto.getTenantId());
@ -119,7 +119,7 @@ public class BpmProcessModelServiceImpl implements BpmProcessModelService {
throw new WorkflowEngineException(MODEL_ID_NOT_EXISTS, dto.getId());
}
originModel.setName(dto.getName());
originModel.setMetaInfo(JSON.toJSONString(dto.getMetaInfo()));
originModel.setMetaInfo(MODEL_META_INFO_PROCESS);
originModel.setCategory(dto.getCategory());
originModel.setKey(dto.getKey());
originModel.setTenantId(dto.getTenantId());

View File

@ -1,19 +1,16 @@
package cn.axzo.workflow.server.controller.web;
import cn.axzo.workflow.core.service.BpmFormDefinitionService;
import cn.axzo.workflow.core.service.dto.request.form.FormModelCreateDTO;
import cn.axzo.workflow.core.service.dto.request.form.FormModelSearchDTO;
import cn.axzo.workflow.core.service.dto.request.form.FormModelUpdateDTO;
import cn.axzo.workflow.core.service.dto.response.BpmPageResult;
import cn.azxo.framework.common.model.CommonResponse;
import lombok.extern.slf4j.Slf4j;
import org.flowable.form.api.FormDeployment;
import org.flowable.form.api.FormInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.List;
import javax.validation.constraints.NotBlank;
/**
* 表单定义相关 Controller
@ -29,26 +26,28 @@ public class BpmFormDefinitionController {
@Autowired
private BpmFormDefinitionService bpmFormDefinitionService;
@PostMapping("/create")
public CommonResponse<String> createFormModel(@Valid @RequestBody FormModelCreateDTO dto) {
return CommonResponse.success(bpmFormDefinitionService.createFormModel(dto));
@PostMapping("/deploy")
public CommonResponse<String> deployFormModelById(@Valid @NotBlank(message = "模型 ID 不能为空") @RequestParam String modelId,
@RequestParam(required = false) String tenantId) {
return CommonResponse.success(bpmFormDefinitionService.deployFormModelById(modelId, tenantId));
}
@PutMapping("/update")
public CommonResponse<Void> updateFormModel(@Valid @RequestBody FormModelUpdateDTO dto) {
bpmFormDefinitionService.updateFormModel(dto);
return CommonResponse.success();
@PostMapping("/deployByKey")
public CommonResponse<String> deployFormModelByKey(@Valid @NotBlank(message = "模型 KEY 不能为空") @RequestParam String modelKey,
@RequestParam(required = false) String tenantId) {
return CommonResponse.success(bpmFormDefinitionService.deployFormModelByKey(modelKey, tenantId));
}
@GetMapping("/list")
public CommonResponse<BpmPageResult<FormDeployment>> list(@Valid @RequestBody FormModelSearchDTO dto) {
return CommonResponse.success(bpmFormDefinitionService.listFormModel(dto));
}
@GetMapping("/deployment/get")
public CommonResponse<List<FormInfo>> get(@RequestParam String deploymentId,
@RequestParam(required = false) String tenantId) {
return CommonResponse.success(bpmFormDefinitionService.get(deploymentId, tenantId));
}
//
// @GetMapping("/list")
// public CommonResponse<BpmPageResult<FormDeployment>> list(@Valid @RequestBody FormModelSearchDTO dto) {
// return CommonResponse.success(bpmFormDefinitionService.listFormModel(dto));
// }
//
// @GetMapping("/deployment/get")
// public CommonResponse<List<FormInfo>> get(@RequestParam String deploymentId,
// @RequestParam(required = false) String tenantId) {
// return CommonResponse.success(bpmFormDefinitionService.get(deploymentId, tenantId));
// }
}

View File

@ -0,0 +1,56 @@
package cn.axzo.workflow.server.controller.web;
import cn.axzo.workflow.core.service.BpmFormModelService;
import cn.axzo.workflow.core.service.dto.request.form.model.FormModelCreateDTO;
import cn.axzo.workflow.core.service.dto.request.form.model.FormModelUpdateDTO;
import cn.axzo.workflow.core.service.dto.request.model.BpmModelBpmPageDTO;
import cn.axzo.workflow.core.service.dto.response.BpmPageResult;
import cn.axzo.workflow.core.service.dto.response.form.model.FormModelVO;
import cn.azxo.framework.common.model.CommonResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
/**
* TODO
*
* @author wangli
* @since 2023/7/25 10:16
*/
@Slf4j
@RequestMapping("/web/v1/api/form/model")
@RestController
@Valid
public class BpmFormModelController {
@Resource
private BpmFormModelService bpmFormModelService;
@GetMapping("/page")
public CommonResponse<BpmPageResult<FormModelVO>> modelPage(@Valid @RequestBody BpmModelBpmPageDTO dto) {
bpmFormModelService.getModelPage(dto);
return CommonResponse.success();
}
@PostMapping("/create")
public CommonResponse<String> createFormModel(@Valid @RequestBody FormModelCreateDTO dto) {
return CommonResponse.success(bpmFormModelService.createFormModel(dto));
}
@PutMapping("/update")
public CommonResponse<Void> updateFormModel(@Valid @RequestBody FormModelUpdateDTO dto) {
bpmFormModelService.updateFormModel(dto);
return CommonResponse.success();
}
@DeleteMapping("/delete")
public CommonResponse<Boolean> deleteFormModel(@RequestParam String formModelId,
@RequestParam(required = false) String tenantId) {
bpmFormModelService.deleteFormModel(formModelId, tenantId);
return CommonResponse.success(true);
}
}

View File

@ -21,10 +21,10 @@ import javax.validation.constraints.NotBlank;
@Tag(name = "运维管理 - 流程模型")
@Slf4j
@RequestMapping("/web/v1/api/model")
@RequestMapping("/web/v1/api/process/model")
@RestController
@Validated
public class BpmModelController {
public class BpmProcessModelController {
@Autowired
private BpmProcessModelService bpmProcessModelService;
@ -33,7 +33,7 @@ public class BpmModelController {
* 获取流程模型的查询结果
*/
@Operation(summary = "流程模型列表")
@GetMapping("/getModelPage")
@GetMapping("/page")
public CommonResponse<BpmPageResult<BpmModelPageItemVO>> modelPage(@Valid @RequestBody BpmModelBpmPageDTO dto) {
log.info("获取流程模型getModelPage===>>>参数:{}", JSON.toJSONString(dto));
BpmPageResult<BpmModelPageItemVO> result = bpmProcessModelService.getModelPage(dto);
@ -99,7 +99,7 @@ public class BpmModelController {
* 部署模型
* return 部署完成的流程定义Id
*/
@Operation(summary = "通过模型ID部署流程")
@Operation(summary = "通过模型 ID 部署流程模型")
@PostMapping("/deploy")
public CommonResponse<String> deployBpmModelById(@Valid @NotBlank(message = "模型 ID 不能为空") @RequestParam String modelId) {
log.info("部署模型deployBpmModelById===>>>参数:{}", JSON.toJSONString(modelId));
@ -112,9 +112,9 @@ public class BpmModelController {
* 部署模型
* return 部署完成的流程定义Id
*/
@Operation(summary = "通过模型KEY部署流程")
@Operation(summary = "通过模型 KEY 部署流程模型")
@PostMapping("/deployByKey")
public CommonResponse<String> deployBpmModelByKey(@Valid @NotBlank(message = "模型 Key 不能为空") @RequestParam String modelKey,
public CommonResponse<String> deployBpmModelByKey(@Valid @NotBlank(message = "模型 KEY 不能为空") @RequestParam String modelKey,
@RequestParam String tenantId) {
log.info("部署模型deployBpmModelByKey===>>>参数:{}", JSON.toJSONString(modelKey));
String result = bpmProcessModelService.deployBpmModelByKey(modelKey, tenantId);
@ -125,7 +125,7 @@ public class BpmModelController {
/**
* 删除模型
*/
@Operation(summary = "删除指定模型ID的模型")
@Operation(summary = "删除指定模型 ID 流程模型")
@DeleteMapping("/delete")
public CommonResponse<Void> deleteBpmModel(@RequestParam String id) {
log.info("删除模型deleteBpmModel===>>>参数:{}", JSON.toJSONString(id));