update menu children
This commit is contained in:
@ -85,6 +85,7 @@ export class MenuController {
|
|||||||
.where(whereAttr, whereVal);
|
.where(whereAttr, whereVal);
|
||||||
const res_list = repo.createQueryBuilder()
|
const res_list = repo.createQueryBuilder()
|
||||||
.where(whereAttr, whereVal)
|
.where(whereAttr, whereVal)
|
||||||
|
.andWhere('id_parent is null')
|
||||||
.orderBy(param.order_field, param.order_direction)
|
.orderBy(param.order_field, param.order_direction)
|
||||||
.offset(offset)
|
.offset(offset)
|
||||||
.limit(param.limit);
|
.limit(param.limit);
|
||||||
@ -94,9 +95,57 @@ export class MenuController {
|
|||||||
res_list.withDeleted();
|
res_list.withDeleted();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const res_list_all = await repo.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] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
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 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 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 k of j.children) {
|
||||||
|
if (list_child[k.id]) {
|
||||||
|
k.children = list_child[k.id];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const current_page = param.page;
|
const current_page = param.page;
|
||||||
const total_count_data = await res_count.getCount();
|
const total_count_data = await res_count.getCount();
|
||||||
const list_data = await res_list.getMany();
|
const list_data = list_data_final;
|
||||||
const count_data = CommonHelper.countObject(list_data);
|
const count_data = CommonHelper.countObject(list_data);
|
||||||
|
|
||||||
return ReturnHelper.successResponselist(res, 200, Language.lang.success_view, count_data, current_page, total_count_data, list_data);
|
return ReturnHelper.successResponselist(res, 200, Language.lang.success_view, count_data, current_page, total_count_data, list_data);
|
||||||
|
|||||||
Reference in New Issue
Block a user