返回 AiToEarn
account.dto.ts
根目录 / project / aitoearn-electron / server / src / modules / account / dto / account.dto.ts
1 import { ApiProperty, PartialType } from '@nestjs/swagger';
2 import {
3 IsArray,
4 IsDate,
5 IsEnum,
6 IsNumber,
7 IsOptional,
8 IsString,
9 } from 'class-validator';
10 import { Expose } from 'class-transformer';
11 import { AccountStatus, AccountType } from '../../../db/schema/account.schema';
12
13 export class CreateAccountDto {
14 @ApiProperty({ description: '平台类型', enum: AccountType })
15 @IsEnum(AccountType)
16 @Expose()
17 type: AccountType;
18
19 @ApiProperty({ description: '登录Cookie' })
20 @IsString()
21 @Expose()
22 loginCookie: string;
23
24 @ApiProperty({ description: '登录时间' })
25 @IsOptional()
26 @IsDate()
27 @Expose()
28 loginTime?: Date;
29
30 @ApiProperty({ description: '平台用户ID' })
31 @IsString()
32 @Expose()
33 uid: string;
34
35 @ApiProperty({ description: '账号' })
36 @IsString()
37 @Expose()
38 account: string;
39
40 @ApiProperty({ description: '头像' })
41 @IsString()
42 @Expose()
43 avatar: string;
44
45 @ApiProperty({ description: '昵称' })
46 @IsString()
47 @Expose()
48 nickname: string;
49
50 @ApiProperty({ description: '粉丝数' })
51 @IsNumber()
52 @IsOptional()
53 @Expose()
54 fansCount?: number;
55
56 @ApiProperty({ description: '阅读数' })
57 @IsNumber()
58 @IsOptional()
59 @Expose()
60 readCount?: number;
61
62 @ApiProperty({ description: '点赞数' })
63 @IsNumber()
64 @IsOptional()
65 @Expose()
66 likeCount?: number;
67
68 @ApiProperty({ description: '收藏数' })
69 @IsNumber()
70 @IsOptional()
71 @Expose()
72 collectCount?: number;
73
74 @ApiProperty({ description: '转发数' })
75 @IsNumber()
76 @IsOptional()
77 @Expose()
78 forwardCount?: number;
79
80 @ApiProperty({ description: '评论数' })
81 @IsNumber()
82 @IsOptional()
83 @Expose()
84 commentCount?: number;
85
86 @ApiProperty({ description: '最后统计时间' })
87 @IsDate()
88 @IsOptional()
89 @Expose()
90 lastStatsTime?: Date;
91
92 @ApiProperty({ description: '作品数' })
93 @IsNumber()
94 @IsOptional()
95 @Expose()
96 workCount?: number;
97
98 @ApiProperty({ description: '收入' })
99 @IsNumber()
100 @IsOptional()
101 @Expose()
102 income?: number;
103
104 @ApiProperty({ description: '账户组ID' })
105 @IsNumber()
106 @IsOptional()
107 @Expose()
108 groupId?: number;
109 }
110
111 export class UpdateAccountDto extends PartialType(CreateAccountDto) {
112 @ApiProperty({ description: '更新ID' })
113 @IsNumber()
114 @Expose()
115 id: number;
116 }
117
118 export class AccountIdDto {
119 @ApiProperty({ description: '账号ID' })
120 @IsNumber()
121 @Expose()
122 id: number;
123 }
124
125 export class UpdateAccountStatusDto extends AccountIdDto {
126 @ApiProperty({ description: '状态' })
127 @IsEnum(AccountStatus, {
128 message: `status must be one of these values: ${Object.values(
129 AccountStatus,
130 ).join(', ')}`,
131 })
132 @Expose()
133 status: AccountStatus;
134 }
135
136 export class AccountListByIdsDto {
137 @ApiProperty({ description: '账号ID数组', type: [Number] })
138 @IsArray()
139 @IsNumber({}, { each: true })
140 @Expose()
141 ids: number[];
142 }
143
144 export class AccountStatisticsDto {
145 @ApiProperty({ description: '账户类型', enum: AccountType, required: false })
146 @IsEnum(AccountType)
147 @IsOptional()
148 @Expose()
149 type?: AccountType;
150 }
151
152 export class UpdateAccountStatisticsDto {
153 @ApiProperty({ description: '账号ID' })
154 @IsNumber()
155 @Expose()
156 id: number;
157
158 @ApiProperty({ description: '作品数' })
159 @IsNumber()
160 @IsOptional()
161 @Expose()
162 workCount?: number;
163
164 @ApiProperty({ description: '粉丝数' })
165 @IsNumber()
166 @IsOptional()
167 @Expose()
168 fansCount?: number;
169
170 @ApiProperty({ description: '阅读数' })
171 @IsNumber()
172 @IsOptional()
173 @Expose()
174 readCount?: number;
175
176 @ApiProperty({ description: '点赞数' })
177 @IsNumber()
178 @IsOptional()
179 @Expose()
180 likeCount?: number;
181
182 @ApiProperty({ description: '收藏数' })
183 @IsNumber()
184 @IsOptional()
185 @Expose()
186 collectCount?: number;
187
188 @ApiProperty({ description: '评论数' })
189 @IsNumber()
190 @IsOptional()
191 @Expose()
192 commentCount?: number;
193
194 @ApiProperty({ description: '收入' })
195 @IsNumber()
196 @IsOptional()
197 @Expose()
198 income?: number;
199 }
200
201 export class GoogleLoginDto {
202 @ApiProperty({ description: 'Google客户端ID' })
203 @IsString()
204 @Expose()
205 clientId: string;
206
207 @ApiProperty({ description: 'Google认证凭证' })
208 @IsString()
209 @Expose()
210 credential: string;
211 }
212
213 export class DeleteAccountsDto {
214 @ApiProperty({ description: '要删除的ID' })
215 @IsArray()
216 @IsNumber({}, { each: true })
217 @Expose()
218 ids: string[];
219 }
220
220 lines TYPESCRIPT