dto.ts 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import { ApiProperty, ApiBody, PartialType } from '@nestjs/swagger';
  2. import { Exclude } from 'class-transformer';
  3. import {
  4. Allow,
  5. IsArray,
  6. IsBoolean,
  7. IsNotEmpty,
  8. IsNumber,
  9. IsOptional,
  10. IsString,
  11. Length,
  12. } from 'class-validator';
  13. export class CreateCategoryDto {
  14. @ApiProperty()
  15. @IsString()
  16. @IsNotEmpty({ message: '标题不能为空' })
  17. @Length(1, 200, {
  18. message: `用户名长度必须大于$constraint1到$constraint2之间,当前传递的值是$value`,
  19. })
  20. title: string;
  21. @ApiProperty({ required: false })
  22. @IsBoolean()
  23. @IsOptional()
  24. enable?: boolean;
  25. @ApiProperty({ required: false })
  26. @IsNumber()
  27. @IsOptional()
  28. parentId?: number;
  29. }
  30. export class GetCategoryDto {
  31. @ApiProperty({ required: false })
  32. @Allow()
  33. pageSize?: number;
  34. @ApiProperty({ required: false })
  35. @Allow()
  36. pageNo?: number;
  37. @ApiProperty({ required: false })
  38. @Allow()
  39. title?: string;
  40. @ApiProperty({ required: false })
  41. @Allow()
  42. enable?: boolean;
  43. }
  44. export class UpdateCategoryDto extends PartialType(CreateCategoryDto) {}