diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java index 2c3d1da6..20c79012 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java @@ -440,8 +440,8 @@ public class EbomApi extends BaseApi { dto.setRealName("郑军榕"); dto.setDepartName("信息流程中心/IT支持"); dto.setFullDeptName("信息流程中心/IT支持"); - dto.setRowId(1585164668335439881l); - SessionUtil.loginUser.set(dto); + dto.setRowId(1585164668335439881L); + BaseApi.loginUser.set(dto); return ResultVO.success(); } diff --git a/nflg_project_dev/nflg-boot-base/nflg-boot-core/src/main/java/com/nflg/product/base/core/conmon/util/SessionUtil.java b/nflg_project_dev/nflg-boot-base/nflg-boot-core/src/main/java/com/nflg/product/base/core/conmon/util/SessionUtil.java index 7b60cd73..e833f0bb 100644 --- a/nflg_project_dev/nflg-boot-base/nflg-boot-core/src/main/java/com/nflg/product/base/core/conmon/util/SessionUtil.java +++ b/nflg_project_dev/nflg-boot-base/nflg-boot-core/src/main/java/com/nflg/product/base/core/conmon/util/SessionUtil.java @@ -1,10 +1,12 @@ package com.nflg.product.base.core.conmon.util; -import cn.hutool.core.util.StrUtil; import com.nflg.product.base.core.api.BaseApi; +import com.nflg.product.base.core.exception.NflgBusinessException; +import nflg.product.common.constant.STATE; import nflg.product.common.dto.LoginUserInfoDTO; -import java.util.*; +import java.util.List; +import java.util.Optional; /** * @decription @@ -12,7 +14,7 @@ import java.util.*; * @Date 2022/7/15 9:04 **/ public class SessionUtil { - public static ThreadLocal loginUser= BaseApi.loginUser; + //public static ThreadLocal loginUser= BaseApi.loginUser; /** * 获取登入用户编号 @@ -20,7 +22,8 @@ public class SessionUtil { * @return */ public static Long getRowId() { - return Optional.ofNullable(loginUser.get()).map(LoginUserInfoDTO::getRowId).orElse(1585164668335439881L); + //return Optional.ofNullable(loginUser.get()).map(LoginUserInfoDTO::getRowId).orElse(1585164668335439881L); + return getUser().getRowId(); } /** @@ -29,7 +32,9 @@ public class SessionUtil { * @return */ public static String getUserCode() { - return Optional.ofNullable(loginUser.get()).map(LoginUserInfoDTO::getUserCode).orElse("QHI17062100"); + //return Optional.ofNullable(loginUser.get()).map(LoginUserInfoDTO::getUserCode).orElse("QHI17062100"); + return getUser().getUserCode(); + } /** @@ -38,7 +43,8 @@ public class SessionUtil { * @return */ public static String getUserName() { - return Optional.ofNullable(loginUser.get()).map(LoginUserInfoDTO::getUserName).orElse("郑军榕"); + //return Optional.ofNullable(loginUser.get()).map(LoginUserInfoDTO::getUserName).orElse("郑军榕"); + return getUser().getUserName(); } /** @@ -47,48 +53,61 @@ public class SessionUtil { * @return */ public static Long getPartRowId() { - return Optional.ofNullable(loginUser.get()).map(LoginUserInfoDTO::getDepartRowId).orElse(null); + //return Optional.ofNullable(loginUser.get()).map(LoginUserInfoDTO::getDepartRowId).orElse(null); + return getUser().getDepartRowId(); } public static String getRealName() { - return Optional.ofNullable(loginUser.get()).map(LoginUserInfoDTO::getRealName).orElse("郑军榕"); + //return Optional.ofNullable(loginUser.get()).map(LoginUserInfoDTO::getRealName).orElse("郑军榕"); + return getUser().getRealName(); } public static String getDepartName() { - return Optional.ofNullable(loginUser.get()).map(LoginUserInfoDTO::getDepartName).orElse(null); + //return Optional.ofNullable(loginUser.get()).map(LoginUserInfoDTO::getDepartName).orElse(null); + return getUser().getDepartName(); } public static List getAruList() { - return Optional.ofNullable(loginUser.get()).map(LoginUserInfoDTO::getAruList).orElse(null); + //return Optional.ofNullable(loginUser.get()).map(LoginUserInfoDTO::getAruList).orElse(null); + return getUser().getAruList(); } // 获取岗位代码 public static Integer getQueryData() { - return Optional.ofNullable(loginUser.get()).map(LoginUserInfoDTO::getQueryData).orElse(null); + //return Optional.ofNullable(loginUser.get()).map(LoginUserInfoDTO::getQueryData).orElse(null); + return getUser().getQueryData(); } public static String getFullDeptName() { - return Optional.ofNullable(loginUser.get()).map(LoginUserInfoDTO::getFullDeptName).orElse(null); + //return Optional.ofNullable(loginUser.get()).map(LoginUserInfoDTO::getFullDeptName).orElse(null); + return getUser().getFullDeptName(); } - //获取2级部门以下 - public static String getSecondFullDeptName() { - String depName = Optional.ofNullable(loginUser.get()).map(LoginUserInfoDTO::getFullDeptName).orElse(""); - - depName= StrUtil.replace(depName,"OU=","").replace("福建南方路面机械有限公司,DC=nflg",""); - List depts = new ArrayList<>(Arrays.asList(StrUtil.split(depName, ","))); - depts.remove(""); - Collections.reverse(depts ); - return StrUtil.join("/",depts); - - - } + // //获取2级部门以下 + // public static String getSecondFullDeptName() { + // String depName = Optional.ofNullable(loginUser.get()).map(LoginUserInfoDTO::getFullDeptName).orElse(""); + // + // depName= StrUtil.replace(depName,"OU=","").replace("福建南方路面机械有限公司,DC=nflg",""); + // List depts = new ArrayList<>(Arrays.asList(StrUtil.split(depName, ","))); + // depts.remove(""); + // Collections.reverse(depts ); + // return StrUtil.join("/",depts); + // + // + // } public static String getLanguage() { - return Optional.ofNullable(loginUser.get()).map(LoginUserInfoDTO::getLanguage).orElse(""); + //return Optional.ofNullable(loginUser.get()).map(LoginUserInfoDTO::getLanguage).orElse(""); + return getUser().getLanguage(); } public static String getSessionKey() { - return Optional.ofNullable(loginUser.get()).map(LoginUserInfoDTO::getSessionKey).orElse(null); + //return Optional.ofNullable(loginUser.get()).map(LoginUserInfoDTO::getSessionKey).orElse(null); + return getUser().getSessionKey(); + } + + private static LoginUserInfoDTO getUser() { + return Optional.ofNullable(BaseApi.loginUser.get()) + .orElseThrow(() -> new NflgBusinessException(STATE.LoginError, "请登录")); } }