mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-21 18:45:57 +08:00
update 忽略租户写法去除使用注解的方式
This commit is contained in:
parent
b663197e45
commit
716d7e7435
@ -1,20 +0,0 @@
|
||||
package org.dromara.common.tenant.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Inherited;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 忽略租户注解
|
||||
*
|
||||
* @author yixiacoco
|
||||
*/
|
||||
@Inherited
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface IgnoreTenant {
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
package org.dromara.common.tenant.aspect;
|
||||
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.dromara.common.tenant.annotation.IgnoreTenant;
|
||||
import org.dromara.common.tenant.helper.TenantHelper;
|
||||
import org.springframework.core.annotation.Order;
|
||||
|
||||
/**
|
||||
* 租户切面
|
||||
*
|
||||
* @author yixiacoco
|
||||
*/
|
||||
@Aspect
|
||||
@Order(-1)
|
||||
public class TenantAspect {
|
||||
|
||||
/**
|
||||
* 处理忽略租户
|
||||
*
|
||||
* @param point 织入点
|
||||
* @param ignoreTenant 忽略注解
|
||||
*/
|
||||
@Around("@within(ignoreTenant) || @annotation(ignoreTenant)")
|
||||
public Object handleIgnore(ProceedingJoinPoint point, IgnoreTenant ignoreTenant) throws Throwable {
|
||||
TenantHelper.enableIgnore();
|
||||
try {
|
||||
return point.proceed();
|
||||
} finally {
|
||||
TenantHelper.disableIgnore();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -9,7 +9,6 @@ import org.dromara.common.core.utils.reflect.ReflectUtils;
|
||||
import org.dromara.common.mybatis.config.MybatisPlusConfig;
|
||||
import org.dromara.common.redis.config.RedisConfig;
|
||||
import org.dromara.common.redis.config.properties.RedissonProperties;
|
||||
import org.dromara.common.tenant.aspect.TenantAspect;
|
||||
import org.dromara.common.tenant.core.TenantSaTokenDao;
|
||||
import org.dromara.common.tenant.handle.PlusTenantLineHandler;
|
||||
import org.dromara.common.tenant.handle.TenantKeyPrefixHandler;
|
||||
@ -98,11 +97,4 @@ public class TenantConfig {
|
||||
return new TenantSaTokenDao();
|
||||
}
|
||||
|
||||
/**
|
||||
* 多租户切面
|
||||
*/
|
||||
@Bean
|
||||
public TenantAspect tenantAspect() {
|
||||
return new TenantAspect();
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,6 +15,7 @@ import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.redis.utils.RedisUtils;
|
||||
import org.dromara.common.satoken.utils.LoginHelper;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
@ -56,10 +57,10 @@ public class TenantHelper {
|
||||
*
|
||||
* @param handle 处理执行方法
|
||||
*/
|
||||
public static void ignore(Runnable handle) {
|
||||
public static void ignore(Consumer<Void> handle) {
|
||||
enableIgnore();
|
||||
try {
|
||||
handle.run();
|
||||
handle.accept(null);
|
||||
} finally {
|
||||
disableIgnore();
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ import org.dromara.common.core.utils.SpringUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.tenant.annotation.IgnoreTenant;
|
||||
import org.dromara.common.tenant.helper.TenantHelper;
|
||||
import org.dromara.system.domain.*;
|
||||
import org.dromara.system.domain.bo.SysTenantBo;
|
||||
import org.dromara.system.domain.vo.SysTenantVo;
|
||||
@ -111,9 +111,9 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||
* 新增租户
|
||||
*/
|
||||
@Override
|
||||
@IgnoreTenant
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean insertByBo(SysTenantBo bo) {
|
||||
TenantHelper.ignore(unused -> {
|
||||
|
||||
SysTenant add = MapstructUtils.convert(bo, SysTenant.class);
|
||||
|
||||
@ -185,7 +185,7 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||
config.setTenantId(tenantId);
|
||||
}
|
||||
configMapper.insertBatch(sysConfigList);
|
||||
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -340,9 +340,9 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||
* 同步租户套餐
|
||||
*/
|
||||
@Override
|
||||
@IgnoreTenant
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean syncTenantPackage(String tenantId, String packageId) {
|
||||
TenantHelper.ignore(unused -> {
|
||||
SysTenantPackage tenantPackage = tenantPackageMapper.selectById(packageId);
|
||||
List<SysRole> roles = roleMapper.selectList(
|
||||
new LambdaQueryWrapper<SysRole>().eq(SysRole::getTenantId, tenantId));
|
||||
@ -367,6 +367,7 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||
roleMenuMapper.delete(
|
||||
new LambdaQueryWrapper<SysRoleMenu>().in(SysRoleMenu::getRoleId, roleIds).notIn(!menuIds.isEmpty(), SysRoleMenu::getMenuId, menuIds));
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user