Commit f7cd1142 by 袁伟铭

1.0.0

parent e3b3c416
...@@ -4,7 +4,6 @@ import cn.hutool.core.exceptions.ExceptionUtil; ...@@ -4,7 +4,6 @@ import cn.hutool.core.exceptions.ExceptionUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.servlet.ServletUtil; import cn.hutool.extra.servlet.ServletUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.zq.api.constant.ApiCodeEnum; import com.zq.api.constant.ApiCodeEnum;
import com.zq.api.form.ApiForm; import com.zq.api.form.ApiForm;
import com.zq.api.form.ApiResp; import com.zq.api.form.ApiResp;
...@@ -44,10 +43,7 @@ public class ApiController { ...@@ -44,10 +43,7 @@ public class ApiController {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
ApiForm form = ServletUtil.toBean(request, ApiForm.class, true); ApiForm form = ServletUtil.toBean(request, ApiForm.class, true);
try { if (!form.parseBizContent()) {
JSONObject jsonObject = JSON.parseObject(form.getBizContent());
form.setBizContentJson(jsonObject);
} catch (Exception e) {
return ApiUtils.getParamError(form); return ApiUtils.getParamError(form);
} }
......
...@@ -41,16 +41,26 @@ public class ApiForm { ...@@ -41,16 +41,26 @@ public class ApiForm {
private JSONObject bizContentJson; // 请求业务的json对象 private JSONObject bizContentJson; // 请求业务的json对象
private ApiTokenVo apiTokenVo; private ApiTokenVo apiTokenVo;
public boolean parseBizContent() {
try {
bizContentJson = JSON.parseObject(bizContent);
if (bizContentJson == null) {
bizContentJson = new JSONObject();
}
return true;
} catch (Exception e) {
log.error("bizContent解析失败:{}", e.getMessage());
return false;
}
}
public JSONObject getContentJson() { public JSONObject getContentJson() {
if (bizContentJson != null) { if (bizContentJson != null) {
return bizContentJson; return bizContentJson;
} }
JSONObject object = JSON.parseObject(bizContent); parseBizContent();
if (object == null) { return bizContentJson;
return new JSONObject();
}
return object;
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment