cron job Revision
This commit is contained in:
parent
148fa2c81c
commit
1abf623924
3 changed files with 50 additions and 10 deletions
|
|
@ -1320,4 +1320,39 @@ export class OrganizationController extends Controller {
|
|||
await this.orgRevisionRepository.save(orgRevisionDraft);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cronjob
|
||||
*/
|
||||
async cronjobRevision() {
|
||||
|
||||
const today = new Date();
|
||||
today.setHours(0, 0, 0, 0); // Set time to the beginning of the day
|
||||
const orgRevisionPublish = await this.orgRevisionRepository
|
||||
.createQueryBuilder("orgRevision")
|
||||
.where("orgRevision.orgRevisionIsDraft = false")
|
||||
.andWhere("orgRevision.orgRevisionIsCurrent = true")
|
||||
.getOne();
|
||||
|
||||
const orgRevisionDraft = await this.orgRevisionRepository
|
||||
.createQueryBuilder("orgRevision")
|
||||
.where("orgRevision.orgRevisionIsDraft = true")
|
||||
.andWhere("orgRevision.orgRevisionIsCurrent = false")
|
||||
.andWhere("DATE(orgRevision.orgPublishDate) = :today", { today })
|
||||
.getOne();
|
||||
if (!orgRevisionDraft) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
if (orgRevisionPublish) {
|
||||
orgRevisionPublish.orgRevisionIsDraft = false;
|
||||
orgRevisionPublish.orgRevisionIsCurrent = false;
|
||||
await this.orgRevisionRepository.save(orgRevisionPublish);
|
||||
|
||||
}
|
||||
orgRevisionDraft.orgRevisionIsCurrent = true;
|
||||
orgRevisionDraft.orgRevisionIsDraft = false;
|
||||
await this.orgRevisionRepository.save(orgRevisionDraft);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,14 +99,13 @@ export class PositionController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล PosLevelId");
|
||||
}
|
||||
|
||||
if (requestBody.posExecutiveId == "") {
|
||||
requestBody.posExecutiveId = null;
|
||||
if (posDict.posExecutiveId == "") {
|
||||
posDict.posExecutiveId = null;
|
||||
}
|
||||
|
||||
if (requestBody.posExecutiveId != null) {
|
||||
if (posDict.posExecutiveId != null) {
|
||||
const checkPosExecutiveId = await this.posExecutiveRepository.findOne({
|
||||
where: { id: requestBody.posExecutiveId },
|
||||
where: { id: posDict.posExecutiveId },
|
||||
});
|
||||
if (!checkPosExecutiveId) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล PosExecutiveId");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue