trackTaskDetail.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import {
  2. Model,
  3. DataTypes,
  4. CreationOptional,
  5. InferAttributes,
  6. InferCreationAttributes,
  7. } from 'sequelize';
  8. import sequelize from '../sequelizeInstance';
  9. import TrackTask from './trackTask';
  10. class TrackTaskDetail extends Model<
  11. // eslint-disable-next-line no-use-before-define
  12. InferAttributes<TrackTaskDetail>,
  13. // eslint-disable-next-line no-use-before-define
  14. InferCreationAttributes<TrackTaskDetail>
  15. > {
  16. declare id: CreationOptional<number>;
  17. declare trackTaskId: number;
  18. declare studentName: string;
  19. declare studentCode: string;
  20. declare courseName: string;
  21. declare courseCode: string;
  22. declare status: number;
  23. declare error: string | null;
  24. declare createdAt: CreationOptional<Date>;
  25. declare updatedAt: CreationOptional<Date>;
  26. }
  27. TrackTaskDetail.init(
  28. {
  29. id: {
  30. type: DataTypes.INTEGER.UNSIGNED,
  31. autoIncrement: true,
  32. primaryKey: true,
  33. },
  34. trackTaskId: {
  35. type: DataTypes.INTEGER.UNSIGNED,
  36. allowNull: false,
  37. },
  38. studentName: {
  39. type: DataTypes.STRING,
  40. allowNull: false,
  41. },
  42. studentCode: {
  43. type: DataTypes.STRING,
  44. allowNull: false,
  45. },
  46. courseName: {
  47. type: DataTypes.STRING,
  48. allowNull: false,
  49. },
  50. courseCode: {
  51. type: DataTypes.STRING,
  52. allowNull: false,
  53. },
  54. status: {
  55. type: DataTypes.INTEGER,
  56. allowNull: false,
  57. defaultValue: 0,
  58. // 任务状态:0:未开始,1:运行中,2:已完成
  59. },
  60. error: {
  61. type: DataTypes.TEXT,
  62. allowNull: true,
  63. comment: '错误信息',
  64. },
  65. createdAt: DataTypes.DATE,
  66. updatedAt: DataTypes.DATE,
  67. },
  68. {
  69. sequelize,
  70. modelName: 'TrackTaskDetail',
  71. underscored: true,
  72. tableName: 'trackTaskDetail',
  73. }
  74. );
  75. TrackTask.hasMany(TrackTaskDetail);
  76. TrackTaskDetail.belongsTo(TrackTask);
  77. export type TrackTaskDetailCreationAttributes = InferCreationAttributes<
  78. TrackTaskDetail,
  79. { omit: 'id' | 'createdAt' | 'updatedAt' }
  80. >;
  81. export default TrackTaskDetail;