1. 替换原始 code 签名
2. 服务与模块生成器,支持指定起始端口批量端口分配
This commit is contained in:
@@ -10,7 +10,7 @@ import java.util.Set;
|
||||
/**
|
||||
* 多租户配置
|
||||
*
|
||||
* @author 芋道源码
|
||||
* @author ZT
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "yudao.tenant")
|
||||
@Data
|
||||
|
||||
@@ -11,7 +11,7 @@ import org.aspectj.lang.annotation.Aspect;
|
||||
* 忽略单位切换,标记指定方法不进行租户切换的覆盖,基于 {@link CompanyVisitIgnore} 注解实现,用于一些全局的逻辑。
|
||||
* 例如说,一个定时任务,读取所有数据,进行处理。
|
||||
* 又例如说,读取所有数据,进行缓存。
|
||||
* @author 芋道源码
|
||||
* @author ZT
|
||||
*/
|
||||
@Aspect
|
||||
@Slf4j
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.lang.annotation.*;
|
||||
* 1、如果添加到 Controller 类上,则该 URL 自动添加到 {@link TenantProperties#getIgnoreUrls()} 中
|
||||
* 2、如果添加到 DO 实体类上,则它对应的表名“相当于”自动添加到 {@link TenantProperties#getIgnoreTables()} 中
|
||||
*
|
||||
* @author 芋道源码
|
||||
* @author ZT
|
||||
*/
|
||||
@Target({ElementType.METHOD, ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.aspectj.lang.annotation.Aspect;
|
||||
*
|
||||
* 整体逻辑的实现,和 {@link TenantUtils#executeIgnore(Runnable)} 需要保持一致
|
||||
*
|
||||
* @author 芋道源码
|
||||
* @author ZT
|
||||
*/
|
||||
@Aspect
|
||||
@Slf4j
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.alibaba.ttl.TransmittableThreadLocal;
|
||||
/**
|
||||
* 公司上下文 Holder
|
||||
*
|
||||
* @author 芋道源码
|
||||
* @author ZT
|
||||
*/
|
||||
public class CompanyContextHolder {
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.alibaba.ttl.TransmittableThreadLocal;
|
||||
/**
|
||||
* 多租户上下文 Holder
|
||||
*
|
||||
* @author 芋道源码
|
||||
* @author ZT
|
||||
*/
|
||||
public class TenantContextHolder {
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import lombok.EqualsAndHashCode;
|
||||
/**
|
||||
* 拓展多租户的 BaseDO 基类
|
||||
*
|
||||
* @author 芋道源码
|
||||
* @author ZT
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.util.Map;
|
||||
/**
|
||||
* 基于 MyBatis Plus 多租户的功能,实现 DB 层面的多租户的功能
|
||||
*
|
||||
* @author 芋道源码
|
||||
* @author ZT
|
||||
*/
|
||||
public class TenantDatabaseInterceptor implements TenantLineHandler {
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
*
|
||||
* 注意,需要保证 JobHandler 的幂等性。因为 Job 因为某个租户执行失败重试时,之前执行成功的租户也会再次执行。
|
||||
*
|
||||
* @author 芋道源码
|
||||
* @author ZT
|
||||
*/
|
||||
@Aspect
|
||||
@RequiredArgsConstructor
|
||||
|
||||
@@ -11,7 +11,7 @@ import org.springframework.core.env.ConfigurableEnvironment;
|
||||
*
|
||||
* Kafka Producer 发送消息时,增加 {@link TenantKafkaProducerInterceptor} 拦截器
|
||||
*
|
||||
* @author 芋道源码
|
||||
* @author ZT
|
||||
*/
|
||||
@Slf4j
|
||||
public class TenantKafkaEnvironmentPostProcessor implements EnvironmentPostProcessor {
|
||||
|
||||
@@ -18,7 +18,7 @@ import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.HEADER_
|
||||
* 1. Producer 发送消息时,将 {@link TenantContextHolder} 租户编号,添加到消息的 Header 中
|
||||
* 2. Consumer 消费消息时,将消息的 Header 的租户编号,添加到 {@link TenantContextHolder} 中,通过 {@link InvocableHandlerMethod} 实现
|
||||
*
|
||||
* @author 芋道源码
|
||||
* @author ZT
|
||||
*/
|
||||
public class TenantKafkaProducerInterceptor implements ProducerInterceptor<Object, Object> {
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
/**
|
||||
* 多租户的 RabbitMQ 初始化器
|
||||
*
|
||||
* @author 芋道源码
|
||||
* @author ZT
|
||||
*/
|
||||
public class TenantRabbitMQInitializer implements BeanPostProcessor {
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.HEADER_
|
||||
* 1. Producer 发送消息时,将 {@link TenantContextHolder} 租户编号,添加到消息的 Header 中
|
||||
* 2. Consumer 消费消息时,将消息的 Header 的租户编号,添加到 {@link TenantContextHolder} 中,通过 {@link InvocableHandlerMethod} 实现
|
||||
*
|
||||
* @author 芋道源码
|
||||
* @author ZT
|
||||
*/
|
||||
public class TenantRabbitMQMessagePostProcessor implements MessagePostProcessor {
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.HEADER_
|
||||
* 1. Producer 发送消息时,将 {@link TenantContextHolder} 租户编号,添加到消息的 Header 中
|
||||
* 2. Consumer 消费消息时,将消息的 Header 的租户编号,添加到 {@link TenantContextHolder} 中
|
||||
*
|
||||
* @author 芋道源码
|
||||
* @author ZT
|
||||
*/
|
||||
public class TenantRedisMessageInterceptor implements RedisMessageInterceptor {
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.HEADER_
|
||||
*
|
||||
* Consumer 消费消息时,将消息的 Header 的租户编号,添加到 {@link TenantContextHolder} 中,通过 {@link InvocableHandlerMethod} 实现
|
||||
*
|
||||
* @author 芋道源码
|
||||
* @author ZT
|
||||
*/
|
||||
public class TenantRocketMQConsumeMessageHook implements ConsumeMessageHook {
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
/**
|
||||
* 多租户的 RocketMQ 初始化器
|
||||
*
|
||||
* @author 芋道源码
|
||||
* @author ZT
|
||||
*/
|
||||
public class TenantRocketMQInitializer implements BeanPostProcessor {
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.HEADER_
|
||||
*
|
||||
* Producer 发送消息时,将 {@link TenantContextHolder} 租户编号,添加到消息的 Header 中
|
||||
*
|
||||
* @author 芋道源码
|
||||
* @author ZT
|
||||
*/
|
||||
public class TenantRocketMQSendMessageHook implements SendMessageHook {
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.HEADER_
|
||||
/**
|
||||
* Tenant 的 RequestInterceptor 实现类:Feign 请求时,将 {@link TenantContextHolder} 设置到 header 中,继续透传给被调用的服务
|
||||
*
|
||||
* @author 芋道源码
|
||||
* @author ZT
|
||||
*/
|
||||
public class TenantRequestInterceptor implements RequestInterceptor {
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.util.Objects;
|
||||
* 2. 如果请求未带租户的编号,检查是否是忽略的 URL,否则也不允许访问。
|
||||
* 3. 校验租户是合法,例如说被禁用、到期
|
||||
*
|
||||
* @author 芋道源码
|
||||
* @author ZT
|
||||
*/
|
||||
@Slf4j
|
||||
public class TenantSecurityWebFilter extends ApiRequestFilter {
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.util.List;
|
||||
/**
|
||||
* Tenant 框架 Service 接口,定义获取租户信息
|
||||
*
|
||||
* @author 芋道源码
|
||||
* @author ZT
|
||||
*/
|
||||
public interface TenantFrameworkService {
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import static cn.iocoder.yudao.framework.common.util.cache.CacheUtils.buildAsync
|
||||
/**
|
||||
* Tenant 框架 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
* @author ZT
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class TenantFrameworkServiceImpl implements TenantFrameworkService {
|
||||
|
||||
@@ -10,7 +10,7 @@ import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.HEADER_
|
||||
/**
|
||||
* 多租户 Util
|
||||
*
|
||||
* @author 芋道源码
|
||||
* @author ZT
|
||||
*/
|
||||
public class TenantUtils {
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.io.IOException;
|
||||
* 多租户 Context Web 过滤器
|
||||
* 将请求 Header 中的 tenant-id 解析出来,添加到 {@link TenantContextHolder} 中,这样后续的 DB 等操作,可以获得到租户编号。
|
||||
*
|
||||
* @author 芋道源码
|
||||
* @author ZT
|
||||
*/
|
||||
public class TenantContextWebFilter extends OncePerRequestFilter {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user