From 277805791d8b62b373d62507c34d8c6afe59db22 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Wed, 15 May 2024 16:09:25 +0700 Subject: [PATCH] no message --- src/controllers/ProfileAvatarController.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/controllers/ProfileAvatarController.ts b/src/controllers/ProfileAvatarController.ts index 70d5d99a..85b9d70e 100644 --- a/src/controllers/ProfileAvatarController.ts +++ b/src/controllers/ProfileAvatarController.ts @@ -22,6 +22,21 @@ export class ProfileAvatarController extends Controller { return new HttpSuccess(lists); } + @Get("select/{profileId}/{id}") + public async selectAvatar(@Path() profileId: string, @Path() id: string) { + const result = await this.avatarRepository.findOneBy({ id: id }); + if (!result) { + throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); + } + const profile = await this.profileRepository.findOneBy({ id: profileId }); + if (!profile) { + throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); + } + profile.avatar = result.avatar; + profile.avatarName = result.avatarName; + return new HttpSuccess(); + } + @Post() public async newAvatar(@Request() req: RequestWithUser, @Body() body: CreateProfileAvatar) { const profile = await this.profileRepository.findOneBy({ id: body.profileId });