test try catch avatar profile

This commit is contained in:
Adisak 2025-10-30 10:37:13 +07:00
parent 5138a01461
commit 1c36e8dac8

View file

@ -29,16 +29,26 @@ export class ProfileAvatarController extends Controller {
@Get("profileId/{id}")
async getProfile(@Path() id: string, @Request() req: RequestWithUser) {
let _workflow = await new permission().Workflow(req, id, "SYS_REGISTRY_OFFICER");
if (_workflow == false)
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", id);
const profile = await this.profileRepository.findOne({
where: { id },
});
try {
let _workflow = await new permission().Workflow(req, id, "SYS_REGISTRY_OFFICER");
if (_workflow == false)
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", id);
const profile = await this.profileRepository.findOne({
where: { id },
});
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
return new HttpSuccess(profile);
return new HttpSuccess(profile);
} catch (error) {
console.error("Error in getProfile:", error);
if (error instanceof HttpError) {
throw error;
}
throw new HttpError(HttpStatus.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาดภายในระบบ");
}
}
@Get("profileId-admin/{id}")