dto.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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({ required: true })
  15. @IsNumber()
  16. userId: number;
  17. @ApiProperty()
  18. @IsString()
  19. @IsNotEmpty({ message: '标题不能为空' })
  20. @Length(1, 200, {
  21. message: `用户名长度必须大于$constraint1到$constraint2之间,当前传递的值是$value`,
  22. })
  23. title: string;
  24. @ApiProperty({ required: false })
  25. @IsBoolean()
  26. @IsOptional()
  27. enable?: boolean;
  28. @ApiProperty({ nullable: true, required: false })
  29. @IsNumber()
  30. @IsOptional()
  31. parentId?: number;
  32. @ApiProperty({ nullable: true, required: false })
  33. @IsString()
  34. @IsOptional()
  35. remark?: string;
  36. }
  37. export class GetCategoryDto {
  38. @ApiProperty({ required: false })
  39. @Allow()
  40. pageSize?: number;
  41. @ApiProperty({ required: false })
  42. @Allow()
  43. pageNo?: number;
  44. @ApiProperty({ required: false })
  45. @Allow()
  46. title?: string;
  47. @ApiProperty({ required: false })
  48. @Allow()
  49. enable?: boolean;
  50. }
  51. export class GetAllCategoryDto {
  52. @ApiProperty({ required: false })
  53. @IsOptional()
  54. enable?: boolean;
  55. }
  56. export class UpdateCategoryDto extends PartialType(CreateCategoryDto) {}