trackTaskDetail.ts 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 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,
  31. autoIncrement: true,
  32. primaryKey: true,
  33. },
  34. trackTaskId: {
  35. type: DataTypes.INTEGER,
  36. allowNull: false,
  37. },
  38. studentId: {
  39. type: DataTypes.STRING,
  40. allowNull: false,
  41. },
  42. studentName: {
  43. type: DataTypes.STRING,
  44. allowNull: false,
  45. },
  46. studentCode: {
  47. type: DataTypes.STRING,
  48. allowNull: false,
  49. },
  50. status: {
  51. type: DataTypes.INTEGER,
  52. allowNull: false,
  53. defaultValue: TRACK_TASK_DETAIL_STATUS.INIT,
  54. },
  55. error: {
  56. type: DataTypes.STRING,
  57. allowNull: true,
  58. comment: '错误信息',
  59. },
  60. createdAt: DataTypes.DATE,
  61. updatedAt: DataTypes.DATE,
  62. },
  63. {
  64. sequelize,
  65. modelName: 'TrackTaskDetail',
  66. underscored: true,
  67. tableName: 'trackTaskDetail',
  68. }
  69. );
  70. TrackTask.hasMany(TrackTaskDetail);
  71. TrackTaskDetail.belongsTo(TrackTask);
  72. export type TrackTaskDetailCreationAttributes = InferCreationAttributes<
  73. TrackTaskDetail,
  74. { omit: 'id' | 'createdAt' | 'updatedAt' | 'error' }
  75. >;
  76. export default TrackTaskDetail;