| 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: publish |
| 7 | */ |
| 8 | import { ApiProperty } from '@nestjs/swagger'; |
| 9 | import { Expose, Transform } from 'class-transformer'; |
| 10 | import { |
| 11 | ArrayMaxSize, |
| 12 | ArrayMinSize, |
| 13 | IsArray, |
| 14 | IsDate, |
| 15 | IsEnum, |
| 16 | IsNumber, |
| 17 | IsOptional, |
| 18 | IsString, |
| 19 | } from 'class-validator'; |
| 20 | import { AccountType } from 'src/db/schema/account.schema'; |
| 21 | import { PubType, PubStatus } from 'src/db/schema/pubRecord.schema'; |
| 22 | |
| 23 | export class CreatePublishDto { |
| 24 | @ApiProperty({ |
| 25 | title: '类型', |
| 26 | required: true, |
| 27 | enum: PubType, |
| 28 | description: '类型', |
| 29 | }) |
| 30 | @IsEnum(PubType, { message: '类型' }) |
| 31 | @Expose() |
| 32 | readonly type: PubType; |
| 33 | |
| 34 | @ApiProperty({ title: '标题', required: true }) |
| 35 | @IsString({ message: '标题' }) |
| 36 | @Expose() |
| 37 | readonly title: string; |
| 38 | |
| 39 | @ApiProperty({ title: '描述', required: true }) |
| 40 | @IsString({ message: '描述' }) |
| 41 | @Expose() |
| 42 | readonly desc: string; |
| 43 | |
| 44 | @ApiProperty({ title: '账户ID', required: true }) |
| 45 | @IsNumber({ allowNaN: false }, { message: '账户ID' }) |
| 46 | @Expose() |
| 47 | readonly accountId: number; |
| 48 | |
| 49 | @ApiProperty({ title: '视频路径', required: false }) |
| 50 | @IsString({ message: '视频路径' }) |
| 51 | @IsOptional() |
| 52 | @Expose() |
| 53 | readonly videoPath?: string; |
| 54 | |
| 55 | @ApiProperty({ title: '定时发布日期', required: false }) |
| 56 | @IsDate({ message: '定时发布日期必须是有效的日期' }) |
| 57 | @IsOptional() |
| 58 | @Expose() |
| 59 | @Transform(({ value }) => new Date(value)) |
| 60 | readonly timingTime?: Date; |
| 61 | |
| 62 | @ApiProperty({ title: '封面路径,展示给前台用', required: false }) |
| 63 | @IsString({ message: '封面路径,展示给前台用' }) |
| 64 | @IsOptional() |
| 65 | @Expose() |
| 66 | readonly coverPath?: string; |
| 67 | |
| 68 | @ApiProperty({ title: '通用封面路径', required: false }) |
| 69 | @IsString({ message: '通用封面路径' }) |
| 70 | @IsOptional() |
| 71 | @Expose() |
| 72 | readonly commonCoverPath?: string; |
| 73 | |
| 74 | @ApiProperty({ title: '发布日期', required: false }) |
| 75 | @IsDate({ message: '发布日期必须是有效的日期' }) |
| 76 | @IsOptional() |
| 77 | @Expose() |
| 78 | @Transform(({ value }) => new Date(value)) |
| 79 | readonly publishTime?: Date; |
| 80 | |
| 81 | @ApiProperty({ |
| 82 | title: '发布状态', |
| 83 | required: false, |
| 84 | enum: PubStatus, |
| 85 | description: '发布状态', |
| 86 | }) |
| 87 | @IsEnum(PubStatus, { message: '发布状态' }) |
| 88 | @IsOptional() |
| 89 | @Expose() |
| 90 | readonly status?: PubStatus; |
| 91 | } |
| 92 | |
| 93 | export class PubRecordListDto { |
| 94 | @ApiProperty({ |
| 95 | title: '账户类型', |
| 96 | required: false, |
| 97 | enum: AccountType, |
| 98 | description: '账户类型', |
| 99 | }) |
| 100 | @IsEnum(AccountType, { message: '账户类型' }) |
| 101 | @IsOptional() |
| 102 | @Expose() |
| 103 | readonly type?: AccountType; |
| 104 | |
| 105 | @ApiProperty({ title: '创建时间区间', required: false }) |
| 106 | @IsArray({ message: '创建时间区间必须是一个数组' }) |
| 107 | @ArrayMinSize(2, { message: '创建时间区间必须包含两个日期' }) |
| 108 | @ArrayMaxSize(2, { message: '创建时间区间必须包含两个日期' }) |
| 109 | @IsDate({ each: true, message: '创建时间区间中的每个元素必须是有效的日期' }) |
| 110 | @IsOptional() |
| 111 | @Expose() |
| 112 | @Transform(({ value }) => value ? value.map((v: string) => new Date(v)) : undefined) |
| 113 | readonly time?: [Date, Date]; |
| 114 | } |
| 115 |