From d040028463d248fe0cb0686e4d142905d5a2d4f3 Mon Sep 17 00:00:00 2001 From: "haoeliu@foxmail.com" Date: Thu, 9 Mar 2023 21:16:37 +0800 Subject: [PATCH] simplify the doip afterExec packing logic --- .../bdware/sc/engine/hook/DOOPAfterExecHandler.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/bdware/sc/engine/hook/DOOPAfterExecHandler.java b/src/main/java/org/bdware/sc/engine/hook/DOOPAfterExecHandler.java index a6d3255..db35a9b 100644 --- a/src/main/java/org/bdware/sc/engine/hook/DOOPAfterExecHandler.java +++ b/src/main/java/org/bdware/sc/engine/hook/DOOPAfterExecHandler.java @@ -6,6 +6,7 @@ import com.google.gson.JsonParser; import org.bdware.doip.codec.doipMessage.DoipMessage; import org.bdware.doip.codec.doipMessage.DoipMessageFactory; import org.bdware.doip.codec.doipMessage.DoipResponseCode; +import org.bdware.doip.codec.doipMessage.MessageHeader; import org.bdware.doip.codec.operations.BasicOperations; import org.bdware.sc.JSEngine; import org.bdware.sc.bean.ContractRequest; @@ -72,17 +73,9 @@ public class DOOPAfterExecHandler implements AnnotationHook { JsonObject header = jsonObjectRes.get("header") != null ? jsonObjectRes.get("header").getAsJsonObject() : null; String body = jsonObjectRes.get("body") != null ? jsonObjectRes.get("body").getAsString() : null; - originDoipMsg.header.setIsRequest(false); + // 和HTTP一样,所有需要的字段自己封装,校验规则也比较简单,这里只做简单的包装返回即可!!! if(header != null) { - String headerRespCode = header.get("response") != null ? header.get("response").getAsString() : null; - if(headerRespCode != null) { - originDoipMsg.header.parameters.response = DoipResponseCode.valueOf(headerRespCode); - } - - // todo 其他的规则的添加 - if(header.get("parameters") != null && header.get("parameters").getAsJsonObject().get("attributes") != null) { - originDoipMsg.header.parameters.attributes = header.get("parameters").getAsJsonObject().get("attributes").getAsJsonObject(); - } + originDoipMsg.header = JsonUtil.fromJson(header, MessageHeader.class); } if(body != null) {