| 1 | import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; |
| 2 | import { TimeTemp } from './time.tamp'; |
| 3 | |
| 4 | export enum PubType { |
| 5 | VIDEO = 'video', // 视频 |
| 6 | ARTICLE = 'article', // 文章 |
| 7 | ImageText = 'image-text', // 图文 |
| 8 | } |
| 9 | |
| 10 | export enum PubStatus { |
| 11 | UNPUBLISH = 0, // 未发布/草稿 |
| 12 | RELEASED = 1, // 已发布 |
| 13 | FAIL = 2, // 发布失败 |
| 14 | PartSuccess = 3, // 部分成功 |
| 15 | } |
| 16 | |
| 17 | @Schema({ |
| 18 | collection: 'pubRecord', |
| 19 | versionKey: false, |
| 20 | toJSON: { virtuals: true }, |
| 21 | toObject: { virtuals: true }, |
| 22 | timestamps: false, |
| 23 | }) |
| 24 | export class PubRecord extends TimeTemp { |
| 25 | @Prop({ |
| 26 | required: true, |
| 27 | unique: true, |
| 28 | type: Number, |
| 29 | }) |
| 30 | id: number; |
| 31 | |
| 32 | @Prop({ |
| 33 | required: true, |
| 34 | }) |
| 35 | userId: string; |
| 36 | |
| 37 | @Prop({ |
| 38 | required: true, |
| 39 | enum: PubType, |
| 40 | }) |
| 41 | type: PubType; |
| 42 | |
| 43 | @Prop({ |
| 44 | required: true, |
| 45 | default: '', |
| 46 | }) |
| 47 | title: string; |
| 48 | |
| 49 | @Prop({ |
| 50 | required: true, |
| 51 | default: '', |
| 52 | }) |
| 53 | desc: string; |
| 54 | |
| 55 | @Prop({ |
| 56 | required: true, |
| 57 | }) |
| 58 | accountId: number; |
| 59 | |
| 60 | @Prop({ |
| 61 | required: false, |
| 62 | }) |
| 63 | videoPath?: string; |
| 64 | |
| 65 | @Prop({ |
| 66 | required: false, |
| 67 | type: Date, |
| 68 | }) |
| 69 | timingTime?: Date; // 定时发布日期 |
| 70 | |
| 71 | @Prop({ |
| 72 | required: false, |
| 73 | }) |
| 74 | coverPath?: string; // '封面路径,展示给前台用 |
| 75 | |
| 76 | @Prop({ |
| 77 | required: false, |
| 78 | }) |
| 79 | commonCoverPath?: string; // 通用封面路径 |
| 80 | |
| 81 | @Prop({ |
| 82 | required: true, |
| 83 | type: Date, |
| 84 | }) |
| 85 | publishTime: Date; |
| 86 | |
| 87 | @Prop({ |
| 88 | required: true, |
| 89 | enum: PubStatus, |
| 90 | default: PubStatus.UNPUBLISH, |
| 91 | }) |
| 92 | status: PubStatus; |
| 93 | } |
| 94 | |
| 95 | export const PubRecordSchema = SchemaFactory.createForClass(PubRecord); |
| 96 |