疯狂的狮子li
2021-12-03 e763381186c3a1f74ed416ea79767ac73b984745
ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java
@@ -13,41 +13,13 @@
 * @author Long Li
 */
public class SecurityUtils {
    /**
     * 用户ID
     **/
    public static Long getUserId() {
        return LoginUtils.getUserId();
    }
    /**
     * 获取部门ID
     **/
    public static Long getDeptId() {
        try {
            return getUser().getDeptId();
        } catch (Exception e) {
            throw new ServiceException("获取部门ID异常", HttpStatus.HTTP_UNAUTHORIZED);
        }
    }
    /**
     * 获取用户账户
     **/
    public static String getUsername() {
        try {
            return getUser().getUserName();
        } catch (Exception e) {
            throw new ServiceException("获取用户账户异常", HttpStatus.HTTP_UNAUTHORIZED);
        }
    }
    /**
     * 获取用户
     **/
    public static SysUser getUser() {
        try {
            return SpringUtils.getBean(UserService.class).selectUserById(getUserId());
            return SpringUtils.getBean(UserService.class).selectUserById(LoginUtils.getUserId());
        } catch (Exception e) {
            throw new ServiceException("获取用户信息异常", HttpStatus.HTTP_UNAUTHORIZED);
        }