fix: update without pos field always result in null
This commit is contained in:
parent
3c21e5351a
commit
6924017849
1 changed files with 23 additions and 4 deletions
|
|
@ -58,8 +58,8 @@ export class ProfileController extends Controller {
|
|||
);
|
||||
}
|
||||
|
||||
if (!body.posLevelId) body.posLevelId = null;
|
||||
if (!body.posTypeId) body.posTypeId = null;
|
||||
if (body.posLevelId === "") body.posLevelId = null;
|
||||
if (body.posTypeId === "") body.posTypeId = null;
|
||||
|
||||
if (body.posLevelId && !(await this.posLevelRepo.findOneBy({ id: body.posLevelId }))) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่งนี้");
|
||||
|
|
@ -102,8 +102,8 @@ export class ProfileController extends Controller {
|
|||
throw new HttpError(HttpStatus.CONFLICT, "เลขประจำตัวประชาชนนี้มีอยู่ในระบบแล้ว");
|
||||
}
|
||||
|
||||
if (!body.posLevelId) body.posLevelId = null;
|
||||
if (!body.posTypeId) body.posTypeId = null;
|
||||
if (body.posLevelId === "") body.posLevelId = null;
|
||||
if (body.posTypeId === "") body.posTypeId = null;
|
||||
|
||||
if (body.posLevelId && !(await this.posLevelRepo.findOneBy({ id: body.posLevelId }))) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลระดับตำแหน่งนี้");
|
||||
|
|
@ -120,6 +120,7 @@ export class ProfileController extends Controller {
|
|||
await this.profileHistoryRepo.save(
|
||||
Object.assign(new ProfileHistory(), {
|
||||
...record,
|
||||
profileId: id,
|
||||
id: undefined,
|
||||
}),
|
||||
);
|
||||
|
|
@ -176,6 +177,24 @@ export class ProfileController extends Controller {
|
|||
return new HttpSuccess(profile);
|
||||
}
|
||||
|
||||
@Get("history/{id}")
|
||||
async getProfileHistory(@Path() id: string) {
|
||||
const profile = await this.profileHistoryRepo.find({
|
||||
relations: {
|
||||
posLevel: true,
|
||||
posType: true,
|
||||
gender: true,
|
||||
relationship: true,
|
||||
bloodGroup: true,
|
||||
},
|
||||
where: { profileId: id },
|
||||
});
|
||||
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
return new HttpSuccess(profile);
|
||||
}
|
||||
|
||||
/**
|
||||
* API รายการทะเบียนประวัติ
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue