API ตั้งเวลาเผยแพร่
This commit is contained in:
parent
e82b4f6a85
commit
fc72620c19
1 changed files with 41 additions and 0 deletions
|
|
@ -335,6 +335,47 @@ export class OrganizationController extends Controller {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API ตั้งเวลาเผยแพร่
|
||||||
|
*
|
||||||
|
* @summary ORG_025 - ตั้งเวลาเผยแพร่ (ADMIN) #27
|
||||||
|
*
|
||||||
|
* @param {string} id Id root
|
||||||
|
*/
|
||||||
|
@Put("/set/publish/{id}")
|
||||||
|
async Edit(
|
||||||
|
@Path() id: string,
|
||||||
|
@Body() requestBody: {"orgPublishDate": Date},
|
||||||
|
@Request() request: { user: Record<string, any> },
|
||||||
|
) {
|
||||||
|
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();
|
||||||
|
} catch (error) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function ANY(arg0: OrgRevision[]): string | import("typeorm").FindOperator<string> | undefined {
|
function ANY(arg0: OrgRevision[]): string | import("typeorm").FindOperator<string> | undefined {
|
||||||
throw new Error("Function not implemented.");
|
throw new Error("Function not implemented.");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue