返回 AiToEarn
tracing.dto.ts
根目录 / project / aitoearn-electron / server / src / modules / tracing / dto / tracing.dto.ts
1 /*
2 * @Author: nevin
3 * @Date: 2024-08-19 15:58:47
4 * @LastEditTime: 2025-05-06 14:10:37
5 * @LastEditors: nevin
6 * @Description: 跟踪
7 */
8 import { ApiProperty } from '@nestjs/swagger';
9 import { Expose } from 'class-transformer';
10 import {
11 ArrayMaxSize,
12 ArrayMinSize,
13 IsArray,
14 IsDateString,
15 IsEnum,
16 IsNumber,
17 IsOptional,
18 IsString,
19 } from 'class-validator';
20 import { TracingType } from 'src/db/schema/tracing.schema';
21
22 export class CreateTracingDto {
23 @ApiProperty({ title: '类型', required: true })
24 @IsEnum(TracingType, { message: '类型' })
25 @Expose()
26 readonly type: TracingType;
27
28 @ApiProperty({ title: 'Tag', required: true })
29 @IsString({ message: 'Tag' })
30 @Expose()
31 readonly tag: string;
32
33 @ApiProperty({ title: '平台账号ID', required: false })
34 @IsNumber({ allowNaN: false }, { message: '平台账号ID' })
35 @IsOptional()
36 @Expose()
37 readonly accountId?: number;
38
39 @ApiProperty({ title: '描述', required: false })
40 @IsString({ message: '描述' })
41 @IsOptional()
42 @Expose()
43 readonly desc?: string;
44
45 @ApiProperty({ title: '关联数据ID', required: false })
46 @IsString({ message: '关联数据ID' })
47 @IsOptional()
48 @Expose()
49 readonly dataId?: string;
50
51 // 任意类型的数据
52 @ApiProperty({ title: '数据', required: false })
53 @IsOptional()
54 @Expose()
55 readonly data?: any;
56 }
57
58 export class TracingTimeDto {
59 @ApiProperty({ title: '创建时间区间', required: false })
60 @IsArray({ message: '创建时间区间必须是一个数组' })
61 @ArrayMinSize(2, { message: '创建时间区间必须包含两个日期' })
62 @ArrayMaxSize(2, { message: '创建时间区间必须包含两个日期' })
63 @IsDateString({}, { each: true })
64 @IsOptional()
65 @Expose()
66 readonly time?: [Date, Date];
67 }
68
68 lines TYPESCRIPT