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
|
* @summary ORG_025 - ตั้งเวลาเผยแพร่ (ADMIN) #27
|
||||||
*
|
*
|
||||||
* @param {string} id Id root
|
* @param {string} id Id revison
|
||||||
*/
|
*/
|
||||||
@Put("/set/publish/{id}")
|
@Put("/set/publish/{id}")
|
||||||
async Edit(
|
async Edit(
|
||||||
|
|
@ -513,17 +513,9 @@ export class OrganizationController extends Controller {
|
||||||
@Body() requestBody: { orgPublishDate: Date },
|
@Body() requestBody: { orgPublishDate: Date },
|
||||||
@Request() request: { user: Record<string, any> },
|
@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({
|
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
id: rootIdExits.orgRevisionId,
|
id: id,
|
||||||
orgRevisionIsDraft: true,
|
orgRevisionIsDraft: true,
|
||||||
orgRevisionIsCurrent: false,
|
orgRevisionIsCurrent: false,
|
||||||
},
|
},
|
||||||
|
|
@ -531,12 +523,11 @@ export class OrganizationController extends Controller {
|
||||||
if (!orgRevision) {
|
if (!orgRevision) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. RevisionId");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. RevisionId");
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
orgRevision.lastUpdateUserId = request.user.sub;
|
orgRevision.lastUpdateUserId = request.user.sub;
|
||||||
orgRevision.lastUpdateFullName = request.user.name;
|
orgRevision.lastUpdateFullName = request.user.name;
|
||||||
orgRevision.lastUpdatedAt = new Date();
|
orgRevision.lastUpdatedAt = new Date();
|
||||||
orgRevision.orgPublishDate = requestBody.orgPublishDate;
|
orgRevision.orgPublishDate = requestBody.orgPublishDate;
|
||||||
|
|
||||||
this.orgRevisionRepository.merge(orgRevision, requestBody);
|
this.orgRevisionRepository.merge(orgRevision, requestBody);
|
||||||
await this.orgRevisionRepository.save(orgRevision);
|
await this.orgRevisionRepository.save(orgRevision);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue