1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- 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<TrackTaskDetail>,
- // eslint-disable-next-line no-use-before-define
- InferCreationAttributes<TrackTaskDetail>
- > {
- declare id: CreationOptional<number>;
- declare trackTaskId: number;
- declare studentId: string;
- declare studentName: string;
- declare studentCode: string;
- declare status: number;
- declare error: string | null;
- declare createdAt: CreationOptional<Date>;
- declare updatedAt: CreationOptional<Date>;
- }
- 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,
- },
- 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 default TrackTaskDetail;
|