From 1f44c7b41851a5291c1800497316562b97fe7f91 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 9 May 2024 12:09:59 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=20type=20date?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/KpiUserPlannedController.ts | 4 ++++ src/controllers/KpiUserRoleController.ts | 4 ++++ src/controllers/KpiUserSpecialController.ts | 4 ++++ src/entities/kpiSpecial.ts | 4 ++-- src/entities/kpiUserPlanned.ts | 12 ++++++------ src/entities/kpiUserRole.ts | 12 ++++++------ src/entities/kpiUserSpecial.ts | 12 ++++++------ 7 files changed, 32 insertions(+), 20 deletions(-) diff --git a/src/controllers/KpiUserPlannedController.ts b/src/controllers/KpiUserPlannedController.ts index e0c23f2..504e426 100644 --- a/src/controllers/KpiUserPlannedController.ts +++ b/src/controllers/KpiUserPlannedController.ts @@ -87,6 +87,8 @@ export class KpiUserPlannedController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } + kpiUserPlanned.startDate = requestBody.startDate == undefined ? null : requestBody.startDate; + kpiUserPlanned.endDate = requestBody.endDate == undefined ? null : requestBody.endDate; kpiUserPlanned.createdUserId = request.user.sub; kpiUserPlanned.createdFullName = request.user.name; kpiUserPlanned.lastUpdateUserId = request.user.sub; @@ -147,6 +149,8 @@ export class KpiUserPlannedController extends Controller { // kpiUserPlanned.achievement5 = request.user.achievement5; this.kpiUserPlannedRepository.merge(kpiUserPlanned, requestBody); + kpiUserPlanned.startDate = requestBody.startDate == undefined ? null : requestBody.startDate; + kpiUserPlanned.endDate = requestBody.endDate == undefined ? null : requestBody.endDate; await this.kpiUserPlannedRepository.save(kpiUserPlanned); return new HttpSuccess(kpiUserPlanned.id); } diff --git a/src/controllers/KpiUserRoleController.ts b/src/controllers/KpiUserRoleController.ts index e89b0d0..afaa7a2 100644 --- a/src/controllers/KpiUserRoleController.ts +++ b/src/controllers/KpiUserRoleController.ts @@ -90,6 +90,8 @@ export class KpiUserRoleController extends Controller { ); } + kpiUserRole.startDate = requestBody.startDate == undefined ? null : requestBody.startDate; + kpiUserRole.endDate = requestBody.endDate == undefined ? null : requestBody.endDate; kpiUserRole.createdUserId = request.user.sub; kpiUserRole.createdFullName = request.user.name; kpiUserRole.lastUpdateUserId = request.user.sub; @@ -149,6 +151,8 @@ export class KpiUserRoleController extends Controller { kpiUserRole.lastUpdateUserId = request.user.sub; kpiUserRole.lastUpdateFullName = request.user.name; this.kpiUserRoleRepository.merge(kpiUserRole, requestBody); + kpiUserRole.startDate = requestBody.startDate == undefined ? null : requestBody.startDate; + kpiUserRole.endDate = requestBody.endDate == undefined ? null : requestBody.endDate; await this.kpiUserRoleRepository.save(kpiUserRole); return new HttpSuccess(kpiUserRole.id); } diff --git a/src/controllers/KpiUserSpecialController.ts b/src/controllers/KpiUserSpecialController.ts index 5987c50..da142cb 100644 --- a/src/controllers/KpiUserSpecialController.ts +++ b/src/controllers/KpiUserSpecialController.ts @@ -101,6 +101,8 @@ export class KpiUserSpecialController extends Controller { kpiSpecial.lastUpdateFullName = request.user.name; await this.kpiSpecialRepository.save(kpiSpecial); } + kpiUserSpecial.startDate = requestBody.startDate == undefined ? null : requestBody.startDate; + kpiUserSpecial.endDate = requestBody.endDate == undefined ? null : requestBody.endDate; kpiUserSpecial.createdUserId = request.user.sub; kpiUserSpecial.createdFullName = request.user.name; kpiUserSpecial.lastUpdateUserId = request.user.sub; @@ -173,6 +175,8 @@ export class KpiUserSpecialController extends Controller { kpiUserSpecial.lastUpdateUserId = request.user.sub; kpiUserSpecial.lastUpdateFullName = request.user.name; Object.assign(kpiUserSpecial, requestBody); + kpiUserSpecial.startDate = requestBody.startDate == undefined ? null : requestBody.startDate; + kpiUserSpecial.endDate = requestBody.endDate == undefined ? null : requestBody.endDate; await this.kpiUserSpecialRepository.save(kpiUserSpecial); return new HttpSuccess(kpiUserSpecial.id); } diff --git a/src/entities/kpiSpecial.ts b/src/entities/kpiSpecial.ts index 5983be2..535848b 100644 --- a/src/entities/kpiSpecial.ts +++ b/src/entities/kpiSpecial.ts @@ -88,7 +88,7 @@ export class KpiSpecial extends EntityBase { comment: "ช่วงเวลาเริ่มเก็บข้อมูล", default: null, }) - startDate: Date; + startDate: Date | null; @Column({ nullable: true, @@ -96,7 +96,7 @@ export class KpiSpecial extends EntityBase { comment: "ช่วงเวลาสิ้นสุดเก็บข้อมูล", default: null, }) - endDate: Date; + endDate: Date | null; @Column({ nullable: true, diff --git a/src/entities/kpiUserPlanned.ts b/src/entities/kpiUserPlanned.ts index 92e52cc..e78e008 100644 --- a/src/entities/kpiUserPlanned.ts +++ b/src/entities/kpiUserPlanned.ts @@ -93,7 +93,7 @@ export class KpiUserPlanned extends EntityBase { comment: "ช่วงเวลาเริ่มเก็บข้อมูล", default: null, }) - startDate: Date; + startDate: Date | null; @Column({ nullable: true, @@ -101,7 +101,7 @@ export class KpiUserPlanned extends EntityBase { comment: "ช่วงเวลาสิ้นสุดเก็บข้อมูล", default: null, }) - endDate: Date; + endDate: Date | null; @Column({ nullable: true, @@ -163,9 +163,9 @@ export class CreateKpiUserPlanned { @Column() documentInfoEvidence: string; @Column({ nullable: true }) - startDate?: Date; + startDate?: Date | null; @Column({ nullable: true }) - endDate?: Date; + endDate?: Date | null; @Column() achievement1: string; @Column() @@ -196,9 +196,9 @@ export class UpdateKpiUserPlanned { @Column() documentInfoEvidence: string; @Column({ nullable: true }) - startDate?: Date; + startDate?: Date | null; @Column({ nullable: true }) - endDate?: Date; + endDate?: Date | null; @Column() achievement1: string; @Column() diff --git a/src/entities/kpiUserRole.ts b/src/entities/kpiUserRole.ts index 86cd8d9..42c8599 100644 --- a/src/entities/kpiUserRole.ts +++ b/src/entities/kpiUserRole.ts @@ -94,7 +94,7 @@ export class KpiUserRole extends EntityBase { comment: "ช่วงเวลาเริ่มเก็บข้อมูล", default: null, }) - startDate: Date; + startDate: Date | null; @Column({ nullable: true, @@ -102,7 +102,7 @@ export class KpiUserRole extends EntityBase { comment: "ช่วงเวลาสิ้นสุดเก็บข้อมูล", default: null, }) - endDate: Date; + endDate: Date | null; @Column({ nullable: true, @@ -164,9 +164,9 @@ export class CreateKpiUserRole { @Column() documentInfoEvidence: string; @Column({ nullable: true }) - startDate?: Date; + startDate?: Date | null; @Column({ nullable: true }) - endDate?: Date; + endDate?: Date | null; @Column() achievement1: string; @Column() @@ -197,9 +197,9 @@ export class UpdateKpiUserRole { @Column() documentInfoEvidence: string; @Column({ nullable: true }) - startDate?: Date; + startDate?: Date | null; @Column({ nullable: true }) - endDate?: Date; + endDate?: Date | null; @Column() achievement1: string; @Column() diff --git a/src/entities/kpiUserSpecial.ts b/src/entities/kpiUserSpecial.ts index d305240..8408c70 100644 --- a/src/entities/kpiUserSpecial.ts +++ b/src/entities/kpiUserSpecial.ts @@ -89,7 +89,7 @@ export class KpiUserSpecial extends EntityBase { comment: "ช่วงเวลาเริ่มเก็บข้อมูล", default: null, }) - startDate: Date; + startDate: Date | null; @Column({ nullable: true, @@ -97,7 +97,7 @@ export class KpiUserSpecial extends EntityBase { comment: "ช่วงเวลาสิ้นสุดเก็บข้อมูล", default: null, }) - endDate: Date; + endDate: Date | null; @Column({ nullable: true, @@ -197,9 +197,9 @@ export class CreateKpiUserSpecial { @Column() documentInfoEvidence: string; @Column({ nullable: true }) - startDate: Date; + startDate?: Date | null; @Column({ nullable: true }) - endDate: Date; + endDate?: Date | null; @Column() period: string; @Column() @@ -236,9 +236,9 @@ export class UpdateKpiUserSpecial { @Column() documentInfoEvidence: string; @Column({ nullable: true }) - startDate: Date; + startDate?: Date | null; @Column({ nullable: true }) - endDate: Date; + endDate?: Date | null; @Column() period: string; @Column()