mirror of
https://github.com/whyour/qinglong.git
synced 2025-07-07 11:56:08 +08:00
修复更新环境变量、定时任务、订阅等操作
This commit is contained in:
parent
6a971a0d6e
commit
083c8869aa
|
@ -12,13 +12,13 @@ import {
|
|||
killTask,
|
||||
} from '../config/util';
|
||||
import { promises, existsSync } from 'fs';
|
||||
import { Op, where, col as colFn } from 'sequelize';
|
||||
import { Op, where, col as colFn, FindOptions } from 'sequelize';
|
||||
import path from 'path';
|
||||
import { TASK_PREFIX, QL_PREFIX } from '../config/const';
|
||||
|
||||
@Service()
|
||||
export default class CronService {
|
||||
constructor(@Inject('logger') private logger: winston.Logger) {}
|
||||
constructor(@Inject('logger') private logger: winston.Logger) { }
|
||||
|
||||
private isSixCron(cron: Crontab) {
|
||||
const { schedule } = cron;
|
||||
|
@ -41,7 +41,8 @@ export default class CronService {
|
|||
}
|
||||
|
||||
public async update(payload: Crontab): Promise<Crontab> {
|
||||
const tab = new Crontab(payload);
|
||||
const doc = await this.getDb({ id: payload.id })
|
||||
const tab = new Crontab({ ...doc, ...payload });
|
||||
tab.saved = false;
|
||||
const newDoc = await this.updateDb(tab);
|
||||
await this.set_crontab();
|
||||
|
@ -332,7 +333,7 @@ export default class CronService {
|
|||
}
|
||||
}
|
||||
|
||||
public async getDb(query: any): Promise<Crontab> {
|
||||
public async getDb(query: FindOptions<Crontab>['where']): Promise<Crontab> {
|
||||
const doc: any = await CrontabModel.findOne({ where: { ...query } });
|
||||
return doc && (doc.get({ plain: true }) as Crontab);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import {
|
|||
minPosition,
|
||||
stepPosition,
|
||||
} from '../data/env';
|
||||
import { FindOptions } from 'sequelize';
|
||||
|
||||
@Service()
|
||||
export default class CronViewService {
|
||||
|
@ -31,7 +32,9 @@ export default class CronViewService {
|
|||
}
|
||||
|
||||
public async update(payload: CrontabView): Promise<CrontabView> {
|
||||
const newDoc = await this.updateDb(new CrontabView(payload));
|
||||
const doc = await this.getDb({ id: payload.id })
|
||||
const tab = new CrontabView({ ...doc, ...payload });
|
||||
const newDoc = await this.updateDb(tab);
|
||||
return newDoc;
|
||||
}
|
||||
|
||||
|
@ -56,7 +59,7 @@ export default class CronViewService {
|
|||
}
|
||||
}
|
||||
|
||||
public async getDb(query: any): Promise<CrontabView> {
|
||||
public async getDb(query: FindOptions<CrontabView>['where']): Promise<CrontabView> {
|
||||
const doc: any = await CrontabViewModel.findOne({ where: { ...query } });
|
||||
return doc && (doc.get({ plain: true }) as CrontabView);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import {
|
|||
} from '../data/dependence';
|
||||
import { spawn } from 'child_process';
|
||||
import SockService from './sock';
|
||||
import { Op } from 'sequelize';
|
||||
import { FindOptions, Op } from 'sequelize';
|
||||
import { concurrentRun } from '../config/util';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
|
@ -132,7 +132,7 @@ export default class DependenceService {
|
|||
return docs;
|
||||
}
|
||||
|
||||
public async getDb(query: any): Promise<Dependence> {
|
||||
public async getDb(query: FindOptions<Dependence>['where']): Promise<Dependence> {
|
||||
const doc: any = await DependenceModel.findOne({ where: { ...query } });
|
||||
return doc && (doc.get({ plain: true }) as Dependence);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import {
|
|||
stepPosition,
|
||||
} from '../data/env';
|
||||
import groupBy from 'lodash/groupBy';
|
||||
import { Op } from 'sequelize';
|
||||
import { FindOptions, Op } from 'sequelize';
|
||||
|
||||
@Service()
|
||||
export default class EnvService {
|
||||
|
@ -49,7 +49,9 @@ export default class EnvService {
|
|||
}
|
||||
|
||||
public async update(payload: Env): Promise<Env> {
|
||||
const newDoc = await this.updateDb(new Env(payload));
|
||||
const doc = await this.getDb({ id: payload.id })
|
||||
const tab = new Env({ ...doc, ...payload });
|
||||
const newDoc = await this.updateDb(tab);
|
||||
await this.set_envs();
|
||||
return newDoc;
|
||||
}
|
||||
|
@ -162,7 +164,7 @@ export default class EnvService {
|
|||
return docs;
|
||||
}
|
||||
|
||||
public async getDb(query: any): Promise<Env> {
|
||||
public async getDb(query: FindOptions<Env>['where']): Promise<Env> {
|
||||
const doc: any = await EnvModel.findOne({ where: { ...query } });
|
||||
return doc && (doc.get({ plain: true }) as Env);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import {
|
|||
killTask,
|
||||
} from '../config/util';
|
||||
import { promises, existsSync } from 'fs';
|
||||
import { Op } from 'sequelize';
|
||||
import { FindOptions, Op } from 'sequelize';
|
||||
import path from 'path';
|
||||
import ScheduleService, { TaskCallbacks } from './schedule';
|
||||
import { SimpleIntervalSchedule } from 'toad-scheduler';
|
||||
|
@ -236,7 +236,8 @@ export default class SubscriptionService {
|
|||
}
|
||||
|
||||
public async update(payload: Subscription): Promise<Subscription> {
|
||||
const tab = new Subscription(payload);
|
||||
const doc = await this.getDb({ id: payload.id })
|
||||
const tab = new Subscription({ ...doc, ...payload });
|
||||
const newDoc = await this.updateDb(tab);
|
||||
await this.handleTask(newDoc, !newDoc.is_disabled);
|
||||
await this.setSshConfig();
|
||||
|
@ -288,7 +289,7 @@ export default class SubscriptionService {
|
|||
await this.setSshConfig();
|
||||
}
|
||||
|
||||
public async getDb(query: any): Promise<Subscription> {
|
||||
public async getDb(query: FindOptions<Subscription>['where']): Promise<Subscription> {
|
||||
const doc: any = await SubscriptionModel.findOne({ where: { ...query } });
|
||||
return doc && (doc.get({ plain: true }) as Subscription);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user