update #1675
This commit is contained in:
parent
5678f333db
commit
0df264e900
1 changed files with 29 additions and 41 deletions
|
|
@ -124,20 +124,20 @@ export class OrganizationController extends Controller {
|
|||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
try {
|
||||
// // CheckQueueInProgress
|
||||
// const [isBusyDraft, isBusyPublish] = await Promise.all([
|
||||
// checkQueueInProgress(`${process.env.AMQ_QUEUE_ORG_DRAFT}`),
|
||||
// checkQueueInProgress(`${process.env.AMQ_QUEUE_ORG}`),
|
||||
// ]);
|
||||
// // console.log("✅ ตรวจสอบแล้ว Draft Busy:", isBusyDraft);
|
||||
// // console.log("✅ ตรวจสอบแล้ว Publish Busy:", isBusyPublish);
|
||||
// if (isBusyDraft || isBusyPublish) {
|
||||
// // console.log("🚫 พบว่ามีงานอยู่ในคิว — error")
|
||||
// throw new HttpError(
|
||||
// HttpStatusCode.CONFLICT,
|
||||
// "ไม่สามารถดำเนินการได้ หากกำลังเผยแพร่หรือสร้างแบบร่างโครงสร้างหน่วยงาน",
|
||||
// );
|
||||
// }
|
||||
// CheckQueueInProgress
|
||||
const [isBusyDraft, isBusyPublish] = await Promise.all([
|
||||
checkQueueInProgress(`${process.env.AMQ_QUEUE_ORG_DRAFT}`),
|
||||
checkQueueInProgress(`${process.env.AMQ_QUEUE_ORG}`),
|
||||
]);
|
||||
// console.log("✅ ตรวจสอบแล้ว Draft Busy:", isBusyDraft);
|
||||
// console.log("✅ ตรวจสอบแล้ว Publish Busy:", isBusyPublish);
|
||||
if (isBusyDraft || isBusyPublish) {
|
||||
// console.log("🚫 พบว่ามีงานอยู่ในคิว — error")
|
||||
throw new HttpError(
|
||||
HttpStatusCode.CONFLICT,
|
||||
"ไม่สามารถดำเนินการได้ หากกำลังเผยแพร่หรือสร้างแบบร่างโครงสร้างหน่วยงาน",
|
||||
);
|
||||
}
|
||||
//new main revision
|
||||
const before = null;
|
||||
const revision = Object.assign(new OrgRevision(), requestBody) as OrgRevision;
|
||||
|
|
@ -163,13 +163,7 @@ export class OrganizationController extends Controller {
|
|||
await sendToQueueOrgDraft(msg);
|
||||
return new HttpSuccess("Draft is being created... Processing in the background.");
|
||||
} catch (error: any) {
|
||||
if (error?.status && error?.message) {
|
||||
return error;
|
||||
}
|
||||
return new HttpError(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"Failed to process the draft. Please try again later.",
|
||||
);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3209,19 +3203,19 @@ export class OrganizationController extends Controller {
|
|||
try {
|
||||
// CheckQueueInProgress
|
||||
// console.log("🚀 ตรวจสอบว่ามีงานอยู่ในคิว");
|
||||
// const [isBusyDraft, isBusyPublish] = await Promise.all([
|
||||
// checkQueueInProgress(`${process.env.AMQ_QUEUE_ORG_DRAFT}`),
|
||||
// checkQueueInProgress(`${process.env.AMQ_QUEUE_ORG}`),
|
||||
// ]);
|
||||
// // console.log("✅ ตรวจสอบแล้ว Draft Busy:", isBusyDraft);
|
||||
// // console.log("✅ ตรวจสอบแล้ว Publish Busy:", isBusyPublish);
|
||||
// if (isBusyDraft || isBusyPublish) {
|
||||
// // console.log("🚫 พบว่ามีงานอยู่ในคิว — error")
|
||||
// throw new HttpError(
|
||||
// HttpStatusCode.CONFLICT,
|
||||
// "ไม่สามารถดำเนินการได้ หากกำลังเผยแพร่หรือสร้างแบบร่างโครงสร้างหน่วยงาน",
|
||||
// );
|
||||
// }
|
||||
const [isBusyDraft, isBusyPublish] = await Promise.all([
|
||||
checkQueueInProgress(`${process.env.AMQ_QUEUE_ORG_DRAFT}`),
|
||||
checkQueueInProgress(`${process.env.AMQ_QUEUE_ORG}`),
|
||||
]);
|
||||
// console.log("✅ ตรวจสอบแล้ว Draft Busy:", isBusyDraft);
|
||||
// console.log("✅ ตรวจสอบแล้ว Publish Busy:", isBusyPublish);
|
||||
if (isBusyDraft || isBusyPublish) {
|
||||
// console.log("🚫 พบว่ามีงานอยู่ในคิว — error")
|
||||
throw new HttpError(
|
||||
HttpStatusCode.CONFLICT,
|
||||
"ไม่สามารถดำเนินการได้ หากกำลังเผยแพร่หรือสร้างแบบร่างโครงสร้างหน่วยงาน",
|
||||
);
|
||||
}
|
||||
|
||||
const today = new Date();
|
||||
today.setHours(0, 0, 0, 0); // Set time to the beginning of the day
|
||||
|
|
@ -3258,13 +3252,7 @@ export class OrganizationController extends Controller {
|
|||
await sendToQueueOrg(msg);
|
||||
return new HttpSuccess();
|
||||
} catch (error: any) {
|
||||
if (error?.status && error?.message) {
|
||||
return error;
|
||||
}
|
||||
return new HttpError(
|
||||
HttpStatusCode.INTERNAL_SERVER_ERROR,
|
||||
"Failed to process the publish. Please try again later.",
|
||||
);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue