update auth menu role

This commit is contained in:
2024-12-01 00:03:23 +07:00
parent 44612b0050
commit 1e60f97208
2 changed files with 55 additions and 34 deletions

View File

@ -120,41 +120,44 @@ export class AuthController {
.andWhere('id_parent is null')
.orderBy('order', 'ASC');
const res_list_all = await repoMenu.createQueryBuilder().andWhere('id_parent is not null').getMany();
let list_data_final = await res_list.getMany();
let list_child: any = {};
for (let p of res_list_all) {
if (!list_child[p.id_parent]) {
list_child[p.id_parent] = [];
if (list_data_final.length > 0) {
const res_list_all = await repoMenu.createQueryBuilder().andWhere('id_parent is not null').getMany();
let list_child: any = {};
for (let p of res_list_all) {
if (!list_child[p.id_parent]) {
list_child[p.id_parent] = [];
}
list_child[p.id_parent].push(p);
}
list_child[p.id_parent].push(p);
}
for (let f of list_data_final) {
if (list_child[f.id]) {
f.children = list_child[f.id];
for (let f of list_data_final) {
if (list_child[f.id]) {
f.children = list_child[f.id];
for (let g of f.children) {
if (list_child[g.id]) {
g.children = list_child[g.id];
for (let g of f.children) {
if (list_child[g.id]) {
g.children = list_child[g.id];
for (let h of g.children) {
if (list_child[h.id]) {
h.children = list_child[h.id];
for (let h of g.children) {
if (list_child[h.id]) {
h.children = list_child[h.id];
for (let i of h.children) {
if (list_child[i.id]) {
i.children = list_child[i.id];
for (let i of h.children) {
if (list_child[i.id]) {
i.children = list_child[i.id];
for (let j of i.children) {
if (list_child[j.id]) {
j.children = list_child[j.id];
for (let j of i.children) {
if (list_child[j.id]) {
j.children = list_child[j.id];
for (let k of j.children) {
if (list_child[k.id]) {
k.children = list_child[k.id];
for (let k of j.children) {
if (list_child[k.id]) {
k.children = list_child[k.id];
}
}
}
}
@ -166,9 +169,12 @@ export class AuthController {
}
}
}
return list_data_final;
}
return list_data_final;
return {};
}
static async logout(req: Request, res: Response, next: NextFunction): Promise<Response> {