Merge branch 'develop' into adiDev
This commit is contained in:
commit
d5373fb62b
10 changed files with 897 additions and 209 deletions
|
|
@ -3267,4 +3267,44 @@ export class PositionController extends Controller {
|
|||
);
|
||||
return new HttpSuccess(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* API บันทึกตำแหน่งใหม่
|
||||
*
|
||||
* @summary บันทึกตำแหน่งใหม่
|
||||
*
|
||||
*/
|
||||
@Post("report/current")
|
||||
async reportApproveCurrent(
|
||||
@Body()
|
||||
body: {
|
||||
posmasterId: string;
|
||||
positionId: string;
|
||||
profileId: string;
|
||||
},
|
||||
) {
|
||||
const posMaster = await this.posMasterRepository.findOne({
|
||||
where: { id: body.posmasterId },
|
||||
});
|
||||
if (posMaster == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่งนี้");
|
||||
|
||||
const posMasterOld = await this.posMasterRepository.findOne({
|
||||
where: {
|
||||
current_holderId: body.profileId,
|
||||
orgRevisionId: posMaster.orgRevisionId,
|
||||
},
|
||||
});
|
||||
if (posMasterOld != null) posMasterOld.current_holderId = null;
|
||||
|
||||
const profile = await this.profileRepository.findOne({
|
||||
where: { id: body.profileId },
|
||||
});
|
||||
if (profile == null)
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
|
||||
|
||||
posMaster.current_holderId = body.profileId;
|
||||
if (posMasterOld != null) await this.posMasterRepository.save(posMasterOld);
|
||||
await this.posMasterRepository.save(posMaster);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue