Fix ตั้งเวลาเผยแพร่
This commit is contained in:
parent
4abee90c38
commit
0b09de7735
1 changed files with 11 additions and 20 deletions
|
|
@ -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<string, any> },
|
||||
) {
|
||||
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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue