From a07d436db852c448589fe3bce9f341b26118888a Mon Sep 17 00:00:00 2001 From: harid Date: Fri, 10 Apr 2026 16:00:12 +0700 Subject: [PATCH] =?UTF-8?q?fix=20=E0=B8=82=E0=B9=89=E0=B8=AD=E0=B8=A1?= =?UTF-8?q?=E0=B8=B9=E0=B8=A5=E0=B8=9C=E0=B8=B9=E0=B9=89=E0=B8=9E=E0=B9=89?= =?UTF-8?q?=E0=B8=99=E0=B8=88=E0=B8=B2=E0=B8=81=E0=B8=A3=E0=B8=B2=E0=B8=8A?= =?UTF-8?q?=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=81=E0=B9=88=E0=B8=AD=E0=B8=99?= =?UTF-8?q?=E0=B8=9B=E0=B8=B5=202568=20=E0=B8=A3=E0=B8=B0=E0=B8=9A?= =?UTF-8?q?=E0=B8=9A=E0=B9=84=E0=B8=A1=E0=B9=88=E0=B9=80=E0=B8=81=E0=B9=87?= =?UTF-8?q?=E0=B8=9A=20logs=20#2383?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileController.ts | 8 ++++---- src/middlewares/logs.ts | 14 +++++++++++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 9e758e67..15461d31 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -8966,13 +8966,13 @@ export class ProfileController extends Controller { "current_holders.orgChild2", "current_holders.orgChild3", "current_holders.orgChild4", - "profileSalary", + // "profileSalary", "profileEducations", ], order: { - profileSalary: { - order: "DESC", - }, + // profileSalary: { + // order: "DESC", + // }, profileEducations: { level: "ASC", }, diff --git a/src/middlewares/logs.ts b/src/middlewares/logs.ts index 3f1a5963..391e8699 100644 --- a/src/middlewares/logs.ts +++ b/src/middlewares/logs.ts @@ -56,6 +56,7 @@ async function logMiddleware(req: Request, res: Response, next: NextFunction) { if (req.url.startsWith("/api/v1/org/profile/")) system = "registry"; if (req.url.startsWith("/api/v1/org/profile-employee/")) system = "registry"; if (req.url.startsWith("/api/v1/org/profile-temp/")) system = "registry"; + if (req.url.startsWith("/api/v1/org/ex/")) system = "retirement"; if (req.url.startsWith("/api/v1/org/commandType/admin")) system = "admin"; if (req.url.startsWith("/api/v1/org/commandSys/")) system = "admin"; @@ -79,6 +80,17 @@ async function logMiddleware(req: Request, res: Response, next: NextFunction) { // Get rootId from token const rootId = req.app.locals.logData?.orgRootDnaId; + let _msg = data?.message; + if (!_msg) { + if (res.statusCode >= 500) { + _msg = "ไม่สำเร็จ"; + } else if (res.statusCode >= 400) { + _msg = "พบข้อผิดพลาด"; + } else if (res.statusCode >= 200) { + _msg = "สำเร็จ"; + } + } + if (level === 1 && res.statusCode < 500) return; if (level === 2 && res.statusCode < 400) return; if (level === 3 && res.statusCode < 200) return; @@ -94,7 +106,7 @@ async function logMiddleware(req: Request, res: Response, next: NextFunction) { method: req.method, endpoint: req.url, responseCode: String(res.statusCode === 304 ? 200 : res.statusCode), - responseDescription: data?.message, + responseDescription: _msg, input: level === 4 ? JSON.stringify(req.body, null, 2) : undefined, output: level === 4 ? JSON.stringify(data, null, 2) : undefined, ...req.app.locals.logData,