trackTask.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. import {
  2. Model,
  3. DataTypes,
  4. CreationOptional,
  5. InferAttributes,
  6. InferCreationAttributes,
  7. } from 'sequelize';
  8. import sequelize from '../sequelizeInstance';
  9. import { TRACK_TASK_STATUS } from '../enumerate';
  10. class TrackTask extends Model<
  11. // eslint-disable-next-line no-use-before-define
  12. InferAttributes<TrackTask>,
  13. // eslint-disable-next-line no-use-before-define
  14. InferCreationAttributes<TrackTask>
  15. > {
  16. declare id: CreationOptional<number>;
  17. declare schoolId: string;
  18. declare semesterId: string;
  19. declare semesterName: string;
  20. declare examId: string;
  21. declare examName: string;
  22. declare courseId: string | null;
  23. declare courseName: string | null;
  24. declare courseCode: string | null;
  25. declare paperNumber: string | null;
  26. declare trackConfig: string;
  27. declare status: number;
  28. declare error: string | null;
  29. declare createdAt: CreationOptional<Date>;
  30. declare updatedAt: CreationOptional<Date>;
  31. }
  32. TrackTask.init(
  33. {
  34. id: {
  35. type: DataTypes.INTEGER,
  36. autoIncrement: true,
  37. primaryKey: true,
  38. },
  39. schoolId: {
  40. type: DataTypes.STRING,
  41. allowNull: false,
  42. },
  43. semesterId: {
  44. type: DataTypes.STRING,
  45. allowNull: false,
  46. },
  47. semesterName: {
  48. type: DataTypes.STRING,
  49. allowNull: false,
  50. },
  51. examId: {
  52. type: DataTypes.STRING,
  53. allowNull: false,
  54. },
  55. examName: {
  56. type: DataTypes.STRING,
  57. allowNull: false,
  58. },
  59. courseId: {
  60. type: DataTypes.STRING,
  61. allowNull: true,
  62. },
  63. courseName: {
  64. type: DataTypes.STRING,
  65. allowNull: true,
  66. },
  67. courseCode: {
  68. type: DataTypes.STRING,
  69. allowNull: true,
  70. },
  71. paperNumber: {
  72. type: DataTypes.STRING,
  73. allowNull: true,
  74. },
  75. trackConfig: {
  76. type: DataTypes.TEXT,
  77. allowNull: false,
  78. comment: '导出设置',
  79. },
  80. status: {
  81. type: DataTypes.INTEGER,
  82. allowNull: false,
  83. defaultValue: TRACK_TASK_STATUS.INIT,
  84. },
  85. error: {
  86. type: DataTypes.STRING,
  87. allowNull: true,
  88. comment: '错误信息',
  89. },
  90. createdAt: DataTypes.DATE,
  91. updatedAt: DataTypes.DATE,
  92. },
  93. {
  94. sequelize,
  95. modelName: 'TrackTask',
  96. underscored: true,
  97. tableName: 'trackTask',
  98. }
  99. );
  100. export type TrackTaskCreationAttributes = InferCreationAttributes<
  101. TrackTask,
  102. { omit: 'id' | 'createdAt' | 'updatedAt' | 'error' }
  103. >;
  104. export type TrackTaskData = InferAttributes<TrackTask>;
  105. export default TrackTask;