add auth sync by menu

This commit is contained in:
Warunee Tamkoo 2024-06-12 13:21:15 +07:00
parent 79a0d847ce
commit 2f525bae95
2 changed files with 49 additions and 14 deletions

View file

@ -27,11 +27,21 @@ export class AuthSysController extends Controller {
@Get("list")
public async listAuthSys() {
const getList = await this.authSysRepo.find();
// if (!getList || getList.length === 0) {
// throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
// }
return new HttpSuccess(getList);
const getList = await this.authSysRepo.find({
select: ["id", "parentId", "sysName", "sysDescription", "order"],
});
const lists = getList
.filter((x) => x.parentId == null)
.map((item) => {
return {
...item,
children: getList.filter((x) => x.parentId == item.id).sort((a, b) => a.order - b.order),
};
})
.sort((a, b) => a.order - b.order);
return new HttpSuccess(lists);
}
@Get("{systemId}")