mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-24 07:19:46 +08:00
update 优化 使用动态租户重构业务对租户的逻辑
This commit is contained in:
@ -1,15 +1,14 @@
|
||||
package org.dromara.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
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.DataPermission;
|
||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.dromara.system.domain.SysUser;
|
||||
import org.dromara.system.domain.vo.SysUserVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -86,37 +85,6 @@ public interface SysUserMapper extends BaseMapperPlus<SysUser, SysUserVo> {
|
||||
*/
|
||||
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查询用户
|
||||
*
|
||||
|
@ -85,9 +85,10 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
|
||||
*/
|
||||
@Override
|
||||
public boolean selectRegisterEnabled(String tenantId) {
|
||||
SysConfig retConfig = baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>()
|
||||
.eq(SysConfig::getConfigKey, "sys.account.registerUser")
|
||||
.eq(TenantHelper.isEnable(),SysConfig::getTenantId, tenantId));
|
||||
SysConfig retConfig = TenantHelper.dynamic(tenantId, () -> {
|
||||
return baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>()
|
||||
.eq(SysConfig::getConfigKey, "sys.account.registerUser"));
|
||||
});
|
||||
if (ObjectUtil.isNull(retConfig)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -57,9 +57,8 @@ public class SysOssConfigServiceImpl implements ISysOssConfigService {
|
||||
new LambdaQueryWrapper<SysOssConfig>().orderByAsc(TenantEntity::getTenantId))
|
||||
);
|
||||
Map<String, List<SysOssConfig>> map = StreamUtils.groupByKey(list, SysOssConfig::getTenantId);
|
||||
try {
|
||||
for (String tenantId : map.keySet()) {
|
||||
TenantHelper.setDynamic(tenantId);
|
||||
for (String tenantId : map.keySet()) {
|
||||
TenantHelper.dynamic(tenantId, () -> {
|
||||
// 加载OSS初始化配置
|
||||
for (SysOssConfig config : map.get(tenantId)) {
|
||||
String configKey = config.getConfigKey();
|
||||
@ -68,9 +67,7 @@ public class SysOssConfigServiceImpl implements ISysOssConfigService {
|
||||
}
|
||||
CacheUtils.put(CacheNames.SYS_OSS_CONFIG, config.getConfigKey(), JsonUtils.toJsonString(config));
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
TenantHelper.clearDynamic();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,21 +118,6 @@
|
||||
where u.del_flag = '0' and u.email = #{email}
|
||||
</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">
|
||||
<include refid="selectUserVo"/>
|
||||
where u.del_flag = '0' and u.user_id = #{userId}
|
||||
|
Reference in New Issue
Block a user