fix - 自测表单定义新/删/改/查接口完成
This commit is contained in:
parent
92f820bcdb
commit
d32dfb3b51
@ -15,12 +15,15 @@ import java.util.List;
|
||||
@Data
|
||||
public class FormDefinitionDTO {
|
||||
@ApiModelProperty(value = "表单定义的key", hidden = true)
|
||||
private transient String key;
|
||||
private String key;
|
||||
|
||||
@ApiModelProperty(value = "表单定义的名称", hidden = true)
|
||||
private transient String name;
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "表单定义的版本", hidden = true)
|
||||
private Integer version;
|
||||
|
||||
@ApiModelProperty(value = "表单定义的具体字段项", example = "[{'': '''}]")
|
||||
private List<FormFieldsDTO> formFields;
|
||||
private List<FormFieldsDTO> fields;
|
||||
|
||||
}
|
||||
|
||||
@ -17,9 +17,11 @@ public class FormDefinitionVO {
|
||||
|
||||
private String key;
|
||||
|
||||
private String category;
|
||||
|
||||
private Integer version;
|
||||
|
||||
private String description;
|
||||
private String tenantId;
|
||||
|
||||
private List<FormFieldsDTO> fields;
|
||||
|
||||
|
||||
@ -21,7 +21,6 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@ -56,19 +55,25 @@ public class BpmFormDefinitionServiceImpl implements BpmFormDefinitionService {
|
||||
if (StringUtils.hasLength(tenantId) && !Objects.equals(model.getTenantId(), tenantId)) {
|
||||
throw new WorkflowEngineException("模型不存在");
|
||||
}
|
||||
FormDefinitionVO formDefinitionVO = null;
|
||||
FormDefinitionVO vo = null;
|
||||
try {
|
||||
formDefinitionVO = objectMapper.readValue(repositoryService.getModelEditorSource(model.getId()),
|
||||
vo = objectMapper.readValue(repositoryService.getModelEditorSource(model.getId()),
|
||||
FormDefinitionVO.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new WorkflowEngineException("解析转换异常");
|
||||
}
|
||||
return formDefinitionVO;
|
||||
vo.setKey(model.getKey());
|
||||
vo.setName(model.getName());
|
||||
vo.setCategory(model.getCategory());
|
||||
vo.setVersion(model.getVersion());
|
||||
vo.setTenantId(model.getTenantId());
|
||||
return vo;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateFormDefinition(FormDefinitionUpdateDTO dto) {
|
||||
Model model = repositoryService.getModel(dto.getFormModelId());
|
||||
if (Objects.isNull(model)) {
|
||||
@ -77,6 +82,7 @@ public class BpmFormDefinitionServiceImpl implements BpmFormDefinitionService {
|
||||
FormDefinitionDTO formDefinition = dto.getFormDefinition();
|
||||
formDefinition.setKey(model.getKey());
|
||||
formDefinition.setName(model.getName());
|
||||
formDefinition.setVersion(model.getVersion());
|
||||
|
||||
try {
|
||||
repositoryService.addModelEditorSource(model.getId(),
|
||||
@ -84,18 +90,22 @@ public class BpmFormDefinitionServiceImpl implements BpmFormDefinitionService {
|
||||
} catch (Exception e) {
|
||||
throw new WorkflowEngineException(e.getMessage());
|
||||
}
|
||||
repositoryService.saveModel(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String deployFormModelById(String formModelId, String tenantId) {
|
||||
Model model = repositoryService.getModel(formModelId);
|
||||
if (Objects.isNull(model) || !Objects.equals(model.getTenantId(), tenantId)) {
|
||||
if (Objects.isNull(model)) {
|
||||
throw new WorkflowEngineException("模型不存在");
|
||||
}
|
||||
if (StringUtils.hasLength(tenantId) && !Objects.equals(model.getTenantId(), tenantId)) {
|
||||
throw new WorkflowEngineException("模型不存在");
|
||||
}
|
||||
FormDeployment deploy = formRepositoryService.createDeployment()
|
||||
.addFormDefinition(model.getKey() + ".form",
|
||||
Arrays.toString(repositoryService.getModelEditorSource(model.getId())))
|
||||
new String(repositoryService.getModelEditorSource(model.getId())))
|
||||
.name(model.getName())
|
||||
.category(model.getCategory())
|
||||
.tenantId(model.getTenantId())
|
||||
|
||||
@ -1,13 +1,12 @@
|
||||
package cn.axzo.workflow.server.controller.web;
|
||||
|
||||
import cn.axzo.workflow.core.service.BpmFormDefinitionService;
|
||||
import cn.axzo.workflow.core.service.dto.request.form.definition.FormDefinitionUpdateDTO;
|
||||
import cn.axzo.workflow.core.service.dto.response.form.definition.FormDefinitionVO;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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 org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
@ -26,28 +25,28 @@ public class BpmFormDefinitionController {
|
||||
@Autowired
|
||||
private BpmFormDefinitionService bpmFormDefinitionService;
|
||||
|
||||
@PutMapping("/update")
|
||||
public CommonResponse<Boolean> updateFormDefinition(@Valid @RequestBody FormDefinitionUpdateDTO dto) {
|
||||
bpmFormDefinitionService.updateFormDefinition(dto);
|
||||
return CommonResponse.success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/deploy")
|
||||
public CommonResponse<String> deployFormModelById(@Valid @NotBlank(message = "模型 ID 不能为空") @RequestParam String modelId,
|
||||
public CommonResponse<String> deployFormModelById(@Valid @NotBlank(message = "模型 ID 不能为空") @RequestParam String formModelId,
|
||||
@RequestParam(required = false) String tenantId) {
|
||||
return CommonResponse.success(bpmFormDefinitionService.deployFormModelById(modelId, tenantId));
|
||||
return CommonResponse.success(bpmFormDefinitionService.deployFormModelById(formModelId, tenantId));
|
||||
}
|
||||
|
||||
@PostMapping("/deployByKey")
|
||||
public CommonResponse<String> deployFormModelByKey(@Valid @NotBlank(message = "模型 KEY 不能为空") @RequestParam String modelKey,
|
||||
public CommonResponse<String> deployFormModelByKey(@Valid @NotBlank(message = "模型 KEY 不能为空") @RequestParam String formModelKey,
|
||||
@RequestParam(required = false) String tenantId) {
|
||||
return CommonResponse.success(bpmFormDefinitionService.deployFormModelByKey(modelKey, tenantId));
|
||||
return CommonResponse.success(bpmFormDefinitionService.deployFormModelByKey(formModelKey, 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("/get")
|
||||
public CommonResponse<FormDefinitionVO> get(@Valid @NotBlank(message = "模型 ID 不能为空") @RequestParam String formModelId,
|
||||
@RequestParam String tenantId) {
|
||||
return CommonResponse.success(bpmFormDefinitionService.get(formModelId, tenantId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user