Commit c8d6c5b0 authored by 周健威's avatar 周健威

Merge branch 'dev' into base-modify

parents dc092f8f 702ff965
......@@ -35,7 +35,14 @@ public interface CommonLogService {
* @param xxLogEntity
* @param result
*/
void initCommonLogLastPart(XxLogEntity xxLogEntity, BaseResponse result);
void initCommonLogLastPart(XxLogEntity xxLogEntity, Object result);
/**
* 初始化日志后半部分(String)
* @param xxLogEntity
* @param result
*/
void initCommonLogLastPart(XxLogEntity xxLogEntity, String result);
/**
......
......@@ -103,10 +103,15 @@ public class CommonLogServiceImpl implements CommonLogService {
}
@Override
public void initCommonLogLastPart(XxLogEntity xxLogEntity, BaseResponse result) {
public void initCommonLogLastPart(XxLogEntity xxLogEntity, Object 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;
import com.github.wxiaoqi.security.common.msg.BaseResponse;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
......@@ -26,6 +29,7 @@ import javax.servlet.http.HttpServletResponse;
*/
@Aspect
@Component
@Slf4j
public class XxLogInterceptor{
@Autowired
......@@ -46,22 +50,32 @@ public class XxLogInterceptor{
Object[] params = pjp.getArgs();//获取请求参数
MethodSignature signature = (MethodSignature) pjp.getSignature();
if(params != null && params.length > 0) {
try{
xxLogEntity.setRequestData(JSON.toJSONString(params[0]));
}catch (Exception e) {
log.error(e.getMessage(), e);
}
}
Object result = new Object();
try{
//###################上面代码为方法执行前#####################
result = pjp.proceed();//执行方法,获取返回参数
//###################下面代码为方法执行后#####################
commonLogService.initCommonLogLastPart(xxLogEntity, (BaseResponse) result);
if(result instanceof JSONObject) {
commonLogService.initCommonLogLastPart(xxLogEntity, ((JSONObject) result).toJSONString());
}else{
commonLogService.initCommonLogLastPart(xxLogEntity, result);
}
}catch (BaseException e){
commonLogService.initCommonLogLastPart(xxLogEntity, ObjectRestResponse.createFailedResult(e.getStatus(), e.getMessage()));
}catch (Exception e){
commonLogService.initCommonLogLastPart(xxLogEntity, (BaseResponse) result);
xxLogEntity.setResponseData(JSON.toJSONString(ObjectRestResponse.createDefaultFail()));
commonLogService.initCommonLogLastPart(xxLogEntity, ObjectRestResponse.createFailedResult(500, e.getMessage()));
throw e;
}finally {
commonLogService.commonLog(xxLogEntity);
}
return result;
}
......
......@@ -24,6 +24,7 @@ import org.springframework.stereotype.Service;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
......@@ -347,9 +348,18 @@ public class CertificationService {
return ObjectRestResponse.succ();
}
Date expirationDate = new Date();
if (!Validation.isDate(endDate)) {
Date date = new Date();
Calendar c = Calendar.getInstance();
c.setTime(date);
c.add(Calendar.YEAR, 100);
expirationDate = c.getTime();
} else {
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
formatter.setLenient(false);
Date expirationDate = null;
try {
expirationDate = formatter.parse(endDate);
} catch (ParseException e) {
......@@ -358,6 +368,8 @@ public class CertificationService {
return ObjectRestResponse.createDefaultFail();
}
}
idInformation.setExpirationDate(expirationDate);
......
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