trackTaskDetail.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. }
  25. TrackTaskDetail.init(
  26. {
  27. id: {
  28. type: DataTypes.INTEGER.UNSIGNED,
  29. autoIncrement: true,
  30. primaryKey: true,
  31. },
  32. trackTaskId: {
  33. type: DataTypes.INTEGER.UNSIGNED,
  34. allowNull: false,
  35. },
  36. studentName: {
  37. type: DataTypes.STRING,
  38. allowNull: false,
  39. },
  40. studentCode: {
  41. type: DataTypes.STRING,
  42. allowNull: false,
  43. },
  44. courseName: {
  45. type: DataTypes.STRING,
  46. allowNull: false,
  47. },
  48. courseCode: {
  49. type: DataTypes.STRING,
  50. allowNull: false,
  51. },
  52. status: {
  53. type: DataTypes.INTEGER,
  54. allowNull: false,
  55. defaultValue: 0,
  56. // 任务状态:0:未开始,1:运行中,2:已完成
  57. },
  58. error: {
  59. type: DataTypes.TEXT,
  60. allowNull: true,
  61. comment: '错误信息',
  62. },
  63. },
  64. {
  65. sequelize,
  66. modelName: 'TrackTaskDetail',
  67. underscored: true,
  68. tableName: 'trackTaskDetail',
  69. }
  70. );
  71. TrackTask.hasMany(TrackTaskDetail);
  72. TrackTaskDetail.belongsTo(TrackTask);
  73. export type TrackTaskDetailCreationAttributes =
  74. InferCreationAttributes<TrackTaskDetail>;
  75. export default TrackTaskDetail;