Browse Source

add datanum

18339543638 3 years ago
parent
commit
1c46792095

+ 7 - 2
nb-common/config-common/src/main/java/com/nb/common/config/mybatisplus/handler/CreateAndUpdateMetaObjectHandler.java

@@ -36,6 +36,12 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
     @Override
     public void insertFill(MetaObject metaObject) {
         try {
+            LoginUser loginUser =null;
+            try {
+                loginUser= SecurityUtil.getLoginUser();
+            }catch (Exception __){
+
+            }
             if (metaObject.hasGetter(CREATE_TIME) && metaObject.getValue(CREATE_TIME) == null) {
                 this.strictInsertFill(metaObject, CREATE_TIME, Date.class, new Date());
             }
@@ -43,14 +49,13 @@ public class CreateAndUpdateMetaObjectHandler implements MetaObjectHandler {
                 this.strictInsertFill(metaObject, IS_DELETE, Integer.class,0);
             }
             if (metaObject.hasGetter(CREATE_BY) && metaObject.getValue(CREATE_BY) == null) {
-                LoginUser loginUser = SecurityUtil.getLoginUser();
+
                 this.strictInsertFill(metaObject, CREATE_BY, String.class, Objects.isNull(loginUser) ? "1" : loginUser.getId().toString());
             }
             if (metaObject.hasGetter(UPDATE_TIME) && metaObject.getValue(UPDATE_TIME) == null) {
                 this.strictUpdateFill(metaObject, UPDATE_TIME, Date.class, new Date());
             }
             if (metaObject.hasGetter(UPDATE_BY) && metaObject.getValue(UPDATE_BY) == null) {
-                LoginUser loginUser = SecurityUtil.getLoginUser();
                 this.strictUpdateFill(metaObject, UPDATE_BY, String.class, Objects.isNull(loginUser) ? "1" : loginUser.getId().toString());
             }
             if (metaObject.hasGetter(TENANT_ID) && metaObject.getValue(TENANT_ID) == null) {

+ 5 - 3
nb-service/app-doctor/src/main/java/com/nb/app/doctor/auth/AppDoctorAuthGranter.java

@@ -1,5 +1,6 @@
 package com.nb.app.doctor.auth;
 
+import cn.dev33.satoken.stp.StpLogic;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.nb.app.doctor.api.entity.AppDoctorUserEntity;
@@ -63,9 +64,10 @@ public class AppDoctorAuthGranter implements IAuthGranter {
         log.info("登录用户:{}", source.getUsername());
 
         // 登录
-        SecurityUtil.getStpLogic().login(user.getId());
+        StpLogic stpLogic = SecurityUtil.getStpLogic(StpTypeEnum.APP_DOCTOR.getText());
+        stpLogic.login(user.getId());
         LoginUser<String> loginUser = new LoginUser();
-        loginUser.setToken(SecurityUtil.getStpLogic(StpTypeEnum.APP_DOCTOR.getText()).getTokenValue());
+        loginUser.setToken(stpLogic.getTokenValue());
         loginUser.setUserPlatform(UserPlatformEnum.APP_DOCTOR.getCode());
         loginUser.setGrantType(source.getGrantType());
         loginUser.setUsername(source.getUsername());
@@ -74,7 +76,7 @@ public class AppDoctorAuthGranter implements IAuthGranter {
         loginUser.setLoginType(StpTypeEnum.APP_DOCTOR.getText());
         fillUserAgentInfo(loginUser);
         // 设置用户信息
-        SecurityUtil.getStpLogic(StpTypeEnum.APP_DOCTOR.getText()).getTokenSessionByToken(loginUser.getToken(),true).set(LOGIN_USER_KEY,loginUser);
+        stpLogic.getTokenSessionByToken(loginUser.getToken(),true).set(LOGIN_USER_KEY,loginUser);
         return loginUser;
     }
 }