update filter common
This commit is contained in:
@ -96,20 +96,26 @@ export class UserActivityController {
|
|||||||
whereVal['id_user'] = req.auth.data.id;
|
whereVal['id_user'] = req.auth.data.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
const res_count = userRepository.createQueryBuilder()
|
// const res_count = userRepository.createQueryBuilder()
|
||||||
.leftJoinAndMapOne('u.username', User, 'u', 'u.id = id_user')
|
// .leftJoinAndMapOne('u.username', User, 'u', 'u.id = id_user')
|
||||||
|
// .where(whereAttr, whereVal);
|
||||||
|
const res_count = userRepository.createQueryBuilder('user_activity')
|
||||||
|
.leftJoinAndSelect("user_activity.application", "application")
|
||||||
|
.leftJoinAndSelect("user_activity.user", "user")
|
||||||
.where(whereAttr, whereVal);
|
.where(whereAttr, whereVal);
|
||||||
const res_list = userRepository.createQueryBuilder()
|
const res_list = userRepository.createQueryBuilder('user_activity')
|
||||||
.select(
|
.leftJoinAndSelect("user_activity.application", "application")
|
||||||
'id,\n\
|
.leftJoinAndSelect("user_activity.user", "user")
|
||||||
id_user,\n\
|
// .select(
|
||||||
module,\n\
|
// 'id,\n\
|
||||||
description,\n\
|
// id_user,\n\
|
||||||
action,\n\
|
// module,\n\
|
||||||
url,\n\
|
// description,\n\
|
||||||
application,\n\
|
// action,\n\
|
||||||
created_at')
|
// url,\n\
|
||||||
.addSelect('(SELECT u.username FROM users u WHERE u.id = id_user)', 'username')
|
// application,\n\
|
||||||
|
// created_at')
|
||||||
|
// .addSelect('(SELECT u.username FROM users u WHERE u.id = id_user)', 'username')
|
||||||
// .leftJoinAndMapOne('u.username', User, 'u', 'u.id = id_user')
|
// .leftJoinAndMapOne('u.username', User, 'u', 'u.id = id_user')
|
||||||
.where(whereAttr, whereVal)
|
.where(whereAttr, whereVal)
|
||||||
.orderBy(param.order_field, param.order_direction)
|
.orderBy(param.order_field, param.order_direction)
|
||||||
@ -123,7 +129,7 @@ export class UserActivityController {
|
|||||||
|
|
||||||
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.getRawMany()
|
const list_data = await res_list.getMany()
|
||||||
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);
|
||||||
@ -287,9 +293,10 @@ export class UserActivityController {
|
|||||||
const param: UserActivity & { application: string } = await schema.validateAsync(req.body);
|
const param: UserActivity & { application: string } = await schema.validateAsync(req.body);
|
||||||
|
|
||||||
const repo_app = OrmHelper.DB.getRepository(Application);
|
const repo_app = OrmHelper.DB.getRepository(Application);
|
||||||
|
const repo_user = OrmHelper.DB.getRepository(User);
|
||||||
|
|
||||||
const data = new UserActivity()
|
const data = new UserActivity()
|
||||||
data.id_user = param.id_user
|
data.user = await repo_user.findOneBy({ id: param.id_user })
|
||||||
data.refresh_token = param.refresh_token
|
data.refresh_token = param.refresh_token
|
||||||
data.module = param.module
|
data.module = param.module
|
||||||
data.description = param.description
|
data.description = param.description
|
||||||
|
|||||||
@ -110,6 +110,7 @@ export default class CommonHelper {
|
|||||||
|
|
||||||
if (p != 'any') {
|
if (p != 'any') {
|
||||||
if (!validate(f)) {
|
if (!validate(f)) {
|
||||||
|
console.log('ffffff', f, p)
|
||||||
let found = false;
|
let found = false;
|
||||||
if (fr['from']) {
|
if (fr['from']) {
|
||||||
whereAttrPre.push(p + " >= :" + p + '_from');
|
whereAttrPre.push(p + " >= :" + p + '_from');
|
||||||
@ -123,7 +124,7 @@ export default class CommonHelper {
|
|||||||
}
|
}
|
||||||
if (fr['like']) {
|
if (fr['like']) {
|
||||||
whereAttrPre.push('LOWER(' + p + ') like :' + p + '_like');
|
whereAttrPre.push('LOWER(' + p + ') like :' + p + '_like');
|
||||||
whereVal[p + '_like'] = '%' + fr['like'] + '%';;
|
whereVal[p + '_like'] = '%' + fr['like'].toLowerCase() + '%';;
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user