พบเลขบัตรให้ return id

This commit is contained in:
Bright 2024-05-07 14:49:39 +07:00
parent c9a8f9dc4d
commit e5f71ba90d
2 changed files with 29 additions and 31 deletions

View file

@ -216,11 +216,9 @@ export class ProfileController extends Controller {
@Request() request: RequestWithUser,
@Body() body: CreateProfileAllFields,
) {
if (await this.profileRepo.findOneBy({ citizenId: body.citizenId })) {
throw new HttpError(
HttpStatus.INTERNAL_SERVER_ERROR,
"เลขประจำตัวประชาชนนี้มีอยู่ในระบบแล้ว",
);
const profileExist = await this.profileRepo.findOneBy({ citizenId: body.citizenId })
if (profileExist) {
return new HttpSuccess(profileExist.id);
}
if (body.posLevelId === "") body.posLevelId = null;