feat: 东区缴费分支初始化
This commit is contained in:
+2
-14
@@ -3,7 +3,6 @@ package com.yida.data.log.aspect;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yida.data.common.core.entity.CurrentUser;
|
||||
import com.yida.data.common.core.exception.FebsException;
|
||||
import com.yida.data.common.core.utils.FebsUtil;
|
||||
import com.yida.data.log.service.LogService;
|
||||
@@ -61,24 +60,13 @@ public class OperationLogAspect {
|
||||
public Object insertOperationLog(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
//返回结果
|
||||
Object result;
|
||||
HttpServletRequest request = ((ServletRequestAttributes) Objects
|
||||
.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
|
||||
HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
|
||||
//请求参数
|
||||
String params = getRequestParams(joinPoint, request);
|
||||
//执行接口
|
||||
result = joinPoint.proceed();
|
||||
//异步保存日志
|
||||
Long createId = null;
|
||||
String createName = null;
|
||||
if (FebsUtil.isLogin()) {
|
||||
CurrentUser currentUser = FebsUtil.getCurrentUser();
|
||||
if (currentUser != null) {
|
||||
createId = currentUser.getUserId();
|
||||
createName = currentUser.getUsername();
|
||||
}
|
||||
}
|
||||
logService.saveOperationLog(joinPoint, FebsUtil.getHttpServletRequestIpAddress(), params, result, createId,
|
||||
createName);
|
||||
logService.saveOperationLog(joinPoint, FebsUtil.getHttpServletRequestIpAddress(), params, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+12
-15
@@ -15,7 +15,6 @@ import com.yida.data.log.annotation.OperationLog;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
@@ -50,23 +49,21 @@ public class LogService {
|
||||
* @author ZYJ
|
||||
* @date 2021/1/8 16:30
|
||||
*/
|
||||
@Async
|
||||
public void saveOperationLog(JoinPoint joinPoint, String ip, String params, Object result, Long createId, String createName) {
|
||||
//@Async
|
||||
public void saveOperationLog(JoinPoint joinPoint, String ip, String params, Object result) {
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
Method method = signature.getMethod();
|
||||
OperationLog opLog = method.getAnnotation(OperationLog.class);
|
||||
//ip地址
|
||||
Log systemLogInfo = new Log();
|
||||
systemLogInfo.setCreateId(createId);
|
||||
systemLogInfo.setCreateName(createName);
|
||||
// 创建人
|
||||
// if (FebsUtil.isLogin()) {
|
||||
// CurrentUser currentUser = FebsUtil.getCurrentUser();
|
||||
// if (currentUser != null) {
|
||||
// systemLogInfo.setCreateId(currentUser.getUserId());
|
||||
// systemLogInfo.setCreateName(currentUser.getUsername());
|
||||
// }
|
||||
// }
|
||||
if (FebsUtil.isLogin()) {
|
||||
CurrentUser currentUser = FebsUtil.getCurrentUser();
|
||||
if (currentUser != null) {
|
||||
systemLogInfo.setCreateId(currentUser.getUserId());
|
||||
systemLogInfo.setCreateName(currentUser.getUsername());
|
||||
}
|
||||
}
|
||||
systemLogInfo.setIp(ip);
|
||||
//设置开始时间
|
||||
systemLogInfo.setStartTime(LocalDateTime.now());
|
||||
@@ -87,8 +84,8 @@ public class LogService {
|
||||
systemLogInfo.setResult(JSON.toJSONString(result));
|
||||
//将返回值转换为对象
|
||||
ResultBean<Object> logResult = JSON.parseObject(JSON.toJSONString(result),
|
||||
new TypeReference<ResultBean<Object>>() {
|
||||
});
|
||||
new TypeReference<ResultBean<Object>>() {
|
||||
});
|
||||
int successStatus = 200;
|
||||
if (logResult != null) {
|
||||
if (logResult.getStatus() == successStatus) {
|
||||
@@ -112,7 +109,7 @@ public class LogService {
|
||||
systemLogInfo.setEndTime(LocalDateTime.now());
|
||||
//操作时长
|
||||
systemLogInfo.setOperationTime(LocalDateTimeUtil.between(systemLogInfo.getStartTime(),
|
||||
systemLogInfo.getEndTime(), ChronoUnit.MILLIS));
|
||||
systemLogInfo.getEndTime(), ChronoUnit.MILLIS));
|
||||
//保存数据到redis list数据
|
||||
redisService.lSet(CachePrefixConstant.OPERATION_LOG_LIST, systemLogInfo);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user