mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-20 18:15:56 +08:00
Merge branch 'dev' into future/flowable
This commit is contained in:
commit
ce46dfd7aa
@ -2,7 +2,7 @@
|
|||||||
<configuration default="false" name="ruoyi-monitor-admin" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
|
<configuration default="false" name="ruoyi-monitor-admin" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
|
||||||
<deployment type="dockerfile">
|
<deployment type="dockerfile">
|
||||||
<settings>
|
<settings>
|
||||||
<option name="imageTag" value="ruoyi/ruoyi-monitor-admin:5.1.0" />
|
<option name="imageTag" value="ruoyi/ruoyi-monitor-admin:5.1.1" />
|
||||||
<option name="buildOnly" value="true" />
|
<option name="buildOnly" value="true" />
|
||||||
<option name="sourceFilePath" value="ruoyi-extend/ruoyi-monitor-admin/Dockerfile" />
|
<option name="sourceFilePath" value="ruoyi-extend/ruoyi-monitor-admin/Dockerfile" />
|
||||||
</settings>
|
</settings>
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
<configuration default="false" name="ruoyi-powerjob-server" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
|
<configuration default="false" name="ruoyi-powerjob-server" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
|
||||||
<deployment type="dockerfile">
|
<deployment type="dockerfile">
|
||||||
<settings>
|
<settings>
|
||||||
<option name="imageTag" value="ruoyi/ruoyi-powerjob-server:5.1.0" />
|
<option name="imageTag" value="ruoyi/ruoyi-powerjob-server:5.1.1" />
|
||||||
<option name="buildOnly" value="true" />
|
<option name="buildOnly" value="true" />
|
||||||
<option name="sourceFilePath" value="ruoyi-extend/ruoyi-powerjob-server/Dockerfile" />
|
<option name="sourceFilePath" value="ruoyi-extend/ruoyi-powerjob-server/Dockerfile" />
|
||||||
</settings>
|
</settings>
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
<configuration default="false" name="ruoyi-server" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
|
<configuration default="false" name="ruoyi-server" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
|
||||||
<deployment type="dockerfile">
|
<deployment type="dockerfile">
|
||||||
<settings>
|
<settings>
|
||||||
<option name="imageTag" value="ruoyi/ruoyi-server:5.1.0" />
|
<option name="imageTag" value="ruoyi/ruoyi-server:5.1.1" />
|
||||||
<option name="buildOnly" value="true" />
|
<option name="buildOnly" value="true" />
|
||||||
<option name="sourceFilePath" value="ruoyi-admin/Dockerfile" />
|
<option name="sourceFilePath" value="ruoyi-admin/Dockerfile" />
|
||||||
</settings>
|
</settings>
|
||||||
|
|||||||
@ -9,10 +9,10 @@
|
|||||||
[](https://gitee.com/dromara/RuoYi-Vue-Plus/blob/master/LICENSE)
|
[](https://gitee.com/dromara/RuoYi-Vue-Plus/blob/master/LICENSE)
|
||||||
[](https://www.jetbrains.com/?from=RuoYi-Vue-Plus)
|
[](https://www.jetbrains.com/?from=RuoYi-Vue-Plus)
|
||||||
<br>
|
<br>
|
||||||
[](https://gitee.com/dromara/RuoYi-Vue-Plus)
|
[](https://gitee.com/dromara/RuoYi-Vue-Plus)
|
||||||
[]()
|
[]()
|
||||||
[]()
|
[]()
|
||||||
[]()
|
[]()
|
||||||
|
|
||||||
> RuoYi-Vue-Plus 是重写 RuoYi-Vue 针对 `分布式集群与多租户` 场景全方位升级(不兼容原框架)
|
> RuoYi-Vue-Plus 是重写 RuoYi-Vue 针对 `分布式集群与多租户` 场景全方位升级(不兼容原框架)
|
||||||
|
|
||||||
|
|||||||
8
pom.xml
8
pom.xml
@ -13,7 +13,7 @@
|
|||||||
<description>RuoYi-Vue-Plus多租户管理系统</description>
|
<description>RuoYi-Vue-Plus多租户管理系统</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<revision>5.1.0</revision>
|
<revision>5.1.1</revision>
|
||||||
<spring-boot.version>3.1.5</spring-boot.version>
|
<spring-boot.version>3.1.5</spring-boot.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
@ -30,7 +30,7 @@
|
|||||||
<hutool.version>5.8.22</hutool.version>
|
<hutool.version>5.8.22</hutool.version>
|
||||||
<okhttp.version>4.10.0</okhttp.version>
|
<okhttp.version>4.10.0</okhttp.version>
|
||||||
<spring-boot-admin.version>3.1.7</spring-boot-admin.version>
|
<spring-boot-admin.version>3.1.7</spring-boot-admin.version>
|
||||||
<redisson.version>3.24.1</redisson.version>
|
<redisson.version>3.24.3</redisson.version>
|
||||||
<lock4j.version>2.2.5</lock4j.version>
|
<lock4j.version>2.2.5</lock4j.version>
|
||||||
<dynamic-ds.version>4.2.0</dynamic-ds.version>
|
<dynamic-ds.version>4.2.0</dynamic-ds.version>
|
||||||
<alibaba-ttl.version>2.14.2</alibaba-ttl.version>
|
<alibaba-ttl.version>2.14.2</alibaba-ttl.version>
|
||||||
@ -67,7 +67,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<!-- 环境标识,需要与配置文件的名称相对应 -->
|
<!-- 环境标识,需要与配置文件的名称相对应 -->
|
||||||
<profiles.active>local</profiles.active>
|
<profiles.active>local</profiles.active>
|
||||||
<logging.level>debug</logging.level>
|
<logging.level>info</logging.level>
|
||||||
</properties>
|
</properties>
|
||||||
</profile>
|
</profile>
|
||||||
<profile>
|
<profile>
|
||||||
@ -75,7 +75,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<!-- 环境标识,需要与配置文件的名称相对应 -->
|
<!-- 环境标识,需要与配置文件的名称相对应 -->
|
||||||
<profiles.active>dev</profiles.active>
|
<profiles.active>dev</profiles.active>
|
||||||
<logging.level>debug</logging.level>
|
<logging.level>info</logging.level>
|
||||||
</properties>
|
</properties>
|
||||||
<activation>
|
<activation>
|
||||||
<!-- 默认环境 -->
|
<!-- 默认环境 -->
|
||||||
|
|||||||
@ -21,4 +21,5 @@ ENTRYPOINT ["java", \
|
|||||||
# 应用名称 如果想区分集群节点监控 改成不同的名称即可
|
# 应用名称 如果想区分集群节点监控 改成不同的名称即可
|
||||||
# "-Dskywalking.agent.service_name=ruoyi-server", \
|
# "-Dskywalking.agent.service_name=ruoyi-server", \
|
||||||
# "-javaagent:/ruoyi/skywalking/agent/skywalking-agent.jar", \
|
# "-javaagent:/ruoyi/skywalking/agent/skywalking-agent.jar", \
|
||||||
"-jar", "app.jar"]
|
"-jar", "app.jar",
|
||||||
|
"-XX:+HeapDumpOnOutOfMemoryError", "-Xlog:gc*,:time,tags,level", "-XX:+UseZGC"]
|
||||||
|
|||||||
@ -1,20 +1,24 @@
|
|||||||
package org.dromara.common.satoken.listener;
|
package org.dromara.web.listener;
|
||||||
|
|
||||||
import cn.dev33.satoken.config.SaTokenConfig;
|
import cn.dev33.satoken.config.SaTokenConfig;
|
||||||
import cn.dev33.satoken.listener.SaTokenListener;
|
import cn.dev33.satoken.listener.SaTokenListener;
|
||||||
import cn.dev33.satoken.stp.SaLoginModel;
|
import cn.dev33.satoken.stp.SaLoginModel;
|
||||||
import cn.hutool.http.useragent.UserAgent;
|
import cn.hutool.http.useragent.UserAgent;
|
||||||
import cn.hutool.http.useragent.UserAgentUtil;
|
import cn.hutool.http.useragent.UserAgentUtil;
|
||||||
import org.dromara.common.core.constant.CacheConstants;
|
|
||||||
import org.dromara.common.core.domain.dto.UserOnlineDTO;
|
|
||||||
import org.dromara.common.core.domain.model.LoginUser;
|
|
||||||
import org.dromara.common.core.enums.UserType;
|
|
||||||
import org.dromara.common.redis.utils.RedisUtils;
|
|
||||||
import org.dromara.common.satoken.utils.LoginHelper;
|
|
||||||
import org.dromara.common.core.utils.ip.AddressUtils;
|
|
||||||
import org.dromara.common.core.utils.ServletUtils;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.dromara.common.core.constant.CacheConstants;
|
||||||
|
import org.dromara.common.core.constant.Constants;
|
||||||
|
import org.dromara.common.core.domain.dto.UserOnlineDTO;
|
||||||
|
import org.dromara.common.core.domain.model.LoginUser;
|
||||||
|
import org.dromara.common.core.utils.MessageUtils;
|
||||||
|
import org.dromara.common.core.utils.ServletUtils;
|
||||||
|
import org.dromara.common.core.utils.SpringUtils;
|
||||||
|
import org.dromara.common.core.utils.ip.AddressUtils;
|
||||||
|
import org.dromara.common.log.event.LogininforEvent;
|
||||||
|
import org.dromara.common.redis.utils.RedisUtils;
|
||||||
|
import org.dromara.common.satoken.utils.LoginHelper;
|
||||||
|
import org.dromara.web.service.SysLoginService;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
@ -30,37 +34,43 @@ import java.time.Duration;
|
|||||||
public class UserActionListener implements SaTokenListener {
|
public class UserActionListener implements SaTokenListener {
|
||||||
|
|
||||||
private final SaTokenConfig tokenConfig;
|
private final SaTokenConfig tokenConfig;
|
||||||
|
private final SysLoginService loginService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 每次登录时触发
|
* 每次登录时触发
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void doLogin(String loginType, Object loginId, String tokenValue, SaLoginModel loginModel) {
|
public void doLogin(String loginType, Object loginId, String tokenValue, SaLoginModel loginModel) {
|
||||||
UserType userType = UserType.getUserType(loginId.toString());
|
UserAgent userAgent = UserAgentUtil.parse(ServletUtils.getRequest().getHeader("User-Agent"));
|
||||||
if (userType == UserType.SYS_USER) {
|
String ip = ServletUtils.getClientIP();
|
||||||
UserAgent userAgent = UserAgentUtil.parse(ServletUtils.getRequest().getHeader("User-Agent"));
|
LoginUser user = LoginHelper.getLoginUser();
|
||||||
String ip = ServletUtils.getClientIP();
|
UserOnlineDTO dto = new UserOnlineDTO();
|
||||||
LoginUser user = LoginHelper.getLoginUser();
|
dto.setIpaddr(ip);
|
||||||
UserOnlineDTO dto = new UserOnlineDTO();
|
dto.setLoginLocation(AddressUtils.getRealAddressByIP(ip));
|
||||||
dto.setIpaddr(ip);
|
dto.setBrowser(userAgent.getBrowser().getName());
|
||||||
dto.setLoginLocation(AddressUtils.getRealAddressByIP(ip));
|
dto.setOs(userAgent.getOs().getName());
|
||||||
dto.setBrowser(userAgent.getBrowser().getName());
|
dto.setLoginTime(System.currentTimeMillis());
|
||||||
dto.setOs(userAgent.getOs().getName());
|
dto.setTokenId(tokenValue);
|
||||||
dto.setLoginTime(System.currentTimeMillis());
|
dto.setUserName(user.getUsername());
|
||||||
dto.setTokenId(tokenValue);
|
dto.setClientKey(user.getClientKey());
|
||||||
dto.setUserName(user.getUsername());
|
dto.setDeviceType(user.getDeviceType());
|
||||||
dto.setClientKey(user.getClientKey());
|
dto.setDeptName(user.getDeptName());
|
||||||
dto.setDeviceType(user.getDeviceType());
|
if(tokenConfig.getTimeout() == -1) {
|
||||||
dto.setDeptName(user.getDeptName());
|
RedisUtils.setCacheObject(CacheConstants.ONLINE_TOKEN_KEY + tokenValue, dto);
|
||||||
if(tokenConfig.getTimeout() == -1) {
|
} else {
|
||||||
RedisUtils.setCacheObject(CacheConstants.ONLINE_TOKEN_KEY + tokenValue, dto);
|
RedisUtils.setCacheObject(CacheConstants.ONLINE_TOKEN_KEY + tokenValue, dto, Duration.ofSeconds(tokenConfig.getTimeout()));
|
||||||
} else {
|
|
||||||
RedisUtils.setCacheObject(CacheConstants.ONLINE_TOKEN_KEY + tokenValue, dto, Duration.ofSeconds(tokenConfig.getTimeout()));
|
|
||||||
}
|
|
||||||
log.info("user doLogin, userId:{}, token:{}", loginId, tokenValue);
|
|
||||||
} else if (userType == UserType.APP_USER) {
|
|
||||||
// app端 自行根据业务编写
|
|
||||||
}
|
}
|
||||||
|
// 记录登录日志
|
||||||
|
LogininforEvent logininforEvent = new LogininforEvent();
|
||||||
|
logininforEvent.setTenantId(user.getTenantId());
|
||||||
|
logininforEvent.setUsername(user.getUsername());
|
||||||
|
logininforEvent.setStatus(Constants.LOGIN_SUCCESS);
|
||||||
|
logininforEvent.setMessage(MessageUtils.message("user.login.success"));
|
||||||
|
logininforEvent.setRequest(ServletUtils.getRequest());
|
||||||
|
SpringUtils.context().publishEvent(logininforEvent);
|
||||||
|
// 更新登录信息
|
||||||
|
loginService.recordLoginInfo(user.getUserId(), ip);
|
||||||
|
log.info("user doLogin, userId:{}, token:{}", loginId, tokenValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -20,18 +20,17 @@ public interface IAuthStrategy {
|
|||||||
*/
|
*/
|
||||||
static LoginVo login(String body, SysClient client, String grantType) {
|
static LoginVo login(String body, SysClient client, String grantType) {
|
||||||
// 授权类型和客户端id
|
// 授权类型和客户端id
|
||||||
String clientId = client.getClientId();
|
|
||||||
String beanName = grantType + BASE_NAME;
|
String beanName = grantType + BASE_NAME;
|
||||||
if (!SpringUtils.containsBean(beanName)) {
|
if (!SpringUtils.containsBean(beanName)) {
|
||||||
throw new ServiceException("授权类型不正确!");
|
throw new ServiceException("授权类型不正确!");
|
||||||
}
|
}
|
||||||
IAuthStrategy instance = SpringUtils.getBean(beanName);
|
IAuthStrategy instance = SpringUtils.getBean(beanName);
|
||||||
return instance.login(clientId, body, client);
|
return instance.login(body, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录
|
* 登录
|
||||||
*/
|
*/
|
||||||
LoginVo login(String clientId, String body, SysClient client);
|
LoginVo login(String body, SysClient client);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package org.dromara.web.service;
|
|||||||
import cn.dev33.satoken.exception.NotLoginException;
|
import cn.dev33.satoken.exception.NotLoginException;
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -17,6 +18,7 @@ import org.dromara.common.core.enums.TenantStatus;
|
|||||||
import org.dromara.common.core.exception.user.UserException;
|
import org.dromara.common.core.exception.user.UserException;
|
||||||
import org.dromara.common.core.utils.*;
|
import org.dromara.common.core.utils.*;
|
||||||
import org.dromara.common.log.event.LogininforEvent;
|
import org.dromara.common.log.event.LogininforEvent;
|
||||||
|
import org.dromara.common.mybatis.helper.DataPermissionHelper;
|
||||||
import org.dromara.common.redis.utils.RedisUtils;
|
import org.dromara.common.redis.utils.RedisUtils;
|
||||||
import org.dromara.common.satoken.utils.LoginHelper;
|
import org.dromara.common.satoken.utils.LoginHelper;
|
||||||
import org.dromara.common.tenant.exception.TenantException;
|
import org.dromara.common.tenant.exception.TenantException;
|
||||||
@ -77,13 +79,13 @@ public class SysLoginService {
|
|||||||
bo.setUserName(authUserData.getUsername());
|
bo.setUserName(authUserData.getUsername());
|
||||||
bo.setNickName(authUserData.getNickname());
|
bo.setNickName(authUserData.getNickname());
|
||||||
// 查询是否已经绑定用户
|
// 查询是否已经绑定用户
|
||||||
SysSocialVo vo = sysSocialService.selectByAuthId(authId);
|
List<SysSocialVo> list = sysSocialService.selectByAuthId(authId);
|
||||||
if (ObjectUtil.isEmpty(vo)) {
|
if (CollUtil.isEmpty(list)) {
|
||||||
// 没有绑定用户, 新增用户信息
|
// 没有绑定用户, 新增用户信息
|
||||||
sysSocialService.insertByBo(bo);
|
sysSocialService.insertByBo(bo);
|
||||||
} else {
|
} else {
|
||||||
// 更新用户信息
|
// 更新用户信息
|
||||||
bo.setId(vo.getId());
|
bo.setId(list.get(0).getId());
|
||||||
sysSocialService.updateByBo(bo);
|
sysSocialService.updateByBo(bo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -152,13 +154,13 @@ public class SysLoginService {
|
|||||||
*
|
*
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
*/
|
*/
|
||||||
public void recordLoginInfo(Long userId) {
|
public void recordLoginInfo(Long userId, String ip) {
|
||||||
SysUser sysUser = new SysUser();
|
SysUser sysUser = new SysUser();
|
||||||
sysUser.setUserId(userId);
|
sysUser.setUserId(userId);
|
||||||
sysUser.setLoginIp(ServletUtils.getClientIP());
|
sysUser.setLoginIp(ip);
|
||||||
sysUser.setLoginDate(DateUtils.getNowDate());
|
sysUser.setLoginDate(DateUtils.getNowDate());
|
||||||
sysUser.setUpdateBy(userId);
|
sysUser.setUpdateBy(userId);
|
||||||
userMapper.updateById(sysUser);
|
DataPermissionHelper.ignore(() -> userMapper.updateById(sysUser));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package org.dromara.web.service;
|
|||||||
import cn.dev33.satoken.secure.BCrypt;
|
import cn.dev33.satoken.secure.BCrypt;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.dromara.common.core.constant.Constants;
|
import org.dromara.common.core.constant.Constants;
|
||||||
import org.dromara.common.core.constant.GlobalConstants;
|
import org.dromara.common.core.constant.GlobalConstants;
|
||||||
import org.dromara.common.core.domain.model.RegisterBody;
|
import org.dromara.common.core.domain.model.RegisterBody;
|
||||||
@ -22,7 +23,6 @@ import org.dromara.system.domain.SysUser;
|
|||||||
import org.dromara.system.domain.bo.SysUserBo;
|
import org.dromara.system.domain.bo.SysUserBo;
|
||||||
import org.dromara.system.mapper.SysUserMapper;
|
import org.dromara.system.mapper.SysUserMapper;
|
||||||
import org.dromara.system.service.ISysUserService;
|
import org.dromara.system.service.ISysUserService;
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,10 +59,11 @@ public class SysRegisterService {
|
|||||||
sysUser.setPassword(BCrypt.hashpw(password));
|
sysUser.setPassword(BCrypt.hashpw(password));
|
||||||
sysUser.setUserType(userType);
|
sysUser.setUserType(userType);
|
||||||
|
|
||||||
boolean exist = userMapper.exists(new LambdaQueryWrapper<SysUser>()
|
boolean exist = TenantHelper.dynamic(tenantId, () -> {
|
||||||
.eq(TenantHelper.isEnable(), SysUser::getTenantId, tenantId)
|
return userMapper.exists(new LambdaQueryWrapper<SysUser>()
|
||||||
.eq(SysUser::getUserName, sysUser.getUserName())
|
.eq(SysUser::getUserName, sysUser.getUserName())
|
||||||
.ne(ObjectUtil.isNotNull(sysUser.getUserId()), SysUser::getUserId, sysUser.getUserId()));
|
.ne(ObjectUtil.isNotNull(sysUser.getUserId()), SysUser::getUserId, sysUser.getUserId()));
|
||||||
|
});
|
||||||
if (exist) {
|
if (exist) {
|
||||||
throw new UserException("user.register.save.error", username);
|
throw new UserException("user.register.save.error", username);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,7 +44,7 @@ public class EmailAuthStrategy implements IAuthStrategy {
|
|||||||
private final SysUserMapper userMapper;
|
private final SysUserMapper userMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LoginVo login(String clientId, String body, SysClient client) {
|
public LoginVo login(String body, SysClient client) {
|
||||||
EmailLoginBody loginBody = JsonUtils.parseObject(body, EmailLoginBody.class);
|
EmailLoginBody loginBody = JsonUtils.parseObject(body, EmailLoginBody.class);
|
||||||
ValidatorUtils.validate(loginBody);
|
ValidatorUtils.validate(loginBody);
|
||||||
String tenantId = loginBody.getTenantId();
|
String tenantId = loginBody.getTenantId();
|
||||||
@ -65,17 +65,14 @@ public class EmailAuthStrategy implements IAuthStrategy {
|
|||||||
// 例如: 后台用户30分钟过期 app用户1天过期
|
// 例如: 后台用户30分钟过期 app用户1天过期
|
||||||
model.setTimeout(client.getTimeout());
|
model.setTimeout(client.getTimeout());
|
||||||
model.setActiveTimeout(client.getActiveTimeout());
|
model.setActiveTimeout(client.getActiveTimeout());
|
||||||
model.setExtra(LoginHelper.CLIENT_KEY, clientId);
|
model.setExtra(LoginHelper.CLIENT_KEY, client.getClientId());
|
||||||
// 生成token
|
// 生成token
|
||||||
LoginHelper.login(loginUser, model);
|
LoginHelper.login(loginUser, model);
|
||||||
|
|
||||||
loginService.recordLogininfor(loginUser.getTenantId(), user.getUserName(), Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"));
|
|
||||||
loginService.recordLoginInfo(user.getUserId());
|
|
||||||
|
|
||||||
LoginVo loginVo = new LoginVo();
|
LoginVo loginVo = new LoginVo();
|
||||||
loginVo.setAccessToken(StpUtil.getTokenValue());
|
loginVo.setAccessToken(StpUtil.getTokenValue());
|
||||||
loginVo.setExpireIn(StpUtil.getTokenTimeout());
|
loginVo.setExpireIn(StpUtil.getTokenTimeout());
|
||||||
loginVo.setClientId(clientId);
|
loginVo.setClientId(client.getClientId());
|
||||||
return loginVo;
|
return loginVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,21 +89,19 @@ public class EmailAuthStrategy implements IAuthStrategy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private SysUserVo loadUserByEmail(String tenantId, String email) {
|
private SysUserVo loadUserByEmail(String tenantId, String email) {
|
||||||
SysUser user = userMapper.selectOne(new LambdaQueryWrapper<SysUser>()
|
return TenantHelper.dynamic(tenantId, () -> {
|
||||||
.select(SysUser::getEmail, SysUser::getStatus)
|
SysUser user = userMapper.selectOne(new LambdaQueryWrapper<SysUser>()
|
||||||
.eq(TenantHelper.isEnable(), SysUser::getTenantId, tenantId)
|
.select(SysUser::getEmail, SysUser::getStatus)
|
||||||
.eq(SysUser::getEmail, email));
|
.eq(SysUser::getEmail, email));
|
||||||
if (ObjectUtil.isNull(user)) {
|
if (ObjectUtil.isNull(user)) {
|
||||||
log.info("登录用户:{} 不存在.", email);
|
log.info("登录用户:{} 不存在.", email);
|
||||||
throw new UserException("user.not.exists", email);
|
throw new UserException("user.not.exists", email);
|
||||||
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
||||||
log.info("登录用户:{} 已被停用.", email);
|
log.info("登录用户:{} 已被停用.", email);
|
||||||
throw new UserException("user.blocked", email);
|
throw new UserException("user.blocked", email);
|
||||||
}
|
}
|
||||||
if (TenantHelper.isEnable()) {
|
return userMapper.selectUserByEmail(email);
|
||||||
return userMapper.selectTenantUserByEmail(email, tenantId);
|
});
|
||||||
}
|
|
||||||
return userMapper.selectUserByEmail(email);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,7 +48,7 @@ public class PasswordAuthStrategy implements IAuthStrategy {
|
|||||||
private final SysUserMapper userMapper;
|
private final SysUserMapper userMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LoginVo login(String clientId, String body, SysClient client) {
|
public LoginVo login(String body, SysClient client) {
|
||||||
PasswordLoginBody loginBody = JsonUtils.parseObject(body, PasswordLoginBody.class);
|
PasswordLoginBody loginBody = JsonUtils.parseObject(body, PasswordLoginBody.class);
|
||||||
ValidatorUtils.validate(loginBody);
|
ValidatorUtils.validate(loginBody);
|
||||||
String tenantId = loginBody.getTenantId();
|
String tenantId = loginBody.getTenantId();
|
||||||
@ -75,17 +75,14 @@ public class PasswordAuthStrategy implements IAuthStrategy {
|
|||||||
// 例如: 后台用户30分钟过期 app用户1天过期
|
// 例如: 后台用户30分钟过期 app用户1天过期
|
||||||
model.setTimeout(client.getTimeout());
|
model.setTimeout(client.getTimeout());
|
||||||
model.setActiveTimeout(client.getActiveTimeout());
|
model.setActiveTimeout(client.getActiveTimeout());
|
||||||
model.setExtra(LoginHelper.CLIENT_KEY, clientId);
|
model.setExtra(LoginHelper.CLIENT_KEY, client.getClientId());
|
||||||
// 生成token
|
// 生成token
|
||||||
LoginHelper.login(loginUser, model);
|
LoginHelper.login(loginUser, model);
|
||||||
|
|
||||||
loginService.recordLogininfor(loginUser.getTenantId(), username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"));
|
|
||||||
loginService.recordLoginInfo(user.getUserId());
|
|
||||||
|
|
||||||
LoginVo loginVo = new LoginVo();
|
LoginVo loginVo = new LoginVo();
|
||||||
loginVo.setAccessToken(StpUtil.getTokenValue());
|
loginVo.setAccessToken(StpUtil.getTokenValue());
|
||||||
loginVo.setExpireIn(StpUtil.getTokenTimeout());
|
loginVo.setExpireIn(StpUtil.getTokenTimeout());
|
||||||
loginVo.setClientId(clientId);
|
loginVo.setClientId(client.getClientId());
|
||||||
return loginVo;
|
return loginVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,21 +108,19 @@ public class PasswordAuthStrategy implements IAuthStrategy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private SysUserVo loadUserByUsername(String tenantId, String username) {
|
private SysUserVo loadUserByUsername(String tenantId, String username) {
|
||||||
SysUser user = userMapper.selectOne(new LambdaQueryWrapper<SysUser>()
|
return TenantHelper.dynamic(tenantId, () -> {
|
||||||
.select(SysUser::getUserName, SysUser::getStatus)
|
SysUser user = userMapper.selectOne(new LambdaQueryWrapper<SysUser>()
|
||||||
.eq(TenantHelper.isEnable(), SysUser::getTenantId, tenantId)
|
.select(SysUser::getUserName, SysUser::getStatus)
|
||||||
.eq(SysUser::getUserName, username));
|
.eq(SysUser::getUserName, username));
|
||||||
if (ObjectUtil.isNull(user)) {
|
if (ObjectUtil.isNull(user)) {
|
||||||
log.info("登录用户:{} 不存在.", username);
|
log.info("登录用户:{} 不存在.", username);
|
||||||
throw new UserException("user.not.exists", username);
|
throw new UserException("user.not.exists", username);
|
||||||
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
||||||
log.info("登录用户:{} 已被停用.", username);
|
log.info("登录用户:{} 已被停用.", username);
|
||||||
throw new UserException("user.blocked", username);
|
throw new UserException("user.blocked", username);
|
||||||
}
|
}
|
||||||
if (TenantHelper.isEnable()) {
|
return userMapper.selectUserByUserName(username);
|
||||||
return userMapper.selectTenantUserByUserName(username, tenantId);
|
});
|
||||||
}
|
|
||||||
return userMapper.selectUserByUserName(username);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,7 +44,7 @@ public class SmsAuthStrategy implements IAuthStrategy {
|
|||||||
private final SysUserMapper userMapper;
|
private final SysUserMapper userMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LoginVo login(String clientId, String body, SysClient client) {
|
public LoginVo login(String body, SysClient client) {
|
||||||
SmsLoginBody loginBody = JsonUtils.parseObject(body, SmsLoginBody.class);
|
SmsLoginBody loginBody = JsonUtils.parseObject(body, SmsLoginBody.class);
|
||||||
ValidatorUtils.validate(loginBody);
|
ValidatorUtils.validate(loginBody);
|
||||||
String tenantId = loginBody.getTenantId();
|
String tenantId = loginBody.getTenantId();
|
||||||
@ -65,17 +65,14 @@ public class SmsAuthStrategy implements IAuthStrategy {
|
|||||||
// 例如: 后台用户30分钟过期 app用户1天过期
|
// 例如: 后台用户30分钟过期 app用户1天过期
|
||||||
model.setTimeout(client.getTimeout());
|
model.setTimeout(client.getTimeout());
|
||||||
model.setActiveTimeout(client.getActiveTimeout());
|
model.setActiveTimeout(client.getActiveTimeout());
|
||||||
model.setExtra(LoginHelper.CLIENT_KEY, clientId);
|
model.setExtra(LoginHelper.CLIENT_KEY, client.getClientId());
|
||||||
// 生成token
|
// 生成token
|
||||||
LoginHelper.login(loginUser, model);
|
LoginHelper.login(loginUser, model);
|
||||||
|
|
||||||
loginService.recordLogininfor(loginUser.getTenantId(), user.getUserName(), Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"));
|
|
||||||
loginService.recordLoginInfo(user.getUserId());
|
|
||||||
|
|
||||||
LoginVo loginVo = new LoginVo();
|
LoginVo loginVo = new LoginVo();
|
||||||
loginVo.setAccessToken(StpUtil.getTokenValue());
|
loginVo.setAccessToken(StpUtil.getTokenValue());
|
||||||
loginVo.setExpireIn(StpUtil.getTokenTimeout());
|
loginVo.setExpireIn(StpUtil.getTokenTimeout());
|
||||||
loginVo.setClientId(clientId);
|
loginVo.setClientId(client.getClientId());
|
||||||
return loginVo;
|
return loginVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,21 +89,19 @@ public class SmsAuthStrategy implements IAuthStrategy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private SysUserVo loadUserByPhonenumber(String tenantId, String phonenumber) {
|
private SysUserVo loadUserByPhonenumber(String tenantId, String phonenumber) {
|
||||||
SysUser user = userMapper.selectOne(new LambdaQueryWrapper<SysUser>()
|
return TenantHelper.dynamic(tenantId, () -> {
|
||||||
.select(SysUser::getPhonenumber, SysUser::getStatus)
|
SysUser user = userMapper.selectOne(new LambdaQueryWrapper<SysUser>()
|
||||||
.eq(TenantHelper.isEnable(), SysUser::getTenantId, tenantId)
|
.select(SysUser::getPhonenumber, SysUser::getStatus)
|
||||||
.eq(SysUser::getPhonenumber, phonenumber));
|
.eq(SysUser::getPhonenumber, phonenumber));
|
||||||
if (ObjectUtil.isNull(user)) {
|
if (ObjectUtil.isNull(user)) {
|
||||||
log.info("登录用户:{} 不存在.", phonenumber);
|
log.info("登录用户:{} 不存在.", phonenumber);
|
||||||
throw new UserException("user.not.exists", phonenumber);
|
throw new UserException("user.not.exists", phonenumber);
|
||||||
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
||||||
log.info("登录用户:{} 已被停用.", phonenumber);
|
log.info("登录用户:{} 已被停用.", phonenumber);
|
||||||
throw new UserException("user.blocked", phonenumber);
|
throw new UserException("user.blocked", phonenumber);
|
||||||
}
|
}
|
||||||
if (TenantHelper.isEnable()) {
|
return userMapper.selectUserByPhonenumber(phonenumber);
|
||||||
return userMapper.selectTenantUserByPhonenumber(phonenumber, tenantId);
|
});
|
||||||
}
|
|
||||||
return userMapper.selectUserByPhonenumber(phonenumber);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,9 +2,9 @@ package org.dromara.web.service.impl;
|
|||||||
|
|
||||||
import cn.dev33.satoken.stp.SaLoginModel;
|
import cn.dev33.satoken.stp.SaLoginModel;
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import cn.hutool.http.HttpUtil;
|
import cn.hutool.http.HttpUtil;
|
||||||
import cn.hutool.http.Method;
|
import cn.hutool.http.Method;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
@ -12,13 +12,11 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import me.zhyd.oauth.model.AuthResponse;
|
import me.zhyd.oauth.model.AuthResponse;
|
||||||
import me.zhyd.oauth.model.AuthUser;
|
import me.zhyd.oauth.model.AuthUser;
|
||||||
import org.dromara.common.core.constant.Constants;
|
|
||||||
import org.dromara.common.core.domain.model.LoginUser;
|
import org.dromara.common.core.domain.model.LoginUser;
|
||||||
import org.dromara.common.core.domain.model.SocialLoginBody;
|
import org.dromara.common.core.domain.model.SocialLoginBody;
|
||||||
import org.dromara.common.core.enums.UserStatus;
|
import org.dromara.common.core.enums.UserStatus;
|
||||||
import org.dromara.common.core.exception.ServiceException;
|
import org.dromara.common.core.exception.ServiceException;
|
||||||
import org.dromara.common.core.exception.user.UserException;
|
import org.dromara.common.core.exception.user.UserException;
|
||||||
import org.dromara.common.core.utils.MessageUtils;
|
|
||||||
import org.dromara.common.core.utils.ValidatorUtils;
|
import org.dromara.common.core.utils.ValidatorUtils;
|
||||||
import org.dromara.common.json.utils.JsonUtils;
|
import org.dromara.common.json.utils.JsonUtils;
|
||||||
import org.dromara.common.satoken.utils.LoginHelper;
|
import org.dromara.common.satoken.utils.LoginHelper;
|
||||||
@ -36,6 +34,9 @@ import org.dromara.web.service.IAuthStrategy;
|
|||||||
import org.dromara.web.service.SysLoginService;
|
import org.dromara.web.service.SysLoginService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 第三方授权策略
|
* 第三方授权策略
|
||||||
*
|
*
|
||||||
@ -54,12 +55,11 @@ public class SocialAuthStrategy implements IAuthStrategy {
|
|||||||
/**
|
/**
|
||||||
* 登录-第三方授权登录
|
* 登录-第三方授权登录
|
||||||
*
|
*
|
||||||
* @param clientId 客户端id
|
|
||||||
* @param body 登录信息
|
* @param body 登录信息
|
||||||
* @param client 客户端信息
|
* @param client 客户端信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public LoginVo login(String clientId, String body, SysClient client) {
|
public LoginVo login(String body, SysClient client) {
|
||||||
SocialLoginBody loginBody = JsonUtils.parseObject(body, SocialLoginBody.class);
|
SocialLoginBody loginBody = JsonUtils.parseObject(body, SocialLoginBody.class);
|
||||||
ValidatorUtils.validate(loginBody);
|
ValidatorUtils.validate(loginBody);
|
||||||
AuthResponse<AuthUser> response = SocialUtils.loginAuth(
|
AuthResponse<AuthUser> response = SocialUtils.loginAuth(
|
||||||
@ -79,19 +79,17 @@ public class SocialAuthStrategy implements IAuthStrategy {
|
|||||||
.executeAsync();
|
.executeAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
SysSocialVo social = sysSocialService.selectByAuthId(authUserData.getSource() + authUserData.getUuid());
|
List<SysSocialVo> list = sysSocialService.selectByAuthId(authUserData.getSource() + authUserData.getUuid());
|
||||||
if (!ObjectUtil.isNotNull(social)) {
|
if (CollUtil.isEmpty(list)) {
|
||||||
throw new ServiceException("你还没有绑定第三方账号,绑定后才可以登录!");
|
throw new ServiceException("你还没有绑定第三方账号,绑定后才可以登录!");
|
||||||
}
|
}
|
||||||
// 验证授权表里面的租户id是否包含当前租户id
|
Optional<SysSocialVo> opt = list.stream().filter(x -> x.getTenantId().equals(loginBody.getTenantId())).findAny();
|
||||||
String tenantId = social.getTenantId();
|
if (opt.isEmpty()) {
|
||||||
if (ObjectUtil.isNotNull(social) && StrUtil.isNotBlank(tenantId)
|
|
||||||
&& !tenantId.contains(loginBody.getTenantId())) {
|
|
||||||
throw new ServiceException("对不起,你没有权限登录当前租户!");
|
throw new ServiceException("对不起,你没有权限登录当前租户!");
|
||||||
}
|
}
|
||||||
|
SysSocialVo social = opt.get();
|
||||||
// 查找用户
|
// 查找用户
|
||||||
SysUserVo user = loadUser(tenantId, social.getUserId());
|
SysUserVo user = loadUser(social.getTenantId(), social.getUserId());
|
||||||
|
|
||||||
// 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了
|
// 此处可根据登录用户的数据不同 自行创建 loginUser 属性不够用继承扩展就行了
|
||||||
LoginUser loginUser = loginService.buildLoginUser(user);
|
LoginUser loginUser = loginService.buildLoginUser(user);
|
||||||
@ -103,36 +101,31 @@ public class SocialAuthStrategy implements IAuthStrategy {
|
|||||||
// 例如: 后台用户30分钟过期 app用户1天过期
|
// 例如: 后台用户30分钟过期 app用户1天过期
|
||||||
model.setTimeout(client.getTimeout());
|
model.setTimeout(client.getTimeout());
|
||||||
model.setActiveTimeout(client.getActiveTimeout());
|
model.setActiveTimeout(client.getActiveTimeout());
|
||||||
model.setExtra(LoginHelper.CLIENT_KEY, clientId);
|
model.setExtra(LoginHelper.CLIENT_KEY, client.getClientId());
|
||||||
// 生成token
|
// 生成token
|
||||||
LoginHelper.login(loginUser, model);
|
LoginHelper.login(loginUser, model);
|
||||||
|
|
||||||
loginService.recordLogininfor(loginUser.getTenantId(), user.getUserName(), Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"));
|
|
||||||
loginService.recordLoginInfo(user.getUserId());
|
|
||||||
|
|
||||||
LoginVo loginVo = new LoginVo();
|
LoginVo loginVo = new LoginVo();
|
||||||
loginVo.setAccessToken(StpUtil.getTokenValue());
|
loginVo.setAccessToken(StpUtil.getTokenValue());
|
||||||
loginVo.setExpireIn(StpUtil.getTokenTimeout());
|
loginVo.setExpireIn(StpUtil.getTokenTimeout());
|
||||||
loginVo.setClientId(clientId);
|
loginVo.setClientId(client.getClientId());
|
||||||
return loginVo;
|
return loginVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private SysUserVo loadUser(String tenantId, Long userId) {
|
private SysUserVo loadUser(String tenantId, Long userId) {
|
||||||
SysUser user = userMapper.selectOne(new LambdaQueryWrapper<SysUser>()
|
return TenantHelper.dynamic(tenantId, () -> {
|
||||||
|
SysUser user = userMapper.selectOne(new LambdaQueryWrapper<SysUser>()
|
||||||
.select(SysUser::getUserName, SysUser::getStatus)
|
.select(SysUser::getUserName, SysUser::getStatus)
|
||||||
.eq(TenantHelper.isEnable(), SysUser::getTenantId, tenantId)
|
|
||||||
.eq(SysUser::getUserId, userId));
|
.eq(SysUser::getUserId, userId));
|
||||||
if (ObjectUtil.isNull(user)) {
|
if (ObjectUtil.isNull(user)) {
|
||||||
log.info("登录用户:{} 不存在.", "");
|
log.info("登录用户:{} 不存在.", "");
|
||||||
throw new UserException("user.not.exists", "");
|
throw new UserException("user.not.exists", "");
|
||||||
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
} else if (UserStatus.DISABLE.getCode().equals(user.getStatus())) {
|
||||||
log.info("登录用户:{} 已被停用.", "");
|
log.info("登录用户:{} 已被停用.", "");
|
||||||
throw new UserException("user.blocked", "");
|
throw new UserException("user.blocked", "");
|
||||||
}
|
}
|
||||||
if (TenantHelper.isEnable()) {
|
return userMapper.selectUserByUserName(user.getUserName());
|
||||||
return userMapper.selectTenantUserByUserName(user.getUserName(), tenantId);
|
});
|
||||||
}
|
|
||||||
return userMapper.selectUserByUserName(user.getUserName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,11 +5,9 @@ import cn.dev33.satoken.stp.StpUtil;
|
|||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.dromara.common.core.constant.Constants;
|
|
||||||
import org.dromara.common.core.domain.model.XcxLoginBody;
|
import org.dromara.common.core.domain.model.XcxLoginBody;
|
||||||
import org.dromara.common.core.domain.model.XcxLoginUser;
|
import org.dromara.common.core.domain.model.XcxLoginUser;
|
||||||
import org.dromara.common.core.enums.UserStatus;
|
import org.dromara.common.core.enums.UserStatus;
|
||||||
import org.dromara.common.core.utils.MessageUtils;
|
|
||||||
import org.dromara.common.core.utils.ValidatorUtils;
|
import org.dromara.common.core.utils.ValidatorUtils;
|
||||||
import org.dromara.common.json.utils.JsonUtils;
|
import org.dromara.common.json.utils.JsonUtils;
|
||||||
import org.dromara.common.satoken.utils.LoginHelper;
|
import org.dromara.common.satoken.utils.LoginHelper;
|
||||||
@ -33,7 +31,7 @@ public class XcxAuthStrategy implements IAuthStrategy {
|
|||||||
private final SysLoginService loginService;
|
private final SysLoginService loginService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LoginVo login(String clientId, String body, SysClient client) {
|
public LoginVo login(String body, SysClient client) {
|
||||||
XcxLoginBody loginBody = JsonUtils.parseObject(body, XcxLoginBody.class);
|
XcxLoginBody loginBody = JsonUtils.parseObject(body, XcxLoginBody.class);
|
||||||
ValidatorUtils.validate(loginBody);
|
ValidatorUtils.validate(loginBody);
|
||||||
// xcxCode 为 小程序调用 wx.login 授权后获取
|
// xcxCode 为 小程序调用 wx.login 授权后获取
|
||||||
@ -64,17 +62,14 @@ public class XcxAuthStrategy implements IAuthStrategy {
|
|||||||
// 例如: 后台用户30分钟过期 app用户1天过期
|
// 例如: 后台用户30分钟过期 app用户1天过期
|
||||||
model.setTimeout(client.getTimeout());
|
model.setTimeout(client.getTimeout());
|
||||||
model.setActiveTimeout(client.getActiveTimeout());
|
model.setActiveTimeout(client.getActiveTimeout());
|
||||||
model.setExtra(LoginHelper.CLIENT_KEY, clientId);
|
model.setExtra(LoginHelper.CLIENT_KEY, client.getClientId());
|
||||||
// 生成token
|
// 生成token
|
||||||
LoginHelper.login(loginUser, model);
|
LoginHelper.login(loginUser, model);
|
||||||
|
|
||||||
loginService.recordLogininfor(loginUser.getTenantId(), user.getUserName(), Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"));
|
|
||||||
loginService.recordLoginInfo(user.getUserId());
|
|
||||||
|
|
||||||
LoginVo loginVo = new LoginVo();
|
LoginVo loginVo = new LoginVo();
|
||||||
loginVo.setAccessToken(StpUtil.getTokenValue());
|
loginVo.setAccessToken(StpUtil.getTokenValue());
|
||||||
loginVo.setExpireIn(StpUtil.getTokenTimeout());
|
loginVo.setExpireIn(StpUtil.getTokenTimeout());
|
||||||
loginVo.setClientId(clientId);
|
loginVo.setClientId(client.getClientId());
|
||||||
loginVo.setOpenid(openid);
|
loginVo.setOpenid(openid);
|
||||||
return loginVo;
|
return loginVo;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -251,6 +251,7 @@ management:
|
|||||||
|
|
||||||
--- # websocket
|
--- # websocket
|
||||||
websocket:
|
websocket:
|
||||||
|
# 如果关闭 需要和前端开关一起关闭
|
||||||
enabled: true
|
enabled: true
|
||||||
# 路径
|
# 路径
|
||||||
path: /resource/websocket
|
path: /resource/websocket
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
</description>
|
</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<revision>5.1.0</revision>
|
<revision>5.1.1</revision>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
|||||||
@ -30,17 +30,17 @@ public enum DataScopeType {
|
|||||||
/**
|
/**
|
||||||
* 自定数据权限
|
* 自定数据权限
|
||||||
*/
|
*/
|
||||||
CUSTOM("2", " #{#deptName} IN ( #{@sdss.getRoleCustom( #user.roleId )} ) ", ""),
|
CUSTOM("2", " #{#deptName} IN ( #{@sdss.getRoleCustom( #user.roleId )} ) ", " 1 = 0 "),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门数据权限
|
* 部门数据权限
|
||||||
*/
|
*/
|
||||||
DEPT("3", " #{#deptName} = #{#user.deptId} ", ""),
|
DEPT("3", " #{#deptName} = #{#user.deptId} ", " 1 = 0 "),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门及以下数据权限
|
* 部门及以下数据权限
|
||||||
*/
|
*/
|
||||||
DEPT_AND_CHILD("4", " #{#deptName} IN ( #{@sdss.getDeptAndChild( #user.deptId )} )", ""),
|
DEPT_AND_CHILD("4", " #{#deptName} IN ( #{@sdss.getDeptAndChild( #user.deptId )} )", " 1 = 0 "),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 仅本人数据权限
|
* 仅本人数据权限
|
||||||
|
|||||||
@ -2,10 +2,14 @@ package org.dromara.common.mybatis.handler;
|
|||||||
|
|
||||||
import cn.hutool.core.annotation.AnnotationUtil;
|
import cn.hutool.core.annotation.AnnotationUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.collection.ConcurrentHashSet;
|
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
|
||||||
import cn.hutool.core.util.ClassUtil;
|
import cn.hutool.core.util.ClassUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.sf.jsqlparser.JSQLParserException;
|
||||||
|
import net.sf.jsqlparser.expression.Expression;
|
||||||
|
import net.sf.jsqlparser.expression.Parenthesis;
|
||||||
|
import net.sf.jsqlparser.expression.operators.conditional.AndExpression;
|
||||||
|
import net.sf.jsqlparser.parser.CCJSqlParserUtil;
|
||||||
import org.dromara.common.core.domain.dto.RoleDTO;
|
import org.dromara.common.core.domain.dto.RoleDTO;
|
||||||
import org.dromara.common.core.domain.model.LoginUser;
|
import org.dromara.common.core.domain.model.LoginUser;
|
||||||
import org.dromara.common.core.exception.ServiceException;
|
import org.dromara.common.core.exception.ServiceException;
|
||||||
@ -17,12 +21,6 @@ import org.dromara.common.mybatis.annotation.DataPermission;
|
|||||||
import org.dromara.common.mybatis.enums.DataScopeType;
|
import org.dromara.common.mybatis.enums.DataScopeType;
|
||||||
import org.dromara.common.mybatis.helper.DataPermissionHelper;
|
import org.dromara.common.mybatis.helper.DataPermissionHelper;
|
||||||
import org.dromara.common.satoken.utils.LoginHelper;
|
import org.dromara.common.satoken.utils.LoginHelper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import net.sf.jsqlparser.JSQLParserException;
|
|
||||||
import net.sf.jsqlparser.expression.Expression;
|
|
||||||
import net.sf.jsqlparser.expression.Parenthesis;
|
|
||||||
import net.sf.jsqlparser.expression.operators.conditional.AndExpression;
|
|
||||||
import net.sf.jsqlparser.parser.CCJSqlParserUtil;
|
|
||||||
import org.springframework.context.expression.BeanFactoryResolver;
|
import org.springframework.context.expression.BeanFactoryResolver;
|
||||||
import org.springframework.expression.BeanResolver;
|
import org.springframework.expression.BeanResolver;
|
||||||
import org.springframework.expression.ExpressionParser;
|
import org.springframework.expression.ExpressionParser;
|
||||||
@ -50,11 +48,6 @@ public class PlusDataPermissionHandler {
|
|||||||
*/
|
*/
|
||||||
private final Map<String, DataPermission> dataPermissionCacheMap = new ConcurrentHashMap<>();
|
private final Map<String, DataPermission> dataPermissionCacheMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
/**
|
|
||||||
* 无效注解方法缓存用于快速返回
|
|
||||||
*/
|
|
||||||
private final Set<String> invalidCacheSet = new ConcurrentHashSet<>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* spel 解析器
|
* spel 解析器
|
||||||
*/
|
*/
|
||||||
@ -68,10 +61,6 @@ public class PlusDataPermissionHandler {
|
|||||||
|
|
||||||
public Expression getSqlSegment(Expression where, String mappedStatementId, boolean isSelect) {
|
public Expression getSqlSegment(Expression where, String mappedStatementId, boolean isSelect) {
|
||||||
DataColumn[] dataColumns = findAnnotation(mappedStatementId);
|
DataColumn[] dataColumns = findAnnotation(mappedStatementId);
|
||||||
if (ArrayUtil.isEmpty(dataColumns)) {
|
|
||||||
invalidCacheSet.add(mappedStatementId);
|
|
||||||
return where;
|
|
||||||
}
|
|
||||||
LoginUser currentUser = DataPermissionHelper.getVariable("user");
|
LoginUser currentUser = DataPermissionHelper.getVariable("user");
|
||||||
if (ObjectUtil.isNull(currentUser)) {
|
if (ObjectUtil.isNull(currentUser)) {
|
||||||
currentUser = LoginHelper.getLoginUser();
|
currentUser = LoginHelper.getLoginUser();
|
||||||
@ -155,7 +144,7 @@ public class PlusDataPermissionHandler {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private DataColumn[] findAnnotation(String mappedStatementId) {
|
public DataColumn[] findAnnotation(String mappedStatementId) {
|
||||||
StringBuilder sb = new StringBuilder(mappedStatementId);
|
StringBuilder sb = new StringBuilder(mappedStatementId);
|
||||||
int index = sb.lastIndexOf(".");
|
int index = sb.lastIndexOf(".");
|
||||||
String clazzName = sb.substring(0, index);
|
String clazzName = sb.substring(0, index);
|
||||||
@ -189,10 +178,4 @@ public class PlusDataPermissionHandler {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否为无效方法 无数据权限
|
|
||||||
*/
|
|
||||||
public boolean isInvalid(String mappedStatementId) {
|
|
||||||
return invalidCacheSet.contains(mappedStatementId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,12 @@
|
|||||||
package org.dromara.common.mybatis.interceptor;
|
package org.dromara.common.mybatis.interceptor;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.ConcurrentHashSet;
|
||||||
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import com.baomidou.mybatisplus.core.plugins.InterceptorIgnoreHelper;
|
import com.baomidou.mybatisplus.core.plugins.InterceptorIgnoreHelper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.PluginUtils;
|
import com.baomidou.mybatisplus.core.toolkit.PluginUtils;
|
||||||
import com.baomidou.mybatisplus.extension.parser.JsqlParserSupport;
|
import com.baomidou.mybatisplus.extension.parser.JsqlParserSupport;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor;
|
||||||
|
import org.dromara.common.mybatis.annotation.DataColumn;
|
||||||
import org.dromara.common.mybatis.handler.PlusDataPermissionHandler;
|
import org.dromara.common.mybatis.handler.PlusDataPermissionHandler;
|
||||||
import net.sf.jsqlparser.expression.Expression;
|
import net.sf.jsqlparser.expression.Expression;
|
||||||
import net.sf.jsqlparser.statement.delete.Delete;
|
import net.sf.jsqlparser.statement.delete.Delete;
|
||||||
@ -23,6 +26,7 @@ import org.apache.ibatis.session.RowBounds;
|
|||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据权限拦截器
|
* 数据权限拦截器
|
||||||
@ -33,6 +37,10 @@ import java.util.List;
|
|||||||
public class PlusDataPermissionInterceptor extends JsqlParserSupport implements InnerInterceptor {
|
public class PlusDataPermissionInterceptor extends JsqlParserSupport implements InnerInterceptor {
|
||||||
|
|
||||||
private final PlusDataPermissionHandler dataPermissionHandler = new PlusDataPermissionHandler();
|
private final PlusDataPermissionHandler dataPermissionHandler = new PlusDataPermissionHandler();
|
||||||
|
/**
|
||||||
|
* 无效注解方法缓存用于快速返回
|
||||||
|
*/
|
||||||
|
private final Set<String> invalidCacheSet = new ConcurrentHashSet<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeQuery(Executor executor, MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) throws SQLException {
|
public void beforeQuery(Executor executor, MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) throws SQLException {
|
||||||
@ -41,7 +49,12 @@ public class PlusDataPermissionInterceptor extends JsqlParserSupport implements
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 检查是否无效 无数据权限注解
|
// 检查是否无效 无数据权限注解
|
||||||
if (dataPermissionHandler.isInvalid(ms.getId())) {
|
if (invalidCacheSet.contains(ms.getId())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DataColumn[] dataColumns = dataPermissionHandler.findAnnotation(ms.getId());
|
||||||
|
if (ArrayUtil.isEmpty(dataColumns)) {
|
||||||
|
invalidCacheSet.add(ms.getId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 解析 sql 分配对应方法
|
// 解析 sql 分配对应方法
|
||||||
@ -58,6 +71,15 @@ public class PlusDataPermissionInterceptor extends JsqlParserSupport implements
|
|||||||
if (InterceptorIgnoreHelper.willIgnoreDataPermission(ms.getId())) {
|
if (InterceptorIgnoreHelper.willIgnoreDataPermission(ms.getId())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// 检查是否无效 无数据权限注解
|
||||||
|
if (invalidCacheSet.contains(ms.getId())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DataColumn[] dataColumns = dataPermissionHandler.findAnnotation(ms.getId());
|
||||||
|
if (ArrayUtil.isEmpty(dataColumns)) {
|
||||||
|
invalidCacheSet.add(ms.getId());
|
||||||
|
return;
|
||||||
|
}
|
||||||
PluginUtils.MPBoundSql mpBs = mpSh.mPBoundSql();
|
PluginUtils.MPBoundSql mpBs = mpSh.mPBoundSql();
|
||||||
mpBs.sql(parserMulti(mpBs.sql(), ms.getId()));
|
mpBs.sql(parserMulti(mpBs.sql(), ms.getId()));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -224,8 +224,12 @@ public class QueueUtils {
|
|||||||
/**
|
/**
|
||||||
* 订阅阻塞队列(可订阅所有实现类 例如: 延迟 优先 有界 等)
|
* 订阅阻塞队列(可订阅所有实现类 例如: 延迟 优先 有界 等)
|
||||||
*/
|
*/
|
||||||
public static <T> void subscribeBlockingQueue(String queueName, Consumer<T> consumer) {
|
public static <T> void subscribeBlockingQueue(String queueName, Consumer<T> consumer, boolean isDelayed) {
|
||||||
RBlockingQueue<T> queue = CLIENT.getBlockingQueue(queueName);
|
RBlockingQueue<T> queue = CLIENT.getBlockingQueue(queueName);
|
||||||
|
if (isDelayed) {
|
||||||
|
// 订阅延迟队列
|
||||||
|
CLIENT.getDelayedQueue(queue);
|
||||||
|
}
|
||||||
queue.subscribeOnElements(consumer);
|
queue.subscribeOnElements(consumer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -61,8 +61,8 @@ public class SecurityConfig implements WebMvcConfigurer {
|
|||||||
|
|
||||||
// 有效率影响 用于临时测试
|
// 有效率影响 用于临时测试
|
||||||
// if (log.isDebugEnabled()) {
|
// if (log.isDebugEnabled()) {
|
||||||
// log.debug("剩余有效时间: {}", StpUtil.getTokenTimeout());
|
// log.info("剩余有效时间: {}", StpUtil.getTokenTimeout());
|
||||||
// log.debug("临时有效时间: {}", StpUtil.getTokenActivityTimeout());
|
// log.info("临时有效时间: {}", StpUtil.getTokenActivityTimeout());
|
||||||
// }
|
// }
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@ -21,4 +21,8 @@ import java.lang.annotation.Target;
|
|||||||
@JsonSerialize(using = SensitiveHandler.class)
|
@JsonSerialize(using = SensitiveHandler.class)
|
||||||
public @interface Sensitive {
|
public @interface Sensitive {
|
||||||
SensitiveStrategy strategy();
|
SensitiveStrategy strategy();
|
||||||
|
|
||||||
|
String roleKey() default "";
|
||||||
|
|
||||||
|
String perms() default "";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,6 @@ public interface SensitiveService {
|
|||||||
/**
|
/**
|
||||||
* 是否脱敏
|
* 是否脱敏
|
||||||
*/
|
*/
|
||||||
boolean isSensitive();
|
boolean isSensitive(String roleKey, String perms);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,12 +26,14 @@ import java.util.Objects;
|
|||||||
public class SensitiveHandler extends JsonSerializer<String> implements ContextualSerializer {
|
public class SensitiveHandler extends JsonSerializer<String> implements ContextualSerializer {
|
||||||
|
|
||||||
private SensitiveStrategy strategy;
|
private SensitiveStrategy strategy;
|
||||||
|
private String roleKey;
|
||||||
|
private String perms;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
||||||
try {
|
try {
|
||||||
SensitiveService sensitiveService = SpringUtils.getBean(SensitiveService.class);
|
SensitiveService sensitiveService = SpringUtils.getBean(SensitiveService.class);
|
||||||
if (ObjectUtil.isNotNull(sensitiveService) && sensitiveService.isSensitive()) {
|
if (ObjectUtil.isNotNull(sensitiveService) && sensitiveService.isSensitive(roleKey, perms)) {
|
||||||
gen.writeString(strategy.desensitizer().apply(value));
|
gen.writeString(strategy.desensitizer().apply(value));
|
||||||
} else {
|
} else {
|
||||||
gen.writeString(value);
|
gen.writeString(value);
|
||||||
@ -47,6 +49,8 @@ public class SensitiveHandler extends JsonSerializer<String> implements Contextu
|
|||||||
Sensitive annotation = property.getAnnotation(Sensitive.class);
|
Sensitive annotation = property.getAnnotation(Sensitive.class);
|
||||||
if (Objects.nonNull(annotation) && Objects.equals(String.class, property.getType().getRawClass())) {
|
if (Objects.nonNull(annotation) && Objects.equals(String.class, property.getType().getRawClass())) {
|
||||||
this.strategy = annotation.strategy();
|
this.strategy = annotation.strategy();
|
||||||
|
this.roleKey = annotation.roleKey();
|
||||||
|
this.perms = annotation.perms();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
return prov.findValueSerializer(property.getType(), property);
|
return prov.findValueSerializer(property.getType(), property);
|
||||||
|
|||||||
@ -63,9 +63,9 @@ public class AuthMaxKeyRequest extends AuthDefaultRequest {
|
|||||||
throw new AuthException(object.getStr("message"));
|
throw new AuthException(object.getStr("message"));
|
||||||
}
|
}
|
||||||
return AuthUser.builder()
|
return AuthUser.builder()
|
||||||
.uuid(object.getStr("id"))
|
.uuid(object.getStr("userId"))
|
||||||
.username(object.getStr("username"))
|
.username(object.getStr("username"))
|
||||||
.nickname(object.getStr("name"))
|
.nickname(object.getStr("displayName"))
|
||||||
.avatar(object.getStr("avatar_url"))
|
.avatar(object.getStr("avatar_url"))
|
||||||
.blog(object.getStr("web_url"))
|
.blog(object.getStr("web_url"))
|
||||||
.company(object.getStr("organization"))
|
.company(object.getStr("organization"))
|
||||||
|
|||||||
@ -2,15 +2,14 @@ package org.dromara.common.tenant.handle;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.ListUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
|
import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.dromara.common.core.utils.StringUtils;
|
|
||||||
import org.dromara.common.satoken.utils.LoginHelper;
|
|
||||||
import org.dromara.common.tenant.helper.TenantHelper;
|
|
||||||
import org.dromara.common.tenant.properties.TenantProperties;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.sf.jsqlparser.expression.Expression;
|
import net.sf.jsqlparser.expression.Expression;
|
||||||
import net.sf.jsqlparser.expression.NullValue;
|
import net.sf.jsqlparser.expression.NullValue;
|
||||||
import net.sf.jsqlparser.expression.StringValue;
|
import net.sf.jsqlparser.expression.StringValue;
|
||||||
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
|
import org.dromara.common.tenant.helper.TenantHelper;
|
||||||
|
import org.dromara.common.tenant.properties.TenantProperties;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -38,7 +37,7 @@ public class PlusTenantLineHandler implements TenantLineHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean ignoreTable(String tableName) {
|
public boolean ignoreTable(String tableName) {
|
||||||
String tenantId = LoginHelper.getTenantId();
|
String tenantId = TenantHelper.getTenantId();
|
||||||
// 判断是否有租户
|
// 判断是否有租户
|
||||||
if (StringUtils.isNotBlank(tenantId)) {
|
if (StringUtils.isNotBlank(tenantId)) {
|
||||||
// 不需要过滤租户的表
|
// 不需要过滤租户的表
|
||||||
|
|||||||
@ -33,7 +33,7 @@ public class TenantKeyPrefixHandler extends KeyPrefixHandler {
|
|||||||
if (StringUtils.isBlank(tenantId)) {
|
if (StringUtils.isBlank(tenantId)) {
|
||||||
log.error("无法获取有效的租户id -> Null");
|
log.error("无法获取有效的租户id -> Null");
|
||||||
}
|
}
|
||||||
if (StringUtils.startsWith(name, tenantId)) {
|
if (StringUtils.startsWith(name, tenantId + "")) {
|
||||||
// 如果存在则直接返回
|
// 如果存在则直接返回
|
||||||
return super.map(name);
|
return super.map(name);
|
||||||
}
|
}
|
||||||
@ -56,7 +56,7 @@ public class TenantKeyPrefixHandler extends KeyPrefixHandler {
|
|||||||
if (StringUtils.isBlank(tenantId)) {
|
if (StringUtils.isBlank(tenantId)) {
|
||||||
log.error("无法获取有效的租户id -> Null");
|
log.error("无法获取有效的租户id -> Null");
|
||||||
}
|
}
|
||||||
if (StringUtils.startsWith(unmap, tenantId)) {
|
if (StringUtils.startsWith(unmap, tenantId + "")) {
|
||||||
// 如果存在则删除
|
// 如果存在则删除
|
||||||
return unmap.substring((tenantId + ":").length());
|
return unmap.substring((tenantId + ":").length());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
package org.dromara.common.tenant.helper;
|
package org.dromara.common.tenant.helper;
|
||||||
|
|
||||||
import cn.dev33.satoken.context.SaHolder;
|
import cn.dev33.satoken.context.SaHolder;
|
||||||
import cn.dev33.satoken.spring.SpringMVCUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import com.alibaba.ttl.TransmittableThreadLocal;
|
import com.alibaba.ttl.TransmittableThreadLocal;
|
||||||
import com.baomidou.mybatisplus.core.plugins.IgnoreStrategy;
|
import com.baomidou.mybatisplus.core.plugins.IgnoreStrategy;
|
||||||
@ -82,10 +82,13 @@ public class TenantHelper {
|
|||||||
/**
|
/**
|
||||||
* 设置动态租户(一直有效 需要手动清理)
|
* 设置动态租户(一直有效 需要手动清理)
|
||||||
* <p>
|
* <p>
|
||||||
* 如果为非web环境 那么只在当前线程内生效
|
* 如果为未登录状态下 那么只在当前线程内生效
|
||||||
*/
|
*/
|
||||||
public static void setDynamic(String tenantId) {
|
public static void setDynamic(String tenantId) {
|
||||||
if (!SpringMVCUtil.isWeb()) {
|
if (!isEnable()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!isLogin()) {
|
||||||
TEMP_DYNAMIC_TENANT.set(tenantId);
|
TEMP_DYNAMIC_TENANT.set(tenantId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -97,10 +100,13 @@ public class TenantHelper {
|
|||||||
/**
|
/**
|
||||||
* 获取动态租户(一直有效 需要手动清理)
|
* 获取动态租户(一直有效 需要手动清理)
|
||||||
* <p>
|
* <p>
|
||||||
* 如果为非web环境 那么只在当前线程内生效
|
* 如果为未登录状态下 那么只在当前线程内生效
|
||||||
*/
|
*/
|
||||||
public static String getDynamic() {
|
public static String getDynamic() {
|
||||||
if (!SpringMVCUtil.isWeb()) {
|
if (!isEnable()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (!isLogin()) {
|
||||||
return TEMP_DYNAMIC_TENANT.get();
|
return TEMP_DYNAMIC_TENANT.get();
|
||||||
}
|
}
|
||||||
String cacheKey = DYNAMIC_TENANT_KEY + ":" + LoginHelper.getUserId();
|
String cacheKey = DYNAMIC_TENANT_KEY + ":" + LoginHelper.getUserId();
|
||||||
@ -117,7 +123,10 @@ public class TenantHelper {
|
|||||||
* 清除动态租户
|
* 清除动态租户
|
||||||
*/
|
*/
|
||||||
public static void clearDynamic() {
|
public static void clearDynamic() {
|
||||||
if (!SpringMVCUtil.isWeb()) {
|
if (!isEnable()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!isLogin()) {
|
||||||
TEMP_DYNAMIC_TENANT.remove();
|
TEMP_DYNAMIC_TENANT.remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -126,6 +135,34 @@ public class TenantHelper {
|
|||||||
SaHolder.getStorage().delete(cacheKey);
|
SaHolder.getStorage().delete(cacheKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在动态租户中执行
|
||||||
|
*
|
||||||
|
* @param handle 处理执行方法
|
||||||
|
*/
|
||||||
|
public static void dynamic(String tenantId, Runnable handle) {
|
||||||
|
setDynamic(tenantId);
|
||||||
|
try {
|
||||||
|
handle.run();
|
||||||
|
} finally {
|
||||||
|
clearDynamic();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在动态租户中执行
|
||||||
|
*
|
||||||
|
* @param handle 处理执行方法
|
||||||
|
*/
|
||||||
|
public static <T> T dynamic(String tenantId, Supplier<T> handle) {
|
||||||
|
setDynamic(tenantId);
|
||||||
|
try {
|
||||||
|
return handle.get();
|
||||||
|
} finally {
|
||||||
|
clearDynamic();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前租户id(动态租户优先)
|
* 获取当前租户id(动态租户优先)
|
||||||
*/
|
*/
|
||||||
@ -137,4 +174,13 @@ public class TenantHelper {
|
|||||||
return tenantId;
|
return tenantId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isLogin() {
|
||||||
|
try {
|
||||||
|
StpUtil.checkLogin();
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,14 +44,14 @@ public class PlusWebInvokeTimeInterceptor implements HandlerInterceptor {
|
|||||||
BufferedReader reader = request.getReader();
|
BufferedReader reader = request.getReader();
|
||||||
jsonParam = IoUtil.read(reader);
|
jsonParam = IoUtil.read(reader);
|
||||||
}
|
}
|
||||||
log.debug("[PLUS]开始请求 => URL[{}],参数类型[json],参数:[{}]", url, jsonParam);
|
log.info("[PLUS]开始请求 => URL[{}],参数类型[json],参数:[{}]", url, jsonParam);
|
||||||
} else {
|
} else {
|
||||||
Map<String, String[]> parameterMap = request.getParameterMap();
|
Map<String, String[]> parameterMap = request.getParameterMap();
|
||||||
if (MapUtil.isNotEmpty(parameterMap)) {
|
if (MapUtil.isNotEmpty(parameterMap)) {
|
||||||
String parameters = JsonUtils.toJsonString(parameterMap);
|
String parameters = JsonUtils.toJsonString(parameterMap);
|
||||||
log.debug("[PLUS]开始请求 => URL[{}],参数类型[param],参数:[{}]", url, parameters);
|
log.info("[PLUS]开始请求 => URL[{}],参数类型[param],参数:[{}]", url, parameters);
|
||||||
} else {
|
} else {
|
||||||
log.debug("[PLUS]开始请求 => URL[{}],无参数", url);
|
log.info("[PLUS]开始请求 => URL[{}],无参数", url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ public class PlusWebInvokeTimeInterceptor implements HandlerInterceptor {
|
|||||||
if (!prodProfile.equals(SpringUtils.getActiveProfile())) {
|
if (!prodProfile.equals(SpringUtils.getActiveProfile())) {
|
||||||
StopWatch stopWatch = invokeTimeTL.get();
|
StopWatch stopWatch = invokeTimeTL.get();
|
||||||
stopWatch.stop();
|
stopWatch.stop();
|
||||||
log.debug("[PLUS]结束请求 => URL[{}],耗时:[{}]毫秒", request.getMethod() + " " + request.getRequestURI(), stopWatch.getTime());
|
log.info("[PLUS]结束请求 => URL[{}],耗时:[{}]毫秒", request.getMethod() + " " + request.getRequestURI(), stopWatch.getTime());
|
||||||
invokeTimeTL.remove();
|
invokeTimeTL.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,4 +13,5 @@ EXPOSE 9090
|
|||||||
|
|
||||||
ADD ./target/ruoyi-monitor-admin.jar ./app.jar
|
ADD ./target/ruoyi-monitor-admin.jar ./app.jar
|
||||||
|
|
||||||
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "app.jar"]
|
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "app.jar",
|
||||||
|
"-XX:+HeapDumpOnOutOfMemoryError", "-Xlog:gc*,:time,tags,level", "-XX:+UseZGC"]
|
||||||
|
|||||||
@ -13,4 +13,5 @@ EXPOSE 7700
|
|||||||
|
|
||||||
ADD ./target/ruoyi-powerjob-server.jar ./app.jar
|
ADD ./target/ruoyi-powerjob-server.jar ./app.jar
|
||||||
|
|
||||||
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "app.jar"]
|
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "app.jar",
|
||||||
|
"-XX:+HeapDumpOnOutOfMemoryError", "-Xlog:gc*,:time,tags,level", "-XX:+UseZGC"]
|
||||||
|
|||||||
@ -50,25 +50,25 @@ public class TestSensitiveController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 电话
|
* 电话
|
||||||
*/
|
*/
|
||||||
@Sensitive(strategy = SensitiveStrategy.PHONE)
|
@Sensitive(strategy = SensitiveStrategy.PHONE, roleKey = "common")
|
||||||
private String phone;
|
private String phone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 地址
|
* 地址
|
||||||
*/
|
*/
|
||||||
@Sensitive(strategy = SensitiveStrategy.ADDRESS)
|
@Sensitive(strategy = SensitiveStrategy.ADDRESS, perms = "system:user:query")
|
||||||
private String address;
|
private String address;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 邮箱
|
* 邮箱
|
||||||
*/
|
*/
|
||||||
@Sensitive(strategy = SensitiveStrategy.EMAIL)
|
@Sensitive(strategy = SensitiveStrategy.EMAIL, roleKey = "common", perms = "system:user:query1")
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 银行卡
|
* 银行卡
|
||||||
*/
|
*/
|
||||||
@Sensitive(strategy = SensitiveStrategy.BANK_CARD)
|
@Sensitive(strategy = SensitiveStrategy.BANK_CARD, roleKey = "common1", perms = "system:user:query")
|
||||||
private String bankCard;
|
private String bankCard;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package org.dromara.demo.controller.queue;
|
package org.dromara.demo.controller.queue;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.annotation.SaIgnore;
|
||||||
import org.dromara.common.core.domain.R;
|
import org.dromara.common.core.domain.R;
|
||||||
import org.dromara.common.redis.utils.QueueUtils;
|
import org.dromara.common.redis.utils.QueueUtils;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@ -22,6 +23,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
* @version 3.6.0
|
* @version 3.6.0
|
||||||
*/
|
*/
|
||||||
|
@SaIgnore
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@ -40,7 +42,7 @@ public class DelayedQueueController {
|
|||||||
QueueUtils.subscribeBlockingQueue(queueName, (String orderNum) -> {
|
QueueUtils.subscribeBlockingQueue(queueName, (String orderNum) -> {
|
||||||
// 观察接收时间
|
// 观察接收时间
|
||||||
log.info("通道: {}, 收到数据: {}", queueName, orderNum);
|
log.info("通道: {}, 收到数据: {}", queueName, orderNum);
|
||||||
});
|
}, true);
|
||||||
return R.ok("操作成功");
|
return R.ok("操作成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -79,7 +79,7 @@ public class GenController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@SaCheckPermission("tool:gen:list")
|
@SaCheckPermission("tool:gen:list")
|
||||||
@GetMapping(value = "/column/{tableId}")
|
@GetMapping(value = "/column/{tableId}")
|
||||||
public TableDataInfo<GenTableColumn> columnList(Long tableId) {
|
public TableDataInfo<GenTableColumn> columnList(@PathVariable("tableId") Long tableId) {
|
||||||
TableDataInfo<GenTableColumn> dataInfo = new TableDataInfo<>();
|
TableDataInfo<GenTableColumn> dataInfo = new TableDataInfo<>();
|
||||||
List<GenTableColumn> list = genTableService.selectGenTableColumnListByTableId(tableId);
|
List<GenTableColumn> list = genTableService.selectGenTableColumnListByTableId(tableId);
|
||||||
dataInfo.setRows(list);
|
dataInfo.setRows(list);
|
||||||
|
|||||||
@ -185,7 +185,7 @@ public class SysMenu extends BaseEntity {
|
|||||||
* 内链域名特殊字符替换
|
* 内链域名特殊字符替换
|
||||||
*/
|
*/
|
||||||
public static String innerLinkReplaceEach(String path) {
|
public static String innerLinkReplaceEach(String path) {
|
||||||
return StringUtils.replaceEach(path, new String[]{Constants.HTTP, Constants.HTTPS, Constants.WWW, "."},
|
return StringUtils.replaceEach(path, new String[]{Constants.HTTP, Constants.HTTPS, Constants.WWW, ".", ":"},
|
||||||
new String[]{"", "", "", "/"});
|
new String[]{"", "", "", "/", "/"});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,12 @@
|
|||||||
package org.dromara.system.domain.vo;
|
package org.dromara.system.domain.vo;
|
||||||
|
|
||||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
|
||||||
import io.github.linpeilie.annotations.AutoMapper;
|
import io.github.linpeilie.annotations.AutoMapper;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.dromara.system.domain.SysSocial;
|
import org.dromara.system.domain.SysSocial;
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -16,7 +15,6 @@ import java.io.Serializable;
|
|||||||
* @author thiszhc
|
* @author thiszhc
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@ExcelIgnoreUnannotated
|
|
||||||
@AutoMapper(target = SysSocial.class)
|
@AutoMapper(target = SysSocial.class)
|
||||||
public class SysSocialVo implements Serializable {
|
public class SysSocialVo implements Serializable {
|
||||||
|
|
||||||
@ -26,13 +24,11 @@ public class SysSocialVo implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 主键
|
* 主键
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "主键")
|
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户ID
|
* 用户ID
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "用户ID")
|
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,123 +39,106 @@ public class SysSocialVo implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* 的唯一ID
|
* 的唯一ID
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "授权UUID")
|
|
||||||
private String authId;
|
private String authId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户来源
|
* 用户来源
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "用户来源")
|
|
||||||
private String source;
|
private String source;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户的授权令牌
|
* 用户的授权令牌
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "用户的授权令牌")
|
|
||||||
private String accessToken;
|
private String accessToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户的授权令牌的有效期,部分平台可能没有
|
* 用户的授权令牌的有效期,部分平台可能没有
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "用户的授权令牌的有效期,部分平台可能没有")
|
|
||||||
private int expireIn;
|
private int expireIn;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 刷新令牌,部分平台可能没有
|
* 刷新令牌,部分平台可能没有
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "刷新令牌,部分平台可能没有")
|
|
||||||
private String refreshToken;
|
private String refreshToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户的 open id
|
* 用户的 open id
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "平台的唯一id")
|
|
||||||
private String openId;
|
private String openId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 授权的第三方账号
|
* 授权的第三方账号
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "授权的第三方账号")
|
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 授权的第三方昵称
|
* 授权的第三方昵称
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "授权的第三方昵称")
|
|
||||||
private String nickName;
|
private String nickName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 授权的第三方邮箱
|
* 授权的第三方邮箱
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "授权的第三方邮箱")
|
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 授权的第三方头像地址
|
* 授权的第三方头像地址
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "授权的第三方头像地址")
|
|
||||||
private String avatar;
|
private String avatar;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 平台的授权信息,部分平台可能没有
|
* 平台的授权信息,部分平台可能没有
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "平台的授权信息,部分平台可能没有")
|
|
||||||
private String accessCode;
|
private String accessCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户的 unionid
|
* 用户的 unionid
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "用户的 unionid")
|
|
||||||
private String unionId;
|
private String unionId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 授予的权限,部分平台可能没有
|
* 授予的权限,部分平台可能没有
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "授予的权限,部分平台可能没有")
|
|
||||||
private String scope;
|
private String scope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 个别平台的授权信息,部分平台可能没有
|
* 个别平台的授权信息,部分平台可能没有
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "个别平台的授权信息,部分平台可能没有")
|
|
||||||
private String tokenType;
|
private String tokenType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* id token,部分平台可能没有
|
* id token,部分平台可能没有
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "id token,部分平台可能没有")
|
|
||||||
private String idToken;
|
private String idToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 小米平台用户的附带属性,部分平台可能没有
|
* 小米平台用户的附带属性,部分平台可能没有
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "小米平台用户的附带属性,部分平台可能没有")
|
|
||||||
private String macAlgorithm;
|
private String macAlgorithm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 小米平台用户的附带属性,部分平台可能没有
|
* 小米平台用户的附带属性,部分平台可能没有
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "小米平台用户的附带属性,部分平台可能没有")
|
|
||||||
private String macKey;
|
private String macKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户的授权code,部分平台可能没有
|
* 用户的授权code,部分平台可能没有
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "用户的授权code,部分平台可能没有")
|
|
||||||
private String code;
|
private String code;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Twitter平台用户的附带属性,部分平台可能没有
|
* Twitter平台用户的附带属性,部分平台可能没有
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "Twitter平台用户的附带属性,部分平台可能没有")
|
|
||||||
private String oauthToken;
|
private String oauthToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Twitter平台用户的附带属性,部分平台可能没有
|
* Twitter平台用户的附带属性,部分平台可能没有
|
||||||
*/
|
*/
|
||||||
@ExcelProperty(value = "Twitter平台用户的附带属性,部分平台可能没有")
|
|
||||||
private String oauthTokenSecret;
|
private String oauthTokenSecret;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private Date createTime;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,15 +1,14 @@
|
|||||||
package org.dromara.system.mapper;
|
package org.dromara.system.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.dromara.common.mybatis.annotation.DataColumn;
|
import org.dromara.common.mybatis.annotation.DataColumn;
|
||||||
import org.dromara.common.mybatis.annotation.DataPermission;
|
import org.dromara.common.mybatis.annotation.DataPermission;
|
||||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||||
import org.dromara.system.domain.SysUser;
|
import org.dromara.system.domain.SysUser;
|
||||||
import org.dromara.system.domain.vo.SysUserVo;
|
import org.dromara.system.domain.vo.SysUserVo;
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -86,37 +85,6 @@ public interface SysUserMapper extends BaseMapperPlus<SysUser, SysUserVo> {
|
|||||||
*/
|
*/
|
||||||
SysUserVo selectUserByEmail(String email);
|
SysUserVo selectUserByEmail(String email);
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过用户名查询用户(不走租户插件)
|
|
||||||
*
|
|
||||||
* @param userName 用户名
|
|
||||||
* @param tenantId 租户id
|
|
||||||
* @return 用户对象信息
|
|
||||||
*/
|
|
||||||
@InterceptorIgnore(tenantLine = "true")
|
|
||||||
SysUserVo selectTenantUserByUserName(@Param("userName") String userName, @Param("tenantId") String tenantId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过手机号查询用户(不走租户插件)
|
|
||||||
*
|
|
||||||
* @param phonenumber 手机号
|
|
||||||
* @param tenantId 租户id
|
|
||||||
* @return 用户对象信息
|
|
||||||
*/
|
|
||||||
@InterceptorIgnore(tenantLine = "true")
|
|
||||||
SysUserVo selectTenantUserByPhonenumber(@Param("phonenumber") String phonenumber, @Param("tenantId") String tenantId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过邮箱查询用户(不走租户插件)
|
|
||||||
*
|
|
||||||
* @param email 邮箱
|
|
||||||
* @param tenantId 租户id
|
|
||||||
* @return 用户对象信息
|
|
||||||
*/
|
|
||||||
@InterceptorIgnore(tenantLine = "true")
|
|
||||||
SysUserVo selectTenantUserByEmail(@Param("email") String email, @Param("tenantId") String tenantId);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过用户ID查询用户
|
* 通过用户ID查询用户
|
||||||
*
|
*
|
||||||
|
|||||||
@ -49,7 +49,7 @@ public interface ISysSocialService {
|
|||||||
* @param authId 认证ID
|
* @param authId 认证ID
|
||||||
* @return SysSocial
|
* @return SysSocial
|
||||||
*/
|
*/
|
||||||
SysSocialVo selectByAuthId(String authId);
|
List<SysSocialVo> selectByAuthId(String authId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,9 +85,10 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean selectRegisterEnabled(String tenantId) {
|
public boolean selectRegisterEnabled(String tenantId) {
|
||||||
SysConfig retConfig = baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>()
|
SysConfig retConfig = TenantHelper.dynamic(tenantId, () -> {
|
||||||
.eq(SysConfig::getConfigKey, "sys.account.registerUser")
|
return baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>()
|
||||||
.eq(TenantHelper.isEnable(),SysConfig::getTenantId, tenantId));
|
.eq(SysConfig::getConfigKey, "sys.account.registerUser"));
|
||||||
|
});
|
||||||
if (ObjectUtil.isNull(retConfig)) {
|
if (ObjectUtil.isNull(retConfig)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -83,9 +83,9 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
|||||||
lqw.eq(ObjectUtil.isNotNull(bo.getParentId()), SysDept::getParentId, bo.getParentId());
|
lqw.eq(ObjectUtil.isNotNull(bo.getParentId()), SysDept::getParentId, bo.getParentId());
|
||||||
lqw.like(StringUtils.isNotBlank(bo.getDeptName()), SysDept::getDeptName, bo.getDeptName());
|
lqw.like(StringUtils.isNotBlank(bo.getDeptName()), SysDept::getDeptName, bo.getDeptName());
|
||||||
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysDept::getStatus, bo.getStatus());
|
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysDept::getStatus, bo.getStatus());
|
||||||
lqw.orderByAsc(SysDept::getDeptId);
|
|
||||||
lqw.orderByAsc(SysDept::getParentId);
|
lqw.orderByAsc(SysDept::getParentId);
|
||||||
lqw.orderByAsc(SysDept::getOrderNum);
|
lqw.orderByAsc(SysDept::getOrderNum);
|
||||||
|
lqw.orderByAsc(SysDept::getDeptId);
|
||||||
return lqw;
|
return lqw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -57,9 +57,8 @@ public class SysOssConfigServiceImpl implements ISysOssConfigService {
|
|||||||
new LambdaQueryWrapper<SysOssConfig>().orderByAsc(TenantEntity::getTenantId))
|
new LambdaQueryWrapper<SysOssConfig>().orderByAsc(TenantEntity::getTenantId))
|
||||||
);
|
);
|
||||||
Map<String, List<SysOssConfig>> map = StreamUtils.groupByKey(list, SysOssConfig::getTenantId);
|
Map<String, List<SysOssConfig>> map = StreamUtils.groupByKey(list, SysOssConfig::getTenantId);
|
||||||
try {
|
for (String tenantId : map.keySet()) {
|
||||||
for (String tenantId : map.keySet()) {
|
TenantHelper.dynamic(tenantId, () -> {
|
||||||
TenantHelper.setDynamic(tenantId);
|
|
||||||
// 加载OSS初始化配置
|
// 加载OSS初始化配置
|
||||||
for (SysOssConfig config : map.get(tenantId)) {
|
for (SysOssConfig config : map.get(tenantId)) {
|
||||||
String configKey = config.getConfigKey();
|
String configKey = config.getConfigKey();
|
||||||
@ -68,9 +67,7 @@ public class SysOssConfigServiceImpl implements ISysOssConfigService {
|
|||||||
}
|
}
|
||||||
CacheUtils.put(CacheNames.SYS_OSS_CONFIG, config.getConfigKey(), JsonUtils.toJsonString(config));
|
CacheUtils.put(CacheNames.SYS_OSS_CONFIG, config.getConfigKey(), JsonUtils.toJsonString(config));
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
} finally {
|
|
||||||
TenantHelper.clearDynamic();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -64,7 +64,12 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
|
|||||||
for (Long id : ossIds) {
|
for (Long id : ossIds) {
|
||||||
SysOssVo vo = SpringUtils.getAopProxy(this).getById(id);
|
SysOssVo vo = SpringUtils.getAopProxy(this).getById(id);
|
||||||
if (ObjectUtil.isNotNull(vo)) {
|
if (ObjectUtil.isNotNull(vo)) {
|
||||||
list.add(this.matchingUrl(vo));
|
try {
|
||||||
|
list.add(this.matchingUrl(vo));
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
// 如果oss异常无法连接则将数据直接返回
|
||||||
|
list.add(vo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
@ -76,7 +81,12 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
|
|||||||
for (Long id : StringUtils.splitTo(ossIds, Convert::toLong)) {
|
for (Long id : StringUtils.splitTo(ossIds, Convert::toLong)) {
|
||||||
SysOssVo vo = SpringUtils.getAopProxy(this).getById(id);
|
SysOssVo vo = SpringUtils.getAopProxy(this).getById(id);
|
||||||
if (ObjectUtil.isNotNull(vo)) {
|
if (ObjectUtil.isNotNull(vo)) {
|
||||||
list.add(this.matchingUrl(vo).getUrl());
|
try {
|
||||||
|
list.add(this.matchingUrl(vo).getUrl());
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
// 如果oss异常无法连接则将数据直接返回
|
||||||
|
list.add(vo.getUrl());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return String.join(StringUtils.SEPARATOR, list);
|
return String.join(StringUtils.SEPARATOR, list);
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
package org.dromara.system.service.impl;
|
package org.dromara.system.service.impl;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
|
import org.dromara.common.core.utils.StringUtils;
|
||||||
import org.dromara.common.satoken.utils.LoginHelper;
|
import org.dromara.common.satoken.utils.LoginHelper;
|
||||||
import org.dromara.common.sensitive.core.SensitiveService;
|
import org.dromara.common.sensitive.core.SensitiveService;
|
||||||
import org.dromara.common.tenant.helper.TenantHelper;
|
import org.dromara.common.tenant.helper.TenantHelper;
|
||||||
@ -20,7 +22,22 @@ public class SysSensitiveServiceImpl implements SensitiveService {
|
|||||||
* 是否脱敏
|
* 是否脱敏
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isSensitive() {
|
public boolean isSensitive(String roleKey, String perms) {
|
||||||
|
if (!StpUtil.isLogin()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
boolean roleExist = StringUtils.isNotBlank(roleKey);
|
||||||
|
boolean permsExist = StringUtils.isNotBlank(perms);
|
||||||
|
if (roleExist && permsExist) {
|
||||||
|
if (StpUtil.hasRole(roleKey) && StpUtil.hasPermission(perms)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (roleExist && StpUtil.hasRole(roleKey)) {
|
||||||
|
return false;
|
||||||
|
} else if (permsExist && StpUtil.hasPermission(perms)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (TenantHelper.isEnable()) {
|
if (TenantHelper.isEnable()) {
|
||||||
return !LoginHelper.isSuperAdmin() && !LoginHelper.isTenantAdmin();
|
return !LoginHelper.isSuperAdmin() && !LoginHelper.isTenantAdmin();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -99,8 +99,8 @@ public class SysSocialServiceImpl implements ISysSocialService {
|
|||||||
* @return 授权信息
|
* @return 授权信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SysSocialVo selectByAuthId(String authId) {
|
public List<SysSocialVo> selectByAuthId(String authId) {
|
||||||
return baseMapper.selectVoOne(new LambdaQueryWrapper<SysSocial>().eq(SysSocial::getAuthId, authId));
|
return baseMapper.selectVoList(new LambdaQueryWrapper<SysSocial>().eq(SysSocial::getAuthId, authId));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -118,21 +118,6 @@
|
|||||||
where u.del_flag = '0' and u.email = #{email}
|
where u.del_flag = '0' and u.email = #{email}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectTenantUserByUserName" parameterType="String" resultMap="SysUserResult">
|
|
||||||
<include refid="selectUserVo"/>
|
|
||||||
where u.del_flag = '0' and u.user_name = #{userName} and u.tenant_id = #{tenantId}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectTenantUserByPhonenumber" parameterType="String" resultMap="SysUserResult">
|
|
||||||
<include refid="selectUserVo"/>
|
|
||||||
where u.del_flag = '0' and u.phonenumber = #{phonenumber} and u.tenant_id = #{tenantId}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectTenantUserByEmail" parameterType="String" resultMap="SysUserResult">
|
|
||||||
<include refid="selectUserVo"/>
|
|
||||||
where u.del_flag = '0' and u.email = #{email} and u.tenant_id = #{tenantId}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
|
<select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
|
||||||
<include refid="selectUserVo"/>
|
<include refid="selectUserVo"/>
|
||||||
where u.del_flag = '0' and u.user_id = #{userId}
|
where u.del_flag = '0' and u.user_id = #{userId}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ rem jar平级目录
|
|||||||
set AppName=ruoyi-admin.jar
|
set AppName=ruoyi-admin.jar
|
||||||
|
|
||||||
rem JVM参数
|
rem JVM参数
|
||||||
set JVM_OPTS="-Dname=%AppName% -Duser.timezone=Asia/Shanghai -Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:NewRatio=1 -XX:SurvivorRatio=30 -XX:+UseParallelGC -XX:+UseParallelOldGC"
|
set JVM_OPTS="-Dname=%AppName% -Duser.timezone=Asia/Shanghai -Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Xlog:gc*,:time,tags,level -XX:+UseZGC"
|
||||||
|
|
||||||
|
|
||||||
ECHO.
|
ECHO.
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
AppName=ruoyi-admin.jar
|
AppName=ruoyi-admin.jar
|
||||||
|
|
||||||
# JVM参数
|
# JVM参数
|
||||||
JVM_OPTS="-Dname=$AppName -Duser.timezone=Asia/Shanghai -Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:NewRatio=1 -XX:SurvivorRatio=30 -XX:+UseParallelGC -XX:+UseParallelOldGC"
|
JVM_OPTS="-Dname=$AppName -Duser.timezone=Asia/Shanghai -Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Xlog:gc*,:time,tags,level -XX:+UseZGC"
|
||||||
APP_HOME=`pwd`
|
APP_HOME=`pwd`
|
||||||
LOG_PATH=$APP_HOME/logs/$AppName.log
|
LOG_PATH=$APP_HOME/logs/$AppName.log
|
||||||
|
|
||||||
|
|||||||
@ -100,7 +100,7 @@ services:
|
|||||||
network_mode: "host"
|
network_mode: "host"
|
||||||
|
|
||||||
ruoyi-server1:
|
ruoyi-server1:
|
||||||
image: ruoyi/ruoyi-server:5.1.0
|
image: ruoyi/ruoyi-server:5.1.1
|
||||||
container_name: ruoyi-server1
|
container_name: ruoyi-server1
|
||||||
environment:
|
environment:
|
||||||
# 时区上海
|
# 时区上海
|
||||||
@ -115,7 +115,7 @@ services:
|
|||||||
network_mode: "host"
|
network_mode: "host"
|
||||||
|
|
||||||
ruoyi-server2:
|
ruoyi-server2:
|
||||||
image: ruoyi/ruoyi-server:5.1.0
|
image: ruoyi/ruoyi-server:5.1.1
|
||||||
container_name: ruoyi-server2
|
container_name: ruoyi-server2
|
||||||
environment:
|
environment:
|
||||||
# 时区上海
|
# 时区上海
|
||||||
@ -130,7 +130,7 @@ services:
|
|||||||
network_mode: "host"
|
network_mode: "host"
|
||||||
|
|
||||||
ruoyi-monitor-admin:
|
ruoyi-monitor-admin:
|
||||||
image: ruoyi/ruoyi-monitor-admin:5.1.0
|
image: ruoyi/ruoyi-monitor-admin:5.1.1
|
||||||
container_name: ruoyi-monitor-admin
|
container_name: ruoyi-monitor-admin
|
||||||
environment:
|
environment:
|
||||||
# 时区上海
|
# 时区上海
|
||||||
@ -142,7 +142,7 @@ services:
|
|||||||
network_mode: "host"
|
network_mode: "host"
|
||||||
|
|
||||||
ruoyi-powerjob-server:
|
ruoyi-powerjob-server:
|
||||||
image: ruoyi/ruoyi-powerjob-server:5.1.0
|
image: ruoyi/ruoyi-powerjob-server:5.1.1
|
||||||
container_name: ruoyi-powerjob-server
|
container_name: ruoyi-powerjob-server
|
||||||
environment:
|
environment:
|
||||||
# 时区上海
|
# 时区上海
|
||||||
|
|||||||
@ -78,6 +78,10 @@ http {
|
|||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header REMOTE-HOST $remote_addr;
|
proxy_set_header REMOTE-HOST $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
# websocket参数
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
proxy_pass http://server/;
|
proxy_pass http://server/;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user