返回 AiToEarn
feedback.dto.ts
根目录 / project / aitoearn-electron / server / src / modules / other / dto / feedback.dto.ts
1 /*
2 * @Author: nevin
3 * @Date: 2024-08-19 15:58:47
4 * @LastEditTime: 2025-03-17 12:41:12
5 * @LastEditors: nevin
6 * @Description: 反馈
7 */
8 import { ApiProperty } from '@nestjs/swagger';
9 import { Expose, Type } from 'class-transformer';
10 import {
11 ArrayMaxSize,
12 ArrayMinSize,
13 IsArray,
14 IsEnum,
15 IsNotEmpty,
16 IsOptional,
17 IsString,
18 Validate,
19 } from 'class-validator';
20 import { FeedbackType } from 'src/db/schema/feedback.schema';
21
22 export class CreateFeedBackDto {
23 @ApiProperty({ title: '内容', required: true })
24 @IsString({ message: '内容' })
25 @Expose()
26 readonly content: string;
27
28 @ApiProperty({
29 title: '类型',
30 required: false,
31 description: '',
32 })
33 @IsEnum(FeedbackType, { message: '类型' })
34 @IsOptional()
35 @Expose()
36 readonly type?: FeedbackType;
37
38 @ApiProperty({ type: [String], description: '标识数组' })
39 @IsArray()
40 @IsString({ each: true, message: '字符串数组' })
41 @IsOptional()
42 @Expose()
43 readonly tagList?: string[];
44
45 @ApiProperty({ type: [String], description: '文件链接数组' })
46 @IsArray()
47 @IsString({ each: true, message: '文件链接' })
48 @IsOptional()
49 @Expose()
50 readonly fileUrlList?: string[];
51 }
52
53 export class GetFeedbackListDto {
54 @ApiProperty({
55 title: '起始时间',
56 required: false,
57 type: [String],
58 description: '时间范围数组,格式为[startDate, endDate],格式YYYY-MM-DD',
59 example: ['2023-01-01', '2023-12-31'],
60 })
61 @Type(() => Date) // 将传入的字符串自动转换为Date对象
62 @IsArray({ message: '时间范围必须为数组' })
63 @ArrayMinSize(2, { message: '时间范围需要两个元素' })
64 @ArrayMaxSize(2, { message: '时间范围不能超过两个元素' })
65 @Validate(
66 (value: Date[]) => {
67 return value;
68 },
69 {
70 each: true,
71 message: '必须为有效的日期格式',
72 },
73 )
74 @IsOptional()
75 @Expose()
76 readonly time?: [Date, Date];
77
78 @ApiProperty({ type: String })
79 @IsNotEmpty({ message: '用户ID不能为空' })
80 @IsString()
81 @IsOptional()
82 @Expose()
83 userId?: string;
84
85 @ApiProperty({ enum: FeedbackType })
86 @IsEnum(FeedbackType)
87 @IsOptional()
88 @Expose()
89 type?: FeedbackType;
90 }
91
91 lines TYPESCRIPT