mirror of
https://gitee.com/BDWare/cp.git
synced 2025-01-10 01:44:08 +00:00
simplify the doip afterExec packing logic
This commit is contained in:
parent
fb8305031e
commit
d040028463
@ -6,6 +6,7 @@ import com.google.gson.JsonParser;
|
|||||||
import org.bdware.doip.codec.doipMessage.DoipMessage;
|
import org.bdware.doip.codec.doipMessage.DoipMessage;
|
||||||
import org.bdware.doip.codec.doipMessage.DoipMessageFactory;
|
import org.bdware.doip.codec.doipMessage.DoipMessageFactory;
|
||||||
import org.bdware.doip.codec.doipMessage.DoipResponseCode;
|
import org.bdware.doip.codec.doipMessage.DoipResponseCode;
|
||||||
|
import org.bdware.doip.codec.doipMessage.MessageHeader;
|
||||||
import org.bdware.doip.codec.operations.BasicOperations;
|
import org.bdware.doip.codec.operations.BasicOperations;
|
||||||
import org.bdware.sc.JSEngine;
|
import org.bdware.sc.JSEngine;
|
||||||
import org.bdware.sc.bean.ContractRequest;
|
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;
|
JsonObject header = jsonObjectRes.get("header") != null ? jsonObjectRes.get("header").getAsJsonObject() : null;
|
||||||
String body = jsonObjectRes.get("body") != null ? jsonObjectRes.get("body").getAsString() : null;
|
String body = jsonObjectRes.get("body") != null ? jsonObjectRes.get("body").getAsString() : null;
|
||||||
|
|
||||||
originDoipMsg.header.setIsRequest(false);
|
// 和HTTP一样,所有需要的字段自己封装,校验规则也比较简单,这里只做简单的包装返回即可!!!
|
||||||
if(header != null) {
|
if(header != null) {
|
||||||
String headerRespCode = header.get("response") != null ? header.get("response").getAsString() : null;
|
originDoipMsg.header = JsonUtil.fromJson(header, MessageHeader.class);
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(body != null) {
|
if(body != null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user