diff --git a/src/controllers/auth.ts b/src/controllers/auth.ts index 0f1f0be..2b37b2a 100644 --- a/src/controllers/auth.ts +++ b/src/controllers/auth.ts @@ -124,16 +124,15 @@ export class AuthController { } const res_list = repoMenu.createQueryBuilder() - .where(whereAttr.join(' or '), whereVal) - .andWhere('id_parent is null') + .where('(' + whereAttr.join(' or ') + ') and id_parent is null', whereVal) .orderBy('order_number', 'ASC'); let list_data_final = await res_list.getMany(); if (list_data_final.length > 0) { const res_list_all = await repoMenu.createQueryBuilder() - .where(whereAttr.join(' or '), whereVal) - .andWhere('id_parent is not null').getMany(); + .where('(' + whereAttr.join(' or ') + ') and id_parent is not null', whereVal) + .orderBy('order_number', 'ASC').getMany(); let list_child: any = {}; for (let p of res_list_all) {