mirror of
https://github.com/cool-team-official/cool-admin-midway.git
synced 2025-12-11 00:22:49 +00:00
更新本地任务到midway最新方案
This commit is contained in:
parent
66a21e97b2
commit
e23099a95e
19
package.json
19
package.json
@ -13,17 +13,18 @@
|
||||
"@midwayjs/bootstrap": "^3.15.0",
|
||||
"@midwayjs/cache": "^3.14.0",
|
||||
"@midwayjs/core": "^3.15.0",
|
||||
"@midwayjs/cross-domain": "^3.15.0",
|
||||
"@midwayjs/cron": "^3.15.0",
|
||||
"@midwayjs/cross-domain": "^3.15.1",
|
||||
"@midwayjs/decorator": "^3.15.0",
|
||||
"@midwayjs/info": "^3.15.0",
|
||||
"@midwayjs/koa": "^3.15.0",
|
||||
"@midwayjs/logger": "^3.2.0",
|
||||
"@midwayjs/static-file": "^3.15.0",
|
||||
"@midwayjs/info": "^3.15.1",
|
||||
"@midwayjs/koa": "^3.15.1",
|
||||
"@midwayjs/logger": "^3.3.0",
|
||||
"@midwayjs/static-file": "^3.15.1",
|
||||
"@midwayjs/task": "^3.6.0",
|
||||
"@midwayjs/typeorm": "^3.15.0",
|
||||
"@midwayjs/upload": "^3.15.0",
|
||||
"@midwayjs/validate": "^3.15.0",
|
||||
"@midwayjs/view-ejs": "^3.15.0",
|
||||
"@midwayjs/upload": "^3.15.1",
|
||||
"@midwayjs/validate": "^3.15.1",
|
||||
"@midwayjs/view-ejs": "^3.15.1",
|
||||
"axios": "^1.6.7",
|
||||
"decompress": "^4.2.1",
|
||||
"ipip-ipdb": "^0.6.0",
|
||||
@ -32,7 +33,7 @@
|
||||
"md5": "^2.3.0",
|
||||
"mini-svg-data-uri": "^1.4.4",
|
||||
"moment": "^2.30.1",
|
||||
"mysql2": "^3.9.1",
|
||||
"mysql2": "^3.9.2",
|
||||
"svg-captcha": "^1.4.0",
|
||||
"svg2png-wasm": "^1.4.1",
|
||||
"typeorm": "^0.3.20",
|
||||
|
||||
@ -6,7 +6,7 @@ import * as info from '@midwayjs/info';
|
||||
import { join } from 'path';
|
||||
import * as view from '@midwayjs/view-ejs';
|
||||
import * as staticFile from '@midwayjs/static-file';
|
||||
import * as localTask from '@midwayjs/task';
|
||||
import * as cron from '@midwayjs/cron';
|
||||
// import * as crossDomain from '@midwayjs/cross-domain';
|
||||
import * as cool from '@cool-midway/core';
|
||||
import * as cloud from '@cool-midway/cloud';
|
||||
@ -32,8 +32,8 @@ import { IMidwayApplication } from '@midwayjs/core';
|
||||
orm,
|
||||
// 参数验证 https://midwayjs.org/docs/extensions/validate
|
||||
validate,
|
||||
// 本地任务 http://midwayjs.org/docs/legacy/task
|
||||
localTask,
|
||||
// 本地任务 http://www.midwayjs.org/docs/extensions/cron
|
||||
cron,
|
||||
// 文件上传
|
||||
upload,
|
||||
// cool-admin 官方组件 https://cool-js.com
|
||||
|
||||
@ -1,27 +1,22 @@
|
||||
import {
|
||||
Provide,
|
||||
Inject,
|
||||
CommonSchedule,
|
||||
TaskLocal,
|
||||
FORMAT,
|
||||
} from '@midwayjs/decorator';
|
||||
import { Job, IJob } from '@midwayjs/cron';
|
||||
import { FORMAT, ILogger, Inject } from '@midwayjs/core';
|
||||
import { BaseSysLogService } from '../service/sys/log';
|
||||
import { ILogger } from '@midwayjs/logger';
|
||||
|
||||
/**
|
||||
* 日志定时任务
|
||||
*/
|
||||
@Provide()
|
||||
export class BaseLogSchedule implements CommonSchedule {
|
||||
@Job({
|
||||
cronTime: FORMAT.CRONTAB.EVERY_PER_10_SECOND,
|
||||
start: true,
|
||||
})
|
||||
export class BaseLogJob implements IJob {
|
||||
@Inject()
|
||||
baseSysLogService: BaseSysLogService;
|
||||
|
||||
@Inject()
|
||||
logger: ILogger;
|
||||
|
||||
// 定时执行的具体任务
|
||||
@TaskLocal(FORMAT.CRONTAB.EVERY_DAY)
|
||||
async exec() {
|
||||
async onTick() {
|
||||
this.logger.info('清除日志定时任务开始执行');
|
||||
const startTime = Date.now();
|
||||
await this.baseSysLogService.clear();
|
||||
Loading…
x
Reference in New Issue
Block a user