1、优化api日志请求参数格式

pull/254/head
xjs 4 years ago
parent b47e51233f
commit b69164753c

@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUnit; import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.domain.R;
import com.xjs.annotation.ApiLog; import com.xjs.annotation.ApiLog;
import com.xjs.business.log.RemoteLogFeign; import com.xjs.business.log.RemoteLogFeign;
@ -109,19 +110,19 @@ public class ApiLogAspect {
String url = apiLog.url();//请求地址 String url = apiLog.url();//请求地址
entity.setUrl(url); entity.setUrl(url);
Object[] args = joinPoint.getArgs();//请求体 Object[] args = joinPoint.getArgs();//请求体
StringBuilder builder = new StringBuilder();
for (int i = 0; i < args.length; i++) { if (args.length > 1) {
String json = JSON.toJSONString(args[i]); JSONArray objects = new JSONArray();
//判断最后一位 for (Object arg : args) {
if (i == args.length - 1) { String json = JSON.toJSONString(arg);
builder.append(json); objects.add(json);
} else { entity.setRequest(objects.toJSONString());
builder.append(json + ",");
} }
} else {
String jsonString = JSON.toJSONString(args[0]);
entity.setRequest(jsonString);
} }
entity.setMethod(apiLog.method()); entity.setMethod(apiLog.method());
entity.setRequest(builder.toString());
if (Objects.nonNull(jsonResult)) { if (Objects.nonNull(jsonResult)) {
entity.setResponse(jsonResult.toString()); entity.setResponse(jsonResult.toString());
} }

Loading…
Cancel
Save