feat(REQ-3982) - 增加部分接口内部是否报错异常的控制

This commit is contained in:
wangli 2025-04-23 15:51:40 +08:00
parent d503a133a9
commit c253c226ec
3 changed files with 34 additions and 25 deletions

View File

@ -34,4 +34,11 @@ public class PrintFieldQueryDTO {
*/
@ApiModelProperty(value = "租户 ID")
private String tenantId;
/**
* 是否抛出内部异常
*/
@ApiModelProperty(value = "是否报错内部异常")
@Builder.Default
private Boolean throwException = true;
}

View File

@ -355,7 +355,7 @@ public class BpmnProcessModelController implements ProcessModelApi {
public CommonResponse<PrintModelDTO> getPrintTemplateConfig(@Validated @RequestBody PrintTemplateConfigQueryDTO dto) {
log.info("获取打印模板配置内容");
if (!StringUtils.hasText(dto.getModelId()) && !StringUtils.hasText(dto.getProcessInstanceId()) && !StringUtils.hasText(dto.getProcessDefinitionKey())) {
if (!StringUtils.hasText(dto.getProcessDefinitionKey()) || !StringUtils.hasText(dto.getTenantId())) {
if (!StringUtils.hasText(dto.getProcessDefinitionKey()) && !StringUtils.hasText(dto.getTenantId())) {
throw new WorkflowEngineException(ILLEGAL_PARAM_ERROR, "processDefinitionKey 与 tenantId 不能同时为空");
}
throw new WorkflowEngineException(ILLEGAL_PARAM_ERROR, "模型 ID 、实例 ID 和业务 ID 不能同时为空");

View File

@ -117,33 +117,35 @@ public class PrintAdminController implements PrintAdminApi {
FormInfo formModel;
try {
formModel = formRepositoryService.getFormModelByKey(dto.getProcessDefinitionKey(), dto.getTenantId(), false);
// 表单字段
List<FormField> formFields = ((SimpleFormModel) formModel.getFormModel()).getFields();
formFields.forEach(formField -> {
FormContainer formContainer = (FormContainer) formField;
printFields.addAll(formContainer.getFields().get(0).stream().map(field -> {
PrintFieldDTO printFieldDTO = new PrintFieldDTO()
.setName(field.getName())
.setCode(field.getId())
.setFieldCategoryType(form)
.setFieldFormType(field.getType());
if (field instanceof FormContainer) {
FormContainer container = (FormContainer) field;
printFieldDTO.setAttributes(container.getFields().get(0)
.stream().map(subField -> new FieldAttributeDTO()
.setCode(subField.getId())
.setFieldFormType(subField.getType())
.setName(subField.getName()))
.collect(Collectors.toList()));
}
return printFieldDTO;
}
).collect(Collectors.toList()));
});
} catch (FlowableObjectNotFoundException e) {
log.warn("can't found form model");
throw new WorkflowEngineException(FORM_MODEL_NOT_EXISTS);
if (Objects.equals(Boolean.TRUE, dto.getThrowException())) {
throw new WorkflowEngineException(FORM_MODEL_NOT_EXISTS);
}
}
// 表单字段
List<FormField> formFields = ((SimpleFormModel) formModel.getFormModel()).getFields();
formFields.forEach(formField -> {
FormContainer formContainer = (FormContainer) formField;
printFields.addAll(formContainer.getFields().get(0).stream().map(field -> {
PrintFieldDTO printFieldDTO = new PrintFieldDTO()
.setName(field.getName())
.setCode(field.getId())
.setFieldCategoryType(form)
.setFieldFormType(field.getType());
if (field instanceof FormContainer) {
FormContainer container = (FormContainer) field;
printFieldDTO.setAttributes(container.getFields().get(0)
.stream().map(subField -> new FieldAttributeDTO()
.setCode(subField.getId())
.setFieldFormType(subField.getType())
.setName(subField.getName()))
.collect(Collectors.toList()));
}
return printFieldDTO;
}
).collect(Collectors.toList()));
});
// 生成固定的系统字段
generateSystemFields(printFields, dto.getProcessDefinitionKey(), dto.getTenantId());