Commit a2441f43 authored by liqin's avatar liqin 💬

bug fixed

parent 192d64ac
package cn.wisenergy.chnmuseum.party.common.log; package cn.wisenergy.chnmuseum.party.common.log;
import cn.wisenergy.chnmuseum.party.auth.util.JwtTokenUtil; import cn.wisenergy.chnmuseum.party.auth.util.JwtTokenUtil;
import cn.wisenergy.chnmuseum.party.common.enums.*; import cn.wisenergy.chnmuseum.party.common.enums.*;
import cn.wisenergy.chnmuseum.party.common.util.DateUtil80; import cn.wisenergy.chnmuseum.party.common.util.DateUtil80;
import cn.wisenergy.chnmuseum.party.common.vo.AuditStatusParam; import cn.wisenergy.chnmuseum.party.common.vo.AuditStatusParam;
import cn.wisenergy.chnmuseum.party.common.vo.GenericPageParam; import cn.wisenergy.chnmuseum.party.common.vo.GenericPageParam;
import cn.wisenergy.chnmuseum.party.core.annotations.OperationLog;
import cn.wisenergy.chnmuseum.party.mapper.SysLogMapper; import cn.wisenergy.chnmuseum.party.mapper.SysLogMapper;
import cn.wisenergy.chnmuseum.party.model.*; import cn.wisenergy.chnmuseum.party.model.*;
import cn.wisenergy.chnmuseum.party.service.CopyrightOwnerService;
import cn.wisenergy.chnmuseum.party.service.TOperationLogService; import cn.wisenergy.chnmuseum.party.service.TOperationLogService;
import cn.wisenergy.chnmuseum.party.service.impl.AuditServiceImpl; import cn.wisenergy.chnmuseum.party.service.impl.AuditServiceImpl;
import cn.wisenergy.chnmuseum.party.service.impl.CopyrightOwnerServiceImpl; import cn.wisenergy.chnmuseum.party.service.impl.CopyrightOwnerServiceImpl;
import cn.wisenergy.chnmuseum.party.service.impl.TUserServiceImpl; import cn.wisenergy.chnmuseum.party.service.impl.TUserServiceImpl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import javassist.util.HotSwapper;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.AuthenticationException;
import org.aspectj.lang.JoinPoint; import org.aspectj.lang.JoinPoint;
...@@ -39,11 +34,10 @@ import java.lang.reflect.Method; ...@@ -39,11 +34,10 @@ import java.lang.reflect.Method;
import java.net.InetAddress; import java.net.InetAddress;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import static cn.wisenergy.chnmuseum.party.common.enums.CopyrightOwnerTypeEnum.*; import static cn.wisenergy.chnmuseum.party.common.enums.CopyrightOwnerTypeEnum.VIDEO_CONTENT;
@Service @Service
@Aspect @Aspect
...@@ -66,7 +60,6 @@ class SystemOperationLogService extends ServiceImpl<SysLogMapper, SysLog> { ...@@ -66,7 +60,6 @@ class SystemOperationLogService extends ServiceImpl<SysLogMapper, SysLog> {
private TOperationLogService operationLogService; private TOperationLogService operationLogService;
public SystemOperationLogService() { public SystemOperationLogService() {
System.out.println("Aop");
} }
public TUser getCurAdmin(HttpServletRequest request) { public TUser getCurAdmin(HttpServletRequest request) {
...@@ -75,8 +68,7 @@ class SystemOperationLogService extends ServiceImpl<SysLogMapper, SysLog> { ...@@ -75,8 +68,7 @@ class SystemOperationLogService extends ServiceImpl<SysLogMapper, SysLog> {
throw new AuthenticationException("token失效,请重新登录"); throw new AuthenticationException("token失效,请重新登录");
} }
String username = JwtTokenUtil.getUsername(header); String username = JwtTokenUtil.getUsername(header);
TUser user = userService.selectByUsername(username); return userService.selectByUsername(username);
return user;
} }
/** /**
...@@ -86,7 +78,6 @@ class SystemOperationLogService extends ServiceImpl<SysLogMapper, SysLog> { ...@@ -86,7 +78,6 @@ class SystemOperationLogService extends ServiceImpl<SysLogMapper, SysLog> {
public void methodCachePointcut() { public void methodCachePointcut() {
} }
/** /**
* 切面 * 切面
* *
...@@ -96,12 +87,10 @@ class SystemOperationLogService extends ServiceImpl<SysLogMapper, SysLog> { ...@@ -96,12 +87,10 @@ class SystemOperationLogService extends ServiceImpl<SysLogMapper, SysLog> {
*/ */
@Around("methodCachePointcut()") @Around("methodCachePointcut()")
public Object around(ProceedingJoinPoint point) throws Throwable { public Object around(ProceedingJoinPoint point) throws Throwable {
HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder
.getRequestAttributes()).getRequest();
MethodLog methodLog = getAnnotationLog(point); MethodLog methodLog = getAnnotationLog(point);
String ip = getIp(request); String ip = getIp(request);
TUser user = null; TUser user;
try { try {
user = getCurAdmin(request); user = getCurAdmin(request);
} catch (Exception e) { } catch (Exception e) {
...@@ -118,22 +107,9 @@ class SystemOperationLogService extends ServiceImpl<SysLogMapper, SysLog> { ...@@ -118,22 +107,9 @@ class SystemOperationLogService extends ServiceImpl<SysLogMapper, SysLog> {
return getFailResult(); return getFailResult();
} }
} }
String operatingcontent = ""; Object[] method_param;
Object[] method_param = null; Object object = point.proceed();
method_param = point.getArgs(); //获取方法参数
Object object = null;
try {
method_param = point.getArgs(); //获取方法参数
// String param=(String) point.proceed(point.getArgs());
object = point.proceed();
} catch (Exception e) {
// 异常处理记录日志..
e.printStackTrace();
return getFailResult();
}
// getMethodLog(user,methodLog,method_param);
if (OperModule.STBOPERATION.getMsg().equals(methodLog.operModule().getMsg())) { if (OperModule.STBOPERATION.getMsg().equals(methodLog.operModule().getMsg())) {
TOperationLog operationLog = new TOperationLog(); TOperationLog operationLog = new TOperationLog();
operationLog.setCreateTime(LocalDateTime.now()); operationLog.setCreateTime(LocalDateTime.now());
...@@ -151,13 +127,11 @@ class SystemOperationLogService extends ServiceImpl<SysLogMapper, SysLog> { ...@@ -151,13 +127,11 @@ class SystemOperationLogService extends ServiceImpl<SysLogMapper, SysLog> {
} }
sysLog.setOperator(user.getUserName()); sysLog.setOperator(user.getUserName());
sysLog.setOperationIp(ip); sysLog.setOperationIp(ip);
// sysLog.setOperationContent(methodName); // sysLog.setOperationContent(methodName);
sysLog.setOperationTime(DateUtil80.getDateTimeOfTimestamp(System.currentTimeMillis())); sysLog.setOperationTime(DateUtil80.getDateTimeOfTimestamp(System.currentTimeMillis()));
// 处理设置注解上的参数 // 处理设置注解上的参数
getControllerMethodDescription(user, methodLog, sysLog, method_param); getControllerMethodDescription(user, methodLog, sysLog, method_param);
sysLogMapper.insert(sysLog);
int insert = sysLogMapper.insert(sysLog);
return object; return object;
} }
...@@ -258,7 +232,7 @@ class SystemOperationLogService extends ServiceImpl<SysLogMapper, SysLog> { ...@@ -258,7 +232,7 @@ class SystemOperationLogService extends ServiceImpl<SysLogMapper, SysLog> {
sysLog.setOperationType(OperType.LOWER.getMsg()); sysLog.setOperationType(OperType.LOWER.getMsg());
} }
} else if (methodLog.operModule().getCode() == OperModule.VIDEOCOPYRIGHT.getCode()) { } else if (methodLog.operModule().getCode() == OperModule.VIDEOCOPYRIGHT.getCode()) {
GenericPageParam g = (GenericPageParam) method_param[0]; GenericPageParam g = (GenericPageParam) method_param[0];
if (VIDEO_CONTENT.name().equals(g.getOwnerType())) { if (VIDEO_CONTENT.name().equals(g.getOwnerType())) {
sysLog.setOperationObject(OperModule.VIDEOCOPYRIGHT.getMsg()); sysLog.setOperationObject(OperModule.VIDEOCOPYRIGHT.getMsg());
......
...@@ -138,11 +138,11 @@ public class GlobalExceptionAdvisor { ...@@ -138,11 +138,11 @@ public class GlobalExceptionAdvisor {
String message = Splitter.on(System.lineSeparator()).trimResults().splitToList(localizedMessage).get(1); String message = Splitter.on(System.lineSeparator()).trimResults().splitToList(localizedMessage).get(1);
String substring = message.substring(message.indexOf("Exception:")); String substring = message.substring(message.indexOf("Exception:"));
if (substring.toUpperCase().contains("NAME")) { if (substring.toUpperCase().contains("NAME")) {
return new cn.wisenergy.chnmuseum.party.common.validator.HttpResult("400", "名称已存在"); return new cn.wisenergy.chnmuseum.party.common.validator.HttpResult("400", "名称已存在", "");
} else if (substring.toUpperCase().contains("CODE")) { } else if (substring.toUpperCase().contains("CODE")) {
return new cn.wisenergy.chnmuseum.party.common.validator.HttpResult("400", "编码已存在"); return new cn.wisenergy.chnmuseum.party.common.validator.HttpResult("400", "编码已存在", "");
} }
return new cn.wisenergy.chnmuseum.party.common.validator.HttpResult("400", message); return new cn.wisenergy.chnmuseum.party.common.validator.HttpResult("400", message, "");
} }
@ExceptionHandler(SQLIntegrityConstraintViolationException.class) @ExceptionHandler(SQLIntegrityConstraintViolationException.class)
......
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