API ตั้งเวลาเผยแพร่

This commit is contained in:
Bright 2024-01-29 15:46:33 +07:00
parent e82b4f6a85
commit fc72620c19

View file

@ -335,6 +335,47 @@ export class OrganizationController extends Controller {
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 {
throw new Error("Function not implemented.");