permission system - permission formatting
This commit is contained in:
parent
d889f92643
commit
2f5d9d3f01
15 changed files with 352 additions and 18 deletions
24
src/service/permissionService.ts
Normal file
24
src/service/permissionService.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
import { dataSource } from "../data-source";
|
||||
import { permission } from "../entity/permission";
|
||||
import InternalException from "../exceptions/internalException";
|
||||
|
||||
export default abstract class PermissionService {
|
||||
/**
|
||||
* @description get permission by user
|
||||
* @param user number
|
||||
* @returns {Promise<Array<permission>>}
|
||||
*/
|
||||
static async getByUser(userId: number): Promise<Array<permission>> {
|
||||
return await dataSource
|
||||
.getRepository(permission)
|
||||
.createQueryBuilder("permission")
|
||||
.where("permission.userId = :userId", { userId: userId })
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new InternalException("permission not found by user");
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue