import { Model, DataTypes, CreationOptional, InferAttributes, InferCreationAttributes, } from 'sequelize'; import sequelize from '../sequelizeInstance'; import TrackTask from './trackTask'; import { TRACK_TASK_DETAIL_STATUS } from '../enumerate'; class TrackTaskDetail extends Model< // eslint-disable-next-line no-use-before-define InferAttributes, // eslint-disable-next-line no-use-before-define InferCreationAttributes > { declare id: CreationOptional; declare trackTaskId: number; declare studentId: string; declare studentName: string; declare studentCode: string; declare className: string; declare status: number; declare error: string | null; declare createdAt: CreationOptional; declare updatedAt: CreationOptional; } TrackTaskDetail.init( { id: { type: DataTypes.INTEGER, autoIncrement: true, primaryKey: true, }, trackTaskId: { type: DataTypes.INTEGER, allowNull: false, }, studentId: { type: DataTypes.STRING, allowNull: false, }, studentName: { type: DataTypes.STRING, allowNull: false, }, studentCode: { type: DataTypes.STRING, allowNull: false, }, className: { type: DataTypes.STRING, allowNull: false, }, status: { type: DataTypes.INTEGER, allowNull: false, defaultValue: TRACK_TASK_DETAIL_STATUS.INIT, }, error: { type: DataTypes.STRING, allowNull: true, comment: '错误信息', }, createdAt: DataTypes.DATE, updatedAt: DataTypes.DATE, }, { sequelize, modelName: 'TrackTaskDetail', underscored: true, tableName: 'trackTaskDetail', } ); TrackTask.hasMany(TrackTaskDetail); TrackTaskDetail.belongsTo(TrackTask); export type TrackTaskDetailCreationAttributes = InferCreationAttributes< TrackTaskDetail, { omit: 'id' | 'createdAt' | 'updatedAt' | 'error' } >; export type TrackTaskDetailData = InferAttributes; export default TrackTaskDetail;