no message

This commit is contained in:
Kittapath 2024-02-21 17:10:30 +07:00
parent 6b2f1c99d8
commit 4ea60efd1a

View file

@ -607,7 +607,7 @@ export class PositionController extends Controller {
orgChild1Id: IsNull(), orgChild1Id: IsNull(),
posMasterNo: requestBody.posMasterNo, posMasterNo: requestBody.posMasterNo,
}, },
relations: ['orgRoot'], relations: ["orgRoot"],
}); });
if (chk_SName0 != null) { if (chk_SName0 != null) {
throw new HttpError( throw new HttpError(
@ -623,7 +623,7 @@ export class PositionController extends Controller {
orgChild2Id: IsNull(), orgChild2Id: IsNull(),
posMasterNo: requestBody.posMasterNo, posMasterNo: requestBody.posMasterNo,
}, },
relations: ['orgChild1'], relations: ["orgChild1"],
}); });
if (chk_SName1 != null) { if (chk_SName1 != null) {
throw new HttpError( throw new HttpError(
@ -639,7 +639,7 @@ export class PositionController extends Controller {
orgChild3Id: IsNull(), orgChild3Id: IsNull(),
posMasterNo: requestBody.posMasterNo, posMasterNo: requestBody.posMasterNo,
}, },
relations: ['orgChild2'], relations: ["orgChild2"],
}); });
if (chk_SName2 != null) { if (chk_SName2 != null) {
throw new HttpError( throw new HttpError(
@ -655,7 +655,7 @@ export class PositionController extends Controller {
orgChild4Id: IsNull(), orgChild4Id: IsNull(),
posMasterNo: requestBody.posMasterNo, posMasterNo: requestBody.posMasterNo,
}, },
relations: ['orgChild3'], relations: ["orgChild3"],
}); });
if (chk_SName3 != null) { if (chk_SName3 != null) {
throw new HttpError( throw new HttpError(
@ -670,7 +670,7 @@ export class PositionController extends Controller {
orgChild4: { orgChild4ShortName: SName }, orgChild4: { orgChild4ShortName: SName },
posMasterNo: requestBody.posMasterNo, posMasterNo: requestBody.posMasterNo,
}, },
relations: ['orgChild4'], relations: ["orgChild4"],
}); });
if (chk_SName4 != null) { if (chk_SName4 != null) {
throw new HttpError( throw new HttpError(
@ -689,9 +689,9 @@ export class PositionController extends Controller {
const position = Object.assign(new Position()); const position = Object.assign(new Position());
position.positionName = x.posDictName; position.positionName = x.posDictName;
position.positionField = x.posDictField; position.positionField = x.posDictField;
position.posTypeId = x.posTypeId; position.posTypeId = x.posTypeId == "" ? null : x.posTypeId;
position.posLevelId = x.posLevelId; position.posLevelId = x.posLevelId == "" ? null : x.posLevelId;
position.posExecutiveId = x.posExecutiveId; position.posExecutiveId = x.posExecutiveId == "" ? null : x.posExecutiveId;
position.positionExecutiveField = x.posDictExecutiveField; position.positionExecutiveField = x.posDictExecutiveField;
position.positionArea = x.posDictArea; position.positionArea = x.posDictArea;
position.isSpecial = x.isSpecial; position.isSpecial = x.isSpecial;
@ -909,9 +909,9 @@ export class PositionController extends Controller {
orgChild1: { orgChild1ShortName: SName }, orgChild1: { orgChild1ShortName: SName },
orgChild2Id: IsNull(), orgChild2Id: IsNull(),
posMasterNo: requestBody.posMasterNo, posMasterNo: requestBody.posMasterNo,
id: Not(posMaster.id) id: Not(posMaster.id),
}, },
relations: ['orgChild1'], relations: ["orgChild1"],
}); });
if (chk_SName1 != null) { if (chk_SName1 != null) {
throw new HttpError( throw new HttpError(
@ -926,9 +926,9 @@ export class PositionController extends Controller {
orgChild2: { orgChild2ShortName: SName }, orgChild2: { orgChild2ShortName: SName },
orgChild3Id: IsNull(), orgChild3Id: IsNull(),
posMasterNo: requestBody.posMasterNo, posMasterNo: requestBody.posMasterNo,
id: Not(posMaster.id) id: Not(posMaster.id),
}, },
relations: ['orgChild2'], relations: ["orgChild2"],
}); });
if (chk_SName2 != null) { if (chk_SName2 != null) {
throw new HttpError( throw new HttpError(
@ -943,9 +943,9 @@ export class PositionController extends Controller {
orgChild3: { orgChild3ShortName: SName }, orgChild3: { orgChild3ShortName: SName },
orgChild4Id: IsNull(), orgChild4Id: IsNull(),
posMasterNo: requestBody.posMasterNo, posMasterNo: requestBody.posMasterNo,
id: Not(posMaster.id) id: Not(posMaster.id),
}, },
relations: ['orgChild3'], relations: ["orgChild3"],
}); });
if (chk_SName3 != null) { if (chk_SName3 != null) {
throw new HttpError( throw new HttpError(
@ -959,9 +959,9 @@ export class PositionController extends Controller {
orgRevisionId: posMaster.orgRevisionId, orgRevisionId: posMaster.orgRevisionId,
orgChild4: { orgChild4ShortName: SName }, orgChild4: { orgChild4ShortName: SName },
posMasterNo: requestBody.posMasterNo, posMasterNo: requestBody.posMasterNo,
id: Not(posMaster.id) id: Not(posMaster.id),
}, },
relations: ['orgChild4'], relations: ["orgChild4"],
}); });
if (chk_SName4 != null) { if (chk_SName4 != null) {
throw new HttpError( throw new HttpError(
@ -976,13 +976,15 @@ export class PositionController extends Controller {
posMaster.lastUpdateFullName = request.user.name; posMaster.lastUpdateFullName = request.user.name;
await this.posMasterRepository.save(posMaster); await this.posMasterRepository.save(posMaster);
await this.positionRepository.delete({ posMasterId: posMaster.id }); await this.positionRepository.delete({ posMasterId: posMaster.id });
requestBody.positions.forEach(async (x: any) => {
await Promise.all(
requestBody.positions.map(async (x: any) => {
const position = Object.assign(new Position()); const position = Object.assign(new Position());
position.positionName = x.posDictName; position.positionName = x.posDictName;
position.positionField = x.posDictField; position.positionField = x.posDictField;
position.posTypeId = x.posTypeId; position.posTypeId = x.posTypeId == "" ? null : x.posTypeId;
position.posLevelId = x.posLevelId; position.posLevelId = x.posLevelId == "" ? null : x.posLevelId;
position.posExecutiveId = x.posExecutiveId; position.posExecutiveId = x.posExecutiveId == "" ? null : x.posExecutiveId;
position.positionExecutiveField = x.posDictExecutiveField; position.positionExecutiveField = x.posDictExecutiveField;
position.positionArea = x.posDictArea; position.positionArea = x.posDictArea;
position.isSpecial = x.isSpecial; position.isSpecial = x.isSpecial;
@ -993,7 +995,8 @@ export class PositionController extends Controller {
position.lastUpdateUserId = request.user.sub; position.lastUpdateUserId = request.user.sub;
position.lastUpdateFullName = request.user.name; position.lastUpdateFullName = request.user.name;
await this.positionRepository.save(position); await this.positionRepository.save(position);
}); }),
);
return new HttpSuccess(posMaster.id); return new HttpSuccess(posMaster.id);
} }