New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix:系统定时任务持久化 #275
fix:系统定时任务持久化 #275
Conversation
@@ -52,6 +55,7 @@ public class JobsServiceImpl extends SonicServiceImpl<JobsMapper, Jobs> implemen | |||
@Transactional(rollbackFor = Exception.class) | |||
public RespModel<String> saveJobs(Jobs jobs) throws SonicException { | |||
jobs.setStatus(JobStatus.ENABLE); | |||
jobs.setType("TEST_JOB"); | |||
save(jobs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个“TEST_JOB”可以提取为一个final string会更优雅,然后其他地方直接引用就行了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private List<String> typeList = Arrays.asList("cleanFile", "cleanResult", "sendDayReport", "sendWeekReport");
你这里全小写的,TEST_JOB也可以统一一下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
因为数据库有变更所以针对历史数据的处理,让用户自行处理,还是写个兼容的逻辑?
/** | ||
* Mapper 接口 | ||
* @author JayWenStar | ||
*/ | ||
@Mapper | ||
public interface JobsMapper extends BaseMapper<Jobs> { | ||
|
||
@Select("select * from jobs where type = #{type}") | ||
Jobs findByType(@Param("type") String type); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我们后面计划逐渐减少这种使用方法,建议可以直接在QuartzHandler.java 用lambdaquery直接eq type就可以了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我把 findByType 加到 JobsService 里面吧,然后用 lambdaquery 的写法
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
大体没什么问题,需要调整的点已经评论啦,可以继续优化一下哦
已优化,我重新提交一个PR |
在提出此拉取请求时,我确认了以下几点(保存后请点击复选框):
填写PR内容:
1、jobs 表添加 type 字段用于区分系统/非系统定时任务,需要对原来的非系统定时任务做下处理
type
VARCHAR(20)type
= 'TEST_JOB' WHEREtype
is null2、定时任务相关的接口根据
type
字段进行了过滤3、系统定时任务保存到 jobs 表中,初始化系统定时任务时,从表中取 cron 表达式
4、如果表中没有系统定时任务,会初始化进去