roles and permissions
This commit is contained in:
parent
d77c3ca1a5
commit
9808100d81
21 changed files with 389 additions and 59 deletions
24
src/service/roleService.ts
Normal file
24
src/service/roleService.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
import { dataSource } from "../data-source";
|
||||
import { role } from "../entity/role";
|
||||
import InternalException from "../exceptions/internalException";
|
||||
|
||||
export default abstract class RoleService {
|
||||
/**
|
||||
* @description get role by id
|
||||
* @param id number
|
||||
* @returns {Promise<role>}
|
||||
*/
|
||||
static async getById(id: number): Promise<role> {
|
||||
return await dataSource
|
||||
.getRepository(role)
|
||||
.createQueryBuilder("role")
|
||||
.where("role.id = :id", { id: id })
|
||||
.getOneOrFail()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("role not found by id");
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue