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}")