Compare commits
3 Commits
3407536e85
...
05496e16a8
Author | SHA1 | Date |
---|---|---|
|
05496e16a8 | |
|
04273ecf39 | |
|
5b370dd9f1 |
|
@ -20,7 +20,7 @@ public class AdminCodeGenerator {
|
||||||
public static final String entity = "Bunny";
|
public static final String entity = "Bunny";
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Generation("v_schedulers");
|
Generation("sys_schedulers_group");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,11 +3,11 @@ package cn.bunny.common.generator.generator;
|
||||||
import cn.bunny.common.generator.entity.BaseField;
|
import cn.bunny.common.generator.entity.BaseField;
|
||||||
import cn.bunny.common.generator.entity.BaseResultMap;
|
import cn.bunny.common.generator.entity.BaseResultMap;
|
||||||
import cn.bunny.common.generator.utils.GeneratorCodeUtils;
|
import cn.bunny.common.generator.utils.GeneratorCodeUtils;
|
||||||
import cn.bunny.dao.dto.schedulers.SchedulersAddDto;
|
import cn.bunny.dao.dto.schedulers.SchedulersGroupAddDto;
|
||||||
import cn.bunny.dao.dto.schedulers.SchedulersDto;
|
import cn.bunny.dao.dto.schedulers.SchedulersGroupDto;
|
||||||
import cn.bunny.dao.dto.schedulers.SchedulersUpdateDto;
|
import cn.bunny.dao.dto.schedulers.SchedulersGroupUpdateDto;
|
||||||
import cn.bunny.dao.entity.schedulers.Schedulers;
|
import cn.bunny.dao.entity.schedulers.SchedulersGroup;
|
||||||
import cn.bunny.dao.vo.schedulers.SchedulersVo;
|
import cn.bunny.dao.vo.schedulers.SchedulersGroupVo;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.google.common.base.CaseFormat;
|
import com.google.common.base.CaseFormat;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
@ -36,7 +36,7 @@ import java.util.stream.Stream;
|
||||||
@Service
|
@Service
|
||||||
public class WebGeneratorCode {
|
public class WebGeneratorCode {
|
||||||
// 公共路径
|
// 公共路径
|
||||||
public static String commonPath = "D:\\MyFolder\\auth-admin\\auth-web\\src";
|
public static String commonPath = "D:\\Project\\web\\PC\\auth\\auth-web\\src";
|
||||||
// 生成API请求路径
|
// 生成API请求路径
|
||||||
public static String apiPath = commonPath + "\\api\\v1\\";
|
public static String apiPath = commonPath + "\\api\\v1\\";
|
||||||
// 生成vue路径
|
// 生成vue路径
|
||||||
|
@ -44,18 +44,18 @@ public class WebGeneratorCode {
|
||||||
// 生成仓库路径
|
// 生成仓库路径
|
||||||
public static String storePath = commonPath + "\\store\\monitor\\";
|
public static String storePath = commonPath + "\\store\\monitor\\";
|
||||||
// 后端controller
|
// 后端controller
|
||||||
public static String controllerPath = "D:\\MyFolder\\auth-admin\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\controller\\";
|
public static String controllerPath = "D:\\Project\\web\\PC\\auth\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\controller\\";
|
||||||
public static String servicePath = "D:\\MyFolder\\auth-admin\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\service\\";
|
public static String servicePath = "D:\\Project\\web\\PC\\auth\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\service\\";
|
||||||
public static String serviceImplPath = "D:\\MyFolder\\auth-admin\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\service\\impl\\";
|
public static String serviceImplPath = "D:\\Project\\web\\PC\\auth\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\service\\impl\\";
|
||||||
public static String mapperPath = "D:\\MyFolder\\auth-admin\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\mapper\\";
|
public static String mapperPath = "D:\\Project\\web\\PC\\auth\\auth-server-java\\service\\src\\main\\java\\cn\\bunny\\services\\mapper\\";
|
||||||
public static String resourceMapperPath = "D:\\MyFolder\\auth-admin\\auth-server-java\\service\\src\\main\\resources\\mapper\\";
|
public static String resourceMapperPath = "D:\\Project\\web\\PC\\auth\\auth-server-java\\service\\src\\main\\resources\\mapper\\";
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
Class<?> originalClass = Schedulers.class;
|
Class<?> originalClass = SchedulersGroup.class;
|
||||||
Class<?> dtoClass = SchedulersDto.class;
|
Class<?> dtoClass = SchedulersGroupDto.class;
|
||||||
Class<?> addDtoClass = SchedulersAddDto.class;
|
Class<?> addDtoClass = SchedulersGroupAddDto.class;
|
||||||
Class<?> updateDtoClass = SchedulersUpdateDto.class;
|
Class<?> updateDtoClass = SchedulersGroupUpdateDto.class;
|
||||||
Class<?> voClass = SchedulersVo.class;
|
Class<?> voClass = SchedulersGroupVo.class;
|
||||||
|
|
||||||
// 设置velocity资源加载器
|
// 设置velocity资源加载器
|
||||||
Properties prop = new Properties();
|
Properties prop = new Properties();
|
||||||
|
|
|
@ -26,8 +26,10 @@
|
||||||
<template>
|
<template>
|
||||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="auto">
|
<el-form ref="formRef" :model="form" :rules="rules" label-width="auto">
|
||||||
#foreach($item in $baseFieldList)
|
#foreach($item in $baseFieldList)
|
||||||
|
|
||||||
|
// $item.annotation
|
||||||
<el-form-item :label="$t('${lowercaseName}_${item.name}')" prop="$item.name">
|
<el-form-item :label="$t('${lowercaseName}_${item.name}')" prop="$item.name">
|
||||||
<el-input v-model="form.$item.name" autocomplete="off" type="text" />
|
<el-input v-model="form.$item.name" autocomplete="off" type="text" :placeholder="$t('input') + $t('${lowercaseName}_${item.name}')" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#end
|
#end
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
|
@ -40,11 +40,6 @@ public class SchedulersAddDto {
|
||||||
@NotNull(message = "corn表达式不能为空")
|
@NotNull(message = "corn表达式不能为空")
|
||||||
private String cronExpression;
|
private String cronExpression;
|
||||||
|
|
||||||
@Schema(name = "jobMethodName", title = "执行方法")
|
|
||||||
@NotBlank(message = "执行方法不能为空")
|
|
||||||
@NotNull(message = "执行方法不能为空")
|
|
||||||
private String jobMethodName;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package cn.bunny.dao.dto.schedulers;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@Schema(name = "SchedulersGroupAddDto对象", title = "添加任务调度分组", description = "添加任务调度分组")
|
||||||
|
public class SchedulersGroupAddDto {
|
||||||
|
|
||||||
|
@Schema(name = "groupName", title = "分组名称")
|
||||||
|
@NotBlank(message = "分组名称不能为空")
|
||||||
|
@NotNull(message = "分组名称不能为空")
|
||||||
|
private String groupName;
|
||||||
|
|
||||||
|
@Schema(name = "description", title = "分组详情")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package cn.bunny.dao.dto.schedulers;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@Schema(name = "SchedulersGroupDto对象", title = "分页查询任务调度分组", description = "分页查询任务调度分组")
|
||||||
|
public class SchedulersGroupDto {
|
||||||
|
|
||||||
|
@Schema(name = "groupName", title = "分组名称")
|
||||||
|
private String groupName;
|
||||||
|
|
||||||
|
@Schema(name = "description", title = "分组详情")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
package cn.bunny.dao.dto.schedulers;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@Schema(name = "SchedulersGroupUpdateDto对象", title = "更新任务调度分组", description = "更新任务调度分组")
|
||||||
|
public class SchedulersGroupUpdateDto {
|
||||||
|
|
||||||
|
@Schema(name = "id", title = "主键")
|
||||||
|
@NotNull(message = "id不能为空")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(name = "groupName", title = "分组名称")
|
||||||
|
@NotBlank(message = "分组名称不能为空")
|
||||||
|
@NotNull(message = "分组名称不能为空")
|
||||||
|
private String groupName;
|
||||||
|
|
||||||
|
@Schema(name = "description", title = "分组详情")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package cn.bunny.dao.entity.schedulers;
|
||||||
|
|
||||||
|
import cn.bunny.dao.entity.BaseEntity;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 任务调度分组表
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author Bunny
|
||||||
|
* @since 2024-10-15
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@TableName("sys_schedulers_group")
|
||||||
|
@Schema(name = "SchedulersGroup对象", title = "任务调度分组", description = "任务调度分组")
|
||||||
|
public class SchedulersGroup extends BaseEntity {
|
||||||
|
|
||||||
|
@Schema(name = "groupName", title = "分组名称")
|
||||||
|
private String groupName;
|
||||||
|
|
||||||
|
@Schema(name = "description", title = "分组详情")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -60,6 +60,7 @@ public enum ResultCodeEnum {
|
||||||
ILLEGAL_CALLBACK_REQUEST_ERROR(217, "非法回调请求"),
|
ILLEGAL_CALLBACK_REQUEST_ERROR(217, "非法回调请求"),
|
||||||
FETCH_USERINFO_ERROR(219, "获取用户信息失败"),
|
FETCH_USERINFO_ERROR(219, "获取用户信息失败"),
|
||||||
ILLEGAL_DATA_REQUEST(219, "非法数据请求"),
|
ILLEGAL_DATA_REQUEST(219, "非法数据请求"),
|
||||||
|
CLASS_NOT_FOUND(219, "类名不存在"),
|
||||||
|
|
||||||
// 无权访问 403
|
// 无权访问 403
|
||||||
FAIL_REQUEST_NOT_AUTH(403, "用户未认证"),
|
FAIL_REQUEST_NOT_AUTH(403, "用户未认证"),
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package cn.bunny.dao.vo.schedulers;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@Schema(name = "SchedulersGroupVo", title = "任务调度分组返回对象", description = "任务调度分组返回对象")
|
||||||
|
public class SchedulersGroupVo {
|
||||||
|
|
||||||
|
@Schema(name = "groupName", title = "分组名称")
|
||||||
|
private String groupName;
|
||||||
|
|
||||||
|
@Schema(name = "description", title = "分组详情")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
}
|
|
@ -33,4 +33,7 @@ public class SchedulersVo {
|
||||||
@Schema(name = "triggerState", title = "triggerState触发器状态")
|
@Schema(name = "triggerState", title = "triggerState触发器状态")
|
||||||
private String triggerState;
|
private String triggerState;
|
||||||
|
|
||||||
|
@Schema(name = "cronExpression", title = "corn表达式")
|
||||||
|
private String cronExpression;
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package cn.bunny.services.aop;
|
||||||
|
|
||||||
|
import cn.bunny.common.service.exception.BunnyException;
|
||||||
|
import cn.bunny.dao.pojo.result.ResultCodeEnum;
|
||||||
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
|
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
|
||||||
|
import org.springframework.core.type.filter.AnnotationTypeFilter;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 扫描指定目录下所有类
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class AnnotationScanner {
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public Set<Class<?>> getClassesWithAnnotation(Class<?> annotation) {
|
||||||
|
ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false);
|
||||||
|
scanner.addIncludeFilter(new AnnotationTypeFilter((Class<? extends Annotation>) annotation));
|
||||||
|
|
||||||
|
Set<Class<?>> classes = new HashSet<>();
|
||||||
|
for (BeanDefinition bd : scanner.findCandidateComponents("cn.bunny.services")) {
|
||||||
|
try {
|
||||||
|
Class<?> clazz = Class.forName(bd.getBeanClassName());
|
||||||
|
classes.add(clazz);
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
throw new BunnyException(ResultCodeEnum.CLASS_NOT_FOUND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return classes;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package cn.bunny.services.aop.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Target(ElementType.TYPE)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface QuartzSchedulers {
|
||||||
|
String value() default "";
|
||||||
|
|
||||||
|
String description();
|
||||||
|
}
|
|
@ -18,6 +18,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Schedulers视图表 前端控制器
|
* Schedulers视图表 前端控制器
|
||||||
|
@ -47,7 +50,14 @@ public class SchedulersController {
|
||||||
return Mono.just(Result.success(pageResult));
|
return Mono.just(Result.success(pageResult));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "添加Schedulers视图", description = "添加Schedulers视图")
|
@Operation(summary = "获取所有可用调度任务", description = "获取所有可用调度任务")
|
||||||
|
@GetMapping("getAllScheduleJobList")
|
||||||
|
public Mono<Result<List<Map<String, String>>>> getAllScheduleJobList() {
|
||||||
|
List<Map<String, String>> mapList = schedulersService.getAllScheduleJobList();
|
||||||
|
return Mono.just(Result.success(mapList));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "添加Schedulers任务", description = "添加Schedulers任务")
|
||||||
@PostMapping("addSchedulers")
|
@PostMapping("addSchedulers")
|
||||||
public Mono<Result<String>> addSchedulers(@Valid @RequestBody SchedulersAddDto dto) {
|
public Mono<Result<String>> addSchedulers(@Valid @RequestBody SchedulersAddDto dto) {
|
||||||
schedulersService.addSchedulers(dto);
|
schedulersService.addSchedulers(dto);
|
||||||
|
|
|
@ -0,0 +1,79 @@
|
||||||
|
package cn.bunny.services.controller;
|
||||||
|
|
||||||
|
import cn.bunny.dao.dto.schedulers.SchedulersGroupAddDto;
|
||||||
|
import cn.bunny.dao.dto.schedulers.SchedulersGroupDto;
|
||||||
|
import cn.bunny.dao.dto.schedulers.SchedulersGroupUpdateDto;
|
||||||
|
import cn.bunny.dao.entity.schedulers.SchedulersGroup;
|
||||||
|
import cn.bunny.dao.pojo.result.PageResult;
|
||||||
|
import cn.bunny.dao.pojo.result.Result;
|
||||||
|
import cn.bunny.dao.pojo.result.ResultCodeEnum;
|
||||||
|
import cn.bunny.dao.vo.schedulers.SchedulersGroupVo;
|
||||||
|
import cn.bunny.services.service.SchedulersGroupService;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 任务调度分组表 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author Bunny
|
||||||
|
* @since 2024-10-15 20:26:32
|
||||||
|
*/
|
||||||
|
@Tag(name = "任务调度分组", description = "任务调度分组相关接口")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("admin/schedulersGroup")
|
||||||
|
public class SchedulersGroupController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SchedulersGroupService schedulersGroupService;
|
||||||
|
|
||||||
|
@Operation(summary = "分页查询任务调度分组", description = "分页查询任务调度分组")
|
||||||
|
@GetMapping("getSchedulersGroupList/{page}/{limit}")
|
||||||
|
public Mono<Result<PageResult<SchedulersGroupVo>>> getSchedulersGroupList(
|
||||||
|
@Parameter(name = "page", description = "当前页", required = true)
|
||||||
|
@PathVariable("page") Integer page,
|
||||||
|
@Parameter(name = "limit", description = "每页记录数", required = true)
|
||||||
|
@PathVariable("limit") Integer limit,
|
||||||
|
SchedulersGroupDto dto) {
|
||||||
|
Page<SchedulersGroup> pageParams = new Page<>(page, limit);
|
||||||
|
PageResult<SchedulersGroupVo> pageResult = schedulersGroupService.getSchedulersGroupList(pageParams, dto);
|
||||||
|
return Mono.just(Result.success(pageResult));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取所有任务调度分组", description = "获取所有任务调度分组")
|
||||||
|
@GetMapping("getAllSchedulersGroup")
|
||||||
|
public Mono<Result<List<SchedulersGroupVo>>> getAllSchedulersGroup() {
|
||||||
|
List<SchedulersGroupVo> voList = schedulersGroupService.getAllSchedulersGroup();
|
||||||
|
return Mono.just(Result.success(voList));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "添加任务调度分组", description = "添加任务调度分组")
|
||||||
|
@PostMapping("addSchedulersGroup")
|
||||||
|
public Mono<Result<String>> addSchedulersGroup(@Valid @RequestBody SchedulersGroupAddDto dto) {
|
||||||
|
schedulersGroupService.addSchedulersGroup(dto);
|
||||||
|
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "更新任务调度分组", description = "更新任务调度分组")
|
||||||
|
@PutMapping("updateSchedulersGroup")
|
||||||
|
public Mono<Result<String>> updateSchedulersGroup(@Valid @RequestBody SchedulersGroupUpdateDto dto) {
|
||||||
|
schedulersGroupService.updateSchedulersGroup(dto);
|
||||||
|
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "删除任务调度分组", description = "删除任务调度分组")
|
||||||
|
@DeleteMapping("deleteSchedulersGroup")
|
||||||
|
public Mono<Result<String>> deleteSchedulersGroup(@RequestBody List<Long> ids) {
|
||||||
|
schedulersGroupService.deleteSchedulersGroup(ids);
|
||||||
|
return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package cn.bunny.services.mapper;
|
||||||
|
|
||||||
|
import cn.bunny.dao.dto.schedulers.SchedulersGroupDto;
|
||||||
|
import cn.bunny.dao.entity.schedulers.SchedulersGroup;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 任务调度分组 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author Bunny
|
||||||
|
* @since 2024-10-15 20:26:32
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface SchedulersGroupMapper extends BaseMapper<SchedulersGroup> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 分页查询任务调度分组内容
|
||||||
|
*
|
||||||
|
* @param pageParams 任务调度分组分页参数
|
||||||
|
* @param dto 任务调度分组查询表单
|
||||||
|
* @return 任务调度分组分页结果
|
||||||
|
*/
|
||||||
|
IPage<SchedulersGroup> selectListByPage(@Param("page") Page<SchedulersGroup> pageParams, @Param("dto") SchedulersGroupDto dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物理删除任务调度分组
|
||||||
|
*
|
||||||
|
* @param ids 删除 id 列表
|
||||||
|
*/
|
||||||
|
void deleteBatchIdsWithPhysics(List<Long> ids);
|
||||||
|
}
|
|
@ -1,37 +0,0 @@
|
||||||
package cn.bunny.services.quartz;
|
|
||||||
|
|
||||||
import org.quartz.Scheduler;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
|
|
||||||
|
|
||||||
@Configuration
|
|
||||||
public class QuartzConfiguration {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private QuartzJobFactory quartzJobFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建调度器工厂
|
|
||||||
* 1.创建SchedulerFactoryBean
|
|
||||||
* 2.加载自定义的quartz.properties配置文件
|
|
||||||
* 3.设置MyJobFactory
|
|
||||||
*
|
|
||||||
* @return SchedulerFactoryBean
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public SchedulerFactoryBean schedulerFactoryBean() {
|
|
||||||
SchedulerFactoryBean factoryBean = new SchedulerFactoryBean();
|
|
||||||
factoryBean.setAutoStartup(true);
|
|
||||||
// 延时1秒启动
|
|
||||||
factoryBean.setStartupDelay(1);
|
|
||||||
factoryBean.setJobFactory(quartzJobFactory);
|
|
||||||
return factoryBean;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean(name = "scheduler")
|
|
||||||
public Scheduler scheduler() {
|
|
||||||
return schedulerFactoryBean().getScheduler();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
package cn.bunny.services.quartz;
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.quartz.spi.TriggerFiredBundle;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
|
|
||||||
import org.springframework.scheduling.quartz.AdaptableJobFactory;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
@Slf4j
|
|
||||||
public class QuartzJobFactory extends AdaptableJobFactory {
|
|
||||||
|
|
||||||
// 这个对象Spring会帮我们自动注入进来
|
|
||||||
@Autowired
|
|
||||||
private AutowireCapableBeanFactory capableBeanFactory;
|
|
||||||
|
|
||||||
// 重写创建Job任务的实例方法
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
protected Object createJobInstance(@NotNull TriggerFiredBundle bundle) throws Exception {
|
|
||||||
Object jobInstance = super.createJobInstance(bundle);
|
|
||||||
// 通过以下方式,解决Job任务无法使用Spring中的Bean问题
|
|
||||||
capableBeanFactory.autowireBean(jobInstance);
|
|
||||||
return super.createJobInstance(bundle);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,11 +1,13 @@
|
||||||
package cn.bunny.services.quartz.job;
|
package cn.bunny.services.quartz.job;
|
||||||
|
|
||||||
|
import cn.bunny.services.aop.annotation.QuartzSchedulers;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.quartz.Job;
|
import org.quartz.Job;
|
||||||
import org.quartz.JobExecutionContext;
|
import org.quartz.JobExecutionContext;
|
||||||
import org.quartz.JobExecutionException;
|
import org.quartz.JobExecutionException;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@QuartzSchedulers(description = "JobHello任务内容")
|
||||||
public class JobHello implements Job {
|
public class JobHello implements Job {
|
||||||
public void start() {
|
public void start() {
|
||||||
log.error("执行任务--JobHello。。。。。。。。。");
|
log.error("执行任务--JobHello。。。。。。。。。");
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
package cn.bunny.services.quartz.job;
|
package cn.bunny.services.quartz.job;
|
||||||
|
|
||||||
|
import cn.bunny.services.aop.annotation.QuartzSchedulers;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.quartz.Job;
|
import org.quartz.Job;
|
||||||
import org.quartz.JobExecutionContext;
|
import org.quartz.JobExecutionContext;
|
||||||
import org.quartz.JobExecutionException;
|
import org.quartz.JobExecutionException;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
@QuartzSchedulers(description = "Demo的类JobHello2")
|
||||||
public class JobHello2 implements Job {
|
public class JobHello2 implements Job {
|
||||||
public void start() {
|
public void start() {
|
||||||
log.error("执行任务---JobHello2。。。。。。。。。");
|
log.error("执行任务---JobHello2。。。。。。。。。");
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
package cn.bunny.services.service;
|
||||||
|
|
||||||
|
import cn.bunny.dao.dto.schedulers.SchedulersGroupAddDto;
|
||||||
|
import cn.bunny.dao.dto.schedulers.SchedulersGroupDto;
|
||||||
|
import cn.bunny.dao.dto.schedulers.SchedulersGroupUpdateDto;
|
||||||
|
import cn.bunny.dao.entity.schedulers.SchedulersGroup;
|
||||||
|
import cn.bunny.dao.pojo.result.PageResult;
|
||||||
|
import cn.bunny.dao.vo.schedulers.SchedulersGroupVo;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 任务调度分组 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author Bunny
|
||||||
|
* @since 2024-10-15 20:26:32
|
||||||
|
*/
|
||||||
|
public interface SchedulersGroupService extends IService<SchedulersGroup> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 获取任务调度分组列表
|
||||||
|
*
|
||||||
|
* @return 任务调度分组返回列表
|
||||||
|
*/
|
||||||
|
PageResult<SchedulersGroupVo> getSchedulersGroupList(Page<SchedulersGroup> pageParams, SchedulersGroupDto dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 添加任务调度分组
|
||||||
|
*
|
||||||
|
* @param dto 添加表单
|
||||||
|
*/
|
||||||
|
void addSchedulersGroup(@Valid SchedulersGroupAddDto dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 更新任务调度分组
|
||||||
|
*
|
||||||
|
* @param dto 更新表单
|
||||||
|
*/
|
||||||
|
void updateSchedulersGroup(@Valid SchedulersGroupUpdateDto dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 删除|批量删除任务调度分组类型
|
||||||
|
*
|
||||||
|
* @param ids 删除id列表
|
||||||
|
*/
|
||||||
|
void deleteSchedulersGroup(List<Long> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 获取所有任务调度分组
|
||||||
|
*
|
||||||
|
* @return 获取所有任务分组
|
||||||
|
*/
|
||||||
|
List<SchedulersGroupVo> getAllSchedulersGroup();
|
||||||
|
}
|
|
@ -10,6 +10,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* Schedulers视图 服务类
|
* Schedulers视图 服务类
|
||||||
|
@ -54,4 +57,11 @@ public interface SchedulersService extends IService<Schedulers> {
|
||||||
* @param dto Schedulers公共操作表单
|
* @param dto Schedulers公共操作表单
|
||||||
*/
|
*/
|
||||||
void deleteSchedulers(SchedulersOperationDto dto);
|
void deleteSchedulers(SchedulersOperationDto dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 获取所有可用调度任务
|
||||||
|
*
|
||||||
|
* @return 所有调度任务内容
|
||||||
|
*/
|
||||||
|
List<Map<String, String>> getAllScheduleJobList();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,106 @@
|
||||||
|
package cn.bunny.services.service.impl;
|
||||||
|
|
||||||
|
import cn.bunny.dao.dto.schedulers.SchedulersGroupAddDto;
|
||||||
|
import cn.bunny.dao.dto.schedulers.SchedulersGroupDto;
|
||||||
|
import cn.bunny.dao.dto.schedulers.SchedulersGroupUpdateDto;
|
||||||
|
import cn.bunny.dao.entity.schedulers.SchedulersGroup;
|
||||||
|
import cn.bunny.dao.pojo.result.PageResult;
|
||||||
|
import cn.bunny.dao.vo.schedulers.SchedulersGroupVo;
|
||||||
|
import cn.bunny.services.mapper.SchedulersGroupMapper;
|
||||||
|
import cn.bunny.services.service.SchedulersGroupService;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 任务调度分组 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author Bunny
|
||||||
|
* @since 2024-10-15 20:26:32
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SchedulersGroupServiceImpl extends ServiceImpl<SchedulersGroupMapper, SchedulersGroup> implements SchedulersGroupService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 任务调度分组 服务实现类
|
||||||
|
*
|
||||||
|
* @param pageParams 任务调度分组分页查询page对象
|
||||||
|
* @param dto 任务调度分组分页查询对象
|
||||||
|
* @return 查询分页任务调度分组返回对象
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public PageResult<SchedulersGroupVo> getSchedulersGroupList(Page<SchedulersGroup> pageParams, SchedulersGroupDto dto) {
|
||||||
|
// 分页查询菜单图标
|
||||||
|
IPage<SchedulersGroup> page = baseMapper.selectListByPage(pageParams, dto);
|
||||||
|
|
||||||
|
List<SchedulersGroupVo> voList = page.getRecords().stream().map(schedulersGroup -> {
|
||||||
|
SchedulersGroupVo schedulersGroupVo = new SchedulersGroupVo();
|
||||||
|
BeanUtils.copyProperties(schedulersGroup, schedulersGroupVo);
|
||||||
|
return schedulersGroupVo;
|
||||||
|
}).toList();
|
||||||
|
|
||||||
|
return PageResult.<SchedulersGroupVo>builder()
|
||||||
|
.list(voList)
|
||||||
|
.pageNo(page.getCurrent())
|
||||||
|
.pageSize(page.getSize())
|
||||||
|
.total(page.getTotal())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加任务调度分组
|
||||||
|
*
|
||||||
|
* @param dto 任务调度分组添加
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void addSchedulersGroup(@Valid SchedulersGroupAddDto dto) {
|
||||||
|
// 保存数据
|
||||||
|
SchedulersGroup schedulersGroup = new SchedulersGroup();
|
||||||
|
BeanUtils.copyProperties(dto, schedulersGroup);
|
||||||
|
save(schedulersGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新任务调度分组
|
||||||
|
*
|
||||||
|
* @param dto 任务调度分组更新
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateSchedulersGroup(@Valid SchedulersGroupUpdateDto dto) {
|
||||||
|
// 更新内容
|
||||||
|
SchedulersGroup schedulersGroup = new SchedulersGroup();
|
||||||
|
BeanUtils.copyProperties(dto, schedulersGroup);
|
||||||
|
updateById(schedulersGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除|批量删除任务调度分组
|
||||||
|
*
|
||||||
|
* @param ids 删除id列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void deleteSchedulersGroup(List<Long> ids) {
|
||||||
|
baseMapper.deleteBatchIdsWithPhysics(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 获取所有任务调度分组
|
||||||
|
*
|
||||||
|
* @return 获取所有任务分组
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<SchedulersGroupVo> getAllSchedulersGroup() {
|
||||||
|
return list().stream().map(schedulersGroup -> {
|
||||||
|
SchedulersGroupVo schedulersGroupVo = new SchedulersGroupVo();
|
||||||
|
BeanUtils.copyProperties(schedulersGroup, schedulersGroupVo);
|
||||||
|
return schedulersGroupVo;
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,8 @@ import cn.bunny.dao.dto.schedulers.SchedulersOperationDto;
|
||||||
import cn.bunny.dao.entity.schedulers.Schedulers;
|
import cn.bunny.dao.entity.schedulers.Schedulers;
|
||||||
import cn.bunny.dao.pojo.result.PageResult;
|
import cn.bunny.dao.pojo.result.PageResult;
|
||||||
import cn.bunny.dao.vo.schedulers.SchedulersVo;
|
import cn.bunny.dao.vo.schedulers.SchedulersVo;
|
||||||
|
import cn.bunny.services.aop.AnnotationScanner;
|
||||||
|
import cn.bunny.services.aop.annotation.QuartzSchedulers;
|
||||||
import cn.bunny.services.mapper.SchedulersMapper;
|
import cn.bunny.services.mapper.SchedulersMapper;
|
||||||
import cn.bunny.services.service.SchedulersService;
|
import cn.bunny.services.service.SchedulersService;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
@ -18,8 +20,10 @@ import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -35,6 +39,9 @@ public class SchedulersServiceImpl extends ServiceImpl<SchedulersMapper, Schedul
|
||||||
@Autowired
|
@Autowired
|
||||||
private Scheduler scheduler;
|
private Scheduler scheduler;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AnnotationScanner annotationScanner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * Schedulers视图 服务实现类
|
* * Schedulers视图 服务实现类
|
||||||
*
|
*
|
||||||
|
@ -70,28 +77,26 @@ public class SchedulersServiceImpl extends ServiceImpl<SchedulersMapper, Schedul
|
||||||
@Override
|
@Override
|
||||||
public void addSchedulers(@Valid SchedulersAddDto dto) {
|
public void addSchedulers(@Valid SchedulersAddDto dto) {
|
||||||
try {
|
try {
|
||||||
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对象
|
||||||
Class<?> className = Class.forName(jobClassName);
|
Class<?> className = Class.forName(dto.getJobClassName());
|
||||||
Constructor<?> constructor = className.getConstructor(); // 获取无参构造函数
|
|
||||||
constructor.newInstance(); // 创建实例
|
// 获取无参构造函数
|
||||||
|
className.getConstructor().newInstance();
|
||||||
|
|
||||||
// 创建任务
|
// 创建任务
|
||||||
JobDetail jobDetail = JobBuilder.newJob((Class<? extends Job>) className).withIdentity(jobName, jobGroup)
|
JobDetail jobDetail = JobBuilder.newJob((Class<? extends Job>) className)
|
||||||
.withDescription(description).build();
|
.withIdentity(dto.getJobName(), dto.getJobGroup())
|
||||||
jobDetail.getJobDataMap().put("jobMethodName", jobMethodName);
|
.withDescription(dto.getDescription())
|
||||||
|
.build();
|
||||||
|
jobDetail.getJobDataMap().put("jobMethodName", "execute");
|
||||||
|
|
||||||
// 执行任务
|
// 执行任务
|
||||||
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(cronExpression);
|
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(dto.getCronExpression());
|
||||||
CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity("trigger" + jobName, jobGroup)
|
CronTrigger trigger = TriggerBuilder.newTrigger()
|
||||||
.startNow().withSchedule(cronScheduleBuilder).build();
|
.withIdentity(dto.getJobName(), dto.getJobGroup())
|
||||||
|
.withDescription(dto.getDescription())
|
||||||
|
.startNow()
|
||||||
|
.withSchedule(cronScheduleBuilder).build();
|
||||||
scheduler.scheduleJob(jobDetail, trigger);
|
scheduler.scheduleJob(jobDetail, trigger);
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
throw new BunnyException(exception.getMessage());
|
throw new BunnyException(exception.getMessage());
|
||||||
|
@ -147,4 +152,26 @@ public class SchedulersServiceImpl extends ServiceImpl<SchedulersMapper, Schedul
|
||||||
throw new BunnyException(exception.getMessage());
|
throw new BunnyException(exception.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 获取所有可用调度任务
|
||||||
|
*
|
||||||
|
* @return 所有调度任务内容
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<Map<String, String>> getAllScheduleJobList() {
|
||||||
|
Set<Class<?>> classesWithAnnotation = annotationScanner.getClassesWithAnnotation(QuartzSchedulers.class);
|
||||||
|
return classesWithAnnotation.stream().map(cls -> {
|
||||||
|
Map<String, String> hashMap = new HashMap<>();
|
||||||
|
|
||||||
|
// 调度器引用路径
|
||||||
|
String classReference = cls.getName();
|
||||||
|
// 调度器详情
|
||||||
|
String description = cls.getAnnotation(QuartzSchedulers.class).description();
|
||||||
|
|
||||||
|
hashMap.put("value", classReference);
|
||||||
|
hashMap.put("label", description);
|
||||||
|
return hashMap;
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ spring:
|
||||||
# 如果使用集群,instanceId必须唯一,设置成AUTO
|
# 如果使用集群,instanceId必须唯一,设置成AUTO
|
||||||
instanceId: AUTO
|
instanceId: AUTO
|
||||||
jobStore:
|
jobStore:
|
||||||
# 存储方式使用JobStoreTX 也就是数据库
|
# 存储方式使用JobStoreTX 也就是数据库 LocalDataSourceJobStore
|
||||||
class: org.springframework.scheduling.quartz.LocalDataSourceJobStore
|
class: org.springframework.scheduling.quartz.LocalDataSourceJobStore
|
||||||
driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate
|
driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate
|
||||||
# 表名前缀
|
# 表名前缀
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="cn.bunny.services.mapper.SchedulersGroupMapper">
|
||||||
|
|
||||||
|
<!-- 通用查询映射结果 -->
|
||||||
|
<resultMap id="BaseResultMap" type="cn.bunny.dao.entity.schedulers.SchedulersGroup">
|
||||||
|
<id column="id" property="id"/>
|
||||||
|
<id column="create_time" property="createTime"/>
|
||||||
|
<id column="update_time" property="updateTime"/>
|
||||||
|
<id column="create_user" property="createUser"/>
|
||||||
|
<id column="update_user" property="updateUser"/>
|
||||||
|
<id column="is_deleted" property="isDeleted"/>
|
||||||
|
<id column="group_name" property="groupName"/>
|
||||||
|
<id column="description" property="description"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<!-- 通用查询结果列 -->
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
id, create_time, update_time, create_user, update_user, is_deleted, group_name, description
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<!-- 分页查询任务调度分组内容 -->
|
||||||
|
<select id="selectListByPage" resultType="cn.bunny.dao.entity.schedulers.SchedulersGroup">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List"/>
|
||||||
|
from sys_schedulers_group
|
||||||
|
<where>
|
||||||
|
<if test="dto.groupName != null and dto.groupName != ''">
|
||||||
|
and group_name like CONCAT('%',#{dto.groupName},'%')
|
||||||
|
</if>
|
||||||
|
<if test="dto.description != null and dto.description != ''">
|
||||||
|
and description like CONCAT('%',#{dto.description},'%')
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
order by update_time desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 物理删除任务调度分组 -->
|
||||||
|
<delete id="deleteBatchIdsWithPhysics">
|
||||||
|
delete
|
||||||
|
from sys_schedulers_group
|
||||||
|
where id in
|
||||||
|
<foreach collection="ids" item="id" open="(" close=")" separator=",">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
</mapper>
|
|
@ -46,6 +46,5 @@
|
||||||
and job_method_name like CONCAT('%',#{dto.jobMethodName},'%')
|
and job_method_name like CONCAT('%',#{dto.jobMethodName},'%')
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
order by update_time desc
|
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
package cn.bunny.services.service.impl;
|
||||||
|
|
||||||
|
import cn.bunny.services.aop.AnnotationScanner;
|
||||||
|
import cn.bunny.services.aop.annotation.QuartzSchedulers;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
class SchedulersServiceImplTest {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AnnotationScanner annotationScanner;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void getAllJobClass() {
|
||||||
|
Set<Class<?>> classesWithAnnotation = annotationScanner.getClassesWithAnnotation(QuartzSchedulers.class);
|
||||||
|
classesWithAnnotation.forEach(cls -> {
|
||||||
|
String classReference = cls.getName();
|
||||||
|
String description = cls.getAnnotation(QuartzSchedulers.class).description();
|
||||||
|
System.out.println(classReference);
|
||||||
|
System.out.println(description);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue