no message

This commit is contained in:
Kittapath 2024-05-15 16:09:25 +07:00
parent 9365c6c62e
commit 277805791d

View file

@ -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 });