| 1 | /* |
| 2 | * @Author: nevin |
| 3 | * @Date: 2025-02-18 22:32:02 |
| 4 | * @LastEditTime: 2025-03-04 15:23:22 |
| 5 | * @LastEditors: nevin |
| 6 | * @Description: 任务-素材 |
| 7 | */ |
| 8 | import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; |
| 9 | import { TimeTemp } from './time.tamp'; |
| 10 | import { TaskType } from './task.schema'; |
| 11 | |
| 12 | @Schema({ |
| 13 | toJSON: { virtuals: true }, |
| 14 | toObject: { virtuals: true }, |
| 15 | }) |
| 16 | export class TaskArticleImg { |
| 17 | @Prop({ required: false, default: '' }) |
| 18 | content?: string; // 内容 |
| 19 | |
| 20 | @Prop({ required: true }) |
| 21 | imageUrl: string; |
| 22 | } |
| 23 | |
| 24 | @Schema({ |
| 25 | collection: 'taskMaterial', |
| 26 | versionKey: false, |
| 27 | toJSON: { virtuals: true }, |
| 28 | toObject: { virtuals: true }, |
| 29 | timestamps: false, |
| 30 | }) |
| 31 | export class TaskMaterial extends TimeTemp { |
| 32 | id: string; |
| 33 | |
| 34 | @Prop({ required: true, index: true }) |
| 35 | taskId: string; |
| 36 | |
| 37 | @Prop({ required: true, enum: TaskType }) |
| 38 | type: TaskType; |
| 39 | |
| 40 | @Prop({ required: false }) |
| 41 | title?: string; // 标题 |
| 42 | |
| 43 | @Prop({ required: false }) |
| 44 | coverUrl?: string; // 封面图 |
| 45 | |
| 46 | @Prop({ required: false }) |
| 47 | temp?: string; // 模板字符 |
| 48 | |
| 49 | @Prop({ |
| 50 | required: false, |
| 51 | }) |
| 52 | desc?: string; |
| 53 | |
| 54 | // 图片列表 |
| 55 | @Prop({ required: true, type: [TaskArticleImg], default: [] }) |
| 56 | imageList: TaskArticleImg[]; |
| 57 | |
| 58 | // 已使用次数 |
| 59 | @Prop({ required: true, default: 0 }) |
| 60 | usedCount: number; |
| 61 | } |
| 62 | |
| 63 | export const TaskMaterialSchema = SchemaFactory.createForClass(TaskMaterial); |
| 64 |