返回 AiToEarn
accountToken.schema.ts
根目录 / project / aitoearn-electron / server / src / db / schema / accountToken.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 TokenPlatform {
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 TokenStatus {
18 // 未失效
19 USABLE = 0,
20 // 失效
21 DISABLE = 1,
22 }
23
24 @Schema({
25 collection: 'accountToken',
26 versionKey: false,
27 toJSON: { virtuals: true },
28 toObject: { virtuals: true },
29 timestamps: false,
30 })
31 export class AccountToken extends TimeTemp {
32
33 @Prop({
34 required: true,
35 type: String,
36 })
37 userId: string;
38
39 @Prop({
40 required: true,
41 enum: TokenPlatform,
42 })
43 platform: TokenPlatform;
44
45 @Prop({
46 required: true,
47 type: String,
48 default: '',
49 })
50 refreshToken: string;
51
52 @Prop({
53 required: true,
54 unique: true,
55 })
56 accountId: string;
57
58 @Prop({
59 required: true,
60 default: TokenStatus.USABLE,
61 })
62 status: TokenStatus;
63
64 @Prop({
65 required: true,
66 type: Date,
67 })
68 createTime: Date;
69
70 @Prop({
71 required: true,
72 type: Date,
73 })
74 expiresAt: Date;
75
76 @Prop({
77 required: true,
78 type: Date,
79 })
80 updateTime: Date;
81 }
82
83 export const AccountTokenSchema = SchemaFactory.createForClass(AccountToken);
84
84 lines TYPESCRIPT