1
0

role.ts 750 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import {
  2. ArrayNotEmpty,
  3. ArrayMinSize,
  4. IsOptional,
  5. IsNumberString,
  6. Length,
  7. Matches,
  8. IsInt,
  9. Allow,
  10. } from 'class-validator';
  11. import { Expose } from 'class-transformer';
  12. export class DeleteRoleDto {
  13. @ArrayNotEmpty()
  14. @Expose()
  15. roleIds: number[];
  16. }
  17. export class CreateRoleDto {
  18. @Length(2)
  19. @Expose()
  20. name: string;
  21. @Matches(/^[a-z0-9A-Z]+$/)
  22. @Expose()
  23. label: string;
  24. @Allow()
  25. @Expose()
  26. remark: string;
  27. @IsOptional()
  28. @ArrayMinSize(0)
  29. @Expose()
  30. menus: number[];
  31. @IsOptional()
  32. @ArrayMinSize(0)
  33. @Expose()
  34. depts: number[];
  35. }
  36. export class UpdateRoleDto extends CreateRoleDto {
  37. @IsInt()
  38. @Expose()
  39. roleId: number;
  40. }
  41. export class InfoRoleDto {
  42. @IsNumberString()
  43. @Expose()
  44. roleId: string;
  45. }