trackTask.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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 filterData: string;
  28. declare status: number;
  29. declare error: string | null;
  30. declare createdAt: CreationOptional<Date>;
  31. declare updatedAt: CreationOptional<Date>;
  32. }
  33. TrackTask.init(
  34. {
  35. id: {
  36. type: DataTypes.INTEGER,
  37. autoIncrement: true,
  38. primaryKey: true,
  39. },
  40. schoolId: {
  41. type: DataTypes.STRING,
  42. allowNull: false,
  43. },
  44. semesterId: {
  45. type: DataTypes.STRING,
  46. allowNull: false,
  47. },
  48. semesterName: {
  49. type: DataTypes.STRING,
  50. allowNull: false,
  51. },
  52. examId: {
  53. type: DataTypes.STRING,
  54. allowNull: false,
  55. },
  56. examName: {
  57. type: DataTypes.STRING,
  58. allowNull: false,
  59. },
  60. courseId: {
  61. type: DataTypes.STRING,
  62. allowNull: true,
  63. },
  64. courseName: {
  65. type: DataTypes.STRING,
  66. allowNull: true,
  67. },
  68. courseCode: {
  69. type: DataTypes.STRING,
  70. allowNull: true,
  71. },
  72. paperNumber: {
  73. type: DataTypes.STRING,
  74. allowNull: true,
  75. },
  76. trackConfig: {
  77. type: DataTypes.TEXT,
  78. allowNull: false,
  79. comment: '导出设置',
  80. },
  81. filterData: {
  82. type: DataTypes.TEXT,
  83. allowNull: true,
  84. comment: '详情条件',
  85. },
  86. status: {
  87. type: DataTypes.INTEGER,
  88. allowNull: false,
  89. defaultValue: TRACK_TASK_STATUS.INIT,
  90. },
  91. error: {
  92. type: DataTypes.STRING,
  93. allowNull: true,
  94. comment: '错误信息',
  95. },
  96. createdAt: DataTypes.DATE,
  97. updatedAt: DataTypes.DATE,
  98. },
  99. {
  100. sequelize,
  101. modelName: 'TrackTask',
  102. underscored: true,
  103. tableName: 'trackTask',
  104. }
  105. );
  106. export type TrackTaskCreationAttributes = InferCreationAttributes<
  107. TrackTask,
  108. { omit: 'id' | 'createdAt' | 'updatedAt' | 'error' }
  109. >;
  110. export type TrackTaskData = InferAttributes<TrackTask>;
  111. export default TrackTask;