Merge branch 'develop' into adiDev

This commit is contained in:
AdisakKanthawilang 2024-06-25 18:42:05 +07:00
commit d5373fb62b
10 changed files with 897 additions and 209 deletions

View file

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