From 7b362d2af7a9baeef750882d41355dad5e8fc2cb Mon Sep 17 00:00:00 2001 From: DQGiac Date: Wed, 1 Jul 2026 18:40:38 +0700 Subject: [PATCH] hotfix/case --- .../src/core/modules/auth/service/auth.service.js | 14 ++++++++------ .../core/modules/lawyer/services/lawyer.mapper.js | 2 +- .../core/modules/user/services/user.service.js | 15 ++++++++++++--- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/backend/src/core/modules/auth/service/auth.service.js b/backend/src/core/modules/auth/service/auth.service.js index 425190a..a1c4c07 100644 --- a/backend/src/core/modules/auth/service/auth.service.js +++ b/backend/src/core/modules/auth/service/auth.service.js @@ -10,6 +10,7 @@ import { AuthRepository } from '../auth.repository'; import { BcryptService } from './bcrypt.service'; import { JwtService } from './jwt.service'; import { UnAuthorizedException, DuplicateException, BadRequestException } from '../../../../packages/httpException'; +import { UserActionType } from 'core/common/enum'; class Service { constructor() { @@ -90,16 +91,17 @@ class Service { fullName: user.full_name, roleName: user.roles?.name ? user.roles.name.toUpperCase() : null, avatarUrl: user.avatar_url ?? null, - avatar: user.avatar_url ?? null, status, phone: user.phone ?? null, location: user.location ?? null, }; - + if (user.banned_by) { - userData.banned_at = user.updated_at?.toISOString() || null; - userData.bannedAt = user.updated_at?.toISOString() || null; - userData.reason = user.ban_reason ?? null; + userData.status = UserActionType.BANNED; + userData.bannedAt = user.banned_at; + userData.banReason = user.ban_reason; + } else { + userData.status = UserActionType.ACTIVE; } const targetUserId = userId ?? user.id; @@ -195,7 +197,7 @@ class Service { return { data: { - password_reset_token: passwordResetToken, + passwordResetToken: passwordResetToken, } }; } diff --git a/backend/src/core/modules/lawyer/services/lawyer.mapper.js b/backend/src/core/modules/lawyer/services/lawyer.mapper.js index 924009e..dc096b3 100644 --- a/backend/src/core/modules/lawyer/services/lawyer.mapper.js +++ b/backend/src/core/modules/lawyer/services/lawyer.mapper.js @@ -61,7 +61,7 @@ export const mapLawyerListItem = user => { return { id: user.id, fullName: user.full_name, - avatar: user.avatar_url, + avatarUrl: user.avatar_url, careerHistory, bio, averageRating: lawyerDetails.rating_avg || 0, diff --git a/backend/src/core/modules/user/services/user.service.js b/backend/src/core/modules/user/services/user.service.js index d560545..194782d 100644 --- a/backend/src/core/modules/user/services/user.service.js +++ b/backend/src/core/modules/user/services/user.service.js @@ -71,7 +71,7 @@ class Service { return { id: user.id, userCode: `USR-${user.id.slice(0, 8).toUpperCase()}`, - avatar: user.avatar_url, + avatarUrl: user.avatar_url, fullName: user.full_name, email: user.email, roleName, @@ -109,7 +109,16 @@ class Service { * Alias for findById (OpenAPI naming) */ async getUserById(id) { - return this.findById(id); + const user = await this.findById(id); + if (!user) { + throw new NotFoundException('User not found'); + } + + return { + data: { + ...this.toUserListItem(user), + } + } } /** @@ -253,7 +262,7 @@ class Service { data: { fullName: updatedUser.full_name, email: updatedUser.email, - avatar: updatedUser.avatar_url, + avatarUrl: updatedUser.avatar_url, roleName: role.toUpperCase(), licenseInfo: role === Role.LAWYER.toLowerCase() ? {