mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-17 17:09:09 +00:00
FEAT: Roles and permissions modules
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { Role } from 'src/modules/roles/dto/entities';
|
||||
export class Customer {
|
||||
@ApiProperty()
|
||||
id: string;
|
||||
@@ -15,28 +16,26 @@ export class Customer {
|
||||
@ApiProperty()
|
||||
updatedAt: string;
|
||||
}
|
||||
export class Permission {
|
||||
@ApiProperty()
|
||||
id: string;
|
||||
@ApiProperty()
|
||||
seqid: number;
|
||||
@ApiProperty()
|
||||
name: string;
|
||||
@ApiProperty()
|
||||
claim: string;
|
||||
@ApiProperty()
|
||||
createdAt: string;
|
||||
@ApiProperty()
|
||||
updatedAt: string;
|
||||
}
|
||||
export class Role {
|
||||
@ApiProperty({ type: [Permission] })
|
||||
permissions: Permission[];
|
||||
export class User {
|
||||
@ApiProperty()
|
||||
id: string;
|
||||
@ApiProperty()
|
||||
name: string;
|
||||
@ApiProperty()
|
||||
email: string;
|
||||
@ApiProperty({ type: [Role] })
|
||||
roles: Role[];
|
||||
@ApiProperty()
|
||||
jobTitle: string;
|
||||
@ApiProperty()
|
||||
department: string;
|
||||
@ApiProperty()
|
||||
hierarchy: number;
|
||||
@ApiProperty()
|
||||
customer: Customer;
|
||||
@ApiProperty()
|
||||
mfaStatus: string;
|
||||
@ApiProperty()
|
||||
createdAt: string;
|
||||
@ApiProperty()
|
||||
updatedAt: string;
|
||||
@@ -57,61 +56,31 @@ export class UserByCustomer {
|
||||
@ApiProperty()
|
||||
updatedAt: string;
|
||||
}
|
||||
export class User {
|
||||
@ApiProperty()
|
||||
id: string;
|
||||
@ApiProperty()
|
||||
name: string;
|
||||
@ApiProperty()
|
||||
username: string;
|
||||
@ApiProperty()
|
||||
UserRole: string[];
|
||||
@ApiProperty()
|
||||
customer: Customer;
|
||||
@ApiProperty()
|
||||
mfaStatus: string;
|
||||
@ApiProperty()
|
||||
createdAt: string;
|
||||
@ApiProperty()
|
||||
updatedAt: string;
|
||||
}
|
||||
export class CreateUserReq {
|
||||
@ApiProperty()
|
||||
@ApiPropertyOptional()
|
||||
name: string;
|
||||
@ApiProperty()
|
||||
email: string;
|
||||
@ApiProperty()
|
||||
@ApiPropertyOptional()
|
||||
roles: string[];
|
||||
@ApiProperty()
|
||||
@ApiPropertyOptional()
|
||||
jobTitle: string;
|
||||
@ApiProperty()
|
||||
@ApiPropertyOptional()
|
||||
department: string;
|
||||
@ApiProperty()
|
||||
@ApiPropertyOptional()
|
||||
hierarchy: number;
|
||||
}
|
||||
export class CreateUserRes {
|
||||
@ApiProperty()
|
||||
id: string;
|
||||
@ApiProperty()
|
||||
name: string;
|
||||
@ApiProperty()
|
||||
email: string;
|
||||
@ApiProperty()
|
||||
roles: string[];
|
||||
@ApiProperty()
|
||||
jobTitle: string;
|
||||
@ApiProperty()
|
||||
department: string;
|
||||
@ApiProperty()
|
||||
hierarchy: number;
|
||||
@ApiProperty()
|
||||
customer: Customer;
|
||||
@ApiProperty()
|
||||
mfaStatus: string;
|
||||
@ApiProperty()
|
||||
createdAt: string;
|
||||
@ApiProperty()
|
||||
updatedAt: string;
|
||||
user: User;
|
||||
}
|
||||
export class BatchCreateUserReq {
|
||||
@ApiProperty({ type: [CreateUserReq] })
|
||||
users: CreateUserReq[];
|
||||
}
|
||||
export class BatchCreateUserRes {
|
||||
@ApiProperty({ type: [User] })
|
||||
users: User[];
|
||||
}
|
||||
|
||||
export class GetAllUsersByCustomerIdReq {
|
||||
|
||||
@@ -39,9 +39,14 @@ export class UsersController {
|
||||
@Post()
|
||||
@ApiOkResponse({ type: CreateUserRes })
|
||||
async createUser(@User() user, @Body() body: CreateUserReq) {
|
||||
console.log(body);
|
||||
this.logger.info('createUser', { user });
|
||||
}
|
||||
|
||||
@Post('batch')
|
||||
@ApiOkResponse({ type: CreateUserRes })
|
||||
async batchCreateUser(@User() user, @Body() body: CreateUserReq) {
|
||||
this.logger.info('batchCreateUser', { user });
|
||||
}
|
||||
@Delete(':id')
|
||||
@ApiOkResponse({ type: DeleteUserRes })
|
||||
async deleteUser(@User() user, @Param('id') id: string) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import { UsersService } from './users.service';
|
||||
import { DadosferaLogger } from 'dadosfera-logs';
|
||||
import { ClientsModule } from '@nestjs/microservices';
|
||||
import { DucClient } from 'src/clients/duc/client.config';
|
||||
|
||||
const ducClient = new DucClient();
|
||||
|
||||
@Module({
|
||||
|
||||
Reference in New Issue
Block a user