87 lines
1.8 KiB
TypeScript
87 lines
1.8 KiB
TypeScript
|
|
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||
|
|
import { Type } from 'class-transformer';
|
||
|
|
import {
|
||
|
|
IsInt,
|
||
|
|
IsNotEmpty,
|
||
|
|
IsOptional,
|
||
|
|
IsString,
|
||
|
|
Max,
|
||
|
|
MaxLength,
|
||
|
|
Min,
|
||
|
|
} from 'class-validator';
|
||
|
|
|
||
|
|
export class CreateProductDto {
|
||
|
|
@ApiProperty({ description: '分类ID' })
|
||
|
|
@IsInt()
|
||
|
|
@Min(1)
|
||
|
|
@Type(() => Number)
|
||
|
|
categoryId: number;
|
||
|
|
|
||
|
|
@ApiProperty({ description: '产品名称' })
|
||
|
|
@IsString()
|
||
|
|
@IsNotEmpty({ message: '产品名称不能为空' })
|
||
|
|
@MaxLength(100)
|
||
|
|
name: string;
|
||
|
|
|
||
|
|
@ApiProperty({ description: '封面图' })
|
||
|
|
@IsString()
|
||
|
|
@IsNotEmpty({ message: '封面图不能为空' })
|
||
|
|
cover: string;
|
||
|
|
|
||
|
|
@ApiPropertyOptional({ description: '简短描述' })
|
||
|
|
@IsString()
|
||
|
|
@IsOptional()
|
||
|
|
desc?: string;
|
||
|
|
|
||
|
|
@ApiPropertyOptional({ description: '详情富文本' })
|
||
|
|
@IsString()
|
||
|
|
@IsOptional()
|
||
|
|
content?: 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 UpdateProductDto extends CreateProductDto {}
|
||
|
|
|
||
|
|
export class QueryProductDto {
|
||
|
|
@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: '分类ID' })
|
||
|
|
@IsInt()
|
||
|
|
@IsOptional()
|
||
|
|
@Type(() => Number)
|
||
|
|
categoryId?: number;
|
||
|
|
|
||
|
|
@ApiPropertyOptional({ description: '关键词(名称)' })
|
||
|
|
@IsString()
|
||
|
|
@IsOptional()
|
||
|
|
keyword?: string;
|
||
|
|
}
|