|
|
@ -1,5 +1,7 @@ |
|
|
|
package com.unionmed.framework.spring.mvc; |
|
|
|
package com.unionmed.framework.spring.mvc; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.unionmed.framework.util.ObjectUtils; |
|
|
|
import com.unionmed.framework.util.ObjectUtils; |
|
|
|
|
|
|
|
|
|
|
@ -11,11 +13,18 @@ import java.util.Map; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public final class BaseReturnUtils { |
|
|
|
public final class BaseReturnUtils { |
|
|
|
|
|
|
|
|
|
|
|
public static BaseReturn parse(JSONObject jsn) { |
|
|
|
public static void main(String[] args) { |
|
|
|
if (ObjectUtils.isEmpty(jsn)) { |
|
|
|
JSONObject object = new JSONObject(); |
|
|
|
return BaseReturn.suc(BaseReturn.suc()); |
|
|
|
object.put("code", "200"); |
|
|
|
|
|
|
|
object.put("errCode", "200"); |
|
|
|
|
|
|
|
object.put("message", "成功"); |
|
|
|
|
|
|
|
object.put("data", new JSONArray()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.err.println(JSON.toJSONString(parse(object))); |
|
|
|
} |
|
|
|
} |
|
|
|
if (isBaseReturnFormat(jsn)) { |
|
|
|
|
|
|
|
|
|
|
|
public static BaseReturn parse(JSONObject jsn) { |
|
|
|
|
|
|
|
if (ObjectUtils.notEmpty(jsn) && isBaseReturnFormat(jsn)) { |
|
|
|
Object data = jsn.get("data"); |
|
|
|
Object data = jsn.get("data"); |
|
|
|
if (data instanceof JSONObject) { |
|
|
|
if (data instanceof JSONObject) { |
|
|
|
return parse(jsn, (JSONObject) data); |
|
|
|
return parse(jsn, (JSONObject) data); |
|
|
|