update filter common
This commit is contained in:
@ -96,20 +96,26 @@ export class UserActivityController {
|
||||
whereVal['id_user'] = req.auth.data.id;
|
||||
}
|
||||
|
||||
const res_count = userRepository.createQueryBuilder()
|
||||
.leftJoinAndMapOne('u.username', User, 'u', 'u.id = id_user')
|
||||
// const res_count = userRepository.createQueryBuilder()
|
||||
// .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);
|
||||
const res_list = userRepository.createQueryBuilder()
|
||||
.select(
|
||||
'id,\n\
|
||||
id_user,\n\
|
||||
module,\n\
|
||||
description,\n\
|
||||
action,\n\
|
||||
url,\n\
|
||||
application,\n\
|
||||
created_at')
|
||||
.addSelect('(SELECT u.username FROM users u WHERE u.id = id_user)', 'username')
|
||||
const res_list = userRepository.createQueryBuilder('user_activity')
|
||||
.leftJoinAndSelect("user_activity.application", "application")
|
||||
.leftJoinAndSelect("user_activity.user", "user")
|
||||
// .select(
|
||||
// 'id,\n\
|
||||
// id_user,\n\
|
||||
// module,\n\
|
||||
// description,\n\
|
||||
// action,\n\
|
||||
// url,\n\
|
||||
// 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')
|
||||
.where(whereAttr, whereVal)
|
||||
.orderBy(param.order_field, param.order_direction)
|
||||
@ -123,7 +129,7 @@ export class UserActivityController {
|
||||
|
||||
const current_page = param.page;
|
||||
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);
|
||||
|
||||
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 repo_app = OrmHelper.DB.getRepository(Application);
|
||||
const repo_user = OrmHelper.DB.getRepository(User);
|
||||
|
||||
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.module = param.module
|
||||
data.description = param.description
|
||||
|
||||
Reference in New Issue
Block a user