Commit 39ca0245 by 袁伟铭

修改API form参数验证方式

parent 765e78e0
...@@ -51,6 +51,7 @@ public class ApiController { ...@@ -51,6 +51,7 @@ public class ApiController {
return ApiUtils.getSuccessResp(form); return ApiUtils.getSuccessResp(form);
} }
form.setType(2);
String method = form.getMethod(); String method = form.getMethod();
if (StrUtil.isBlank(method)) { if (StrUtil.isBlank(method)) {
method = request.getParameter("method"); method = request.getParameter("method");
......
...@@ -42,6 +42,7 @@ public class AppController { ...@@ -42,6 +42,7 @@ public class AppController {
return ApiUtils.getSuccessResp(form); return ApiUtils.getSuccessResp(form);
} }
form.setType(1);
//解析业务参数 //解析业务参数
if (!form.parseBizContent()) { if (!form.parseBizContent()) {
return ApiUtils.getParamError(form); return ApiUtils.getParamError(form);
......
...@@ -36,16 +36,29 @@ public class ApiForm { ...@@ -36,16 +36,29 @@ public class ApiForm {
private String nonce; // 随机字串(建议使用UUID) private String nonce; // 随机字串(建议使用UUID)
private String version; // 接口版本 private String version; // 接口版本
private String apiNo; // 接口码 private String apiNo; // 接口码
private Integer type; // 1-app;2-api,内部定
private String clientType; // 客户端类型 xcx-小程序,H5
private String bizContent; // 请求业务参数 private String bizContent; // 请求业务参数
private JSONObject bizContentJson; // 请求业务的json对象 private JSONObject bizContentJson; // 请求业务的json对象
private ApiTokenVo apiTokenVo; private ApiTokenVo apiTokenVo;
public boolean parseBizContent() { public boolean parseBizContent() {
try { try {
boolean flag = ConfigCache.getValueToBoolean("API.PARAM.ENCRYPT"); // API参数是否加密 if (type == 1) {
if (StrUtil.isNotBlank(bizContent) && flag && StrUtil.isNotBlank(sign)) { // API参数是否加密
boolean flag = ConfigCache.getValueToBoolean("API.PARAM.ENCRYPT");
if (StrUtil.isNotBlank(bizContent) && flag) {
bizContent = ApiUtils.decode(bizContent, "");
}
} else {
if (StrUtil.isNotBlank(bizContent)) {
bizContent = ApiUtils.decode(bizContent, "BASE64"); bizContent = ApiUtils.decode(bizContent, "BASE64");
} }
}
if (bizContent == null) {
bizContent = "";
}
bizContentJson = JSON.parseObject(bizContent); bizContentJson = JSON.parseObject(bizContent);
if (bizContentJson == null) { if (bizContentJson == null) {
bizContentJson = new JSONObject(); bizContentJson = new JSONObject();
......
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