Merge remote-tracking branch 'base-version/main' into dev
# Conflicts: # zt-framework/zt-spring-boot-starter-job/src/main/java/com/zt/plat/framework/quartz/config/ZtXxlJobAutoConfiguration.java
This commit is contained in:
@@ -35,6 +35,11 @@ public class XxlJobProperties {
|
||||
@NotNull(message = "执行器配置不能为空")
|
||||
private ExecutorProperties executor;
|
||||
|
||||
/**
|
||||
* 系统用户配置
|
||||
*/
|
||||
private SystemUserProperties systemUser = new SystemUserProperties();
|
||||
|
||||
/**
|
||||
* XXL-Job 调度器配置类
|
||||
*/
|
||||
@@ -96,4 +101,37 @@ public class XxlJobProperties {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* XXL-Job 系统用户配置类
|
||||
*/
|
||||
@Data
|
||||
public static class SystemUserProperties {
|
||||
|
||||
/**
|
||||
* 系统用户 ID
|
||||
*/
|
||||
private Long userId = 0L;
|
||||
|
||||
/**
|
||||
* 系统用户昵称
|
||||
*/
|
||||
private String nickname = "job";
|
||||
|
||||
/**
|
||||
* 系统租户 ID
|
||||
*/
|
||||
private Long tenantId = 1L;
|
||||
|
||||
/**
|
||||
* 系统公司 ID(可选)
|
||||
*/
|
||||
private Long companyId;
|
||||
|
||||
/**
|
||||
* 系统部门 ID(可选)
|
||||
*/
|
||||
private Long deptId;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.zt.plat.framework.quartz.config;
|
||||
|
||||
import com.zt.plat.framework.quartz.core.handler.XxlJobSystemAuthenticationAspect;
|
||||
import com.xxl.job.core.executor.XxlJobExecutor;
|
||||
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -9,6 +10,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
/**
|
||||
@@ -21,6 +23,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
@ConditionalOnProperty(prefix = "xxl.job", name = "enabled", havingValue = "true", matchIfMissing = true)
|
||||
@EnableConfigurationProperties({XxlJobProperties.class})
|
||||
@EnableScheduling // 开启 Spring 自带的定时任务
|
||||
@EnableAspectJAutoProxy // 开启 AOP
|
||||
@Slf4j
|
||||
public class ZtXxlJobAutoConfiguration {
|
||||
|
||||
@@ -43,4 +46,17 @@ public class ZtXxlJobAutoConfiguration {
|
||||
return xxlJobExecutor;
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置 XXL-Job 系统认证切面
|
||||
*
|
||||
* 为 @XxlJob 注解的方法提供系统用户认证上下文
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public XxlJobSystemAuthenticationAspect xxlJobSystemAuthenticationAspect(XxlJobProperties properties) {
|
||||
log.info("[ZtXxlJobAutoConfiguration][注册 XXL-Job 系统认证切面] systemUserId=[{}], systemTenantId=[{}]",
|
||||
properties.getSystemUser().getUserId(), properties.getSystemUser().getTenantId());
|
||||
return new XxlJobSystemAuthenticationAspect(properties.getSystemUser());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user