🚀 feat(新增): 查询所有任务
This commit is contained in:
parent
fb9d7d116f
commit
cc2d8b9d82
|
@ -15,15 +15,13 @@ public class NewCodeGet {
|
||||||
// 作者名称
|
// 作者名称
|
||||||
public static final String author = "Bunny";
|
public static final String author = "Bunny";
|
||||||
// 公共路径
|
// 公共路径
|
||||||
// public static final String outputDir = "D:\\MyFolder\\Quartz-Demo\\service";
|
public static final String outputDir = "D:\\MyFolder\\Quartz-Demo\\service";
|
||||||
public static final String outputDir = "D:\\Project\\web\\PC\\demo\\Quartz-Demo\\service";
|
// public static final String outputDir = "D:\\Project\\web\\PC\\demo\\Quartz-Demo\\service";
|
||||||
// 实体类名称
|
// 实体类名称
|
||||||
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("QRTZ_CALENDARS","QRTZ_CRON_TRIGGERS","QRTZ_FIRED_TRIGGERS","QRTZ_JOB_DETAILS","QRTZ_LOCKS","QRTZ_PAUSED_TRIGGER_GRPS","QRTZ_SCHEDULER_STATE",
|
Generation("job_list");
|
||||||
"QRTZ_SIMPLE_TRIGGERS","QRTZ_SIMPROP_TRIGGERS","QRTZ_TRIGGERS"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,10 +43,10 @@ public class NewCodeGet {
|
||||||
builder.entity(entity)// 实体类包名
|
builder.entity(entity)// 实体类包名
|
||||||
// TODO 父包名。如果为空,将下面子包名必须写全部, 否则就只需写子包名
|
// TODO 父包名。如果为空,将下面子包名必须写全部, 否则就只需写子包名
|
||||||
.parent("cn.bunny.service")
|
.parent("cn.bunny.service")
|
||||||
.controller("controller.quartz")// 控制层包名
|
.controller("controller")// 控制层包名
|
||||||
.mapper("mapper.quartz")// mapper层包名
|
.mapper("mapper")// mapper层包名
|
||||||
.service("service.quartz")// service层包名
|
.service("service")// service层包名
|
||||||
.serviceImpl("service.quartz.impl")// service实现类包名
|
.serviceImpl("service.impl")// service实现类包名
|
||||||
// 自定义mapper.xml文件输出目录
|
// 自定义mapper.xml文件输出目录
|
||||||
.pathInfo(Collections.singletonMap(OutputFile.xml, outputDir + "/src/main/resources/mapper/quartz"));
|
.pathInfo(Collections.singletonMap(OutputFile.xml, outputDir + "/src/main/resources/mapper/quartz"));
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
package cn.bunny.common.generator;
|
|
||||||
|
|
||||||
public class OldCodeGet {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
// // 1、创建代码生成器
|
|
||||||
// AutoGenerator mpg = new AutoGenerator();
|
|
||||||
//
|
|
||||||
// // 2、全局配置
|
|
||||||
// // 全局配置
|
|
||||||
// GlobalConfig gc = new GlobalConfig();
|
|
||||||
// // TODO 需要修改路径名称
|
|
||||||
// gc.setOutputDir("F:\\web项目\\Bunny-Cli\\Java\\java-template\\service" + "/src/main/java");
|
|
||||||
// gc.setServiceName("%sService"); // 去掉Service接口的首字母I
|
|
||||||
// gc.setAuthor("bunny");
|
|
||||||
// gc.setOpen(false);
|
|
||||||
// mpg.setGlobalConfig(gc);
|
|
||||||
//
|
|
||||||
// // 3、数据源配置
|
|
||||||
// DataSourceConfig dsc = new DataSourceConfig();
|
|
||||||
// // TODO 需要修改数据库
|
|
||||||
// dsc.setUrl("jdbc:mysql://106.15.251.123:3305/guigu-oa?serverTimezone=GMT%2B8&useSSL=false&characterEncoding=utf-8&allowPublicKeyRetrieval=true");
|
|
||||||
// dsc.setDriverName("com.mysql.cj.jdbc.Driver");
|
|
||||||
// dsc.setUsername("root");
|
|
||||||
// dsc.setPassword("02120212");
|
|
||||||
// dsc.setDbType(DbType.MYSQL);
|
|
||||||
// mpg.setDataSource(dsc);
|
|
||||||
//
|
|
||||||
// // 4、包配置
|
|
||||||
// PackageConfig pc = new PackageConfig();
|
|
||||||
// pc.setParent("cn.bunny");
|
|
||||||
// // TODO 需要修改模块名
|
|
||||||
// pc.setModuleName("service");
|
|
||||||
// pc.setController("controller");
|
|
||||||
// pc.setService("service");
|
|
||||||
// pc.setMapper("mapper");
|
|
||||||
// mpg.setPackageInfo(pc);
|
|
||||||
//
|
|
||||||
// // 5、策略配置
|
|
||||||
// StrategyConfig strategy = getStrategyConfig();
|
|
||||||
// mpg.setStrategy(strategy);
|
|
||||||
//
|
|
||||||
// // 6、执行
|
|
||||||
// mpg.execute();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private static StrategyConfig getStrategyConfig() {
|
|
||||||
// StrategyConfig strategy = new StrategyConfig();
|
|
||||||
// // TODO 要生成的表
|
|
||||||
// strategy.setInclude("sys_menu", "sys_role_menu");
|
|
||||||
// strategy.setNaming(NamingStrategy.underline_to_camel);// 数据库表映射到实体的命名策略
|
|
||||||
// strategy.setColumnNaming(NamingStrategy.underline_to_camel);// 数据库表字段映射到实体的命名策略
|
|
||||||
// strategy.setEntityLombokModel(true); // lombok 模型 @Accessors(chain = true) setter链式操作
|
|
||||||
// strategy.setRestControllerStyle(true); // restful api风格控制器
|
|
||||||
// strategy.setControllerMappingHyphenStyle(true); // url中驼峰转连字符
|
|
||||||
// return strategy;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
package cn.bunny.entity.system.quartz;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* VIEW
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author Bunny
|
||||||
|
* @since 2024-07-26
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@TableName("job_list")
|
||||||
|
@ApiModel(value = "JobList对象", description = "VIEW")
|
||||||
|
public class JobList implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private String jobName;
|
||||||
|
|
||||||
|
private String jobGroup;
|
||||||
|
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
private String jobClassName;
|
||||||
|
|
||||||
|
private String cronExpression;
|
||||||
|
|
||||||
|
private String triggerName;
|
||||||
|
|
||||||
|
private String triggerState;
|
||||||
|
}
|
|
@ -2,8 +2,11 @@ package cn.bunny.service.controller;
|
||||||
|
|
||||||
import cn.bunny.dto.quartz.QuartzAddDto;
|
import cn.bunny.dto.quartz.QuartzAddDto;
|
||||||
import cn.bunny.dto.quartz.QuartzOperationDto;
|
import cn.bunny.dto.quartz.QuartzOperationDto;
|
||||||
|
import cn.bunny.entity.system.quartz.JobList;
|
||||||
import cn.bunny.pojo.result.Result;
|
import cn.bunny.pojo.result.Result;
|
||||||
import cn.bunny.service.service.JobService;
|
import cn.bunny.service.service.JobService;
|
||||||
|
import cn.bunny.vo.page.PageResult;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -17,6 +20,17 @@ public class JobController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private JobService jobService;
|
private JobService jobService;
|
||||||
|
|
||||||
|
@Operation(summary = "分页查询所有任务", description = "分页查询所有任务")
|
||||||
|
@PostMapping("/page/{page}/{limit}")
|
||||||
|
public Result<PageResult<JobList>> pageQuery(
|
||||||
|
@PathVariable Integer page,
|
||||||
|
@PathVariable Integer limit
|
||||||
|
) {
|
||||||
|
Page<JobList> pageParams = new Page<>();
|
||||||
|
PageResult<JobList> pageResult = jobService.pageQuery(pageParams);
|
||||||
|
return Result.success(pageResult);
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "添加任务", description = "添加任务")
|
@Operation(summary = "添加任务", description = "添加任务")
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
public Result<String> addJob(@RequestBody QuartzAddDto dto) {
|
public Result<String> addJob(@RequestBody QuartzAddDto dto) {
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package cn.bunny.service.mapper;
|
||||||
|
|
||||||
|
import cn.bunny.entity.system.quartz.JobList;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* VIEW Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author Bunny
|
||||||
|
* @since 2024-07-26
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface JobListMapper extends BaseMapper<JobList> {
|
||||||
|
|
||||||
|
}
|
|
@ -2,8 +2,12 @@ package cn.bunny.service.service;
|
||||||
|
|
||||||
import cn.bunny.dto.quartz.QuartzAddDto;
|
import cn.bunny.dto.quartz.QuartzAddDto;
|
||||||
import cn.bunny.dto.quartz.QuartzOperationDto;
|
import cn.bunny.dto.quartz.QuartzOperationDto;
|
||||||
|
import cn.bunny.entity.system.quartz.JobList;
|
||||||
|
import cn.bunny.vo.page.PageResult;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
public interface JobService {
|
public interface JobService extends IService<JobList> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 添加任务
|
* * 添加任务
|
||||||
|
@ -32,4 +36,12 @@ public interface JobService {
|
||||||
* @param dto 移出任务
|
* @param dto 移出任务
|
||||||
*/
|
*/
|
||||||
void remove(QuartzOperationDto dto);
|
void remove(QuartzOperationDto dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 分页查询所有任务
|
||||||
|
*
|
||||||
|
* @param pageParams 分页删除
|
||||||
|
* @return 分页结果
|
||||||
|
*/
|
||||||
|
PageResult<JobList> pageQuery(Page<JobList> pageParams);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,13 @@ package cn.bunny.service.service.impl;
|
||||||
|
|
||||||
import cn.bunny.dto.quartz.QuartzAddDto;
|
import cn.bunny.dto.quartz.QuartzAddDto;
|
||||||
import cn.bunny.dto.quartz.QuartzOperationDto;
|
import cn.bunny.dto.quartz.QuartzOperationDto;
|
||||||
|
import cn.bunny.entity.system.quartz.JobList;
|
||||||
|
import cn.bunny.service.mapper.JobListMapper;
|
||||||
import cn.bunny.service.service.JobService;
|
import cn.bunny.service.service.JobService;
|
||||||
|
import cn.bunny.vo.page.PageResult;
|
||||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.quartz.*;
|
import org.quartz.*;
|
||||||
|
@ -16,7 +21,7 @@ import java.lang.reflect.Constructor;
|
||||||
@Service
|
@Service
|
||||||
@DS("quartz")
|
@DS("quartz")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class JobServiceImpl implements JobService {
|
public class JobServiceImpl extends ServiceImpl<JobListMapper, JobList> implements JobService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private Scheduler scheduler;
|
private Scheduler scheduler;
|
||||||
|
@ -96,4 +101,22 @@ public class JobServiceImpl implements JobService {
|
||||||
|
|
||||||
log.warn("删除成功");
|
log.warn("删除成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 分页查询所有任务
|
||||||
|
*
|
||||||
|
* @param pageParams 分页删除
|
||||||
|
* @return 分页结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public PageResult<JobList> pageQuery(Page<JobList> pageParams) {
|
||||||
|
Page<JobList> listPage = page(pageParams);
|
||||||
|
|
||||||
|
return PageResult.<JobList>builder()
|
||||||
|
.pageNo((int) listPage.getCurrent())
|
||||||
|
.pageSize((int) listPage.getSize())
|
||||||
|
.total(listPage.getTotal())
|
||||||
|
.list(listPage.getRecords())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?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.service.mapper.JobListMapper">
|
||||||
|
|
||||||
|
<!-- 通用查询映射结果 -->
|
||||||
|
<resultMap id="BaseResultMap" type="cn.bunny.entity.system.quartz.JobList">
|
||||||
|
<result column="jobName" property="jobName"/>
|
||||||
|
<result column="jobGroup" property="jobGroup"/>
|
||||||
|
<result column="description" property="description"/>
|
||||||
|
<result column="jobClassName" property="jobClassName"/>
|
||||||
|
<result column="cronExpression" property="cronExpression"/>
|
||||||
|
<result column="triggerName" property="triggerName"/>
|
||||||
|
<result column="triggerState" property="triggerState"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<!-- 通用查询结果列 -->
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
jobName, jobGroup, description, jobClassName, cronExpression, triggerName, triggerState
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
</mapper>
|
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"jobName": "hello2 方法",
|
||||||
|
"jobGroup": "test"
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
"jobName": "hello 方法",
|
||||||
|
"jobGroup": "test",
|
||||||
|
"description": "测试方法",
|
||||||
|
"jobClassName": "cn.bunny.service.job.dynamic.JobHello",
|
||||||
|
"jobMethodName": "start",
|
||||||
|
"cronExpression": "0/2 * * * * ?"
|
||||||
|
}
|
Loading…
Reference in New Issue