【代码评审】BPM:触发器 - 表单修改

This commit is contained in:
YunaiV 2025-02-09 06:55:56 +08:00
parent f5050807e1
commit 9569c3fbed
5 changed files with 13 additions and 5 deletions

View File

@ -206,4 +206,5 @@ public class JsonUtils {
public static boolean isJsonObject(String str) { public static boolean isJsonObject(String str) {
return JSONUtil.isTypeJSONObject(str); return JSONUtil.isTypeJSONObject(str);
} }
} }

View File

@ -17,8 +17,7 @@ import java.util.Arrays;
public enum BpmTriggerTypeEnum implements ArrayValuable<Integer> { public enum BpmTriggerTypeEnum implements ArrayValuable<Integer> {
HTTP_REQUEST(1, "发起 HTTP 请求"), HTTP_REQUEST(1, "发起 HTTP 请求"),
UPDATE_NORMAL_FORM(2, "更新流程表单"); UPDATE_NORMAL_FORM(2, "更新流程表单"); // TODO @jasonFORM_UPDATE
/** /**
* 触发器执行动作类型 * 触发器执行动作类型

View File

@ -345,6 +345,8 @@ public class BpmSimpleModelNodeVO {
@Valid @Valid
private HttpRequestTriggerSetting httpRequestSetting; private HttpRequestTriggerSetting httpRequestSetting;
// TODO @jason这个要不直接叫 formSetting更好理解一点哈
// TODO @jason如果搞成 List<NormalFormTriggerSetting>是不是可以做条件组了微信讨论哈
/** /**
* 流程表单触发器设置 * 流程表单触发器设置
*/ */
@ -376,6 +378,7 @@ public class BpmSimpleModelNodeVO {
*/ */
@Schema(description = "请求返回处理设置", example = "[]") @Schema(description = "请求返回处理设置", example = "[]")
private List<KeyValue<String, String>> response; private List<KeyValue<String, String>> response;
} }
@Schema(description = "流程表单触发器设置", example = "{}") @Schema(description = "流程表单触发器设置", example = "{}")
@ -384,6 +387,8 @@ public class BpmSimpleModelNodeVO {
@Schema(description = "修改的表单字段", example = "userName") @Schema(description = "修改的表单字段", example = "userName")
private Map<String, Object> updateFormFields; private Map<String, Object> updateFormFields;
} }
} }
} }

View File

@ -81,13 +81,14 @@ public class BpmHttpRequestTrigger implements BpmTrigger {
} }
// 4.1 判断是否需要解析返回值 // 4.1 判断是否需要解析返回值
if (StrUtil.isEmpty(responseEntity.getBody()) || !responseEntity.getStatusCode().is2xxSuccessful() if (StrUtil.isEmpty(responseEntity.getBody())
|| !responseEntity.getStatusCode().is2xxSuccessful()
|| CollUtil.isEmpty(setting.getResponse())) { || CollUtil.isEmpty(setting.getResponse())) {
return; return;
} }
// 4.2 解析返回值, 返回值必须符合 CommonResult 规范 // 4.2 解析返回值, 返回值必须符合 CommonResult 规范
CommonResult<Map<String, Object>> respResult = JsonUtils.parseObjectQuietly(responseEntity.getBody(), CommonResult<Map<String, Object>> respResult = JsonUtils.parseObjectQuietly(
new TypeReference<>() {}); responseEntity.getBody(), new TypeReference<>() {});
if (respResult == null || !respResult.isSuccess()){ if (respResult == null || !respResult.isSuccess()){
return; return;
} }

View File

@ -9,6 +9,7 @@ import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
// TODO @jason改成 BpmFormUpdateTrigger
/** /**
* BPM 更新流程表单触发器 * BPM 更新流程表单触发器
* *
@ -39,4 +40,5 @@ public class BpmUpdateNormalFormTrigger implements BpmTrigger {
processInstanceService.updateProcessInstanceVariables(processInstanceId, setting.getUpdateFormFields()); processInstanceService.updateProcessInstanceVariables(processInstanceId, setting.getUpdateFormFields());
} }
} }
} }