trackTaskDetail.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. import { TRACK_TASK_DETAIL_STATUS } from '../enumerate';
  11. class TrackTaskDetail extends Model<
  12. // eslint-disable-next-line no-use-before-define
  13. InferAttributes<TrackTaskDetail>,
  14. // eslint-disable-next-line no-use-before-define
  15. InferCreationAttributes<TrackTaskDetail>
  16. > {
  17. declare id: CreationOptional<number>;
  18. declare trackTaskId: number;
  19. declare studentId: string;
  20. declare studentName: string;
  21. declare studentCode: string;
  22. declare className: string;
  23. declare status: number;
  24. declare error: string | null;
  25. declare createdAt: CreationOptional<Date>;
  26. declare updatedAt: CreationOptional<Date>;
  27. }
  28. TrackTaskDetail.init(
  29. {
  30. id: {
  31. type: DataTypes.INTEGER,
  32. autoIncrement: true,
  33. primaryKey: true,
  34. },
  35. trackTaskId: {
  36. type: DataTypes.INTEGER,
  37. allowNull: false,
  38. },
  39. studentId: {
  40. type: DataTypes.STRING,
  41. allowNull: false,
  42. },
  43. studentName: {
  44. type: DataTypes.STRING,
  45. allowNull: false,
  46. },
  47. studentCode: {
  48. type: DataTypes.STRING,
  49. allowNull: false,
  50. },
  51. className: {
  52. type: DataTypes.STRING,
  53. allowNull: false,
  54. },
  55. status: {
  56. type: DataTypes.INTEGER,
  57. allowNull: false,
  58. defaultValue: TRACK_TASK_DETAIL_STATUS.INIT,
  59. },
  60. error: {
  61. type: DataTypes.STRING,
  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' | 'error' }
  80. >;
  81. export type TrackTaskDetailData = InferAttributes<TrackTaskDetail>;
  82. export default TrackTaskDetail;