From 61bd2d01de70d1d0300876f8ebbf769707d1859d Mon Sep 17 00:00:00 2001 From: tanghc Date: Tue, 27 Aug 2019 12:47:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8F=82=E6=95=B0=E7=BB=91?= =?UTF-8?q?=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sop/servercommon/bean/OpenContextImpl.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/bean/OpenContextImpl.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/bean/OpenContextImpl.java index bc3c4329..515b66e3 100644 --- a/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/bean/OpenContextImpl.java +++ b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/bean/OpenContextImpl.java @@ -1,5 +1,6 @@ package com.gitee.sop.servercommon.bean; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import org.apache.commons.lang3.time.DateUtils; @@ -30,13 +31,15 @@ public class OpenContextImpl implements OpenContext { } public OpenContextImpl(JSONObject rootJsonObject, Class bizClass) { + if (rootJsonObject == null) { + throw new IllegalArgumentException("rootJsonObject can not be null"); + } this.rootJsonObject = rootJsonObject; if (bizClass != null) { - JSONObject bizJsonObj = this.rootJsonObject.getJSONObject(BIZ_CONTENT_NAME); - if (bizJsonObj == null) { - bizJsonObj = rootJsonObject; + String bizContent = getBizContent(); + if (bizContent != null) { + bizObject = (T) JSON.parseObject(bizContent, bizClass); } - bizObject = (T) bizJsonObj.toJavaObject(bizClass); } } @@ -105,10 +108,10 @@ public class OpenContextImpl implements OpenContext { if (bizObject != null && bizObject.getClass() == clazz) { return (E) bizObject; } - JSONObject bizJsonObj = this.rootJsonObject.getJSONObject(BIZ_CONTENT_NAME); - if (bizJsonObj == null) { + String bizContent = getBizContent(); + if (bizContent == null) { return null; } - return bizJsonObj.toJavaObject(clazz); + return JSON.parseObject(bizContent, clazz); } }