Search in sources :

Example 6 with UserType

use of com.ruoyi.common.enums.UserType in project RuoYi-Vue-Plus by JavaLionLi.

the class LoginHelper method getUserId.

/**
 * 获取用户id
 */
public static Long getUserId() {
    LoginUser loginUser = getLoginUser();
    if (ObjectUtil.isNull(loginUser)) {
        String loginId = StpUtil.getLoginIdAsString();
        String userId = null;
        for (UserType value : UserType.values()) {
            if (StringUtils.contains(loginId, value.getUserType())) {
                String[] strs = StringUtils.split(loginId, JOIN_CODE);
                // 用户id在总是在最后
                userId = strs[strs.length - 1];
            }
        }
        if (StringUtils.isBlank(userId)) {
            throw new UtilException("登录用户: LoginId异常 => " + loginId);
        }
        return Long.parseLong(userId);
    }
    return loginUser.getUserId();
}
Also used : UtilException(com.ruoyi.common.exception.UtilException) LoginUser(com.ruoyi.common.core.domain.model.LoginUser) UserType(com.ruoyi.common.enums.UserType)

Example 7 with UserType

use of com.ruoyi.common.enums.UserType in project RuoYi-Vue-Plus by JavaLionLi.

the class SaInterfaceImpl method getPermissionList.

@Override
public List<String> getPermissionList(Object loginId, String loginType) {
    LoginUser loginUser = LoginHelper.getLoginUser();
    UserType userType = UserType.getUserType(loginUser.getUserType());
    if (userType == UserType.SYS_USER) {
        return new ArrayList<>(loginUser.getMenuPermission());
    } else if (userType == UserType.APP_USER) {
    // app端权限返回 自行根据业务编写
    }
    return new ArrayList<>();
}
Also used : ArrayList(java.util.ArrayList) LoginUser(com.ruoyi.common.core.domain.model.LoginUser) UserType(com.ruoyi.common.enums.UserType)

Example 8 with UserType

use of com.ruoyi.common.enums.UserType in project RuoYi-Flowable-Plus by KonBAI-Q.

the class LoginHelper method getUserId.

/**
 * 获取用户id
 */
public static Long getUserId() {
    LoginUser loginUser = getLoginUser();
    if (ObjectUtil.isNull(loginUser)) {
        String loginId = StpUtil.getLoginIdAsString();
        String userId = null;
        for (UserType value : UserType.values()) {
            if (StringUtils.contains(loginId, value.getUserType())) {
                String[] strs = StringUtils.split(loginId, JOIN_CODE);
                // 用户id在总是在最后
                userId = strs[strs.length - 1];
            }
        }
        if (StringUtils.isBlank(userId)) {
            throw new UtilException("登录用户: LoginId异常 => " + loginId);
        }
        return Long.parseLong(userId);
    }
    return loginUser.getUserId();
}
Also used : UtilException(com.ruoyi.common.exception.UtilException) LoginUser(com.ruoyi.common.core.domain.model.LoginUser) UserType(com.ruoyi.common.enums.UserType)

Aggregations

LoginUser (com.ruoyi.common.core.domain.model.LoginUser)8 UserType (com.ruoyi.common.enums.UserType)8 ArrayList (java.util.ArrayList)4 UserAgent (cn.hutool.http.useragent.UserAgent)2 UserOnlineDTO (com.ruoyi.common.core.domain.dto.UserOnlineDTO)2 UtilException (com.ruoyi.common.exception.UtilException)2