From 0b09de77353f0c5ade4f31df3fdcd3dc97c32e28 Mon Sep 17 00:00:00 2001 From: Bright Date: Tue, 30 Jan 2024 14:18:46 +0700 Subject: [PATCH] =?UTF-8?q?Fix=20=E0=B8=95=E0=B8=B1=E0=B9=89=E0=B8=87?= =?UTF-8?q?=E0=B9=80=E0=B8=A7=E0=B8=A5=E0=B8=B2=E0=B9=80=E0=B8=9C=E0=B8=A2?= =?UTF-8?q?=E0=B9=81=E0=B8=9E=E0=B8=A3=E0=B9=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/OrganizationController.ts | 31 ++++++++--------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index 7996b46e..72909cdd 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -505,7 +505,7 @@ export class OrganizationController extends Controller { * * @summary ORG_025 - ตั้งเวลาเผยแพร่ (ADMIN) #27 * - * @param {string} id Id root + * @param {string} id Id revison */ @Put("/set/publish/{id}") async Edit( @@ -513,30 +513,21 @@ export class OrganizationController extends Controller { @Body() requestBody: { orgPublishDate: Date }, @Request() request: { user: Record }, ) { + const orgRevision = await this.orgRevisionRepository.findOne({ + where: { + id: id, + orgRevisionIsDraft: true, + orgRevisionIsCurrent: false, + }, + }); + if (!orgRevision) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. RevisionId"); + } try { - const rootIdExits = await this.orgRootRepository.findOne({ - where: { id: id }, - }); - if (!rootIdExits) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. RootId"); - } - - const orgRevision = await this.orgRevisionRepository.findOne({ - where: { - id: rootIdExits.orgRevisionId, - orgRevisionIsDraft: true, - orgRevisionIsCurrent: false, - }, - }); - if (!orgRevision) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. RevisionId"); - } - orgRevision.lastUpdateUserId = request.user.sub; orgRevision.lastUpdateFullName = request.user.name; orgRevision.lastUpdatedAt = new Date(); orgRevision.orgPublishDate = requestBody.orgPublishDate; - this.orgRevisionRepository.merge(orgRevision, requestBody); await this.orgRevisionRepository.save(orgRevision); return new HttpSuccess();