From 566b4db692ef86236b0577be9c3e3996b9226998 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Tue, 14 May 2024 15:43:24 +0700 Subject: [PATCH] =?UTF-8?q?path=20=E0=B8=A3=E0=B8=B9=E0=B8=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileAvatarController.ts | 5 +++++ src/controllers/ProfileAvatarEmployeeController.ts | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/controllers/ProfileAvatarController.ts b/src/controllers/ProfileAvatarController.ts index 6d105a11..492636a7 100644 --- a/src/controllers/ProfileAvatarController.ts +++ b/src/controllers/ProfileAvatarController.ts @@ -42,6 +42,11 @@ export class ProfileAvatarController extends Controller { Object.assign(data, { ...body, ...meta }); await this.avatarRepository.save(data); + let avatar = `ทะเบียนประวัติ/โปรไฟล์/${profile.id}/profile-${data.id}`; + data.avatar = avatar; + await this.avatarRepository.save(data); + profile.avatar = avatar; + await this.profileRepository.save(profile); return new HttpSuccess(); } diff --git a/src/controllers/ProfileAvatarEmployeeController.ts b/src/controllers/ProfileAvatarEmployeeController.ts index 2cc3ce65..e1a7a7d0 100644 --- a/src/controllers/ProfileAvatarEmployeeController.ts +++ b/src/controllers/ProfileAvatarEmployeeController.ts @@ -10,7 +10,7 @@ import { ProfileEmployee } from "../entities/ProfileEmployee"; @Route("api/v1/org/profile-employee/avatar") @Tags("ProfileAvatar") @Security("bearerAuth") -export class ProfileAvatarController extends Controller { +export class ProfileAvatarEmployeeController extends Controller { private profileRepository = AppDataSource.getRepository(ProfileEmployee); private avatarRepository = AppDataSource.getRepository(ProfileAvatar); @@ -45,8 +45,13 @@ export class ProfileAvatarController extends Controller { Object.assign(data, { ...body, ...meta }); await this.avatarRepository.save(data); + let avatar = `ทะเบียนประวัติ/โปรไฟล์/${profile.id}/profile-employee-${data.id}`; + data.avatar = avatar; + await this.avatarRepository.save(data); + profile.avatar = avatar; + await this.profileRepository.save(profile); - return new HttpSuccess(); + return new HttpSuccess(avatar); } @Delete("{avatarId}")