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

修改bug

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