import { Model, DataTypes, CreationOptional, InferAttributes, InferCreationAttributes, } from 'sequelize'; import sequelize from '../sequelizeInstance'; import { TRACK_TASK_STATUS } from '../enumerate'; class TrackTask extends Model< // eslint-disable-next-line no-use-before-define InferAttributes, // eslint-disable-next-line no-use-before-define InferCreationAttributes > { declare id: CreationOptional; declare schoolId: string; declare semesterId: string; declare semesterName: string; declare examId: string; declare examName: string; declare courseId: string | null; declare courseName: string | null; declare courseCode: string | null; declare paperNumber: string | null; declare pictureType: string; declare outputDir: string; declare status: number; declare error: string | null; declare createdAt: CreationOptional; declare updatedAt: CreationOptional; } TrackTask.init( { id: { type: DataTypes.INTEGER, autoIncrement: true, primaryKey: true, }, schoolId: { type: DataTypes.STRING, allowNull: false, }, semesterId: { type: DataTypes.STRING, allowNull: false, }, semesterName: { type: DataTypes.STRING, allowNull: false, }, examId: { type: DataTypes.STRING, allowNull: false, }, examName: { type: DataTypes.STRING, allowNull: false, }, courseId: { type: DataTypes.STRING, allowNull: true, }, courseName: { type: DataTypes.STRING, allowNull: true, }, courseCode: { type: DataTypes.STRING, allowNull: true, }, paperNumber: { type: DataTypes.STRING, allowNull: true, }, pictureType: { type: DataTypes.STRING, allowNull: false, comment: '图片类型', }, outputDir: { type: DataTypes.STRING, allowNull: false, comment: '保存目录', }, status: { type: DataTypes.INTEGER, allowNull: false, defaultValue: TRACK_TASK_STATUS.INIT, }, error: { type: DataTypes.STRING, allowNull: true, comment: '错误信息', }, createdAt: DataTypes.DATE, updatedAt: DataTypes.DATE, }, { sequelize, modelName: 'TrackTask', underscored: true, tableName: 'trackTask', } ); export type TrackTaskCreationAttributes = InferCreationAttributes< TrackTask, { omit: 'id' | 'createdAt' | 'updatedAt' | 'error' } >; export type TrackTaskData = InferAttributes; export default TrackTask;