no message

This commit is contained in:
Kittapath 2024-06-24 10:52:40 +07:00
parent 5a634b4dd3
commit b11be3364f
7 changed files with 201 additions and 125 deletions

View file

@ -1056,7 +1056,7 @@ export class EmployeePositionController extends Controller {
});
const authRoleName = await this.authRoleRepo.findOne({
where: { id: String(posMaster.authRoleId) }
where: { id: String(posMaster.authRoleId) },
});
let profile: any;
@ -1149,7 +1149,8 @@ export class EmployeePositionController extends Controller {
profilePoslevel:
level == null || type == null ? null : `${type.posTypeShortName} ${level.posLevelName}`,
authRoleId: posMaster.authRoleId,
authRoleName: authRoleName == null || authRoleName.roleName == null ? null : authRoleName.roleName,
authRoleName:
authRoleName == null || authRoleName.roleName == null ? null : authRoleName.roleName,
positions: positions.map((position) => ({
id: position.id,
positionName: position.positionName,
@ -2150,4 +2151,46 @@ export class EmployeePositionController extends Controller {
return new HttpSuccess();
}
/**
* API
*
* @summary
*
*/
@Post("report/current")
async reportApproveCurrent(
@Body()
body: {
posmasterId: string;
positionId: string;
profileId: string;
},
) {
const posMaster = await this.employeePosMasterRepository.findOne({
where: { id: body.posmasterId },
});
if (posMaster == null) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่งนี้");
const posMasterOld = await this.employeePosMasterRepository.findOne({
where: {
current_holderId: body.profileId,
orgRevisionId: posMaster.orgRevisionId,
},
});
if (posMasterOld != null) posMasterOld.current_holderId = null;
if (posMasterOld != null) posMasterOld.next_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;
posMaster.next_holderId = body.profileId;
if (posMasterOld != null) await this.employeePosMasterRepository.save(posMasterOld);
await this.employeePosMasterRepository.save(posMaster);
return new HttpSuccess();
}
}