no message

This commit is contained in:
Kittapath 2024-02-13 15:36:23 +07:00
parent 89beced8cc
commit ed862a3802

View file

@ -337,11 +337,12 @@ export class PositionController extends Controller {
} else { } else {
const order: any = await this.posMasterRepository.findOne({ const order: any = await this.posMasterRepository.findOne({
where: { where: {
orgChild4Id: orgChild4.id orgChild4Id: orgChild4.id,
}, },
order: { posMasterNo: "DESC" } order: { posMasterNo: "DESC" },
}) });
posMaster.posMasterOrder = order.posMasterOrder == null ? 1: order.posMasterOrder+1 posMaster.posMasterOrder =
order.posMasterOrder == null ? 1 : order.posMasterOrder + 1;
posMaster.orgRootId = orgChild4.orgRootId; posMaster.orgRootId = orgChild4.orgRootId;
posMaster.orgChild1Id = orgChild4.orgChild1Id; posMaster.orgChild1Id = orgChild4.orgChild1Id;
posMaster.orgChild2Id = orgChild4.orgChild2Id; posMaster.orgChild2Id = orgChild4.orgChild2Id;
@ -353,11 +354,11 @@ export class PositionController extends Controller {
const order: any = await this.posMasterRepository.findOne({ const order: any = await this.posMasterRepository.findOne({
where: { where: {
orgChild3Id: orgChild3.id, orgChild3Id: orgChild3.id,
orgChild4Id: IsNull() || "" orgChild4Id: IsNull() || "",
}, },
order: { posMasterNo: "DESC" } order: { posMasterNo: "DESC" },
}) });
posMaster.posMasterOrder = order.posMasterOrder == null ? 1: order.posMasterOrder+1 posMaster.posMasterOrder = order.posMasterOrder == null ? 1 : order.posMasterOrder + 1;
posMaster.orgRootId = orgChild3.orgRootId; posMaster.orgRootId = orgChild3.orgRootId;
posMaster.orgChild1Id = orgChild3.orgChild1Id; posMaster.orgChild1Id = orgChild3.orgChild1Id;
posMaster.orgChild2Id = orgChild3.orgChild2Id; posMaster.orgChild2Id = orgChild3.orgChild2Id;
@ -371,9 +372,9 @@ export class PositionController extends Controller {
orgChild3Id: IsNull() || "", orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "", orgChild4Id: IsNull() || "",
}, },
order: { posMasterNo: "DESC" } order: { posMasterNo: "DESC" },
}) });
posMaster.posMasterOrder = order.posMasterOrder == null ? 1: order.posMasterOrder+1 posMaster.posMasterOrder = order.posMasterOrder == null ? 1 : order.posMasterOrder + 1;
posMaster.orgRootId = orgChild2.orgRootId; posMaster.orgRootId = orgChild2.orgRootId;
posMaster.orgChild1Id = orgChild2.orgChild1Id; posMaster.orgChild1Id = orgChild2.orgChild1Id;
posMaster.orgChild2Id = orgChild2.id; posMaster.orgChild2Id = orgChild2.id;
@ -387,9 +388,9 @@ export class PositionController extends Controller {
orgChild3Id: IsNull() || "", orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "", orgChild4Id: IsNull() || "",
}, },
order: { posMasterNo: "DESC" } order: { posMasterNo: "DESC" },
}) });
posMaster.posMasterOrder = order.posMasterOrder == null ? 1: order.posMasterOrder+1 posMaster.posMasterOrder = order.posMasterOrder == null ? 1 : order.posMasterOrder + 1;
posMaster.orgRootId = orgChild1.orgRootId; posMaster.orgRootId = orgChild1.orgRootId;
posMaster.orgChild1Id = orgChild1.id; posMaster.orgChild1Id = orgChild1.id;
posMaster.orgRevisionId = orgChild1.orgRevisionId; posMaster.orgRevisionId = orgChild1.orgRevisionId;
@ -403,9 +404,9 @@ export class PositionController extends Controller {
orgChild3Id: IsNull() || "", orgChild3Id: IsNull() || "",
orgChild4Id: IsNull() || "", orgChild4Id: IsNull() || "",
}, },
order: { posMasterNo: "DESC" } order: { posMasterNo: "DESC" },
}) });
posMaster.posMasterOrder = order.posMasterOrder == null ? 1: order.posMasterOrder+1 posMaster.posMasterOrder = order.posMasterOrder == null ? 1 : order.posMasterOrder + 1;
posMaster.orgRootId = orgRoot.id; posMaster.orgRootId = orgRoot.id;
posMaster.orgRevisionId = orgRoot.orgRevisionId; posMaster.orgRevisionId = orgRoot.orgRevisionId;
} }
@ -1051,7 +1052,12 @@ export class PositionController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่งตามไอดีนี้ : " + id); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่งตามไอดีนี้ : " + id);
} }
const posMasters = await this.posMasterRepository.find({ const posMasters = await this.posMasterRepository.find({
where: { ancestorDNA: posMaster.ancestorDNA }, where: {
ancestorDNA:
posMaster.ancestorDNA == null || posMaster.ancestorDNA == ""
? "123"
: posMaster.ancestorDNA,
},
order: { lastUpdatedAt: "DESC" }, order: { lastUpdatedAt: "DESC" },
relations: ["orgRoot", "orgChild1", "orgChild2", "orgChild3", "orgChild4"], relations: ["orgRoot", "orgChild1", "orgChild2", "orgChild3", "orgChild4"],
}); });
@ -1383,8 +1389,7 @@ export class PositionController extends Controller {
default: default:
break; break;
} }
} } else {
else {
switch (requestBody.type) { switch (requestBody.type) {
case 0: { case 0: {
const NodeId = await this.posMasterRepository.findOne({ const NodeId = await this.posMasterRepository.findOne({
@ -1789,23 +1794,28 @@ export class PositionController extends Controller {
* *
*/ */
@Post("dna") @Post("dna")
async dna(@Body() requestBody: { draftPositionId: string; publishPositionId: string;}) { async dna(@Body() requestBody: { draftPositionId: string; publishPositionId: string }) {
const dataDraft = await this.posMasterRepository.findOne({ const dataDraft = await this.posMasterRepository.findOne({
where: { id: requestBody.draftPositionId }, where: { id: requestBody.draftPositionId },
}); });
if (!dataDraft) { if (!dataDraft) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้(draftPositionId) : " + requestBody.draftPositionId); throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลไอดีนี้(draftPositionId) : " + requestBody.draftPositionId,
);
} }
const dataPublish = await this.posMasterRepository.findOne({ const dataPublish = await this.posMasterRepository.findOne({
where: { id: requestBody.publishPositionId }, where: { id: requestBody.publishPositionId },
}); });
if (!dataPublish) { if (!dataPublish) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้(publishPositionId) : " + requestBody.publishPositionId); throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลไอดีนี้(publishPositionId) : " + requestBody.publishPositionId,
);
} }
try { try {
dataDraft.ancestorDNA = dataPublish.ancestorDNA; dataDraft.ancestorDNA = dataPublish.ancestorDNA;
await this.posMasterRepository.save(dataDraft); await this.posMasterRepository.save(dataDraft);