mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-24 07:19:46 +08:00
update 数据库更改 对接多用户体系
This commit is contained in:
@ -64,6 +64,12 @@ public class SysUser extends BaseEntity {
|
||||
@Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 用户类型(sys_user系统用户)
|
||||
*/
|
||||
@ApiModelProperty(value = "用户类型")
|
||||
private String userType;
|
||||
|
||||
/**
|
||||
* 用户邮箱
|
||||
*/
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.ruoyi.common.core.domain.model;
|
||||
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
@ -85,8 +86,11 @@ public class LoginUser implements Serializable {
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 获取登录id
|
||||
*/
|
||||
public String getLoginId() {
|
||||
return userType + userId;
|
||||
return userType + LoginHelper.JOIN_CODE + userId;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,13 +1,23 @@
|
||||
package com.ruoyi.common.core.domain.model;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
|
||||
/**
|
||||
* 用户注册对象
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@ApiModel("用户注册对象")
|
||||
public class RegisterBody extends LoginBody {
|
||||
|
||||
}
|
||||
package com.ruoyi.common.core.domain.model;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 用户注册对象
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel("用户注册对象")
|
||||
public class RegisterBody extends LoginBody {
|
||||
|
||||
@ApiModelProperty(value = "用户类型")
|
||||
private String userType;
|
||||
|
||||
}
|
||||
|
@ -1,13 +1,12 @@
|
||||
package com.ruoyi.common.enums;
|
||||
|
||||
import com.ruoyi.common.exception.UtilException;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 设备类型
|
||||
* 针对两套 用户体系
|
||||
* 针对多套 用户体系
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@ -18,12 +17,12 @@ public enum UserType {
|
||||
/**
|
||||
* pc端
|
||||
*/
|
||||
SYS_USER("sys_user:"),
|
||||
SYS_USER("sys_user"),
|
||||
|
||||
/**
|
||||
* app端
|
||||
*/
|
||||
APP_USER("app_user:");
|
||||
APP_USER("app_user");
|
||||
|
||||
private final String userType;
|
||||
|
||||
|
@ -19,7 +19,9 @@ import lombok.NoArgsConstructor;
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class LoginHelper {
|
||||
|
||||
private static final String LOGIN_USER_KEY = "loginUser";
|
||||
public static final String JOIN_CODE = ":";
|
||||
public static final String LOGIN_USER_KEY = "loginUser";
|
||||
|
||||
private static final ThreadLocal<LoginUser> LOGIN_CACHE = new ThreadLocal<>();
|
||||
|
||||
/**
|
||||
@ -80,7 +82,9 @@ public class LoginHelper {
|
||||
String userId = null;
|
||||
for (UserType value : UserType.values()) {
|
||||
if (StringUtils.contains(loginId, value.getUserType())) {
|
||||
userId = StringUtils.replace(loginId, value.getUserType(), StringUtils.EMPTY);
|
||||
String[] strs = StringUtils.split(loginId, JOIN_CODE);
|
||||
// 用户id在总是在最后
|
||||
userId = strs[strs.length - 1];
|
||||
}
|
||||
}
|
||||
if (StringUtils.isBlank(userId)) {
|
||||
|
Reference in New Issue
Block a user