🚀 feat(新增): 添加任务
This commit is contained in:
parent
1b90ad8521
commit
29b396c245
|
@ -89,6 +89,7 @@ public class WebSecurityConfig {
|
|||
@Bean
|
||||
public WebSecurityCustomizer webSecurityCustomizer() {
|
||||
String[] annotations = {"/", "/test/**", "/diagram-viewer/**", "/editor-app/**", "/*.html",
|
||||
"/api/**",
|
||||
"/*/*/noAuth/**", "/*/noAuth/**", "/favicon.ico", "/swagger-resources/**", "/webjars/**", "/v3/**", "/swagger-ui.html/**", "/doc.html"};
|
||||
return web -> web.ignoring().requestMatchers(annotations);
|
||||
}
|
||||
|
|
|
@ -78,7 +78,6 @@
|
|||
<artifactId>dynamic-datasource-spring-boot3-starter</artifactId>
|
||||
<version>4.3.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package cn.bunny.service.controller.quartz;
|
||||
|
||||
import cn.bunny.dto.quartz.QuartzDto;
|
||||
import cn.bunny.pojo.result.Result;
|
||||
import cn.bunny.service.service.quartz.JobService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Tag(name = "Quartz定时任务")
|
||||
@RestController
|
||||
@RequestMapping("/api/job")
|
||||
public class JobController {
|
||||
|
||||
@Autowired
|
||||
private JobService jobService;
|
||||
|
||||
@Operation(summary = "添加任务", description = "添加任务")
|
||||
@PostMapping("/add")
|
||||
public Result<String> addJob(@RequestBody QuartzDto dto) {
|
||||
jobService.addJob(dto);
|
||||
return Result.success();
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package cn.bunny.service.controller.quartz;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-07-25
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/jobDetails")
|
||||
public class JobDetailsController {
|
||||
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
package cn.bunny.service.controller.web;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Tag(name = "Quartz定时任务")
|
||||
@RestController
|
||||
@RequestMapping("/api/job")
|
||||
public class JobController {
|
||||
}
|
|
@ -6,13 +6,12 @@ import org.quartz.JobExecutionContext;
|
|||
import org.quartz.JobExecutionException;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.SimpleTimeZone;
|
||||
|
||||
@Slf4j
|
||||
public class MyJob implements Job {
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
log.info("Executing job " + new SimpleDateFormat("yyyy-MM-dd").format(context.getFireTime()));
|
||||
log.error("Executing job " + new SimpleDateFormat("yyyy-MM-dd").format(context.getFireTime()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@ public class MyJobCron implements Job {
|
|||
|
||||
Integer someKey = (Integer) jobDataMap.get("age");
|
||||
|
||||
log.info("执行MyJobMap---->{}", jobDataMap.get("username"));
|
||||
log.info("触发器内容--->{}", jobExecutionContext.getTrigger().getJobDataMap().get("someKey"));
|
||||
log.error("执行MyJobMap---->{}", jobDataMap.get("username"));
|
||||
log.error("触发器内容--->{}", jobExecutionContext.getTrigger().getJobDataMap().get("someKey"));
|
||||
jobDataMap.put("age", ++someKey);
|
||||
|
||||
// 修改触发器变量没有变化
|
||||
|
|
|
@ -16,10 +16,10 @@ public class MyJobMap implements Job {
|
|||
JobDataMap jobDataMap = jobExecutionContext.getJobDetail()
|
||||
.getJobDataMap();
|
||||
|
||||
log.info("执行MyJobMap->{}", jobDataMap.get("username"));
|
||||
log.info("执行MyJobMap->{}", jobDataMap.get("password"));
|
||||
log.info("执行MyJobMap->{}", jobDataMap.get("something"));
|
||||
log.info("执行MyJobMap->{}", jobDataMap.get("age"));
|
||||
log.error("执行MyJobMap->{}", jobDataMap.get("username"));
|
||||
log.error("执行MyJobMap->{}", jobDataMap.get("password"));
|
||||
log.error("执行MyJobMap->{}", jobDataMap.get("something"));
|
||||
log.error("执行MyJobMap->{}", jobDataMap.get("age"));
|
||||
|
||||
Integer age = (Integer) jobDataMap.get("age");
|
||||
System.out.println("啊啊啊啊啊啊啊啊_>" + age);
|
||||
|
|
|
@ -1,5 +1,19 @@
|
|||
package cn.bunny.service.job.dynamic;
|
||||
|
||||
public class JobHello {
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
@Slf4j
|
||||
public class JobHello implements Job {
|
||||
public void start() {
|
||||
log.error("执行任务。。。。。。。。。");
|
||||
System.out.print("执行任务。。。。。。。。。");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
start();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package cn.bunny.service.job.dynamic;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
@Slf4j
|
||||
public class JobHello2 implements Job {
|
||||
public void start() {
|
||||
log.error("执行任务22w2222。。。。。。。。。");
|
||||
System.out.print("执行任务22w2222。。。。。。。。。");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
start();
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package cn.bunny.service.service.quartz;
|
||||
|
||||
import cn.bunny.entity.system.quartz.BlobTriggers;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-07-25
|
||||
*/
|
||||
public interface BlobTriggersService extends IService<BlobTriggers> {
|
||||
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package cn.bunny.service.service.quartz;
|
||||
|
||||
import cn.bunny.entity.system.quartz.Calendars;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-07-25
|
||||
*/
|
||||
public interface CalendarsService extends IService<Calendars> {
|
||||
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package cn.bunny.service.service.quartz;
|
||||
|
||||
import cn.bunny.entity.system.quartz.CronTriggers;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-07-25
|
||||
*/
|
||||
public interface CronTriggersService extends IService<CronTriggers> {
|
||||
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package cn.bunny.service.service.quartz;
|
||||
|
||||
import cn.bunny.entity.system.quartz.FiredTriggers;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-07-25
|
||||
*/
|
||||
public interface FiredTriggersService extends IService<FiredTriggers> {
|
||||
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package cn.bunny.service.service.quartz;
|
||||
|
||||
import cn.bunny.entity.system.quartz.JobDetails;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-07-25
|
||||
*/
|
||||
public interface JobDetailsService extends IService<JobDetails> {
|
||||
|
||||
}
|
|
@ -1,4 +1,15 @@
|
|||
package cn.bunny.service.service.quartz;
|
||||
|
||||
public interface JobService {
|
||||
import cn.bunny.dto.quartz.QuartzDto;
|
||||
import cn.bunny.entity.system.quartz.JobDetails;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
public interface JobService extends IService<JobDetails> {
|
||||
|
||||
/**
|
||||
* * 添加任务
|
||||
*
|
||||
* @param dto 添加任务
|
||||
*/
|
||||
void addJob(QuartzDto dto);
|
||||
}
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
package cn.bunny.service.service.quartz;
|
||||
|
||||
import cn.bunny.entity.system.quartz.Locks;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-07-25
|
||||
*/
|
||||
public interface LocksService extends IService<Locks> {
|
||||
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package cn.bunny.service.service.quartz;
|
||||
|
||||
import cn.bunny.entity.system.quartz.PausedTriggerGrps;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-07-25
|
||||
*/
|
||||
public interface PausedTriggerGrpsService extends IService<PausedTriggerGrps> {
|
||||
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package cn.bunny.service.service.quartz;
|
||||
|
||||
import cn.bunny.entity.system.quartz.SchedulerState;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-07-25
|
||||
*/
|
||||
public interface SchedulerStateService extends IService<SchedulerState> {
|
||||
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package cn.bunny.service.service.quartz;
|
||||
|
||||
import cn.bunny.entity.system.quartz.SimpleTriggers;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-07-25
|
||||
*/
|
||||
public interface SimpleTriggersService extends IService<SimpleTriggers> {
|
||||
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package cn.bunny.service.service.quartz;
|
||||
|
||||
import cn.bunny.entity.system.quartz.SimpropTriggers;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-07-25
|
||||
*/
|
||||
public interface SimpropTriggersService extends IService<SimpropTriggers> {
|
||||
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package cn.bunny.service.service.quartz;
|
||||
|
||||
import cn.bunny.entity.system.quartz.Triggers;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-07-25
|
||||
*/
|
||||
public interface TriggersService extends IService<Triggers> {
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package cn.bunny.service.service.quartz.impl;
|
||||
|
||||
import cn.bunny.entity.system.quartz.BlobTriggers;
|
||||
import cn.bunny.service.mapper.quartz.BlobTriggersMapper;
|
||||
import cn.bunny.service.service.quartz.BlobTriggersService;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-07-25
|
||||
*/
|
||||
@Service
|
||||
@DS("myDS")
|
||||
public class BlobTriggersServiceImpl extends ServiceImpl<BlobTriggersMapper, BlobTriggers> implements BlobTriggersService {
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package cn.bunny.service.service.quartz.impl;
|
||||
|
||||
import cn.bunny.entity.system.quartz.Calendars;
|
||||
import cn.bunny.service.mapper.quartz.CalendarsMapper;
|
||||
import cn.bunny.service.service.quartz.CalendarsService;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-07-25
|
||||
*/
|
||||
@Service
|
||||
@DS("myDS")
|
||||
public class CalendarsServiceImpl extends ServiceImpl<CalendarsMapper, Calendars> implements CalendarsService {
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package cn.bunny.service.service.quartz.impl;
|
||||
|
||||
import cn.bunny.entity.system.quartz.CronTriggers;
|
||||
import cn.bunny.service.mapper.quartz.CronTriggersMapper;
|
||||
import cn.bunny.service.service.quartz.CronTriggersService;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-07-25
|
||||
*/
|
||||
@Service
|
||||
@DS("myDS")
|
||||
public class CronTriggersServiceImpl extends ServiceImpl<CronTriggersMapper, CronTriggers> implements CronTriggersService {
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package cn.bunny.service.service.quartz.impl;
|
||||
|
||||
import cn.bunny.entity.system.quartz.FiredTriggers;
|
||||
import cn.bunny.service.mapper.quartz.FiredTriggersMapper;
|
||||
import cn.bunny.service.service.quartz.FiredTriggersService;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-07-25
|
||||
*/
|
||||
@Service
|
||||
@DS("myDS")
|
||||
public class FiredTriggersServiceImpl extends ServiceImpl<FiredTriggersMapper, FiredTriggers> implements FiredTriggersService {
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package cn.bunny.service.service.quartz.impl;
|
||||
|
||||
import cn.bunny.entity.system.quartz.JobDetails;
|
||||
import cn.bunny.service.mapper.quartz.JobDetailsMapper;
|
||||
import cn.bunny.service.service.quartz.JobDetailsService;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-07-25
|
||||
*/
|
||||
@Service
|
||||
@DS("myDS")
|
||||
public class JobDetailsServiceImpl extends ServiceImpl<JobDetailsMapper, JobDetails> implements JobDetailsService {
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package cn.bunny.service.service.quartz.impl;
|
||||
|
||||
import cn.bunny.dto.quartz.QuartzDto;
|
||||
import cn.bunny.entity.system.quartz.JobDetails;
|
||||
import cn.bunny.service.mapper.quartz.JobDetailsMapper;
|
||||
import cn.bunny.service.service.quartz.JobService;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.SneakyThrows;
|
||||
import org.quartz.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Service
|
||||
@DS("quartz")
|
||||
public class JobServiceImpl extends ServiceImpl<JobDetailsMapper, JobDetails> implements JobService {
|
||||
|
||||
@Autowired
|
||||
private Scheduler scheduler;
|
||||
|
||||
/**
|
||||
* * 添加任务
|
||||
*
|
||||
* @param dto 添加任务
|
||||
*/
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public void addJob(QuartzDto dto) {
|
||||
String jobGroup = dto.getJobGroup();
|
||||
String jobName = dto.getJobName();
|
||||
String cronExpression = dto.getCronExpression();
|
||||
String description = dto.getDescription();
|
||||
String jobMethodName = dto.getJobMethodName();
|
||||
String jobClassName = dto.getJobClassName();
|
||||
|
||||
|
||||
// 动态创建Class对象
|
||||
Class<?> className = Class.forName(jobClassName);
|
||||
Constructor<?> constructor = className.getConstructor(); // 获取无参构造函数
|
||||
constructor.newInstance(); // 创建实例
|
||||
|
||||
// 创建任务
|
||||
JobDetail jobDetail = JobBuilder.newJob((Class<? extends Job>) className).withIdentity(jobName, jobGroup)
|
||||
.withDescription(description).build();
|
||||
jobDetail.getJobDataMap().put("jobMethodName", jobMethodName);
|
||||
|
||||
// 执行任务
|
||||
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(cronExpression);
|
||||
CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity("trigger" + jobName, jobGroup)
|
||||
.startNow().withSchedule(cronScheduleBuilder).build();
|
||||
scheduler.scheduleJob(jobDetail, trigger);
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package cn.bunny.service.service.quartz.impl;
|
||||
|
||||
import cn.bunny.entity.system.quartz.Locks;
|
||||
import cn.bunny.service.mapper.quartz.LocksMapper;
|
||||
import cn.bunny.service.service.quartz.LocksService;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-07-25
|
||||
*/
|
||||
@Service
|
||||
@DS("myDS")
|
||||
public class LocksServiceImpl extends ServiceImpl<LocksMapper, Locks> implements LocksService {
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package cn.bunny.service.service.quartz.impl;
|
||||
|
||||
import cn.bunny.entity.system.quartz.PausedTriggerGrps;
|
||||
import cn.bunny.service.mapper.quartz.PausedTriggerGrpsMapper;
|
||||
import cn.bunny.service.service.quartz.PausedTriggerGrpsService;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-07-25
|
||||
*/
|
||||
@Service
|
||||
@DS("myDS")
|
||||
public class PausedTriggerGrpsServiceImpl extends ServiceImpl<PausedTriggerGrpsMapper, PausedTriggerGrps> implements PausedTriggerGrpsService {
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package cn.bunny.service.service.quartz.impl;
|
||||
|
||||
import cn.bunny.entity.system.quartz.SchedulerState;
|
||||
import cn.bunny.service.mapper.quartz.SchedulerStateMapper;
|
||||
import cn.bunny.service.service.quartz.SchedulerStateService;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-07-25
|
||||
*/
|
||||
@Service
|
||||
@DS("myDS")
|
||||
public class SchedulerStateServiceImpl extends ServiceImpl<SchedulerStateMapper, SchedulerState> implements SchedulerStateService {
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package cn.bunny.service.service.quartz.impl;
|
||||
|
||||
import cn.bunny.entity.system.quartz.SimpleTriggers;
|
||||
import cn.bunny.service.mapper.quartz.SimpleTriggersMapper;
|
||||
import cn.bunny.service.service.quartz.SimpleTriggersService;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-07-25
|
||||
*/
|
||||
@Service
|
||||
@DS("myDS")
|
||||
public class SimpleTriggersServiceImpl extends ServiceImpl<SimpleTriggersMapper, SimpleTriggers> implements SimpleTriggersService {
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package cn.bunny.service.service.quartz.impl;
|
||||
|
||||
import cn.bunny.entity.system.quartz.SimpropTriggers;
|
||||
import cn.bunny.service.mapper.quartz.SimpropTriggersMapper;
|
||||
import cn.bunny.service.service.quartz.SimpropTriggersService;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-07-25
|
||||
*/
|
||||
@Service
|
||||
@DS("myDS")
|
||||
public class SimpropTriggersServiceImpl extends ServiceImpl<SimpropTriggersMapper, SimpropTriggers> implements SimpropTriggersService {
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package cn.bunny.service.service.quartz.impl;
|
||||
|
||||
import cn.bunny.entity.system.quartz.Triggers;
|
||||
import cn.bunny.service.mapper.quartz.TriggersMapper;
|
||||
import cn.bunny.service.service.quartz.TriggersService;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author Bunny
|
||||
* @since 2024-07-25
|
||||
*/
|
||||
@Service
|
||||
@DS("myDS")
|
||||
public class TriggersServiceImpl extends ServiceImpl<TriggersMapper, Triggers> implements TriggersService {
|
||||
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
package cn.bunny.service.service.web.impl;
|
||||
|
||||
import cn.bunny.service.service.quartz.JobService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class JobServiceImpl implements JobService {
|
||||
}
|
|
@ -21,6 +21,7 @@ import cn.bunny.service.service.web.UserService;
|
|||
import cn.bunny.vo.system.login.LoginVo;
|
||||
import cn.hutool.captcha.CaptchaUtil;
|
||||
import cn.hutool.captcha.CircleCaptcha;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
@ -42,6 +43,7 @@ import java.util.concurrent.TimeUnit;
|
|||
* @since 2024-05-18
|
||||
*/
|
||||
@Service
|
||||
@DS("master")
|
||||
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
|
||||
@Autowired
|
||||
private AdminRoleMapper roleMapper;
|
||||
|
|
|
@ -6,10 +6,9 @@ spring:
|
|||
active: @profiles.active@
|
||||
application:
|
||||
name: bunny-service
|
||||
|
||||
datasource:
|
||||
dynamic:
|
||||
primary: master #设置默认的数据源或者数据源组,默认值即为master
|
||||
primary: quartz #设置默认的数据源或者数据源组,默认值即为master
|
||||
strict: false #严格匹配数据源,默认false. true未匹配到指定数据源时抛异常,false使用默认数据源
|
||||
grace-destroy: false #是否优雅关闭数据源,默认为false,设置为true时,关闭数据源时如果数据源中还存在活跃连接,至多等待10s后强制关闭
|
||||
datasource:
|
||||
|
@ -42,6 +41,14 @@ spring:
|
|||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: GMT+8
|
||||
quartz:
|
||||
job-store-type: jdbc
|
||||
jdbc:
|
||||
initialize-schema: embedded
|
||||
scheduler-name: quartzScheduler
|
||||
auto-startup: true
|
||||
wait-for-jobs-to-complete-on-shutdown: true
|
||||
overwrite-existing-jobs: false
|
||||
|
||||
mybatis-plus:
|
||||
mapper-locations: classpath:mapper/*/*.xml
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
org.quartz.scheduler.instanceName=MyScheduler
|
||||
org.quartz.threadPool.threadCount=5
|
||||
org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX
|
||||
org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate
|
||||
org.quartz.jobStore.tablePrefix=QRTZ_
|
||||
org.quartz.jobStore.dataSource=myDS
|
||||
org.quartz.dataSource.myDS.driver=com.mysql.cj.jdbc.Driver
|
||||
org.quartz.dataSource.myDS.URL=jdbc:mysql://106.15.251.123:3305/myDS?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true
|
||||
#org.quartz.dataSource.quartz.URL=jdbc:mysql://192.168.3.98:3306/quartz?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true
|
||||
org.quartz.dataSource.myDS.user=root
|
||||
org.quartz.dataSource.myDS.password=02120212
|
||||
org.quartz.dataSource.myDS.maxConnections=5
|
Loading…
Reference in New Issue