phanes
2022-01-16 868942e202aeb967b8ce47b38cc2433a636a128d
ruoyi-common/src/main/java/com/ruoyi/common/utils/LoginUtils.java
@@ -6,6 +6,8 @@
import com.ruoyi.common.enums.DeviceType;
import com.ruoyi.common.enums.UserType;
import com.ruoyi.common.exception.UtilException;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
/**
 * 登录鉴权工具
@@ -13,13 +15,15 @@
 *
 * @author Lion Li
 */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class LoginUtils {
    private final static String LOGIN_USER_KEY = "loginUser";
    private static final String LOGIN_USER_KEY = "loginUser";
    /**
     * 登录系统
     * 针对两套用户体系
     *
     * @param loginUser 登录用户信息
     */
    public static void login(LoginUser loginUser, UserType userType) {
@@ -30,6 +34,7 @@
    /**
     * 登录系统 基于 设备类型
     * 针对一套用户体系
     *
     * @param loginUser 登录用户信息
     */
    public static void loginByDevice(LoginUser loginUser, UserType userType, DeviceType deviceType) {
@@ -62,7 +67,7 @@
            String replace = "";
            if (StringUtils.contains(loginId, UserType.SYS_USER.getUserType())) {
                userId = StringUtils.replace(loginId, UserType.SYS_USER.getUserType(), replace);
            } else if (StringUtils.contains(loginId, UserType.APP_USER.getUserType())){
            } else if (StringUtils.contains(loginId, UserType.APP_USER.getUserType())) {
                userId = StringUtils.replace(loginId, UserType.APP_USER.getUserType(), replace);
            } else {
                throw new UtilException("登录用户: LoginId异常 => " + loginId);
@@ -97,7 +102,7 @@
    public static UserType getUserType(Object loginId) {
        if (StringUtils.contains(loginId.toString(), UserType.SYS_USER.getUserType())) {
            return UserType.SYS_USER;
        } else if (StringUtils.contains(loginId.toString(), UserType.APP_USER.getUserType())){
        } else if (StringUtils.contains(loginId.toString(), UserType.APP_USER.getUserType())) {
            return UserType.APP_USER;
        } else {
            throw new UtilException("登录用户: LoginId异常 => " + loginId);