import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { Type } from 'class-transformer'; import { IsInt, IsNotEmpty, IsOptional, IsString, Max, MaxLength, Min, } from 'class-validator'; export class CreateBannerDto { @ApiProperty({ description: '轮播标题' }) @IsString() @IsNotEmpty({ message: '标题不能为空' }) @MaxLength(100) title: string; @ApiProperty({ description: '图片地址' }) @IsString() @IsNotEmpty({ message: '图片不能为空' }) image: string; @ApiPropertyOptional({ description: '跳转链接', default: '' }) @IsString() @IsOptional() @MaxLength(255) link?: string; @ApiPropertyOptional({ description: '排序值', default: 0 }) @IsInt() @Min(0) @Max(99999) @IsOptional() @Type(() => Number) sort?: number; @ApiPropertyOptional({ description: '是否展示 1是0否', default: 1 }) @IsInt() @Min(0) @Max(1) @IsOptional() @Type(() => Number) isShow?: number; } export class UpdateBannerDto extends CreateBannerDto {} export class QueryBannerDto { @ApiPropertyOptional({ description: '页码', default: 1 }) @IsInt() @Min(1) @IsOptional() @Type(() => Number) page?: number; @ApiPropertyOptional({ description: '每页数量', default: 10 }) @IsInt() @Min(1) @Max(100) @IsOptional() @Type(() => Number) pageSize?: number; @ApiPropertyOptional({ description: '关键词(标题)' }) @IsString() @IsOptional() keyword?: string; }