import { Column, Model, Table, DataType, CreatedAt, UpdatedAt } from "sequelize-typescript"; @Table({ tableName: "sys_job", comment: "定时任务定义与调度配置表", timestamps: true, createdAt: "created_at", updatedAt: "updated_at" }) export default class SysJob extends Model { @Column({ type: DataType.BIGINT, autoIncrement: true, primaryKey: true }) id!: number; @Column({ type: DataType.STRING(64), field: "job_key", comment: "任务键(唯一标识)" }) jobKey!: string; @Column({ type: DataType.STRING(64), field: "job_name", comment: "任务名称" }) jobName!: string; @Column({ type: DataType.STRING(64), field: "cron_expression", comment: "cron 表达式" }) cronExpression!: string; @Column({ type: DataType.STRING(16), field: "freq_type", comment: "频率类型: minute/hour/day/week/month/custom" }) freqType!: string; @Column({ type: DataType.JSONB, field: "freq_config", comment: "频率配置(人性化配置表单回填用)" }) freqConfig!: Record; @Column({ type: DataType.JSONB, field: "params", comment: "任务参数(JSONB)" }) params!: Record; @Column({ type: DataType.SMALLINT, field: "retry_times", comment: "重试次数" }) retryTimes!: number; @Column({ type: DataType.INTEGER, field: "retry_interval", comment: "重试间隔(秒)" }) retryInterval!: number; @Column({ type: DataType.SMALLINT, comment: "状态: 1-启用 0-停用" }) status!: number; @Column({ type: DataType.STRING(255), comment: "备注" }) remark!: string | null; @Column({ type: DataType.DATE, field: "last_run_at", comment: "上次执行时间" }) lastRunAt!: Date | null; @Column({ type: DataType.SMALLINT, field: "last_run_status", comment: "上次执行状态: 1-成功 2-失败 3-跳过" }) lastRunStatus!: number | null; @Column({ type: DataType.INTEGER, field: "last_run_cost_ms", comment: "上次执行耗时(毫秒)" }) lastRunCostMs!: number | null; @Column({ type: DataType.TEXT, field: "last_error", comment: "上次失败原因" }) lastError!: string | null; @CreatedAt created_at!: Date; @UpdatedAt updated_at!: Date; }