移除租户相关信息
This commit is contained in:
parent
9221f64f2e
commit
cebe648db9
@ -76,9 +76,6 @@ public class AuthController {
|
||||
return R.fail(MessageUtils.message("auth.grant.type.error"));
|
||||
}
|
||||
|
||||
// TODO:校验租户
|
||||
//loginService.checkTenant(loginBody.getTenantId());
|
||||
|
||||
// 登录
|
||||
return R.ok(IAuthStrategy.login(loginBody, client));
|
||||
}
|
||||
@ -137,7 +134,6 @@ public class AuthController {
|
||||
*/
|
||||
@PostMapping("LoginHelper.getUserId()")
|
||||
public R<Void> register(@Validated @RequestBody RegisterBody user) {
|
||||
//if (!configService.selectRegisterEnabled(user.getTenantId())) // TODO:注册代码
|
||||
{
|
||||
return R.fail("当前系统没有开启注册功能!");
|
||||
}
|
||||
|
@ -13,15 +13,12 @@ import com.ruoyi.common.core.utils.SpringUtils;
|
||||
import com.ruoyi.common.log.event.LogininforEvent;
|
||||
import com.ruoyi.common.redis.utils.RedisUtils;
|
||||
import com.ruoyi.common.security.utils.LoginHelper;
|
||||
import com.ruoyi.common.tenant.helper.TenantHelper;
|
||||
import com.ruoyi.system.domain.SysUser;
|
||||
import com.ruoyi.system.domain.bo.SysUserBo;
|
||||
import com.ruoyi.system.domain.vo.SysUserVo;
|
||||
import com.ruoyi.system.service.ISysPermissionService;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.ruoyi.common.core.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.core.utils.DateUtils;
|
||||
import com.ruoyi.common.core.utils.MessageUtils;
|
||||
@ -57,7 +54,7 @@ public class SysLoginService {
|
||||
/**
|
||||
* 登录校验
|
||||
*/
|
||||
public void checkLogin(LoginType loginType, Long tenantId, String username, Supplier<Boolean> supplier) {
|
||||
public void checkLogin(LoginType loginType, String username, Supplier<Boolean> supplier) {
|
||||
String errorKey = GlobalConstants.PWD_ERR_CNT_KEY + username;
|
||||
String loginFail = Constants.LOGIN_FAIL;
|
||||
|
||||
@ -65,7 +62,7 @@ public class SysLoginService {
|
||||
int errorNumber = ObjectUtil.defaultIfNull(RedisUtils.getCacheObject(errorKey), 0);
|
||||
// 锁定时间内登录 则踢出
|
||||
if (errorNumber >= maxRetryCount) {
|
||||
recordLogininfor(tenantId, username, loginFail, MessageUtils.message(loginType.getRetryLimitExceed(), maxRetryCount, lockTime));
|
||||
recordLogininfor(username, loginFail, MessageUtils.message(loginType.getRetryLimitExceed(), maxRetryCount, lockTime));
|
||||
throw new UserException(loginType.getRetryLimitExceed(), maxRetryCount, lockTime);
|
||||
}
|
||||
|
||||
@ -75,11 +72,11 @@ public class SysLoginService {
|
||||
RedisUtils.setCacheObject(errorKey, errorNumber, Duration.ofMinutes(lockTime));
|
||||
// 达到规定错误次数 则锁定登录
|
||||
if (errorNumber >= maxRetryCount) {
|
||||
recordLogininfor(tenantId, username, loginFail, MessageUtils.message(loginType.getRetryLimitExceed(), maxRetryCount, lockTime));
|
||||
recordLogininfor(username, loginFail, MessageUtils.message(loginType.getRetryLimitExceed(), maxRetryCount, lockTime));
|
||||
throw new UserException(loginType.getRetryLimitExceed(), maxRetryCount, lockTime);
|
||||
} else {
|
||||
// 未达到规定错误次数
|
||||
recordLogininfor(tenantId, username, loginFail, MessageUtils.message(loginType.getRetryLimitCount(), errorNumber));
|
||||
recordLogininfor(username, loginFail, MessageUtils.message(loginType.getRetryLimitCount(), errorNumber));
|
||||
throw new UserException(loginType.getRetryLimitCount(), errorNumber);
|
||||
}
|
||||
}
|
||||
@ -88,28 +85,11 @@ public class SysLoginService {
|
||||
RedisUtils.deleteObject(errorKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验租户
|
||||
*
|
||||
* @param tenantId 租户ID
|
||||
*/
|
||||
public void checkTenant(String tenantId) {
|
||||
if (!TenantHelper.isEnable()) {
|
||||
return;
|
||||
}
|
||||
if (TenantConstants.DEFAULT_TENANT_ID.equals(tenantId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//TODO:完善heckTenant功能
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建登录用户
|
||||
*/
|
||||
public LoginUser buildLoginUser(SysUserVo user) {
|
||||
LoginUser loginUser = new LoginUser();
|
||||
loginUser.setTenantId(user.getTenantId());
|
||||
loginUser.setUserId(user.getUserId());
|
||||
loginUser.setDeptId(user.getDeptId());
|
||||
loginUser.setUsername(user.getUserName());
|
||||
@ -140,14 +120,12 @@ public class SysLoginService {
|
||||
/**
|
||||
* 记录租户登录信息
|
||||
*
|
||||
* @param tenantId 租户ID
|
||||
* @param username 用户名
|
||||
* @param status 状态
|
||||
* @param message 消息内容
|
||||
*/
|
||||
public void recordLogininfor(Long tenantId, String username, String status, String message) {
|
||||
public void recordLogininfor(String username, String status, String message) {
|
||||
LogininforEvent logininforEvent = new LogininforEvent();
|
||||
logininforEvent.setTenantId(tenantId);
|
||||
logininforEvent.setUsername(username);
|
||||
logininforEvent.setStatus(status);
|
||||
logininforEvent.setMessage(message);
|
||||
@ -161,11 +139,7 @@ public class SysLoginService {
|
||||
public void logout() {
|
||||
try {
|
||||
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||
if (TenantHelper.isEnable() && LoginHelper.isSuperAdmin()) {
|
||||
// 超级管理员 登出清除动态租户
|
||||
TenantHelper.clearDynamic();
|
||||
}
|
||||
recordLogininfor(loginUser.getTenantId(), loginUser.getUsername(), Constants.LOGOUT, MessageUtils.message("user.logout.success"));
|
||||
recordLogininfor(loginUser.getUsername(), Constants.LOGOUT, MessageUtils.message("user.logout.success"));
|
||||
} catch (NotLoginException ignored) {
|
||||
} finally {
|
||||
try {
|
||||
|
@ -9,7 +9,6 @@ import com.ruoyi.common.core.utils.SpringUtils;
|
||||
import com.ruoyi.common.log.event.LogininforEvent;
|
||||
import com.ruoyi.common.redis.utils.RedisUtils;
|
||||
import com.ruoyi.common.web.config.properties.CaptchaProperties;
|
||||
import com.ruoyi.system.domain.SysUser;
|
||||
import com.ruoyi.system.domain.bo.SysUserBo;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -45,7 +44,6 @@ public class SysRegisterService
|
||||
*/
|
||||
public void register(RegisterBody registerBody)
|
||||
{
|
||||
Long tenantId = registerBody.getTenantId();
|
||||
String username = registerBody.getUsername();
|
||||
String password = registerBody.getPassword();
|
||||
// 校验用户类型是否存在
|
||||
@ -54,7 +52,7 @@ public class SysRegisterService
|
||||
boolean captchaEnabled = captchaProperties.getEnable();
|
||||
// 验证码开关
|
||||
if (captchaEnabled) {
|
||||
validateCaptcha(tenantId, username, registerBody.getCode(), registerBody.getUuid());
|
||||
validateCaptcha(username, registerBody.getCode(), registerBody.getUuid());
|
||||
}
|
||||
SysUserBo sysUser = new SysUserBo();
|
||||
sysUser.setUserName(username);
|
||||
@ -65,31 +63,30 @@ public class SysRegisterService
|
||||
if (!userService.checkUserNameUnique(sysUser)) {
|
||||
throw new UserException("user.register.save.error", username);
|
||||
}
|
||||
boolean regFlag = userService.registerUser(sysUser, tenantId);
|
||||
boolean regFlag = userService.registerUser(sysUser);
|
||||
if (!regFlag) {
|
||||
throw new UserException("user.register.error");
|
||||
}
|
||||
recordLogininfor(tenantId, username, Constants.REGISTER, MessageUtils.message("user.register.success"));
|
||||
recordLogininfor(username, MessageUtils.message("user.register.success"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验验证码
|
||||
*
|
||||
* @param tenantId 租户ID
|
||||
* @param username 用户名
|
||||
* @param code 验证码
|
||||
* @param uuid 唯一标识
|
||||
*/
|
||||
public void validateCaptcha(Long tenantId, String username, String code, String uuid) {
|
||||
public void validateCaptcha(String username, String code, String uuid) {
|
||||
String verifyKey = GlobalConstants.CAPTCHA_CODE_KEY + StringUtils.defaultString(uuid, "");
|
||||
String captcha = RedisUtils.getCacheObject(verifyKey);
|
||||
RedisUtils.deleteObject(verifyKey);
|
||||
if (captcha == null) {
|
||||
recordLogininfor(tenantId, username, Constants.REGISTER, MessageUtils.message("user.jcaptcha.expire"));
|
||||
recordLogininfor(username, MessageUtils.message("user.jcaptcha.expire"));
|
||||
throw new CaptchaExpireException();
|
||||
}
|
||||
if (!code.equalsIgnoreCase(captcha)) {
|
||||
recordLogininfor(tenantId, username, Constants.REGISTER, MessageUtils.message("user.jcaptcha.error"));
|
||||
recordLogininfor(username, MessageUtils.message("user.jcaptcha.error"));
|
||||
throw new CaptchaException();
|
||||
}
|
||||
}
|
||||
@ -97,17 +94,13 @@ public class SysRegisterService
|
||||
/**
|
||||
* 记录登录信息
|
||||
*
|
||||
* @param tenantId 租户ID
|
||||
* @param username 用户名
|
||||
* @param status 状态
|
||||
* @param message 消息内容
|
||||
* @return
|
||||
*/
|
||||
private void recordLogininfor(Long tenantId, String username, String status, String message) {
|
||||
private void recordLogininfor(String username, String message) {
|
||||
LogininforEvent logininforEvent = new LogininforEvent();
|
||||
logininforEvent.setTenantId(tenantId);
|
||||
logininforEvent.setUsername(username);
|
||||
logininforEvent.setStatus(status);
|
||||
logininforEvent.setStatus(Constants.REGISTER);
|
||||
logininforEvent.setMessage(message);
|
||||
logininforEvent.setRequest(ServletUtils.getRequest());
|
||||
SpringUtils.context().publishEvent(logininforEvent);
|
||||
|
@ -46,7 +46,6 @@ public class EmailAuthStrategy implements IAuthStrategy {
|
||||
|
||||
@Resource
|
||||
private ISysUserService userService;
|
||||
// private final SysUserMapper userMapper;
|
||||
|
||||
@Override
|
||||
public void validate(LoginBody loginBody) {
|
||||
@ -55,14 +54,13 @@ public class EmailAuthStrategy implements IAuthStrategy {
|
||||
|
||||
@Override
|
||||
public LoginVo login(String clientId, LoginBody loginBody, SysClient client) {
|
||||
Long tenantId = loginBody.getTenantId();
|
||||
String email = loginBody.getEmail();
|
||||
String emailCode = loginBody.getEmailCode();
|
||||
|
||||
// 通过邮箱查找用户
|
||||
SysUserVo user = loadUserByEmail(tenantId, email);
|
||||
SysUserVo user = loadUserByEmail(email);
|
||||
|
||||
loginService.checkLogin(LoginType.EMAIL, tenantId, user.getUserName(), () -> !validateEmailCode(tenantId, email, emailCode));
|
||||
loginService.checkLogin(LoginType.EMAIL, user.getUserName(), () -> !validateEmailCode(email, emailCode));
|
||||
// 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了
|
||||
LoginUser loginUser = loginService.buildLoginUser(user);
|
||||
SaLoginModel model = new SaLoginModel();
|
||||
@ -75,7 +73,7 @@ public class EmailAuthStrategy implements IAuthStrategy {
|
||||
// 生成token
|
||||
LoginHelper.login(loginUser, model);
|
||||
|
||||
loginService.recordLogininfor(loginUser.getTenantId(), user.getUserName(), Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"));
|
||||
loginService.recordLogininfor(user.getUserName(), Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"));
|
||||
loginService.recordLoginInfo(user.getUserId());
|
||||
|
||||
LoginVo loginVo = new LoginVo();
|
||||
@ -89,20 +87,16 @@ public class EmailAuthStrategy implements IAuthStrategy {
|
||||
/**
|
||||
* 校验邮箱验证码
|
||||
*/
|
||||
private boolean validateEmailCode(Long tenantId, String email, String emailCode) {
|
||||
private boolean validateEmailCode(String email, String emailCode) {
|
||||
String code = RedisUtils.getCacheObject(GlobalConstants.CAPTCHA_CODE_KEY + email);
|
||||
if (StringUtils.isBlank(code)) {
|
||||
loginService.recordLogininfor(tenantId, email, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"));
|
||||
loginService.recordLogininfor(email, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"));
|
||||
throw new CaptchaExpireException();
|
||||
}
|
||||
return code.equals(emailCode);
|
||||
}
|
||||
|
||||
private SysUserVo loadUserByEmail(Long tenantId, String email) {
|
||||
// SysUser user = userMapper.selectOne(new LambdaQueryWrapper<SysUser>()
|
||||
// .select(SysUser::getEmail, SysUser::getStatus)
|
||||
// .eq(TenantHelper.isEnable(), SysUser::getTenantId, tenantId)
|
||||
// .eq(SysUser::getEmail, email));
|
||||
private SysUserVo loadUserByEmail(String email) {
|
||||
SysUserVo user =userService.selectUserByEmail(email);
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
log.info("登录用户:{} 不存在.", email);
|
||||
@ -111,9 +105,6 @@ public class EmailAuthStrategy implements IAuthStrategy {
|
||||
log.info("登录用户:{} 已被停用.", email);
|
||||
throw new UserException("user.blocked", email);
|
||||
}
|
||||
// if (TenantHelper.isEnable()) {
|
||||
// return userMapper.selectTenantUserByEmail(email, tenantId);
|
||||
// }
|
||||
return user;
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@ import cn.dev33.satoken.secure.BCrypt;
|
||||
import cn.dev33.satoken.stp.SaLoginModel;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.ruoyi.common.core.core.domain.AjaxResult;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -26,12 +25,11 @@ import com.ruoyi.common.redis.utils.RedisUtils;
|
||||
import com.ruoyi.common.security.utils.LoginHelper;
|
||||
import com.ruoyi.common.web.config.properties.CaptchaProperties;
|
||||
import com.ruoyi.system.domain.SysClient;
|
||||
import com.ruoyi.system.domain.SysUser;
|
||||
import com.ruoyi.system.domain.vo.SysUserVo;
|
||||
import com.ruoyi.system.mapper.SysUserMapper;
|
||||
import com.ruoyi.web.domain.vo.LoginVo;
|
||||
import com.ruoyi.web.service.IAuthStrategy;
|
||||
import com.ruoyi.web.service.SysLoginService;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
@ -57,7 +55,6 @@ public class PasswordAuthStrategy implements IAuthStrategy {
|
||||
|
||||
@Override
|
||||
public LoginVo login(String clientId, LoginBody loginBody, SysClient client) {
|
||||
Long tenantId = loginBody.getTenantId();
|
||||
String username = loginBody.getUsername();
|
||||
String password = loginBody.getPassword();
|
||||
String code = loginBody.getCode();
|
||||
@ -66,11 +63,11 @@ public class PasswordAuthStrategy implements IAuthStrategy {
|
||||
boolean captchaEnabled = captchaProperties.getEnable();
|
||||
// 验证码开关
|
||||
if (captchaEnabled) {
|
||||
validateCaptcha(tenantId, username, code, uuid);
|
||||
validateCaptcha(username, code, uuid);
|
||||
}
|
||||
|
||||
SysUserVo user = loadUserByUsername(tenantId, username);
|
||||
loginService.checkLogin(LoginType.PASSWORD, tenantId, username, () -> !BCrypt.checkpw(password, user.getPassword()));
|
||||
SysUserVo user = loadUserByUsername(username);
|
||||
loginService.checkLogin(LoginType.PASSWORD, username, () -> !BCrypt.checkpw(password, user.getPassword()));
|
||||
// 此处可根据登录用户的数据不同 自行创建 loginUser
|
||||
LoginUser loginUser = loginService.buildLoginUser(user);
|
||||
SaLoginModel model = new SaLoginModel();
|
||||
@ -83,7 +80,7 @@ public class PasswordAuthStrategy implements IAuthStrategy {
|
||||
// 生成token
|
||||
LoginHelper.login(loginUser, model);
|
||||
|
||||
loginService.recordLogininfor(loginUser.getTenantId(), username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"));
|
||||
loginService.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"));
|
||||
loginService.recordLoginInfo(user.getUserId());
|
||||
|
||||
LoginVo loginVo = new LoginVo();
|
||||
@ -103,33 +100,34 @@ public class PasswordAuthStrategy implements IAuthStrategy {
|
||||
* @param code 验证码
|
||||
* @param uuid 唯一标识
|
||||
*/
|
||||
private void validateCaptcha(Long tenantId, String username, String code, String uuid) {
|
||||
private void validateCaptcha(String username, String code, String uuid) {
|
||||
String verifyKey = GlobalConstants.CAPTCHA_CODE_KEY + StringUtils.defaultString(uuid, "");
|
||||
String captcha = RedisUtils.getCacheObject(verifyKey);
|
||||
RedisUtils.deleteObject(verifyKey);
|
||||
if (captcha == null) {
|
||||
loginService.recordLogininfor(tenantId, username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"));
|
||||
loginService.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"));
|
||||
throw new CaptchaExpireException();
|
||||
}
|
||||
if (!code.equalsIgnoreCase(captcha)) {
|
||||
loginService.recordLogininfor(tenantId, username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error"));
|
||||
loginService.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error"));
|
||||
throw new CaptchaException();
|
||||
}
|
||||
}
|
||||
|
||||
private SysUserVo loadUserByUsername(Long tenantId, String username) {
|
||||
//TODO:以后根据tenantId条件过滤查询:
|
||||
private SysUserVo loadUserByUsername(String username) {
|
||||
SysUserVo user = userService.selectUserByUserName(username);
|
||||
return getSysUserVo(username, user);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
static SysUserVo getSysUserVo(String username, SysUserVo user) {
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
log.info("登录用户:{} 不存在.", username);
|
||||
PasswordAuthStrategy.log.info("登录用户:{} 不存在.", username);
|
||||
throw new UserException("user.not.exists", username);
|
||||
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
||||
log.info("登录用户:{} 已被停用.", username);
|
||||
PasswordAuthStrategy.log.info("登录用户:{} 已被停用.", username);
|
||||
throw new UserException("user.blocked", username);
|
||||
}
|
||||
// if (TenantHelper.isEnable()) {
|
||||
// return userMapper.selectTenantUserByUserName(username, tenantId);
|
||||
// }
|
||||
return user;
|
||||
}
|
||||
|
||||
|
@ -234,21 +234,6 @@ security:
|
||||
- /captcha/get
|
||||
- /captcha/check
|
||||
|
||||
# 多租户配置
|
||||
tenant:
|
||||
# 是否开启
|
||||
enable: false
|
||||
# 排除表
|
||||
excludes:
|
||||
- sys_menu
|
||||
- sys_tenant
|
||||
- sys_tenant_package
|
||||
- sys_role_dept
|
||||
- sys_role_menu
|
||||
- sys_user_post
|
||||
- sys_user_role
|
||||
- sys_client
|
||||
|
||||
--- # Actuator 监控端点的配置项
|
||||
management:
|
||||
endpoints:
|
||||
|
@ -50,8 +50,3 @@ email.code.not.blank=邮箱验证码不能为空
|
||||
email.code.retry.limit.count=邮箱验证码输入错误{0}次
|
||||
email.code.retry.limit.exceed=邮箱验证码输入错误{0}次,帐户锁定{1}分钟
|
||||
xcx.code.not.blank=小程序code不能为空
|
||||
##租户
|
||||
tenant.number.not.blank=租户编号不能为空
|
||||
tenant.not.exists=对不起, 您的租户不存在,请联系管理员
|
||||
tenant.blocked=对不起,您的租户已禁用,请联系管理员
|
||||
tenant.expired=对不起,您的租户已过期,请联系管理员
|
||||
|
@ -50,8 +50,3 @@ email.code.not.blank=Email code cannot be blank
|
||||
email.code.retry.limit.count=Email code input error {0} times
|
||||
email.code.retry.limit.exceed=Email code input error {0} times, account locked for {1} minutes
|
||||
xcx.code.not.blank=Mini program code cannot be blank
|
||||
##租户
|
||||
tenant.number.not.blank=Tenant number cannot be blank
|
||||
tenant.not.exists=Sorry, your tenant does not exist. Please contact the administrator
|
||||
tenant.blocked=Sorry, your tenant is disabled. Please contact the administrator
|
||||
tenant.expired=Sorry, your tenant has expired. Please contact the administrator.
|
||||
|
@ -50,8 +50,3 @@ email.code.not.blank=邮箱验证码不能为空
|
||||
email.code.retry.limit.count=邮箱验证码输入错误{0}次
|
||||
email.code.retry.limit.exceed=邮箱验证码输入错误{0}次,帐户锁定{1}分钟
|
||||
xcx.code.not.blank=小程序code不能为空
|
||||
##租户
|
||||
tenant.number.not.blank=租户编号不能为空
|
||||
tenant.not.exists=对不起, 您的租户不存在,请联系管理员
|
||||
tenant.blocked=对不起,您的租户已禁用,请联系管理员
|
||||
tenant.expired=对不起,您的租户已过期,请联系管理员
|
||||
|
@ -23,7 +23,6 @@
|
||||
<module>ruoyi-common-redis</module>
|
||||
<module>ruoyi-common-security</module>
|
||||
<module>ruoyi-common-springdoc</module>
|
||||
<module>ruoyi-common-tenant</module>
|
||||
<module>ruoyi-common-web</module>
|
||||
</modules>
|
||||
|
||||
|
@ -96,13 +96,6 @@
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 多租户模块 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-tenant</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- web服务 -->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
|
@ -30,11 +30,6 @@ public interface CacheNames {
|
||||
*/
|
||||
String SYS_DICT = "sys_dict";
|
||||
|
||||
/**
|
||||
* 租户
|
||||
*/
|
||||
String SYS_TENANT = GlobalConstants.GLOBAL_REDIS_KEY + "sys_tenant#30d";
|
||||
|
||||
/**
|
||||
* 用户账户
|
||||
*/
|
||||
|
@ -1,45 +0,0 @@
|
||||
package com.ruoyi.common.core.constant;
|
||||
|
||||
/**
|
||||
* 租户常量信息
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface TenantConstants {
|
||||
|
||||
/**
|
||||
* 租户正常状态
|
||||
*/
|
||||
String NORMAL = "0";
|
||||
|
||||
/**
|
||||
* 租户封禁状态
|
||||
*/
|
||||
String DISABLE = "1";
|
||||
|
||||
/**
|
||||
* 超级管理员ID
|
||||
*/
|
||||
Long SUPER_ADMIN_ID = 1L;
|
||||
|
||||
/**
|
||||
* 超级管理员角色 roleKey
|
||||
*/
|
||||
String SUPER_ADMIN_ROLE_KEY = "superadmin";
|
||||
|
||||
/**
|
||||
* 租户管理员角色 roleKey
|
||||
*/
|
||||
String TENANT_ADMIN_ROLE_KEY = "admin";
|
||||
|
||||
/**
|
||||
* 租户管理员角色名称
|
||||
*/
|
||||
String TENANT_ADMIN_ROLE_NAME = "管理员";
|
||||
|
||||
/**
|
||||
* 默认租户ID
|
||||
*/
|
||||
String DEFAULT_TENANT_ID = "000000";
|
||||
|
||||
}
|
@ -13,12 +13,6 @@ import lombok.Data;
|
||||
@Data
|
||||
public class EmailLoginBody {
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@NotBlank(message = "{tenant.number.not.blank}")
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
|
@ -37,11 +37,6 @@ public class LoginBody
|
||||
@NotBlank(message = "{auth.grant.type.not.blank}")
|
||||
private String grantType;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
|
@ -20,11 +20,6 @@ public class LoginUser
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
|
@ -89,7 +89,6 @@ public class LogAspect {
|
||||
|
||||
// *========数据库日志=========*//
|
||||
OperLogEvent operLog = new OperLogEvent();
|
||||
operLog.setTenantId(LoginHelper.getTenantId());
|
||||
operLog.setStatus(BusinessStatus.SUCCESS.ordinal());
|
||||
// 请求的地址
|
||||
String ip = ServletUtils.getClientIP();
|
||||
|
@ -19,11 +19,6 @@ public class LogininforEvent implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 用户账号
|
||||
*/
|
||||
|
@ -23,11 +23,6 @@ public class OperLogEvent implements Serializable {
|
||||
*/
|
||||
private Long operId;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 操作模块
|
||||
*/
|
||||
|
@ -24,12 +24,6 @@ public class BaseEntity implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// /**
|
||||
// * 租户编号
|
||||
// */
|
||||
// @Column(ignore = true)
|
||||
// private Long tenantId;
|
||||
|
||||
/**
|
||||
* 搜索值
|
||||
*/
|
||||
|
@ -46,18 +46,17 @@ public class OssFactory {
|
||||
}
|
||||
OssProperties properties = JsonUtils.parseObject(json, OssProperties.class);
|
||||
// 使用租户标识避免多个租户相同key实例覆盖
|
||||
String key = properties.getTenantId() + ":" + configKey;
|
||||
OssClient client = CLIENT_CACHE.get(key);
|
||||
OssClient client = CLIENT_CACHE.get(configKey);
|
||||
if (client == null) {
|
||||
CLIENT_CACHE.put(key, new OssClient(configKey, properties));
|
||||
CLIENT_CACHE.put(configKey, new OssClient(configKey, properties));
|
||||
log.info("创建OSS实例 key => {}", configKey);
|
||||
return CLIENT_CACHE.get(key);
|
||||
return CLIENT_CACHE.get(configKey);
|
||||
}
|
||||
// 配置不相同则重新构建
|
||||
if (!client.checkPropertiesSame(properties)) {
|
||||
CLIENT_CACHE.put(key, new OssClient(configKey, properties));
|
||||
CLIENT_CACHE.put(configKey, new OssClient(configKey, properties));
|
||||
log.info("重载OSS实例 key => {}", configKey);
|
||||
return CLIENT_CACHE.get(key);
|
||||
return CLIENT_CACHE.get(configKey);
|
||||
}
|
||||
return client;
|
||||
}
|
||||
|
@ -10,11 +10,6 @@ import lombok.Data;
|
||||
@Data
|
||||
public class OssProperties {
|
||||
|
||||
/**
|
||||
* 租户id
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 访问站点
|
||||
*/
|
||||
|
@ -9,13 +9,10 @@ import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import com.ruoyi.common.core.constant.TenantConstants;
|
||||
import com.ruoyi.common.core.constant.UserConstants;
|
||||
import com.ruoyi.common.core.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.core.enums.UserType;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 登录鉴权助手
|
||||
* <p>
|
||||
@ -32,7 +29,6 @@ import java.util.Set;
|
||||
public class LoginHelper {
|
||||
|
||||
public static final String LOGIN_USER_KEY = "loginUser";
|
||||
public static final String TENANT_KEY = "tenantId";
|
||||
public static final String USER_KEY = "userId";
|
||||
public static final String DEPT_KEY = "deptId";
|
||||
public static final String CLIENT_KEY = "clientid";
|
||||
@ -47,14 +43,12 @@ public class LoginHelper {
|
||||
public static void login(LoginUser loginUser, SaLoginModel model) {
|
||||
SaStorage storage = SaHolder.getStorage();
|
||||
storage.set(LOGIN_USER_KEY, loginUser);
|
||||
storage.set(TENANT_KEY, loginUser.getTenantId());
|
||||
storage.set(USER_KEY, loginUser.getUserId());
|
||||
storage.set(DEPT_KEY, loginUser.getDeptId());
|
||||
model = ObjectUtil.defaultIfNull(model, new SaLoginModel());
|
||||
//登录,生成token
|
||||
StpUtil.login(loginUser.getLoginId(),
|
||||
model.setExtra(TENANT_KEY, loginUser.getTenantId())
|
||||
.setExtra(USER_KEY, loginUser.getUserId())
|
||||
model.setExtra(USER_KEY, loginUser.getUserId())
|
||||
.setExtra(DEPT_KEY, loginUser.getDeptId()));
|
||||
StpUtil.getSession().set(LOGIN_USER_KEY, loginUser);
|
||||
}
|
||||
@ -95,13 +89,6 @@ public class LoginHelper {
|
||||
return Convert.toLong(getExtra(USER_KEY));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取租户ID
|
||||
*/
|
||||
public static String getTenantId() {
|
||||
return Convert.toStr(getExtra(TENANT_KEY));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门ID
|
||||
*/
|
||||
@ -152,18 +139,4 @@ public class LoginHelper {
|
||||
return isSuperAdmin(getUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为超级管理员
|
||||
*
|
||||
* @param rolePermission 角色权限标识组
|
||||
* @return 结果
|
||||
*/
|
||||
public static boolean isTenantAdmin(Set<String> rolePermission) {
|
||||
return rolePermission.contains(TenantConstants.TENANT_ADMIN_ROLE_KEY);
|
||||
}
|
||||
|
||||
public static boolean isTenantAdmin() {
|
||||
return isTenantAdmin(getLoginUser().getRolePermission());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,36 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>ruoyi-common-tenant</artifactId>
|
||||
|
||||
<description>
|
||||
ruoyi-common-tenant 租户模块
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-orm</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>transmittable-thread-local</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -1,23 +0,0 @@
|
||||
package com.ruoyi.common.tenant.core;
|
||||
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import com.ruoyi.common.orm.core.domain.BaseEntity;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 租户基类
|
||||
*
|
||||
* @author Michelle.Chung
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class TenantEntity extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 租户编号
|
||||
*/
|
||||
private Long tenantId;
|
||||
|
||||
}
|
@ -1,148 +0,0 @@
|
||||
package com.ruoyi.common.tenant.core;
|
||||
|
||||
import com.ruoyi.common.core.constant.GlobalConstants;
|
||||
import com.ruoyi.common.redis.utils.RedisUtils;
|
||||
import com.ruoyi.common.security.core.dao.FlexSaTokenDao;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* SaToken 认证数据持久层 适配多租户
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public class TenantSaTokenDao extends FlexSaTokenDao {
|
||||
|
||||
@Override
|
||||
public String get(String key) {
|
||||
return super.get(GlobalConstants.GLOBAL_REDIS_KEY + key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(String key, String value, long timeout) {
|
||||
super.set(GlobalConstants.GLOBAL_REDIS_KEY + key, value, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修修改指定key-value键值对 (过期时间不变)
|
||||
*/
|
||||
@Override
|
||||
public void update(String key, String value) {
|
||||
long expire = getTimeout(key);
|
||||
// -2 = 无此键
|
||||
if (expire == NOT_VALUE_EXPIRE) {
|
||||
return;
|
||||
}
|
||||
this.set(key, value, expire);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除Value
|
||||
*/
|
||||
@Override
|
||||
public void delete(String key) {
|
||||
super.delete(GlobalConstants.GLOBAL_REDIS_KEY + key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Value的剩余存活时间 (单位: 秒)
|
||||
*/
|
||||
@Override
|
||||
public long getTimeout(String key) {
|
||||
return super.getTimeout(GlobalConstants.GLOBAL_REDIS_KEY + key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改Value的剩余存活时间 (单位: 秒)
|
||||
*/
|
||||
@Override
|
||||
public void updateTimeout(String key, long timeout) {
|
||||
// 判断是否想要设置为永久
|
||||
if (timeout == NEVER_EXPIRE) {
|
||||
long expire = getTimeout(key);
|
||||
if (expire == NEVER_EXPIRE) {
|
||||
// 如果其已经被设置为永久,则不作任何处理
|
||||
} else {
|
||||
// 如果尚未被设置为永久,那么再次set一次
|
||||
this.set(key, this.get(key), timeout);
|
||||
}
|
||||
return;
|
||||
}
|
||||
RedisUtils.expire(GlobalConstants.GLOBAL_REDIS_KEY + key, Duration.ofSeconds(timeout));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取Object,如无返空
|
||||
*/
|
||||
@Override
|
||||
public Object getObject(String key) {
|
||||
return super.getObject(GlobalConstants.GLOBAL_REDIS_KEY + key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入Object,并设定存活时间 (单位: 秒)
|
||||
*/
|
||||
@Override
|
||||
public void setObject(String key, Object object, long timeout) {
|
||||
super.setObject(GlobalConstants.GLOBAL_REDIS_KEY + key, object, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新Object (过期时间不变)
|
||||
*/
|
||||
@Override
|
||||
public void updateObject(String key, Object object) {
|
||||
long expire = getObjectTimeout(key);
|
||||
// -2 = 无此键
|
||||
if (expire == NOT_VALUE_EXPIRE) {
|
||||
return;
|
||||
}
|
||||
this.setObject(key, object, expire);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除Object
|
||||
*/
|
||||
@Override
|
||||
public void deleteObject(String key) {
|
||||
super.deleteObject(GlobalConstants.GLOBAL_REDIS_KEY + key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取Object的剩余存活时间 (单位: 秒)
|
||||
*/
|
||||
@Override
|
||||
public long getObjectTimeout(String key) {
|
||||
return super.getObjectTimeout(GlobalConstants.GLOBAL_REDIS_KEY + key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改Object的剩余存活时间 (单位: 秒)
|
||||
*/
|
||||
@Override
|
||||
public void updateObjectTimeout(String key, long timeout) {
|
||||
// 判断是否想要设置为永久
|
||||
if (timeout == NEVER_EXPIRE) {
|
||||
long expire = getObjectTimeout(key);
|
||||
if (expire == NEVER_EXPIRE) {
|
||||
// 如果其已经被设置为永久,则不作任何处理
|
||||
} else {
|
||||
// 如果尚未被设置为永久,那么再次set一次
|
||||
this.setObject(key, this.getObject(key), timeout);
|
||||
}
|
||||
return;
|
||||
}
|
||||
RedisUtils.expire(GlobalConstants.GLOBAL_REDIS_KEY + key, Duration.ofSeconds(timeout));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 搜索数据
|
||||
*/
|
||||
@Override
|
||||
public List<String> searchData(String prefix, String keyword, int start, int size, boolean sortType) {
|
||||
return super.searchData(GlobalConstants.GLOBAL_REDIS_KEY + prefix, keyword, start, size, sortType);
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package com.ruoyi.common.tenant.exception;
|
||||
|
||||
import com.ruoyi.common.core.exception.base.BaseException;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 租户异常类
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public class TenantException extends BaseException {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public TenantException(String code, Object... args) {
|
||||
super("tenant", code, args, null);
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
package com.ruoyi.common.tenant.handle;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.common.security.utils.LoginHelper;
|
||||
import com.ruoyi.common.tenant.helper.TenantHelper;
|
||||
import com.ruoyi.common.tenant.properties.TenantProperties;
|
||||
import lombok.AllArgsConstructor;
|
||||
import net.sf.jsqlparser.expression.Expression;
|
||||
import net.sf.jsqlparser.expression.NullValue;
|
||||
import net.sf.jsqlparser.expression.StringValue;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 自定义租户处理器
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
//public class PlusTenantLineHandler implements TenantLineHandler {
|
||||
public class PlusTenantLineHandler {
|
||||
|
||||
private final TenantProperties tenantProperties;
|
||||
|
||||
public Expression getTenantId() {
|
||||
String tenantId = LoginHelper.getTenantId();
|
||||
if (StringUtils.isBlank(tenantId)) {
|
||||
return new NullValue();
|
||||
}
|
||||
String dynamicTenantId = TenantHelper.getDynamic();
|
||||
if (StringUtils.isNotBlank(dynamicTenantId)) {
|
||||
// 返回动态租户
|
||||
return new StringValue(dynamicTenantId);
|
||||
}
|
||||
// 返回固定租户
|
||||
return new StringValue(tenantId);
|
||||
}
|
||||
|
||||
public boolean ignoreTable(String tableName) {
|
||||
String tenantId = LoginHelper.getTenantId();
|
||||
// 判断是否有租户
|
||||
if (StringUtils.isNotBlank(tenantId)) {
|
||||
// 不需要过滤租户的表
|
||||
List<String> excludes = tenantProperties.getExcludes();
|
||||
// 非业务表
|
||||
List<String> tables = ListUtil.toList(
|
||||
"gen_table",
|
||||
"gen_table_column"
|
||||
);
|
||||
tables.addAll(excludes);
|
||||
return tables.contains(tableName);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
package com.ruoyi.common.tenant.handle;
|
||||
|
||||
import com.ruoyi.common.core.constant.GlobalConstants;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.common.redis.handler.KeyPrefixHandler;
|
||||
import com.ruoyi.common.tenant.helper.TenantHelper;
|
||||
|
||||
/**
|
||||
* 多租户redis缓存key前缀处理
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public class TenantKeyPrefixHandler extends KeyPrefixHandler {
|
||||
|
||||
public TenantKeyPrefixHandler(String keyPrefix) {
|
||||
super(keyPrefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加前缀
|
||||
*/
|
||||
@Override
|
||||
public String map(String name) {
|
||||
if (StringUtils.isBlank(name)) {
|
||||
return null;
|
||||
}
|
||||
if (StringUtils.contains(name, GlobalConstants.GLOBAL_REDIS_KEY)) {
|
||||
return super.map(name);
|
||||
}
|
||||
String tenantId = TenantHelper.getTenantId();
|
||||
if (StringUtils.startsWith(name, tenantId)) {
|
||||
// 如果存在则直接返回
|
||||
return super.map(name);
|
||||
}
|
||||
return super.map(tenantId + ":" + name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 去除前缀
|
||||
*/
|
||||
@Override
|
||||
public String unmap(String name) {
|
||||
String unmap = super.unmap(name);
|
||||
if (StringUtils.isBlank(unmap)) {
|
||||
return null;
|
||||
}
|
||||
if (StringUtils.contains(name, GlobalConstants.GLOBAL_REDIS_KEY)) {
|
||||
return super.unmap(name);
|
||||
}
|
||||
String tenantId = TenantHelper.getTenantId();
|
||||
if (StringUtils.startsWith(unmap, tenantId)) {
|
||||
// 如果存在则删除
|
||||
return unmap.substring((tenantId + ":").length());
|
||||
}
|
||||
return unmap;
|
||||
}
|
||||
|
||||
}
|
@ -1,138 +0,0 @@
|
||||
package com.ruoyi.common.tenant.helper;
|
||||
|
||||
import cn.dev33.satoken.context.SaHolder;
|
||||
import cn.dev33.satoken.spring.SpringMVCUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.alibaba.ttl.TransmittableThreadLocal;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.ruoyi.common.core.constant.GlobalConstants;
|
||||
import com.ruoyi.common.core.utils.SpringUtils;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.common.redis.utils.RedisUtils;
|
||||
import com.ruoyi.common.security.utils.LoginHelper;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* 租户助手
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Slf4j
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class TenantHelper {
|
||||
|
||||
private static final String DYNAMIC_TENANT_KEY = GlobalConstants.GLOBAL_REDIS_KEY + "dynamicTenant";
|
||||
|
||||
private static final ThreadLocal<String> TEMP_DYNAMIC_TENANT = new TransmittableThreadLocal<>();
|
||||
|
||||
/**
|
||||
* 租户功能是否启用
|
||||
*/
|
||||
public static boolean isEnable() {
|
||||
return Convert.toBool(SpringUtils.getProperty("tenant.enable"), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启忽略租户(开启后需手动调用 {@link #disableIgnore()} 关闭)
|
||||
*/
|
||||
public static void enableIgnore() {
|
||||
//InterceptorIgnoreHelper.handle(IgnoreStrategy.builder().tenantLine(true).build());
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭忽略租户
|
||||
*/
|
||||
public static void disableIgnore() {
|
||||
//InterceptorIgnoreHelper.clearIgnoreStrategy();
|
||||
}
|
||||
|
||||
/**
|
||||
* 在忽略租户中执行
|
||||
*
|
||||
* @param handle 处理执行方法
|
||||
*/
|
||||
public static void ignore(Runnable handle) {
|
||||
enableIgnore();
|
||||
try {
|
||||
handle.run();
|
||||
} finally {
|
||||
disableIgnore();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 在忽略租户中执行
|
||||
*
|
||||
* @param handle 处理执行方法
|
||||
*/
|
||||
public static <T> T ignore(Supplier<T> handle) {
|
||||
enableIgnore();
|
||||
try {
|
||||
return handle.get();
|
||||
} finally {
|
||||
disableIgnore();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置动态租户(一直有效 需要手动清理)
|
||||
* <p>
|
||||
* 如果为非web环境 那么只在当前线程内生效
|
||||
*/
|
||||
public static void setDynamic(String tenantId) {
|
||||
if (!SpringMVCUtil.isWeb()) {
|
||||
TEMP_DYNAMIC_TENANT.set(tenantId);
|
||||
return;
|
||||
}
|
||||
String cacheKey = DYNAMIC_TENANT_KEY + ":" + LoginHelper.getUserId();
|
||||
RedisUtils.setCacheObject(cacheKey, tenantId);
|
||||
SaHolder.getStorage().set(cacheKey, tenantId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取动态租户(一直有效 需要手动清理)
|
||||
* <p>
|
||||
* 如果为非web环境 那么只在当前线程内生效
|
||||
*/
|
||||
public static String getDynamic() {
|
||||
if (!SpringMVCUtil.isWeb()) {
|
||||
return TEMP_DYNAMIC_TENANT.get();
|
||||
}
|
||||
String cacheKey = DYNAMIC_TENANT_KEY + ":" + LoginHelper.getUserId();
|
||||
String tenantId = (String) SaHolder.getStorage().get(cacheKey);
|
||||
if (StringUtils.isNotBlank(tenantId)) {
|
||||
return tenantId;
|
||||
}
|
||||
tenantId = RedisUtils.getCacheObject(cacheKey);
|
||||
SaHolder.getStorage().set(cacheKey, tenantId);
|
||||
return tenantId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除动态租户
|
||||
*/
|
||||
public static void clearDynamic() {
|
||||
if (!SpringMVCUtil.isWeb()) {
|
||||
TEMP_DYNAMIC_TENANT.remove();
|
||||
return;
|
||||
}
|
||||
String cacheKey = DYNAMIC_TENANT_KEY + ":" + LoginHelper.getUserId();
|
||||
RedisUtils.deleteObject(cacheKey);
|
||||
SaHolder.getStorage().delete(cacheKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前租户id(动态租户优先)
|
||||
*/
|
||||
public static String getTenantId() {
|
||||
String tenantId = TenantHelper.getDynamic();
|
||||
if (StringUtils.isBlank(tenantId)) {
|
||||
tenantId = LoginHelper.getTenantId();
|
||||
}
|
||||
return tenantId;
|
||||
}
|
||||
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package com.ruoyi.common.tenant.manager;
|
||||
|
||||
import com.ruoyi.common.core.constant.GlobalConstants;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.common.redis.manager.FlexSpringCacheManager;
|
||||
import com.ruoyi.common.tenant.helper.TenantHelper;
|
||||
import org.springframework.cache.Cache;
|
||||
|
||||
/**
|
||||
* 重写 cacheName 处理方法 支持多租户
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public class TenantSpringCacheManager extends FlexSpringCacheManager {
|
||||
|
||||
public TenantSpringCacheManager() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cache getCache(String name) {
|
||||
if (StringUtils.contains(name, GlobalConstants.GLOBAL_REDIS_KEY)) {
|
||||
return super.getCache(name);
|
||||
}
|
||||
String tenantId = TenantHelper.getTenantId();
|
||||
if (StringUtils.startsWith(name, tenantId)) {
|
||||
// 如果存在则直接返回
|
||||
return super.getCache(name);
|
||||
}
|
||||
return super.getCache(tenantId + ":" + name);
|
||||
}
|
||||
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package com.ruoyi.common.tenant.properties;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 租户 配置属性
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Data
|
||||
@ConfigurationProperties(prefix = "tenant")
|
||||
public class TenantProperties {
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
*/
|
||||
private Boolean enable;
|
||||
|
||||
/**
|
||||
* 排除表
|
||||
*/
|
||||
private List<String> excludes;
|
||||
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
# 代码生成
|
||||
gen:
|
||||
# 作者
|
||||
author: 数据小王子
|
||||
author: 轩辕龙儿
|
||||
# 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool
|
||||
packageName: com.ruoyi.demo
|
||||
# 自动去除表前缀,默认是false
|
||||
|
@ -70,11 +70,6 @@
|
||||
<artifactId>ruoyi-common-springdoc</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-tenant</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common-web</artifactId>
|
||||
|
@ -18,7 +18,6 @@ import com.ruoyi.common.log.enums.BusinessType;
|
||||
import com.ruoyi.common.orm.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.security.utils.LoginHelper;
|
||||
import com.ruoyi.common.core.constant.UserConstants;
|
||||
import com.ruoyi.common.tenant.helper.TenantHelper;
|
||||
import com.ruoyi.system.domain.bo.SysDeptBo;
|
||||
import com.ruoyi.system.domain.bo.SysPostBo;
|
||||
import com.ruoyi.system.domain.bo.SysRoleBo;
|
||||
@ -117,10 +116,6 @@ public class SysUserController extends BaseController {
|
||||
public R<UserInfoVo> getInfo() {
|
||||
UserInfoVo userInfoVo = new UserInfoVo();
|
||||
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||
if (TenantHelper.isEnable() && LoginHelper.isSuperAdmin()) {
|
||||
// 超级管理员 如果重新加载用户信息需清除动态租户
|
||||
TenantHelper.clearDynamic();
|
||||
}
|
||||
SysUserVo user = userService.selectUserById(loginUser.getUserId());
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
return R.fail("没有权限访问用户数据!");
|
||||
|
@ -25,11 +25,6 @@ public class SysUser extends BaseEntity
|
||||
@Id
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 租户编号
|
||||
*/
|
||||
private Long tenantId;
|
||||
|
||||
/** 部门ID */
|
||||
private Long deptId;
|
||||
|
||||
|
@ -23,11 +23,6 @@ public class SysLogininforBo {
|
||||
*/
|
||||
private Long infoId;
|
||||
|
||||
/**
|
||||
* 租户编号
|
||||
*/
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 用户账号
|
||||
*/
|
||||
|
@ -29,11 +29,6 @@ public class SysOperLogBo {
|
||||
*/
|
||||
private Long operId;
|
||||
|
||||
/**
|
||||
* 租户编号
|
||||
*/
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 模块标题
|
||||
*/
|
||||
|
@ -33,11 +33,6 @@ public class SysLogininforVo implements Serializable {
|
||||
@ExcelProperty(value = "序号")
|
||||
private Long infoId;
|
||||
|
||||
/**
|
||||
* 租户编号
|
||||
*/
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 用户账号
|
||||
*/
|
||||
|
@ -33,11 +33,6 @@ public class SysOperLogVo implements Serializable {
|
||||
@ExcelProperty(value = "日志主键")
|
||||
private Long operId;
|
||||
|
||||
/**
|
||||
* 租户编号
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 模块标题
|
||||
*/
|
||||
|
@ -32,11 +32,6 @@ public class SysUserVo implements Serializable {
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
|
@ -158,7 +158,7 @@ public interface ISysUserService extends IBaseService<SysUser>
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
boolean registerUser(SysUserBo user, Long tenantId);
|
||||
boolean registerUser(SysUserBo user);
|
||||
|
||||
/**
|
||||
* 修改用户信息
|
||||
|
@ -79,7 +79,6 @@ public class SysLogininforServiceImpl extends BaseServiceImpl<SysLogininforMappe
|
||||
String browser = userAgent.getBrowser().getName();
|
||||
// 封装对象
|
||||
SysLogininforBo logininfor = new SysLogininforBo();
|
||||
logininfor.setTenantId(logininforEvent.getTenantId());
|
||||
logininfor.setUserName(logininforEvent.getUsername());
|
||||
logininfor.setIpaddr(ip);
|
||||
logininfor.setLoginLocation(address);
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.constant.TenantConstants;
|
||||
import com.ruoyi.common.security.utils.LoginHelper;
|
||||
import com.ruoyi.system.service.ISysMenuService;
|
||||
import com.ruoyi.system.service.ISysPermissionService;
|
||||
@ -35,7 +34,7 @@ public class SysPermissionServiceImpl implements ISysPermissionService {
|
||||
Set<String> roles = new HashSet<>();
|
||||
// 管理员拥有所有权限
|
||||
if (LoginHelper.isSuperAdmin(userId)) {
|
||||
roles.add(TenantConstants.SUPER_ADMIN_ROLE_KEY);
|
||||
roles.add("superadmin");
|
||||
} else {
|
||||
roles.addAll(roleService.selectRolePermissionByUserId(userId));
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryMethods;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.core.update.UpdateChain;
|
||||
import com.ruoyi.common.core.constant.TenantConstants;
|
||||
import com.ruoyi.common.core.core.domain.dto.RoleDTO;
|
||||
import com.ruoyi.common.core.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.core.utils.MapstructUtils;
|
||||
@ -269,11 +268,11 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole>
|
||||
*/
|
||||
@Override
|
||||
public boolean checkRoleNameUnique(SysRoleBo roleBo) {
|
||||
Long roleId = ObjectUtil.isNull(roleBo.getRoleId()) ? -1L : roleBo.getRoleId();
|
||||
long roleId = ObjectUtil.isNull(roleBo.getRoleId()) ? -1L : roleBo.getRoleId();
|
||||
QueryWrapper queryWrapper = query().where(SYS_ROLE.ROLE_NAME.eq(roleBo.getRoleName()))
|
||||
.and(SYS_ROLE.DEL_FLAG.eq(0));
|
||||
SysRole info = this.getOne(queryWrapper);
|
||||
if (ObjectUtil.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) {
|
||||
if (ObjectUtil.isNotNull(info) && info.getRoleId() != roleId) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
@ -287,11 +286,11 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole>
|
||||
*/
|
||||
@Override
|
||||
public boolean checkRoleKeyUnique(SysRoleBo roleBo) {
|
||||
Long roleId = ObjectUtil.isNull(roleBo.getRoleId()) ? -1L : roleBo.getRoleId();
|
||||
long roleId = ObjectUtil.isNull(roleBo.getRoleId()) ? -1L : roleBo.getRoleId();
|
||||
QueryWrapper queryWrapper = query().where(SYS_ROLE.ROLE_KEY.eq(roleBo.getRoleKey()))
|
||||
.and(SYS_ROLE.DEL_FLAG.eq(0));
|
||||
SysRole info = this.getOne(queryWrapper);
|
||||
if (ObjectUtil.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) {
|
||||
if (ObjectUtil.isNotNull(info) && info.getRoleId() != roleId) {
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
@ -307,7 +306,7 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole>
|
||||
if (ObjectUtil.isNotNull(roleBo.getRoleId()) && LoginHelper.isSuperAdmin(roleBo.getRoleId())) {
|
||||
throw new ServiceException("不允许操作超级管理员角色");
|
||||
}
|
||||
String[] keys = new String[]{TenantConstants.SUPER_ADMIN_ROLE_KEY, TenantConstants.TENANT_ADMIN_ROLE_KEY};
|
||||
String[] keys = new String[]{"superadmin", "admin"};
|
||||
// 新增:不允许使用 管理员标识符
|
||||
if (ObjectUtil.isNull(roleBo.getRoleId())
|
||||
&& StringUtils.equalsAny(roleBo.getRoleKey(), keys)) {
|
||||
@ -358,10 +357,11 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole>
|
||||
@Transactional
|
||||
public boolean insertRole(SysRoleBo roleBo) {
|
||||
SysRole role = MapstructUtils.convert(roleBo, SysRole.class);
|
||||
assert role != null;
|
||||
role.setDelFlag(0);
|
||||
role.setDataScope("1");//默认1:全部数据权限
|
||||
role.setDataScope("1");
|
||||
// 新增角色信息
|
||||
boolean inserted = this.save(role);//使用全局配置的雪花算法主键生成器生成ID值
|
||||
boolean inserted = this.save(role);
|
||||
if (inserted) {
|
||||
return insertRoleMenu(role);
|
||||
}
|
||||
@ -382,6 +382,7 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole>
|
||||
boolean updated = this.updateById(role);
|
||||
// 删除角色与菜单关联
|
||||
if (updated) {
|
||||
assert role != null;
|
||||
roleMenuService.deleteRoleMenuByRoleId(role.getRoleId());
|
||||
|
||||
return insertRoleMenu(role);
|
||||
@ -423,6 +424,7 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole>
|
||||
// 修改角色信息
|
||||
boolean updated = this.updateById(role);
|
||||
// 删除角色与部门关联
|
||||
assert role != null;
|
||||
roleDeptService.deleteRoleDeptByRoleId(role.getRoleId());
|
||||
// 新增角色和部门 信息(数据权限)
|
||||
insertRoleDept(role);
|
||||
@ -447,8 +449,8 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole>
|
||||
rm.setMenuId(menuId);
|
||||
list.add(rm);
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
inserted = roleMenuService.saveBatchWithPk(list, 100);//批量保存
|
||||
if (!list.isEmpty()) {
|
||||
inserted = roleMenuService.saveBatchWithPk(list, 100);
|
||||
}
|
||||
return inserted;
|
||||
}
|
||||
@ -459,8 +461,7 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole>
|
||||
* @param role 角色对象
|
||||
*/
|
||||
@Transactional
|
||||
public boolean insertRoleDept(SysRole role) {
|
||||
boolean inserted = true;
|
||||
public void insertRoleDept(SysRole role) {
|
||||
// 新增角色与部门(数据权限)管理
|
||||
List<SysRoleDept> list = new ArrayList<>();
|
||||
for (Long deptId : role.getDeptIds()) {
|
||||
@ -469,10 +470,9 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole>
|
||||
rd.setDeptId(deptId);
|
||||
list.add(rd);
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
inserted = roleDeptService.saveBatchWithPk(list, 100);//批量保存
|
||||
if (!list.isEmpty()) {
|
||||
roleDeptService.saveBatchWithPk(list, 100);
|
||||
}
|
||||
return inserted;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -528,6 +528,7 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleMapper, SysRole>
|
||||
return;
|
||||
}
|
||||
LoginUser loginUser = LoginHelper.getLoginUser(token);
|
||||
assert loginUser != null;
|
||||
for (RoleDTO roleDTO : loginUser.getRoles()) {
|
||||
if (ObjectUtil.isNotNull(roleDTO.getRoleId()) && roleDTO.getRoleId().equals(roleId)) {
|
||||
try {
|
||||
|
@ -86,12 +86,8 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
|
||||
}
|
||||
|
||||
private QueryWrapper buildListQueryWrapper(SysUserBo userBo){
|
||||
/*select u.user_id, u.tenant_id, u.dept_id, u.nick_name, u.user_name, u.user_type, u.email, u.avatar, u.phonenumber, u.gender, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader
|
||||
from sys_user u
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
where u.del_flag = '0'*/
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.select(SYS_USER.USER_ID,SYS_USER.TENANT_ID,SYS_USER.DEPT_ID,SYS_USER.NICK_NAME,SYS_USER.USER_NAME,SYS_USER.USER_TYPE,SYS_USER.EMAIL,SYS_USER.AVATAR,SYS_USER.PHONENUMBER,SYS_USER.GENDER,SYS_USER.STATUS,SYS_USER.DEL_FLAG,SYS_USER.LOGIN_IP,SYS_USER.LOGIN_DATE,SYS_USER.CREATE_BY,SYS_USER.CREATE_TIME,SYS_USER.REMARK,SYS_DEPT.DEPT_NAME,SYS_DEPT.LEADER)
|
||||
.select(SYS_USER.USER_ID,SYS_USER.DEPT_ID,SYS_USER.NICK_NAME,SYS_USER.USER_NAME,SYS_USER.USER_TYPE,SYS_USER.EMAIL,SYS_USER.AVATAR,SYS_USER.PHONENUMBER,SYS_USER.GENDER,SYS_USER.STATUS,SYS_USER.DEL_FLAG,SYS_USER.LOGIN_IP,SYS_USER.LOGIN_DATE,SYS_USER.CREATE_BY,SYS_USER.CREATE_TIME,SYS_USER.REMARK,SYS_DEPT.DEPT_NAME,SYS_DEPT.LEADER)
|
||||
.from(SYS_USER.as("u"))
|
||||
.leftJoin(SYS_DEPT).as("d").on(SYS_DEPT.DEPT_ID.eq(SYS_USER.DEPT_ID))
|
||||
.where(SYS_USER.DEL_FLAG.eq(0));
|
||||
@ -119,23 +115,8 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
|
||||
}
|
||||
|
||||
private QueryWrapper buildOneQueryWrapper(){
|
||||
/* select u.user_id, u.tenant_id,u.dept_id, u.user_name, u.nick_name, u.user_type, u.email, u.avatar, u.phonenumber, u.password, u.gender, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
|
||||
d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
|
||||
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status
|
||||
from sys_user u
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
left join sys_user_role ur on u.user_id = ur.user_id
|
||||
left join sys_role r on r.role_id = ur.role_id */
|
||||
/*return QueryWrapper.create()
|
||||
.select(QueryMethods.distinct(SYS_USER.USER_ID,SYS_USER.TENANT_ID,SYS_USER.DEPT_ID,SYS_USER.NICK_NAME,SYS_USER.USER_NAME,SYS_USER.USER_TYPE,SYS_USER.EMAIL,SYS_USER.AVATAR,SYS_USER.PHONENUMBER,SYS_USER.PASSWORD,SYS_USER.GENDER,SYS_USER.STATUS,SYS_USER.DEL_FLAG,SYS_USER.LOGIN_IP,SYS_USER.LOGIN_DATE,SYS_USER.CREATE_BY,SYS_USER.CREATE_TIME,SYS_USER.REMARK,
|
||||
SYS_DEPT.DEPT_ID,SYS_DEPT.PARENT_ID,SYS_DEPT.ANCESTORS,SYS_DEPT.DEPT_NAME,SYS_DEPT.ORDER_NUM,SYS_DEPT.LEADER,SYS_DEPT.STATUS.as("dept_status"),
|
||||
SYS_ROLE.ROLE_ID,SYS_ROLE.ROLE_NAME,SYS_ROLE.ROLE_KEY,SYS_ROLE.ROLE_SORT,SYS_ROLE.DATA_SCOPE,SYS_ROLE.STATUS.as("role_status")))
|
||||
.from(SYS_USER.as("u"))
|
||||
.leftJoin(SYS_DEPT).as("d").on(SYS_DEPT.DEPT_ID.eq(SYS_USER.DEPT_ID))
|
||||
.leftJoin(SYS_USER_ROLE).as("ur").on(SYS_USER_ROLE.USER_ID.eq(SYS_USER.USER_ID))
|
||||
.leftJoin(SYS_ROLE).as("r").on(SYS_ROLE.ROLE_ID.eq(SYS_USER_ROLE.ROLE_ID));*/
|
||||
return QueryWrapper.create()
|
||||
.select(QueryMethods.distinct(SYS_USER.USER_ID,SYS_USER.TENANT_ID,SYS_USER.DEPT_ID,SYS_USER.NICK_NAME,SYS_USER.USER_NAME,SYS_USER.USER_TYPE,SYS_USER.EMAIL,SYS_USER.AVATAR,SYS_USER.PHONENUMBER,SYS_USER.PASSWORD,SYS_USER.GENDER,SYS_USER.STATUS,SYS_USER.DEL_FLAG,SYS_USER.LOGIN_IP,SYS_USER.LOGIN_DATE,SYS_USER.CREATE_BY,SYS_USER.CREATE_TIME,SYS_USER.REMARK,
|
||||
.select(QueryMethods.distinct(SYS_USER.USER_ID,SYS_USER.DEPT_ID,SYS_USER.NICK_NAME,SYS_USER.USER_NAME,SYS_USER.USER_TYPE,SYS_USER.EMAIL,SYS_USER.AVATAR,SYS_USER.PHONENUMBER,SYS_USER.PASSWORD,SYS_USER.GENDER,SYS_USER.STATUS,SYS_USER.DEL_FLAG,SYS_USER.LOGIN_IP,SYS_USER.LOGIN_DATE,SYS_USER.CREATE_BY,SYS_USER.CREATE_TIME,SYS_USER.REMARK,
|
||||
SYS_DEPT.DEPT_ID,SYS_DEPT.PARENT_ID,SYS_DEPT.ANCESTORS,SYS_DEPT.DEPT_NAME,SYS_DEPT.ORDER_NUM,SYS_DEPT.LEADER,SYS_DEPT.STATUS.as("dept_status")
|
||||
))
|
||||
.from(SYS_USER.as("u"))
|
||||
@ -179,22 +160,8 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<SysUserVo> selectAllocatedPage(SysUserBo userBo) {
|
||||
/* select distinct u.user_id, u.tenant_id, u.dept_id, u.user_name, u.nick_name, u.user_type, u.email, u.phonenumber, u.status, u.create_time
|
||||
from sys_user u
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
left join sys_user_role ur on u.user_id = ur.user_id
|
||||
left join sys_role r on r.role_id = ur.role_id
|
||||
where u.del_flag = '0' and r.role_id = #{roleId}
|
||||
<if test="userName != null and userName != ''">
|
||||
AND u.user_name like concat('%', #{userName}, '%')
|
||||
</if>
|
||||
<if test="phonenumber != null and phonenumber != ''">
|
||||
AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${params.dataScope}*/
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.select(QueryMethods.distinct(SYS_USER.USER_ID,SYS_USER.TENANT_ID,SYS_USER.DEPT_ID,SYS_USER.USER_NAME,SYS_USER.NICK_NAME,SYS_USER.USER_TYPE,SYS_USER.EMAIL,SYS_USER.PHONENUMBER,SYS_USER.STATUS,SYS_USER.CREATE_TIME))
|
||||
.select(QueryMethods.distinct(SYS_USER.USER_ID,SYS_USER.DEPT_ID,SYS_USER.USER_NAME,SYS_USER.NICK_NAME,SYS_USER.USER_TYPE,SYS_USER.EMAIL,SYS_USER.PHONENUMBER,SYS_USER.STATUS,SYS_USER.CREATE_TIME))
|
||||
.from(SYS_USER.as("u"))
|
||||
.leftJoin(SYS_DEPT).as("d").on(SYS_DEPT.DEPT_ID.eq(SYS_USER.DEPT_ID))
|
||||
.leftJoin(SYS_USER_ROLE).as("ur").on(SYS_USER_ROLE.USER_ID.eq(SYS_USER.USER_ID))
|
||||
@ -220,23 +187,8 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<SysUserVo> selectUnallocatedPage(SysUserBo userBo) {
|
||||
/*select distinct u.user_id, u.tenant_id, u.dept_id, u.user_name, u.nick_name, u.user_type, u.email, u.phonenumber, u.status, u.create_time
|
||||
from sys_user u
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
left join sys_user_role ur on u.user_id = ur.user_id
|
||||
left join sys_role r on r.role_id = ur.role_id
|
||||
where u.del_flag = '0' and (r.role_id != #{roleId} or r.role_id IS NULL)
|
||||
and u.user_id not in (select u.user_id from sys_user u inner join sys_user_role ur on u.user_id = ur.user_id and ur.role_id = #{roleId})
|
||||
<if test="userName != null and userName != ''">
|
||||
AND u.user_name like concat('%', #{userName}, '%')
|
||||
</if>
|
||||
<if test="phonenumber != null and phonenumber != ''">
|
||||
AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${params.dataScope}*/
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.select(QueryMethods.distinct(SYS_USER.USER_ID,SYS_USER.TENANT_ID,SYS_USER.DEPT_ID,SYS_USER.USER_NAME,SYS_USER.NICK_NAME,SYS_USER.USER_TYPE,SYS_USER.EMAIL,SYS_USER.PHONENUMBER,SYS_USER.STATUS,SYS_USER.CREATE_TIME))
|
||||
.select(QueryMethods.distinct(SYS_USER.USER_ID,SYS_USER.DEPT_ID,SYS_USER.USER_NAME,SYS_USER.NICK_NAME,SYS_USER.USER_TYPE,SYS_USER.EMAIL,SYS_USER.PHONENUMBER,SYS_USER.STATUS,SYS_USER.CREATE_TIME))
|
||||
.from(SYS_USER.as("u"))
|
||||
.leftJoin(SYS_DEPT).as("d").on(SYS_DEPT.DEPT_ID.eq(SYS_USER.DEPT_ID))
|
||||
.leftJoin(SYS_USER_ROLE).as("ur").on(SYS_USER_ROLE.USER_ID.eq(SYS_USER.USER_ID))
|
||||
@ -314,7 +266,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
|
||||
public SysUserVo selectProfileUserById(Long userId) {
|
||||
//使用leftjoin取得部门名称
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.select(QueryMethods.distinct(SYS_USER.USER_ID,SYS_USER.TENANT_ID,SYS_USER.DEPT_ID,SYS_USER.NICK_NAME,SYS_USER.USER_NAME,SYS_USER.USER_TYPE,SYS_USER.EMAIL,SYS_USER.AVATAR,SYS_USER.PHONENUMBER,SYS_USER.PASSWORD,SYS_USER.GENDER,SYS_USER.STATUS,SYS_USER.DEL_FLAG,SYS_USER.LOGIN_IP,SYS_USER.LOGIN_DATE,SYS_USER.CREATE_BY,SYS_USER.CREATE_TIME,SYS_USER.REMARK,
|
||||
.select(QueryMethods.distinct(SYS_USER.USER_ID,SYS_USER.DEPT_ID,SYS_USER.NICK_NAME,SYS_USER.USER_NAME,SYS_USER.USER_TYPE,SYS_USER.EMAIL,SYS_USER.AVATAR,SYS_USER.PHONENUMBER,SYS_USER.PASSWORD,SYS_USER.GENDER,SYS_USER.STATUS,SYS_USER.DEL_FLAG,SYS_USER.LOGIN_IP,SYS_USER.LOGIN_DATE,SYS_USER.CREATE_BY,SYS_USER.CREATE_TIME,SYS_USER.REMARK,
|
||||
SYS_DEPT.DEPT_ID,SYS_DEPT.PARENT_ID,SYS_DEPT.ANCESTORS,SYS_DEPT.DEPT_NAME,SYS_DEPT.ORDER_NUM,SYS_DEPT.LEADER,SYS_DEPT.STATUS.as("dept_status")
|
||||
))
|
||||
.from(SYS_USER.as("u"))
|
||||
@ -476,6 +428,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
|
||||
boolean saved = this.save(user);
|
||||
if(saved){
|
||||
// 新增用户岗位关联
|
||||
assert user != null;
|
||||
insertUserPost(user);
|
||||
// 新增用户与角色管理
|
||||
insertUserRole(user);
|
||||
@ -491,9 +444,8 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean registerUser(SysUserBo user, Long tenantId) {
|
||||
public boolean registerUser(SysUserBo user) {
|
||||
SysUser sysUser = MapstructUtils.convert(user, SysUser.class);
|
||||
sysUser.setTenantId(Long.valueOf(tenantId));
|
||||
return this.save(sysUser);
|
||||
}
|
||||
|
||||
@ -624,8 +576,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
|
||||
*
|
||||
* @param user 用户对象
|
||||
*/
|
||||
public boolean insertUserPost(SysUser user) {
|
||||
boolean inserted = true;
|
||||
public void insertUserPost(SysUser user) {
|
||||
Long[] posts = user.getPostIds();
|
||||
if (ObjectUtil.isNotEmpty(posts)) {
|
||||
// 新增用户与岗位管理
|
||||
@ -636,11 +587,10 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
|
||||
up.setPostId(postId);
|
||||
list.add(up);
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
return userPostService.saveBatchWithPk(list,100);//批量保存
|
||||
if (!list.isEmpty()) {
|
||||
userPostService.saveBatchWithPk(list, 100);
|
||||
}
|
||||
}
|
||||
return inserted;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -703,7 +653,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
|
||||
*/
|
||||
@Override
|
||||
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, Long operId) {
|
||||
if (StringUtils.isNull(userList) || userList.size() == 0) {
|
||||
if (StringUtils.isNull(userList) || userList.isEmpty()) {
|
||||
throw new ServiceException("导入用户数据不能为空!");
|
||||
}
|
||||
int successNum = 0;
|
||||
@ -721,7 +671,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
|
||||
user.setCreateBy(operId);
|
||||
this.save(user);
|
||||
successNum++;
|
||||
successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 导入成功");
|
||||
successMsg.append("<br/>").append(successNum).append("、账号 ").append(user.getUserName()).append(" 导入成功");
|
||||
} else if (isUpdateSupport) {
|
||||
BeanValidators.validateWithException(validator, user);
|
||||
checkUserAllowed(u.getUserId());
|
||||
@ -730,15 +680,15 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
|
||||
user.setUpdateBy(operId);
|
||||
this.updateById(user);
|
||||
successNum++;
|
||||
successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 更新成功");
|
||||
successMsg.append("<br/>").append(successNum).append("、账号 ").append(user.getUserName()).append(" 更新成功");
|
||||
} else {
|
||||
failureNum++;
|
||||
failureMsg.append("<br/>" + failureNum + "、账号 " + user.getUserName() + " 已存在");
|
||||
failureMsg.append("<br/>").append(failureNum).append("、账号 ").append(user.getUserName()).append(" 已存在");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
failureNum++;
|
||||
String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:";
|
||||
failureMsg.append(msg + e.getMessage());
|
||||
failureMsg.append(msg).append(e.getMessage());
|
||||
log.error(msg, e);
|
||||
}
|
||||
}
|
||||
@ -761,7 +711,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
|
||||
/**
|
||||
* 通过部门id查询当前部门所有用户
|
||||
*
|
||||
* @param deptId
|
||||
* @param deptId 部门ID
|
||||
* @return 用户vo列表
|
||||
*/
|
||||
@Override
|
||||
|
@ -1414,40 +1414,10 @@ INSERT INTO `sys_role_menu` (`role_id`, `menu_id`) VALUES
|
||||
(65652406490345472, 2066),
|
||||
(65652406490345472, 2067);
|
||||
|
||||
-- 导出 表 ruoyi-flex.sys_tenant 结构
|
||||
DROP TABLE IF EXISTS `sys_tenant`;
|
||||
CREATE TABLE IF NOT EXISTS `sys_tenant` (
|
||||
`id` bigint NOT NULL COMMENT 'id',
|
||||
`tenant_id` bigint NOT NULL COMMENT '租户编号',
|
||||
`contact_user_name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '联系人',
|
||||
`contact_phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '联系电话',
|
||||
`company_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '企业名称',
|
||||
`license_number` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '统一社会信用代码',
|
||||
`address` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '地址',
|
||||
`intro` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '企业简介',
|
||||
`domain` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '域名',
|
||||
`remark` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '备注',
|
||||
`package_id` bigint DEFAULT NULL COMMENT '租户套餐编号',
|
||||
`expire_time` datetime DEFAULT NULL COMMENT '过期时间',
|
||||
`account_count` int DEFAULT '-1' COMMENT '用户数量(-1不限制)',
|
||||
`status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT '0' COMMENT '租户状态(0正常 1停用)',
|
||||
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT '0' COMMENT '删除标志(0代表存在 2代表删除)',
|
||||
`create_by` bigint DEFAULT NULL COMMENT '创建者',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_by` bigint DEFAULT NULL COMMENT '更新者',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='租户表';
|
||||
|
||||
-- 正在导出表 ruoyi-flex.sys_tenant 的数据:~0 rows (大约)
|
||||
INSERT INTO `sys_tenant` (`id`, `tenant_id`, `contact_user_name`, `contact_phone`, `company_name`, `license_number`, `address`, `intro`, `domain`, `remark`, `package_id`, `expire_time`, `account_count`, `status`, `del_flag`, `create_by`, `create_time`, `update_by`, `update_time`) VALUES
|
||||
(1, 1, '租户管理组', '18888888888', 'XXX有限公司', NULL, NULL, 'RuoYi-Flex多租户通用后台管理管理系统', NULL, NULL, NULL, NULL, -1, '0', '0', 1, '2023-08-13 08:08:08', NULL, NULL);
|
||||
|
||||
-- 导出 表 ruoyi-flex.sys_user 结构
|
||||
DROP TABLE IF EXISTS `sys_user`;
|
||||
CREATE TABLE IF NOT EXISTS `sys_user` (
|
||||
`user_id` bigint NOT NULL COMMENT '用户ID',
|
||||
`tenant_id` bigint NOT NULL DEFAULT '0' COMMENT '租户主键',
|
||||
`dept_id` bigint DEFAULT NULL COMMENT '部门ID',
|
||||
`user_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '用户账号',
|
||||
`nick_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '用户昵称',
|
||||
@ -1470,16 +1440,16 @@ CREATE TABLE IF NOT EXISTS `sys_user` (
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='用户信息表';
|
||||
|
||||
-- 正在导出表 ruoyi-flex.sys_user 的数据:~9 rows (大约)
|
||||
INSERT INTO `sys_user` (`user_id`, `tenant_id`, `dept_id`, `user_name`, `nick_name`, `user_type`, `email`, `phonenumber`, `gender`, `avatar`, `password`, `status`, `del_flag`, `login_ip`, `login_date`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES
|
||||
(1, 1, 103, 'admin', '若依', 'sys_user', 'ry@163.com', '15888888888', '1', NULL, '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', '0', '0', '0:0:0:0:0:0:0:1', '2023-12-18 10:57:01', 1, '2023-06-03 21:32:28', 1, '2023-12-18 10:57:01', '管理员'),
|
||||
(2, 1, 65929080159150080, 'ry', 'ruoyi-flex', 'sys_user', 'ry@qq.com', '15666666666', '1', NULL, '$2a$10$LM1zq1y9I7QhvnMOK5NPuOkyr9r7fo8IGm2MGfeD5KKdQAOLcRmEe', '0', '0', '0:0:0:0:0:0:0:1', '2023-12-14 21:22:18', 1, '2023-06-03 21:32:28', 2, '2023-12-14 21:22:18', '测试员'),
|
||||
(100, 1, 102, 'flex', 'flex昵称', 'sys_user', 'flex8888@163.com', '18808928888', '0', NULL, '$2a$10$jbN5LcYAQQ2E8g8MT.w7cu1YFNwKa/Nf4.A373DUc9fyRHLl9zwWO', '0', '0', '127.0.0.1', '2023-11-15 16:42:43', 1, '2023-07-06 16:49:17', 100, '2023-11-15 16:45:08', NULL),
|
||||
(101, 0, 100, 'vue3', 'vue3用户名', 'sys_user', '', '', '0', NULL, '$2a$10$MEjgdOQgvs7obwu6yoVnLO/K3wGPMlV3CAQMxVIpqwebFZat22NUW', '1', '0', '', NULL, 1, '2023-09-12 11:53:15', 1, '2023-10-16 17:15:32', 'vue3新增测试用户'),
|
||||
(71449897878007808, 0, 65929080159150080, 'java', 'java', 'sys_user', 'javaisgood@qq.com', '18966666666', '0', NULL, '$2a$10$fPvJrZBCZojxIauT/VERm.gX6jGVLfJLkKo5j5DGJstT6dO/AX4Dm', '0', '0', '127.0.0.1', '2023-11-21 19:28:48', 1, '2023-10-16 16:57:23', 71449897878007808, '2023-11-21 19:28:48', 'java用户'),
|
||||
(71454850805735424, 0, 65929460884512768, 'java2', 'java2', 'sys_user', 'java2@1126.com', '18855556963', '1', NULL, '$2a$10$m2g/pdS9ciOBYfVAEH6FoOsC2.Ls7b86oQ/TM/4WowwvGGE1aSRLS', '0', '1', '', NULL, 1, '2023-10-16 17:17:04', 1, '2023-10-16 17:19:24', NULL),
|
||||
(71500938010955776, 0, 65929267321577472, 'javaTest', 'java测试', 'sys_user', 'test@163.com', '13366666666', '0', NULL, '', '0', '0', '127.0.0.1', '2023-10-19 20:49:24', 1, '2023-10-16 20:20:12', 71449897878007808, '2023-11-21 09:35:54', NULL),
|
||||
(75077525943939072, 0, 65929460884512768, 'li', 'li', 'sys_user', 'li@qq.com', '13666666666', '0', NULL, '', '0', '0', '', NULL, 1, '2023-10-26 17:12:17', 1, '2023-11-21 16:07:15', NULL),
|
||||
(75081100715675648, 0, 203, 'vue3-li', 'vue3-li', 'sys_user', 'vue3-li@qq.com', '13566666666', '1', NULL, '', '0', '0', '127.0.0.1', '2023-10-27 22:33:10', 1, '2023-10-26 17:26:29', 71449897878007808, '2023-11-21 16:26:17', NULL);
|
||||
INSERT INTO `sys_user` (`user_id`, `dept_id`, `user_name`, `nick_name`, `user_type`, `email`, `phonenumber`, `gender`, `avatar`, `password`, `status`, `del_flag`, `login_ip`, `login_date`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES
|
||||
(1, 103, 'admin', '若依', 'sys_user', 'ry@163.com', '15888888888', '1', NULL, '$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2', '0', '0', '0:0:0:0:0:0:0:1', '2023-12-18 10:57:01', 1, '2023-06-03 21:32:28', 1, '2023-12-18 10:57:01', '管理员'),
|
||||
(2, 65929080159150080, 'ry', 'ruoyi-flex', 'sys_user', 'ry@qq.com', '15666666666', '1', NULL, '$2a$10$LM1zq1y9I7QhvnMOK5NPuOkyr9r7fo8IGm2MGfeD5KKdQAOLcRmEe', '0', '0', '0:0:0:0:0:0:0:1', '2023-12-14 21:22:18', 1, '2023-06-03 21:32:28', 2, '2023-12-14 21:22:18', '测试员'),
|
||||
(100, 102, 'flex', 'flex昵称', 'sys_user', 'flex8888@163.com', '18808928888', '0', NULL, '$2a$10$jbN5LcYAQQ2E8g8MT.w7cu1YFNwKa/Nf4.A373DUc9fyRHLl9zwWO', '0', '0', '127.0.0.1', '2023-11-15 16:42:43', 1, '2023-07-06 16:49:17', 100, '2023-11-15 16:45:08', NULL),
|
||||
(101, 100, 'vue3', 'vue3用户名', 'sys_user', '', '', '0', NULL, '$2a$10$MEjgdOQgvs7obwu6yoVnLO/K3wGPMlV3CAQMxVIpqwebFZat22NUW', '1', '0', '', NULL, 1, '2023-09-12 11:53:15', 1, '2023-10-16 17:15:32', 'vue3新增测试用户'),
|
||||
(71449897878007808, 65929080159150080, 'java', 'java', 'sys_user', 'javaisgood@qq.com', '18966666666', '0', NULL, '$2a$10$fPvJrZBCZojxIauT/VERm.gX6jGVLfJLkKo5j5DGJstT6dO/AX4Dm', '0', '0', '127.0.0.1', '2023-11-21 19:28:48', 1, '2023-10-16 16:57:23', 71449897878007808, '2023-11-21 19:28:48', 'java用户'),
|
||||
(71454850805735424, 65929460884512768, 'java2', 'java2', 'sys_user', 'java2@1126.com', '18855556963', '1', NULL, '$2a$10$m2g/pdS9ciOBYfVAEH6FoOsC2.Ls7b86oQ/TM/4WowwvGGE1aSRLS', '0', '1', '', NULL, 1, '2023-10-16 17:17:04', 1, '2023-10-16 17:19:24', NULL),
|
||||
(71500938010955776, 65929267321577472, 'javaTest', 'java测试', 'sys_user', 'test@163.com', '13366666666', '0', NULL, '', '0', '0', '127.0.0.1', '2023-10-19 20:49:24', 1, '2023-10-16 20:20:12', 71449897878007808, '2023-11-21 09:35:54', NULL),
|
||||
(75077525943939072, 65929460884512768, 'li', 'li', 'sys_user', 'li@qq.com', '13666666666', '0', NULL, '', '0', '0', '', NULL, 1, '2023-10-26 17:12:17', 1, '2023-11-21 16:07:15', NULL),
|
||||
(75081100715675648, 203, 'vue3-li', 'vue3-li', 'sys_user', 'vue3-li@qq.com', '13566666666', '1', NULL, '', '0', '0', '127.0.0.1', '2023-10-27 22:33:10', 1, '2023-10-26 17:26:29', 71449897878007808, '2023-11-21 16:26:17', NULL);
|
||||
|
||||
-- 导出 表 ruoyi-flex.sys_user_post 结构
|
||||
DROP TABLE IF EXISTS `sys_user_post`;
|
||||
|
@ -1,30 +0,0 @@
|
||||
--V4.1.8升级到V4.2.0:
|
||||
-- sys_menu菜单表结构修改、去掉主键自增
|
||||
ALTER TABLE `sys_menu`
|
||||
CHANGE COLUMN `menu_id` `menu_id` BIGINT(19) NOT NULL COMMENT '菜单ID' FIRST,
|
||||
CHANGE COLUMN `order_num` `order_num` INT(4) NULL DEFAULT '0' COMMENT '显示顺序' AFTER `parent_id`,
|
||||
CHANGE COLUMN `query` `query_param` VARCHAR(255) NULL DEFAULT NULL COMMENT '路由参数' COLLATE 'utf8mb4_bin' AFTER `component`,
|
||||
CHANGE COLUMN `is_frame` `is_frame` INT(1) NULL DEFAULT '1' COMMENT '是否为外链(0是 1否)' AFTER `query_param`,
|
||||
CHANGE COLUMN `is_cache` `is_cache` INT(1) NULL DEFAULT '0' COMMENT '是否缓存(0缓存 1不缓存)' AFTER `is_frame`;
|
||||
-- gen_table表去掉主键自增
|
||||
ALTER TABLE `gen_table`
|
||||
CHANGE COLUMN `table_id` `table_id` BIGINT(19) NOT NULL COMMENT '编号' FIRST;
|
||||
-- gen_table_column表去掉主键自增
|
||||
ALTER TABLE `gen_table_column`
|
||||
CHANGE COLUMN `column_id` `column_id` BIGINT(19) NOT NULL COMMENT '编号' FIRST;
|
||||
|
||||
ALTER TABLE `sys_tenant` DROP COLUMN `create_dept`;
|
||||
|
||||
-- 修改数据库表的del_flag字段为smallint类型
|
||||
ALTER TABLE `sys_client`
|
||||
CHANGE COLUMN `del_flag` `del_flag` SMALLINT NULL DEFAULT '0' COMMENT '删除标志(0代表存在 1代表删除)' COLLATE 'utf8mb4_bin' AFTER `status`;
|
||||
ALTER TABLE `sys_dept`
|
||||
CHANGE COLUMN `del_flag` `del_flag` SMALLINT NULL DEFAULT '0' COMMENT '删除标志(0代表存在 1代表删除)' COLLATE 'utf8mb4_bin' AFTER `status`;
|
||||
ALTER TABLE `sys_role`
|
||||
CHANGE COLUMN `del_flag` `del_flag` SMALLINT NULL DEFAULT '0' COMMENT '删除标志(0代表存在 1代表删除)' COLLATE 'utf8mb4_bin' AFTER `status`;
|
||||
ALTER TABLE `sys_tenant`
|
||||
CHANGE COLUMN `del_flag` `del_flag` SMALLINT NULL DEFAULT '0' COMMENT '删除标志(0代表存在 1代表删除)' COLLATE 'utf8mb4_bin' AFTER `status`;
|
||||
ALTER TABLE `sys_user`
|
||||
CHANGE COLUMN `del_flag` `del_flag` SMALLINT NULL DEFAULT '0' COMMENT '删除标志(0代表存在 1代表删除)' COLLATE 'utf8mb4_bin' AFTER `status`;
|
||||
|
||||
|
@ -1619,59 +1619,10 @@ INSERT INTO sys_role_menu VALUES
|
||||
(65652406490345472, 2066),
|
||||
(65652406490345472, 2067);
|
||||
|
||||
drop table if exists sys_tenant;
|
||||
create table if not exists sys_tenant
|
||||
(
|
||||
id bigint,
|
||||
tenant_id bigint,
|
||||
contact_user_name varchar(20) default null::varchar,
|
||||
contact_phone varchar(20) default null::varchar,
|
||||
company_name varchar(50) default null::varchar,
|
||||
license_number varchar(30) default null::varchar,
|
||||
address varchar(200) default null::varchar,
|
||||
intro varchar(200) default null::varchar,
|
||||
domain varchar(200) default null::varchar,
|
||||
remark varchar(200) default null::varchar,
|
||||
package_id bigint,
|
||||
expire_time timestamp,
|
||||
account_count int4 default -1,
|
||||
status char default '0'::bpchar,
|
||||
del_flag smallint default 0,
|
||||
create_by bigint,
|
||||
create_time timestamp,
|
||||
update_by bigint,
|
||||
update_time timestamp,
|
||||
constraint "pk_sys_tenant" primary key (id)
|
||||
);
|
||||
|
||||
comment on table sys_tenant is '租户表';
|
||||
comment on column sys_tenant.tenant_id is '租户编号';
|
||||
comment on column sys_tenant.contact_phone is '联系电话';
|
||||
comment on column sys_tenant.company_name is '企业名称';
|
||||
comment on column sys_tenant.company_name is '联系人';
|
||||
comment on column sys_tenant.license_number is '统一社会信用代码';
|
||||
comment on column sys_tenant.address is '地址';
|
||||
comment on column sys_tenant.intro is '企业简介';
|
||||
comment on column sys_tenant.domain is '域名';
|
||||
comment on column sys_tenant.remark is '备注';
|
||||
comment on column sys_tenant.package_id is '租户套餐编号';
|
||||
comment on column sys_tenant.expire_time is '过期时间';
|
||||
comment on column sys_tenant.account_count is '用户数量(-1不限制)';
|
||||
comment on column sys_tenant.status is '租户状态(0正常 1停用)';
|
||||
comment on column sys_tenant.del_flag is '删除标志(0代表存在 1代表删除)';
|
||||
comment on column sys_tenant.create_by is '创建者';
|
||||
comment on column sys_tenant.create_time is '创建时间';
|
||||
comment on column sys_tenant.update_by is '更新者';
|
||||
comment on column sys_tenant.update_time is '更新时间';
|
||||
|
||||
insert into sys_tenant values
|
||||
(1, 1, '租户管理组', '18888888888', 'XXX有限公司', NULL, NULL, 'RuoYi-Flex多租户通用后台管理管理系统', NULL, NULL, NULL, NULL, -1, '0', 0, 1, '2023-08-13 08:08:08', NULL, NULL);
|
||||
|
||||
drop table if exists sys_user;
|
||||
create table if not exists sys_user
|
||||
(
|
||||
user_id bigint,
|
||||
tenant_id bigint,
|
||||
dept_id bigint,
|
||||
user_name varchar(30) not null,
|
||||
nick_name varchar(30) not null,
|
||||
@ -1695,7 +1646,6 @@ create table if not exists sys_user
|
||||
|
||||
comment on table sys_user is '用户信息表';
|
||||
comment on column sys_user.user_id is '用户ID';
|
||||
comment on column sys_user.tenant_id is '租户编号';
|
||||
comment on column sys_user.dept_id is '部门ID';
|
||||
comment on column sys_user.user_name is '用户账号';
|
||||
comment on column sys_user.nick_name is '用户昵称';
|
||||
|
Loading…
Reference in New Issue
Block a user