Browse Source

1、修改获取不到userId和enterpriseId提示错误问题

rayson 6 months ago
parent
commit
4e8afa806d

+ 3 - 2
menduner/menduner-common/src/main/java/com/citu/module/menduner/common/util/LoginUserContext.java

@@ -7,6 +7,7 @@ import com.citu.framework.security.core.LoginUser;
 import com.citu.framework.security.core.util.SecurityFrameworkUtils;
 
 import static com.citu.framework.common.exception.enums.GlobalErrorCodeConstants.FORBIDDEN;
+import static com.citu.framework.common.exception.enums.GlobalErrorCodeConstants.UNAUTHORIZED;
 import static com.citu.framework.common.exception.util.ServiceExceptionUtil.exception;
 
 /**
@@ -24,7 +25,7 @@ public class LoginUserContext {
         LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
         if (null == loginUser) {
             // 没权限
-            throw exception(FORBIDDEN);
+            throw exception(UNAUTHORIZED);
         }
         return loginUser;
     }
@@ -76,7 +77,7 @@ public class LoginUserContext {
      **/
     public static Long getEnterpriseId(LoginUser loginUser) {
         if (!checkEnterprise(loginUser)) {
-            throw exception(FORBIDDEN);
+            throw exception(UNAUTHORIZED);
         }
         return Long.valueOf(loginUser.getInfo().get(LoginUser.INFO_KEY_DATA_ID));
     }