mirror of
https://github.com/dadosfera/maestro.git
synced 2026-09-28 21:14:47 +00:00
116 lines
2.4 KiB
TypeScript
116 lines
2.4 KiB
TypeScript
import { ApiProperty, ApiPropertyOptional, OmitType } from '@nestjs/swagger';
|
|
import { PermissionDto } from 'src/modules/permissions/dto/entities';
|
|
import {
|
|
Customer,
|
|
UserNoRolesAndCustomer,
|
|
} from 'src/modules/users/dtos/entities';
|
|
export class RoleDto {
|
|
@ApiProperty()
|
|
id: string;
|
|
@ApiProperty()
|
|
name: string;
|
|
@ApiProperty()
|
|
description: string;
|
|
@ApiPropertyOptional({ type: () => [PermissionDto] })
|
|
permissions: PermissionDto[];
|
|
@ApiPropertyOptional({ type: () => [UserNoRolesAndCustomer] })
|
|
users?: UserNoRolesAndCustomer[];
|
|
@ApiProperty()
|
|
createdAt: string;
|
|
@ApiProperty()
|
|
updatedAt: string;
|
|
@ApiProperty()
|
|
isPublic: boolean;
|
|
@ApiProperty({ type: () => Customer })
|
|
customer?: Customer;
|
|
}
|
|
|
|
export class CustomerRole extends OmitType(RoleDto, ['customer']) {}
|
|
export class UserRole extends OmitType(RoleDto, ['users']) {}
|
|
|
|
export enum TrueOrFalseEnum {
|
|
true = 'true',
|
|
false = 'false',
|
|
}
|
|
export class GetRolesByCustomerReq {
|
|
@ApiPropertyOptional()
|
|
permissionId: string[];
|
|
@ApiPropertyOptional({ enum: TrueOrFalseEnum })
|
|
getUsers: TrueOrFalseEnum;
|
|
}
|
|
|
|
export class GetRolesByCustomerRes {
|
|
@ApiProperty({ type: [RoleDto] })
|
|
roles: RoleDto[];
|
|
}
|
|
export class CreateRoleReq {
|
|
@ApiProperty()
|
|
name: string;
|
|
@ApiProperty()
|
|
permissionIds: number[];
|
|
@ApiPropertyOptional()
|
|
userIds: string[];
|
|
@ApiProperty()
|
|
description: string;
|
|
}
|
|
export class CreateRoleRes {
|
|
@ApiProperty()
|
|
role: CustomerRole;
|
|
}
|
|
|
|
export class GrantPermissionsToRoleReq {
|
|
@ApiProperty()
|
|
roleId: string;
|
|
@ApiProperty()
|
|
permissionIds: number[];
|
|
}
|
|
export class GrantPermissionsToRoleRes {
|
|
@ApiProperty()
|
|
role: RoleDto;
|
|
}
|
|
|
|
export class RevokePermissionsFromRoleReq {
|
|
@ApiProperty()
|
|
roleId: string;
|
|
@ApiProperty()
|
|
permissionIds: number[];
|
|
}
|
|
export class RevokePermissionsFromRoleRes {
|
|
@ApiProperty()
|
|
role: RoleDto;
|
|
}
|
|
|
|
export class UpdateRoleReq {
|
|
@ApiPropertyOptional()
|
|
name: string;
|
|
@ApiPropertyOptional()
|
|
description: string;
|
|
}
|
|
|
|
export class UpdateRoleRes {
|
|
@ApiProperty()
|
|
role: RoleDto;
|
|
}
|
|
|
|
export class SetRolePermissionsReq {
|
|
@ApiProperty()
|
|
roleId: string;
|
|
@ApiProperty()
|
|
permissionIds: number[];
|
|
}
|
|
export class SetRolePermissionsRes {
|
|
@ApiProperty()
|
|
role: RoleDto;
|
|
}
|
|
|
|
export class SetRoleUsersReq {
|
|
@ApiProperty()
|
|
roleId: string;
|
|
@ApiProperty()
|
|
userIds: string[];
|
|
}
|
|
export class SetRoleUsersRes {
|
|
@ApiProperty()
|
|
role: RoleDto;
|
|
}
|