This commit is contained in:
AdisakKanthawilang 2024-04-26 15:00:35 +07:00
parent 19e1b55aee
commit 63bd675740

View file

@ -841,6 +841,7 @@ export class PositionController extends Controller {
where: {
orgChild3: { orgChild3ShortName: SName },
posMasterNo: requestBody.posMasterNo,
orgChild4Id: IsNull(),
id: Not(posMaster.id),
},
});
@ -855,6 +856,7 @@ export class PositionController extends Controller {
where: {
orgChild2: { orgChild2ShortName: SName },
posMasterNo: requestBody.posMasterNo,
orgChild3Id: IsNull(),
id: Not(posMaster.id),
},
});
@ -869,6 +871,7 @@ export class PositionController extends Controller {
where: {
orgChild1: { orgChild1ShortName: SName },
posMasterNo: requestBody.posMasterNo,
orgChild2Id: IsNull(),
id: Not(posMaster.id),
},
});
@ -883,6 +886,7 @@ export class PositionController extends Controller {
where: {
orgRoot: { orgRootShortName: SName },
posMasterNo: requestBody.posMasterNo,
orgChild1Id: IsNull(),
id: Not(posMaster.id),
},
});
@ -1736,6 +1740,47 @@ export class PositionController extends Controller {
posMaster.orgRevisionId = org.orgRevisionId;
}
}
// let org = null;
// let repo = null;
// switch (requestBody.type) {
// case 1:
// repo = this.child1Repository;
// break;
// case 2:
// repo = this.child2Repository;
// break;
// case 3:
// repo = this.child3Repository;
// break;
// case 4:
// repo = this.child4Repository;
// break;
// default:
// throw new Error('Invalid type');
// }
// org = await repo.findOne({ where: { id: requestBody.id } });
// if (org != null) {
// const posMasterCheck = await this.posMasterRepository.findOne({
// where: {
// [`orgChild${requestBody.type}Id`]: org.id,
// posMasterNo: posMaster.posMasterNo,
// orgChild2Id: (requestBody.type > 1) ? IsNull() : undefined,
// orgChild3Id: (requestBody.type > 2) ? IsNull() : undefined,
// orgChild4Id: (requestBody.type > 3) ? IsNull() : undefined,
// },
// });
// if (posMasterCheck != null) {
// throw new HttpError(
// HttpStatusCode.NOT_FOUND,
// `เลขที่ตำแหน่งมีอยู่ในระบบอยู่แล้ว`,
// );
// }
// }
if (change == true) {
posMaster.posMasterOrder = maxPosMasterOrder += 1;
posMaster.createdUserId = request.user.sub;