mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-01 04:40:38 +08:00
修改定时规则类型
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
export enum ScheduleType {
|
||||
BOOT = '@boot',
|
||||
ONCE = '@once',
|
||||
}
|
||||
|
||||
export type ScheduleValidator = (schedule?: string) => boolean;
|
||||
export type CronSchedulerPayload = {
|
||||
name: string;
|
||||
id: string;
|
||||
schedule: string;
|
||||
command: string;
|
||||
extra_schedules: Array<{ schedule: string }>;
|
||||
};
|
||||
@@ -22,6 +22,7 @@ import dayjs from 'dayjs';
|
||||
import pickBy from 'lodash/pickBy';
|
||||
import omit from 'lodash/omit';
|
||||
import { writeFileWithLock } from '../shared/utils';
|
||||
import { ScheduleType } from '../interface/schedule';
|
||||
|
||||
@Service()
|
||||
export default class CronService {
|
||||
@@ -36,11 +37,11 @@ export default class CronService {
|
||||
}
|
||||
|
||||
private isOnceSchedule(schedule?: string) {
|
||||
return schedule?.startsWith('@once');
|
||||
return schedule?.startsWith(ScheduleType.ONCE);
|
||||
}
|
||||
|
||||
private isBootSchedule(schedule?: string) {
|
||||
return schedule?.startsWith('@boot');
|
||||
return schedule?.startsWith(ScheduleType.BOOT);
|
||||
}
|
||||
|
||||
private isSpecialSchedule(schedule?: string) {
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
import { Joi } from 'celebrate';
|
||||
import cron_parser from 'cron-parser';
|
||||
import { ScheduleType } from '../interface/schedule';
|
||||
|
||||
const validateSchedule = (value: string, helpers: any) => {
|
||||
if (value.startsWith('@once') || value.startsWith('@boot')) {
|
||||
if (
|
||||
value.startsWith(ScheduleType.ONCE) ||
|
||||
value.startsWith(ScheduleType.BOOT)
|
||||
) {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user