Files
wwjcloud-nest-v1/wwjcloud/src/common/schedule/entities/Schedule.ts

66 lines
1.6 KiB
TypeScript
Raw Normal View History

import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm';
import { BaseEntity } from '@wwjCore/base/BaseEntity';
import { ScheduleStatus } from '../enums/schedule-status.enum';
/**
*
* 对应数据库表: sys_schedule
*/
@Entity('sys_schedule')
export class Schedule extends BaseEntity {
@PrimaryGeneratedColumn()
id: number;
@Column({ name: 'addon', type: 'varchar', length: 255, default: '' })
addon: string;
@Column({ name: 'key', type: 'varchar', length: 255, default: '' })
key: string;
@Column({ name: 'status', type: 'int', default: 1 })
status: ScheduleStatus;
@Column({ name: 'time', type: 'varchar', length: 500, default: '' })
time: string;
@Column({ name: 'count', type: 'int', default: 0 })
count: number;
@Column({ name: 'last_time', type: 'int', default: 0 })
last_time: number;
@Column({ name: 'next_time', type: 'int', default: 0 })
next_time: number;
@Column({ name: 'sort', type: 'int', default: 0 })
sort: number;
/**
*
*/
getStatusText(): string {
const statusMap = {
[ScheduleStatus.DISABLED]: '禁用',
[ScheduleStatus.ENABLED]: '启用',
[ScheduleStatus.RUNNING]: '执行中',
[ScheduleStatus.ERROR]: '错误',
[ScheduleStatus.PAUSED]: '暂停',
};
return statusMap[this.status] || '未知';
}
/**
*
*/
isEnabled(): boolean {
return this.status === ScheduleStatus.ENABLED;
}
/**
*
*/
isRunning(): boolean {
return this.status === ScheduleStatus.RUNNING;
}
}