返回 AiToEarn
oauth2-credential.schema.ts
根目录 / project / aitoearn-backend / libs / channel-db / src / schemas / oauth2-credential.schema.ts
1 import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
2 import { AccountType } from '@yikart/common'
3 import { DEFAULT_SCHEMA_OPTIONS } from '../channel-db.constants'
4 import { BaseTemp } from './time.tamp'
5
6 // 账号状态
7 export enum TokenStatus {
8 NORMAL = 1, // 可用
9 ABNORMAL = 0, // 不可用
10 }
11
12 @Schema({ ...DEFAULT_SCHEMA_OPTIONS, collection: 'oauth2Credential' })
13 export class OAuth2Credential extends BaseTemp {
14 @Prop({
15 required: true,
16 type: String,
17 })
18 accountId: string
19
20 @Prop({
21 required: true,
22 enum: AccountType,
23 })
24 platform: AccountType
25
26 @Prop({
27 required: true,
28 type: String,
29 default: '',
30 })
31 accessToken: string
32
33 @Prop({
34 required: false,
35 type: String,
36 })
37 refreshToken: string
38
39 @Prop({
40 required: true,
41 type: Number,
42 })
43 accessTokenExpiresAt: number
44
45 @Prop({
46 required: false,
47 type: Number,
48 })
49 refreshTokenExpiresAt?: number
50
51 @Prop({
52 required: false,
53 type: String,
54 default: '',
55 })
56 raw?: string
57 }
58
59 export const OAuth2CredentialSchema = SchemaFactory.createForClass(OAuth2Credential)
60
60 lines TYPESCRIPT