update auth menu role
This commit is contained in:
@ -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> {
|
||||
|
||||
@ -57,7 +57,7 @@ export class UserController {
|
||||
|
||||
try {
|
||||
const schema = Joi.object().keys({
|
||||
filter: Joi.string().allow('').optional().label('Filter'),
|
||||
filter: Joi.array().allow('').optional().label('Filter'),
|
||||
page: Joi.number().required().min(1).label('Page'),
|
||||
limit: Joi.number().required().min(1).label('Limit'),
|
||||
with_deleted: Joi.bool().required().label('With Deleted'),
|
||||
@ -72,13 +72,28 @@ export class UserController {
|
||||
|
||||
const offset = (param.page - 1) * param.limit
|
||||
|
||||
let whereAttr = '';
|
||||
let whereAttr = [];
|
||||
let whereVal: any = {};
|
||||
|
||||
if (param.filter) {
|
||||
whereAttr = 'name like :filter_like or username like :filter_like or email = :filter ';
|
||||
whereVal['filter'] = param.filter
|
||||
whereVal['filter_like'] = '%' + param.filter + '%'
|
||||
if (param.filter && param.filter.length > 0) {
|
||||
let filter_any = false;
|
||||
|
||||
for (let p in param.filter) {
|
||||
if (p != 'any') {
|
||||
let f = param.filter[p];
|
||||
|
||||
whereAttr.push(p + " = :" + p);
|
||||
whereVal[p] = f;
|
||||
} else {
|
||||
filter_any = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (filter_any) {
|
||||
whereAttr.push('name like :filter_like or username like :filter_like or email = :filter ');
|
||||
whereVal['filter'] = param.filter
|
||||
whereVal['filter_like'] = '%' + param.filter + '%'
|
||||
}
|
||||
}
|
||||
|
||||
const res_count = userRepository.createQueryBuilder()
|
||||
@ -140,7 +155,7 @@ export class UserController {
|
||||
|
||||
try {
|
||||
const schema = Joi.object().keys({
|
||||
filter: Joi.string().allow('').optional().label('Filter'),
|
||||
filter: Joi.array().allow('').optional().label('Filter'),
|
||||
order_field: Joi.string().required().label('Order Field'),
|
||||
order_direction: Joi.string().allow('asc', 'desc').required().label('Order Direction'),
|
||||
token: Joi.string().required().label('Token'),
|
||||
|
||||
Reference in New Issue
Block a user