trackTask.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 examId: string;
  20. declare extType: string;
  21. declare pictureType: string;
  22. declare outputDir: string;
  23. declare status: number;
  24. declare createdAt: CreationOptional<Date>;
  25. declare updatedAt: CreationOptional<Date>;
  26. }
  27. TrackTask.init(
  28. {
  29. id: {
  30. type: DataTypes.INTEGER,
  31. autoIncrement: true,
  32. primaryKey: true,
  33. },
  34. schoolId: {
  35. type: DataTypes.STRING,
  36. allowNull: false,
  37. },
  38. semesterId: {
  39. type: DataTypes.STRING,
  40. allowNull: false,
  41. },
  42. examId: {
  43. type: DataTypes.STRING,
  44. allowNull: false,
  45. },
  46. extType: {
  47. type: DataTypes.STRING,
  48. allowNull: false,
  49. comment: '文件类型',
  50. },
  51. pictureType: {
  52. type: DataTypes.STRING,
  53. allowNull: false,
  54. comment: '图片类型',
  55. },
  56. outputDir: {
  57. type: DataTypes.STRING,
  58. allowNull: false,
  59. comment: '保存目录',
  60. },
  61. status: {
  62. type: DataTypes.INTEGER,
  63. allowNull: false,
  64. defaultValue: TRACK_TASK_STATUS.INIT,
  65. },
  66. createdAt: DataTypes.DATE,
  67. updatedAt: DataTypes.DATE,
  68. },
  69. {
  70. sequelize,
  71. modelName: 'TrackTask',
  72. underscored: true,
  73. tableName: 'trackTask',
  74. }
  75. );
  76. export type TrackTaskCreationAttributes = InferCreationAttributes<
  77. TrackTask,
  78. { omit: 'id' | 'createdAt' | 'updatedAt' }
  79. >;
  80. export default TrackTask;