roles and permissions

This commit is contained in:
Julian Krauser 2024-08-27 17:54:59 +02:00
parent d77c3ca1a5
commit 9808100d81
21 changed files with 389 additions and 59 deletions

View 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");
});
}
}