返回 AiToEarn
cfg.schema.ts
根目录 / project / aitoearn-electron / server / src / db / schema / cfg.schema.ts
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 { ONOFF } from 'src/global/enum/all.enum';
11
12 export enum CfgType {
13 comment = 'comment', // 通用
14 }
15
16 @Schema({
17 collection: 'cfg',
18 versionKey: false,
19 toJSON: { virtuals: true },
20 toObject: { virtuals: true },
21 timestamps: false,
22 })
23 export class Cfg extends TimeTemp {
24 id: string;
25
26 @Prop({
27 required: true,
28 type: String,
29 unique: true,
30 })
31 key: string;
32
33 @Prop({
34 required: true,
35 type: String,
36 })
37 title: string;
38
39 @Prop({
40 required: true,
41 type: Object,
42 })
43 content: any;
44
45 @Prop({
46 required: true,
47 enum: CfgType,
48 default: CfgType.comment,
49 })
50 type: CfgType;
51
52 @Prop({
53 required: true,
54 enum: ONOFF,
55 default: ONOFF.ON,
56 })
57 status: ONOFF;
58
59 @Prop({
60 required: false,
61 type: String,
62 default: '',
63 })
64 desc?: string;
65 }
66
67 export const CfgSchema = SchemaFactory.createForClass(Cfg);
68
68 lines TYPESCRIPT