| 1 | /* |
| 2 | * @Author: nevin |
| 3 | * @Date: 2024-09-02 14:45:57 |
| 4 | * @LastEditTime: 2025-02-22 12:37:22 |
| 5 | * @LastEditors: nevin |
| 6 | * @Description: 草稿箱 |
| 7 | */ |
| 8 | import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose' |
| 9 | import { AccountType, UserType } from '@yikart/common' |
| 10 | import { DEFAULT_SCHEMA_OPTIONS } from '../mongodb.constants' |
| 11 | import { WithTimestampSchema } from './timestamp.schema' |
| 12 | |
| 13 | @Schema({ ...DEFAULT_SCHEMA_OPTIONS, collection: 'materialGroup' }) |
| 14 | export class MaterialGroup extends WithTimestampSchema { |
| 15 | id: string |
| 16 | |
| 17 | @Prop({ |
| 18 | required: true, |
| 19 | index: true, |
| 20 | }) |
| 21 | userId: string |
| 22 | |
| 23 | @Prop({ |
| 24 | required: true, |
| 25 | index: true, |
| 26 | default: UserType.User, |
| 27 | }) |
| 28 | userType: UserType |
| 29 | |
| 30 | @Prop({ |
| 31 | required: true, |
| 32 | index: true, |
| 33 | }) |
| 34 | name: string |
| 35 | |
| 36 | @Prop({ |
| 37 | required: false, |
| 38 | }) |
| 39 | desc?: string |
| 40 | |
| 41 | // 是否默认 |
| 42 | @Prop({ |
| 43 | required: true, |
| 44 | index: true, |
| 45 | default: false, |
| 46 | }) |
| 47 | isDefault: boolean |
| 48 | |
| 49 | // 平台限制,空数组表示不限制 |
| 50 | @Prop({ |
| 51 | required: false, |
| 52 | type: [String], |
| 53 | enum: AccountType, |
| 54 | index: true, |
| 55 | default: [], |
| 56 | }) |
| 57 | platforms: AccountType[] |
| 58 | } |
| 59 | |
| 60 | export const MaterialGroupSchema = SchemaFactory.createForClass(MaterialGroup) |
| 61 |