无关风月
2025-04-10 099ea14bba367fd86f0dde37d908f07cc04c3d39
ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java
@@ -1,6 +1,7 @@
package com.ruoyi.common.utils;
import com.ruoyi.common.core.domain.model.LoginUserApplet;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
@@ -13,6 +14,7 @@
 * 
 * @author ruoyi
 */
@Slf4j
public class SecurityUtils
{
    /**
@@ -44,7 +46,20 @@
            throw new ServiceException("获取部门ID异常", HttpStatus.UNAUTHORIZED);
        }
    }
    /**
     * 获取营业部ID
     **/
    public static String getBusinessDeptId()
    {
        try
        {
            return getLoginUser().getUser().getBusinessDeptId();
        }
        catch (Exception e)
        {
            throw new ServiceException("获取营业部ID异常", HttpStatus.UNAUTHORIZED);
        }
    }
    /**
     * 获取用户账户
     **/
@@ -56,8 +71,10 @@
        }
        catch (Exception e)
        {
            throw new ServiceException("获取用户账户异常", HttpStatus.UNAUTHORIZED);
            log.error("获取用户信息发生异常",e);
//            throw new ServiceException("获取用户账户异常", HttpStatus.UNAUTHORIZED);
        }
        return "";
    }
    /**
     * 获取用户账户小程序