Commit 6f2732de authored by 周健威's avatar 周健威

修改bug

parent 7899f85d
......@@ -37,6 +37,13 @@ public interface CommonLogService {
*/
void initCommonLogLastPart(XxLogEntity xxLogEntity, BaseResponse result);
/**
* 初始化日志后半部分(String)
* @param xxLogEntity
* @param result
*/
void initCommonLogLastPart(XxLogEntity xxLogEntity, String result);
/**
* 初始化FeignClient日志前半部分
......
......@@ -104,9 +104,14 @@ public class CommonLogServiceImpl implements CommonLogService {
@Override
public void initCommonLogLastPart(XxLogEntity xxLogEntity, BaseResponse result) {
initCommonLogLastPart(xxLogEntity, JSON.toJSONString(result));
}
@Override
public void initCommonLogLastPart(XxLogEntity xxLogEntity, String result) {
LocalDateTime endTime = LocalDateTime.now();//结束时间
xxLogEntity.setEndDate(endTime.toString());
xxLogEntity.setResponseData(JSON.toJSONString(result));
xxLogEntity.setResponseData(result);
}
@Override
......
package com.github.wxiaoqi.security.common.log;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.log.CommonLogService;
import com.github.wxiaoqi.security.common.log.entity.XxLogEntity;
......@@ -54,7 +55,11 @@ public class XxLogInterceptor{
//###################上面代码为方法执行前#####################
result = pjp.proceed();//执行方法,获取返回参数
//###################下面代码为方法执行后#####################
if(result instanceof JSONObject) {
commonLogService.initCommonLogLastPart(xxLogEntity, ((JSONObject) result).toJSONString());
}else{
commonLogService.initCommonLogLastPart(xxLogEntity, (BaseResponse) result);
}
}catch (BaseException e){
commonLogService.initCommonLogLastPart(xxLogEntity, ObjectRestResponse.createFailedResult(e.getStatus(), e.getMessage()));
}catch (Exception e){
......
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