|
|
@ -1,5 +1,6 @@ |
|
|
|
package com.gitee.sop.servercommon.bean; |
|
|
|
package com.gitee.sop.servercommon.bean; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import org.apache.commons.lang3.time.DateUtils; |
|
|
|
import org.apache.commons.lang3.time.DateUtils; |
|
|
|
|
|
|
|
|
|
|
@ -30,13 +31,15 @@ public class OpenContextImpl<T> implements OpenContext<T> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public OpenContextImpl(JSONObject rootJsonObject, Class<?> bizClass) { |
|
|
|
public OpenContextImpl(JSONObject rootJsonObject, Class<?> bizClass) { |
|
|
|
|
|
|
|
if (rootJsonObject == null) { |
|
|
|
|
|
|
|
throw new IllegalArgumentException("rootJsonObject can not be null"); |
|
|
|
|
|
|
|
} |
|
|
|
this.rootJsonObject = rootJsonObject; |
|
|
|
this.rootJsonObject = rootJsonObject; |
|
|
|
if (bizClass != null) { |
|
|
|
if (bizClass != null) { |
|
|
|
JSONObject bizJsonObj = this.rootJsonObject.getJSONObject(BIZ_CONTENT_NAME); |
|
|
|
String bizContent = getBizContent(); |
|
|
|
if (bizJsonObj == null) { |
|
|
|
if (bizContent != null) { |
|
|
|
bizJsonObj = rootJsonObject; |
|
|
|
bizObject = (T) JSON.parseObject(bizContent, bizClass); |
|
|
|
} |
|
|
|
} |
|
|
|
bizObject = (T) bizJsonObj.toJavaObject(bizClass); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -105,10 +108,10 @@ public class OpenContextImpl<T> implements OpenContext<T> { |
|
|
|
if (bizObject != null && bizObject.getClass() == clazz) { |
|
|
|
if (bizObject != null && bizObject.getClass() == clazz) { |
|
|
|
return (E) bizObject; |
|
|
|
return (E) bizObject; |
|
|
|
} |
|
|
|
} |
|
|
|
JSONObject bizJsonObj = this.rootJsonObject.getJSONObject(BIZ_CONTENT_NAME); |
|
|
|
String bizContent = getBizContent(); |
|
|
|
if (bizJsonObj == null) { |
|
|
|
if (bizContent == null) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
return bizJsonObj.toJavaObject(clazz); |
|
|
|
return JSON.parseObject(bizContent, clazz); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|