trackTask.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import {
  2. Model,
  3. DataTypes,
  4. CreationOptional,
  5. InferAttributes,
  6. InferCreationAttributes,
  7. } from 'sequelize';
  8. import sequelize from '../sequelizeInstance';
  9. class TrackTask extends Model<
  10. // eslint-disable-next-line no-use-before-define
  11. InferAttributes<TrackTask>,
  12. // eslint-disable-next-line no-use-before-define
  13. InferCreationAttributes<TrackTask>
  14. > {
  15. declare id: CreationOptional<number>;
  16. declare schoolId: string;
  17. declare semesterId: string;
  18. declare examId: string;
  19. declare pathRule: string;
  20. declare status: number;
  21. declare createdAt: CreationOptional<Date>;
  22. declare updatedAt: CreationOptional<Date>;
  23. }
  24. TrackTask.init(
  25. {
  26. id: {
  27. type: DataTypes.INTEGER,
  28. autoIncrement: true,
  29. primaryKey: true,
  30. },
  31. schoolId: {
  32. type: DataTypes.STRING,
  33. allowNull: false,
  34. },
  35. semesterId: {
  36. type: DataTypes.STRING,
  37. allowNull: false,
  38. },
  39. examId: {
  40. type: DataTypes.STRING,
  41. allowNull: false,
  42. },
  43. pathRule: {
  44. type: DataTypes.STRING,
  45. allowNull: false,
  46. comment: '保存路径规则',
  47. },
  48. status: {
  49. type: DataTypes.INTEGER,
  50. allowNull: false,
  51. defaultValue: 0,
  52. // 任务状态:0:未开始,1:运行中,2:已完成
  53. },
  54. createdAt: DataTypes.DATE,
  55. updatedAt: DataTypes.DATE,
  56. },
  57. {
  58. sequelize,
  59. modelName: 'TrackTask',
  60. underscored: true,
  61. tableName: 'trackTask',
  62. }
  63. );
  64. export type TrackTaskCreationAttributes = InferCreationAttributes<
  65. TrackTask,
  66. { omit: 'id' | 'createdAt' | 'updatedAt' }
  67. >;
  68. export default TrackTask;