返回 AiToEarn
user-task.schema.ts
根目录 / project / aitoearn-electron / server / src / db / schema / user-task.schema.ts
1 /*
2 * @Author: nevin
3 * @Date: 2024-09-02 14:45:57
4 * @LastEditTime: 2025-05-06 14:15:29
5 * @LastEditors: nevin
6 * @Description: 用户的任务
7 */
8 import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
9 import { Types } from 'mongoose';
10 import { TimeTemp } from './time.tamp';
11 import { AccountType } from './account.schema';
12
13 export enum UserTaskStatus {
14 DODING = 'doing', // 进行中
15 PENDING = 'pending', // 待审核
16 APPROVED = 'approved', // 已通过
17 REJECTED = 'rejected', // 已拒绝
18 CANCELLED = 'cancelled', // 已取消
19 DEL = 'del', // 已删除或回退
20 }
21
22 @Schema({
23 toJSON: { virtuals: true },
24 toObject: { virtuals: true },
25 })
26 export class AutoData {
27 @Prop({
28 required: true,
29 })
30 status: -1 | 0 | 1;
31
32 @Prop({ required: false })
33 message?: string;
34 }
35
36 @Schema({
37 collection: 'user_task',
38 versionKey: false,
39 toJSON: { virtuals: true },
40 toObject: { virtuals: true },
41 timestamps: false,
42 })
43 export class UserTask extends TimeTemp {
44 id: string;
45
46 @Prop({ type: Types.ObjectId, ref: 'User', required: true, index: true })
47 userId: Types.ObjectId;
48
49 @Prop({ type: Types.ObjectId, ref: 'Task', required: true })
50 taskId: Types.ObjectId;
51
52 @Prop({
53 type: String,
54 enum: UserTaskStatus,
55 default: UserTaskStatus.DODING,
56 index: true,
57 })
58 status: UserTaskStatus;
59
60 @Prop({
61 required: true,
62 enum: AccountType,
63 })
64 accountType: AccountType;
65
66 @Prop({
67 required: true,
68 })
69 uid: string; // 平台的用户ID
70
71 @Prop({
72 required: true,
73 })
74 account: string; // 平台的账号
75
76 @Prop({ required: true, default: 0 })
77 keepTime: number; // 保持时间(秒)
78
79 @Prop()
80 submissionUrl?: string; // 提交的视频、文章或截图URL
81
82 @Prop({
83 required: false,
84 })
85 taskMaterialId?: string; // 任务的素材ID
86
87 @Prop({ type: [String] })
88 screenshotUrls?: string[]; // 任务完成截图
89
90 @Prop()
91 qrCodeScanResult?: string; // 二维码扫描结果
92
93 @Prop()
94 submissionTime?: Date; // 提交时间
95
96 @Prop()
97 completionTime?: Date; // 完成时间
98
99 @Prop()
100 rejectionReason?: string; // 拒绝原因
101
102 @Prop({ type: Object })
103 metadata?: Record<string, any>; // 额外信息,如审核反馈等
104
105 @Prop({ default: false })
106 isFirstTimeSubmission: boolean; // 是否首次提交,用于确定是否给予首次奖励
107
108 @Prop()
109 verificationNote?: string; // 人工核查备注
110
111 @Prop({
112 required: true,
113 default: 0,
114 })
115 reward: number; // 奖励金额
116
117 @Prop()
118 rewardTime?: Date; // 奖励发放时间
119
120 @Prop({ type: Types.ObjectId, ref: 'User' })
121 verifiedBy?: Types.ObjectId; // 核查人员ID
122
123 @Prop({ type: Object, required: false, default: {} })
124 autoData?: AutoData;
125 }
126
127 export const UserTaskSchema = SchemaFactory.createForClass(UserTask);
128
128 lines TYPESCRIPT