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();
}
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<>();
}
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();
}
Aggregations