ccj 2 lat temu
rodzic
commit
40bb9bf841

+ 10 - 0
winsea-haixin-plugin-wangluohuoyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/util/LogAspect.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.aliyun.oss.HttpMethod;
 import com.winsea.svc.base.security.entity.User;
 import com.winsea.svc.base.security.util.AuthSecurityUtils;
+import com.yh.saas.plugin.yiliangyiyun.entity.CommonUser;
 import com.yh.saas.plugin.yiliangyiyun.entity.HyOperLog;
 import com.yh.saas.plugin.yiliangyiyun.service.IHyOperLogService;
 import lombok.extern.slf4j.Slf4j;
@@ -12,6 +13,7 @@ import org.aspectj.lang.JoinPoint;
 import org.aspectj.lang.annotation.AfterReturning;
 import org.aspectj.lang.annotation.Aspect;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.stereotype.Component;
 import org.springframework.validation.BindingResult;
 import org.springframework.web.multipart.MultipartFile;
@@ -39,6 +41,8 @@ public class LogAspect {
     @Autowired
     private IHyOperLogService operLogService;
 
+    @Autowired
+    private StringRedisTemplate userRedisTemplate;
     /**
      * 处理完请求后执行
      * @param joinPoint 切点
@@ -60,6 +64,12 @@ public class LogAspect {
                     operLog.setCreateUserId(accountId);
                 }
             }
+            else{
+                CommonUser commonUser =  JSONObject.parseObject(userRedisTemplate.opsForValue().get(Const.USER_REDIS_PREFIX + ServletUtils.getRequest().getHeader("accessToken")),CommonUser.class);
+                if(commonUser != null){
+                    operLog.setCreateUserId(commonUser.getId());
+                }
+            }
             operLog.setStatus("成功");
             // 请求的IP地址
             String iP = ServletUtil.getClientIP(ServletUtils.getRequest());

+ 2 - 1
winsea-haixin-plugin-wangluohuoyun/src/main/resources/mapper/HyOperLogMapper.xml

@@ -37,11 +37,12 @@
         o.request_method as requestMethod,
         o.request_value as requestValue,
         o.json_result as jsonResult,
-        c.staff_name as operator,
+        IFNULL(c.staff_name,u.user_name) as operator,
         o.create_date as createDate,
         o.update_date as updateDate
         FROM hy_oper_log o
         left join common_staff c on c.staff_id=o.create_user_id AND c.delete_flag = '0'
+        left join common_user u on u.id = o.create_user_id
         WHERE o.delete_flag = '0'
         <if test="searchKeyWord != null and searchKeyWord != ''">
             AND (lower(o.title) like lower(CONCAT('%',#{searchKeyWord},'%'))