update auth response
This commit is contained in:
@ -112,18 +112,27 @@ export class AuthController {
|
||||
static async getListRole(roles: any): Promise<any> {
|
||||
const repoMenu = OrmHelper.DB.getRepository(Menu);
|
||||
|
||||
const whereAttr = "id in (:id_menu)";
|
||||
const whereVal = roles;
|
||||
const whereAttr = [];
|
||||
const whereVal = {};
|
||||
|
||||
for (let k in roles) {
|
||||
let p = roles[k];
|
||||
|
||||
whereAttr.push('id = :id' + k);
|
||||
whereVal['id' + k] = p;
|
||||
}
|
||||
|
||||
const res_list = repoMenu.createQueryBuilder()
|
||||
.where(whereAttr, whereVal)
|
||||
.where(whereAttr.join(' or '), whereVal)
|
||||
.andWhere('id_parent is null')
|
||||
.orderBy('order', 'ASC');
|
||||
.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().andWhere('id_parent is not null').getMany();
|
||||
const res_list_all = await repoMenu.createQueryBuilder()
|
||||
.where(whereAttr.join(' or '), whereVal)
|
||||
.andWhere('id_parent is not null').getMany();
|
||||
|
||||
let list_child: any = {};
|
||||
for (let p of res_list_all) {
|
||||
@ -131,10 +140,20 @@ export class AuthController {
|
||||
list_child[p.id_parent] = [];
|
||||
}
|
||||
|
||||
delete p.status
|
||||
delete p.created_at
|
||||
delete p.updated_at
|
||||
delete p.deleted_at
|
||||
|
||||
list_child[p.id_parent].push(p);
|
||||
}
|
||||
|
||||
for (let f of list_data_final) {
|
||||
delete f.status
|
||||
delete f.created_at
|
||||
delete f.updated_at
|
||||
delete f.deleted_at
|
||||
|
||||
if (list_child[f.id]) {
|
||||
f.children = list_child[f.id];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user