mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
feat(nestjs): migrate to NestJS
This commit is contained in:
62
packages/server/src/modules/Roles/Roles.application.ts
Normal file
62
packages/server/src/modules/Roles/Roles.application.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateRoleService } from './commands/CreateRole.service';
|
||||
import { DeleteRoleService } from './commands/DeleteRole.service';
|
||||
import { EditRoleService } from './commands/EditRole.service';
|
||||
import { GetRoleService } from './queries/GetRole.service';
|
||||
import { GetRolesService } from './queries/GetRoles.service';
|
||||
|
||||
@Injectable()
|
||||
export class RolesApplication {
|
||||
constructor(
|
||||
private readonly createRoleService: CreateRoleService,
|
||||
private readonly editRoleService: EditRoleService,
|
||||
private readonly deleteRoleService: DeleteRoleService,
|
||||
private readonly getRoleService: GetRoleService,
|
||||
private readonly getRolesService: GetRolesService,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Creates a new role.
|
||||
* @param createRoleDto The data for creating a new role.
|
||||
* @returns The created role.
|
||||
*/
|
||||
async createRole(createRoleDto: any) {
|
||||
return this.createRoleService.createRole(createRoleDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edits an existing role.
|
||||
* @param roleId The ID of the role to edit.
|
||||
* @param editRoleDto The data for editing the role.
|
||||
* @returns The edited role.
|
||||
*/
|
||||
async editRole(roleId: number, editRoleDto: any) {
|
||||
return this.editRoleService.editRole(roleId, editRoleDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a role.
|
||||
* @param roleId The ID of the role to delete.
|
||||
* @returns The result of the deletion operation.
|
||||
*/
|
||||
async deleteRole(roleId: number) {
|
||||
return this.deleteRoleService.deleteRole(roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a specific role by ID.
|
||||
* @param roleId The ID of the role to retrieve.
|
||||
* @returns The requested role.
|
||||
*/
|
||||
async getRole(roleId: number) {
|
||||
return this.getRoleService.getRole(roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all roles.
|
||||
* @returns A list of all roles.
|
||||
*/
|
||||
async getRoles() {
|
||||
return this.getRolesService.getRoles();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user