From e1e6261b4f95cfd158e41d6699e69e4784ccad75 Mon Sep 17 00:00:00 2001 From: whyour Date: Fri, 24 Feb 2023 23:21:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AE=9A=E6=97=B6=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1/=E8=A7=86=E5=9B=BE/=E7=8E=AF=E5=A2=83=E5=8F=98?= =?UTF-8?q?=E9=87=8F=E6=9B=B4=E6=96=B0=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/services/cron.ts | 8 ++++---- back/services/cronView.ts | 2 +- back/services/env.ts | 10 +++++++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/back/services/cron.ts b/back/services/cron.ts index 6bc36aa8..e39f1357 100644 --- a/back/services/cron.ts +++ b/back/services/cron.ts @@ -18,7 +18,7 @@ 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,8 +41,9 @@ export default class CronService { } public async update(payload: Crontab): Promise { - payload.saved = false; - const newDoc = await this.updateDb(payload); + const tab = new Crontab(payload); + tab.saved = false; + const newDoc = await this.updateDb(tab); await this.set_crontab(); return newDoc; } @@ -452,7 +453,6 @@ export default class CronService { } else { return []; } - } private make_command(tab: Crontab) { diff --git a/back/services/cronView.ts b/back/services/cronView.ts index 4c079112..48917ccd 100644 --- a/back/services/cronView.ts +++ b/back/services/cronView.ts @@ -31,7 +31,7 @@ export default class CronViewService { } public async update(payload: CrontabView): Promise { - const newDoc = await this.updateDb(payload); + const newDoc = await this.updateDb(new CrontabView(payload)); return newDoc; } diff --git a/back/services/env.ts b/back/services/env.ts index 95e5198a..63b0b74c 100644 --- a/back/services/env.ts +++ b/back/services/env.ts @@ -16,7 +16,7 @@ import { Op } from 'sequelize'; @Service() export default class EnvService { - constructor(@Inject('logger') private logger: winston.Logger) { } + constructor(@Inject('logger') private logger: winston.Logger) {} public async create(payloads: Env[]): Promise { const envs = await this.envs(); @@ -49,7 +49,7 @@ export default class EnvService { } public async update(payload: Env): Promise { - const newDoc = await this.updateDb(payload); + const newDoc = await this.updateDb(new Env(payload)); await this.set_envs(); return newDoc; } @@ -98,7 +98,11 @@ export default class EnvService { private async checkPosition(position: number, edge: number = 0) { const precisionPosition = parseFloat(position.toPrecision(16)); - if (precisionPosition < minPosition || precisionPosition > maxPosition || Math.abs(precisionPosition - edge) < minPosition) { + if ( + precisionPosition < minPosition || + precisionPosition > maxPosition || + Math.abs(precisionPosition - edge) < minPosition + ) { const envs = await this.envs(); let position = initPosition; for (const env of envs) {