From 69079d5514fe6362621680f6eaf62bacb327f54b Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Fri, 29 Mar 2024 09:12:01 +0700 Subject: [PATCH 1/3] fix: null error --- src/controllers/ProfileGovernmentController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/ProfileGovernmentController.ts b/src/controllers/ProfileGovernmentController.ts index 518e3e12..551beef9 100644 --- a/src/controllers/ProfileGovernmentController.ts +++ b/src/controllers/ProfileGovernmentController.ts @@ -112,7 +112,7 @@ export class ProfileGovernmentHistoryController extends Controller { org: org, //สังกัด positionField: position == null ? null : position.positionField, //สายงาน position: record.position, //ตำแหน่ง - posLevel: record.posLevel.posLevelName, //ระดับ + posLevel: record.posLevel.posLevelName || null, //ระดับ posMasterNo: posMaster == null ? null : `${orgShortName} ${posMaster.posMasterNo}`, //เลขที่ตำแหน่ง posType: record.posType.posTypeName, //ประเภท posExecutive: From 79a39554ee724162198fdd672b155270c1ad1262 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Fri, 29 Mar 2024 09:12:23 +0700 Subject: [PATCH 2/3] chore: cleanup --- .../ProfileGovernmentController.ts | 21 ++----------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/src/controllers/ProfileGovernmentController.ts b/src/controllers/ProfileGovernmentController.ts index 551beef9..80f766d6 100644 --- a/src/controllers/ProfileGovernmentController.ts +++ b/src/controllers/ProfileGovernmentController.ts @@ -1,28 +1,11 @@ -import { - Body, - Controller, - Delete, - Example, - Get, - Patch, - Path, - Post, - Request, - Route, - Security, - Tags, -} from "tsoa"; +import { Body, Controller, Example, Get, Patch, Path, Request, Route, Security, Tags } from "tsoa"; import { AppDataSource } from "../database/data-source"; import HttpSuccess from "../interfaces/http-success"; import HttpStatus from "../interfaces/http-status"; import HttpError from "../interfaces/http-error"; import { RequestWithUser } from "../middlewares/user"; import { Profile } from "../entities/Profile"; -import { - CreateProfileGovernment, - ProfileGovernment, - UpdateProfileGovernment, -} from "../entities/ProfileGovernment"; +import { ProfileGovernment, UpdateProfileGovernment } from "../entities/ProfileGovernment"; import { Position } from "../entities/Position"; import { PosMaster } from "../entities/PosMaster"; import { calculateAge, calculateRetireDate } from "../interfaces/utils"; From 4084f8b4e800d34198ecad270b768249f9e118c8 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Fri, 29 Mar 2024 09:17:07 +0700 Subject: [PATCH 3/3] fix: null assertion --- src/controllers/ProfileGovernmentController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/ProfileGovernmentController.ts b/src/controllers/ProfileGovernmentController.ts index 80f766d6..42304e69 100644 --- a/src/controllers/ProfileGovernmentController.ts +++ b/src/controllers/ProfileGovernmentController.ts @@ -95,7 +95,7 @@ export class ProfileGovernmentHistoryController extends Controller { org: org, //สังกัด positionField: position == null ? null : position.positionField, //สายงาน position: record.position, //ตำแหน่ง - posLevel: record.posLevel.posLevelName || null, //ระดับ + posLevel: record.posLevel?.posLevelName || null, //ระดับ posMasterNo: posMaster == null ? null : `${orgShortName} ${posMaster.posMasterNo}`, //เลขที่ตำแหน่ง posType: record.posType.posTypeName, //ประเภท posExecutive: