返回 AiToEarn
account.schema.ts
根目录 / project / aitoearn-electron / server / src / db / schema / account.schema.ts
1 import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
2 import { TimeTemp } from './time.tamp';
3 import { Types } from 'mongoose';
4
5 // 平台类型
6 export enum AccountType {
7 Douyin = 'douyin', // 抖音
8 Xhs = 'xhs', // 小红书
9 WxSph = 'wxSph', // 微信视频号
10 KWAI = 'KWAI', // 快手
11 YOUTUBE = 'youtube', // youtube
12 TWITTER = 'twitter', // twitter
13 TIKTOK = 'tiktok', // tiktok
14 }
15
16 // 账号状态
17 export enum AccountStatus {
18 // 未失效
19 USABLE = 0,
20 // 失效
21 DISABLE = 1,
22 }
23
24 @Schema({
25 collection: 'account',
26 versionKey: false,
27 toJSON: { virtuals: true },
28 toObject: { virtuals: true },
29 timestamps: false,
30 })
31 export class Account extends TimeTemp {
32 @Prop({
33 required: true,
34 unique: true,
35 type: Number,
36 index: true,
37 })
38 id: number;
39
40 @Prop({
41 required: true,
42 type: String,
43 })
44 userId: string;
45
46 @Prop({
47 required: true,
48 enum: AccountType,
49 })
50 type: AccountType;
51
52 @Prop({
53 required: true,
54 type: String,
55 })
56 loginCookie: string;
57
58 @Prop({
59 required: false,
60 type: String,
61 default: '',
62 })
63 token: string; // 其他token 目前抖音用
64
65 @Prop({
66 required: false,
67 type: Date,
68 })
69 loginTime?: Date;
70
71 @Prop({
72 required: true,
73 })
74 uid: string;
75
76 @Prop({
77 required: true,
78 })
79 account: string;
80
81 @Prop({
82 required: true,
83 })
84 avatar: string;
85
86 @Prop({
87 required: true,
88 })
89 nickname: string;
90
91 @Prop({
92 required: true,
93 default: 0,
94 })
95 fansCount: number;
96
97 @Prop({
98 required: true,
99 default: 0,
100 })
101 readCount: number;
102
103 @Prop({
104 required: true,
105 default: 0,
106 })
107 likeCount: number;
108
109 @Prop({
110 required: true,
111 default: 0,
112 })
113 collectCount: number;
114
115 @Prop({
116 required: true,
117 default: 0,
118 })
119 forwardCount: number;
120
121 @Prop({
122 required: true,
123 default: 0,
124 })
125 commentCount: number;
126
127 @Prop({
128 required: false,
129 type: Date,
130 })
131 lastStatsTime?: Date;
132
133 @Prop({
134 required: true,
135 default: 0,
136 })
137 workCount: number;
138
139 @Prop({
140 required: true,
141 default: 0,
142 })
143 income: number;
144
145 // 账户关联组,与 accountGroup.id 关联
146 @Prop({ type: Number, required: true })
147 groupId: number;
148
149 @Prop({
150 required: true,
151 default: AccountStatus.USABLE,
152 })
153 status: AccountStatus; // 登录状态,用于判断是否失效
154
155 @Prop({
156 required: false,
157 })
158 googleId: string;
159
160 // @Prop({
161 // required: false,
162 // })
163 // accessToken: string;
164
165 // @Prop({
166 // required: false,
167 // })
168 // refreshToken: string;
169 }
170
171 export const AccountSchema = SchemaFactory.createForClass(Account);
172
172 lines TYPESCRIPT