update add role_name

This commit is contained in:
2024-12-31 14:46:14 +07:00
parent 0418bece71
commit 1931a30e48

View File

@ -85,6 +85,8 @@ export class UserController {
.where(whereAttr, whereVal); .where(whereAttr, whereVal);
const res_list = userRepository.createQueryBuilder() const res_list = userRepository.createQueryBuilder()
.where(whereAttr, whereVal) .where(whereAttr, whereVal)
.select('id,email,username,name,id_role,status,created_at,updated_at')
.addSelect('(select role.name from user_roles role where role.id=User.id_role )', 'role_name')
.orderBy(param.order_field, param.order_direction) .orderBy(param.order_field, param.order_direction)
.offset(offset) .offset(offset)
.limit(param.limit); .limit(param.limit);
@ -96,7 +98,7 @@ export class UserController {
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.getMany(); const list_data = await res_list.getRawMany();
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);