Compare commits
4 commits
15ac8d0514
...
57dc171997
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57dc171997 | ||
|
|
a07d436db8 | ||
|
|
2864bea92f | ||
|
|
6a1ca6b867 |
8 changed files with 39 additions and 19 deletions
|
|
@ -321,6 +321,7 @@ export class DevelopmentRequestController extends Controller {
|
|||
}
|
||||
const orgRoot = await this.orgRootRepo.findOne({
|
||||
select: {
|
||||
id: true,
|
||||
isDeputy: true
|
||||
},
|
||||
where: {
|
||||
|
|
@ -369,7 +370,8 @@ export class DevelopmentRequestController extends Controller {
|
|||
posLevelName: profile.posLevel.posLevelName,
|
||||
posTypeName: profile.posType.posTypeName,
|
||||
fullName: `${profile.prefix}${profile.firstName} ${profile.lastName}`,
|
||||
isDeputy: orgRoot?.isDeputy ?? false
|
||||
isDeputy: orgRoot?.isDeputy ?? false,
|
||||
orgRootId: orgRoot?.id ?? null
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Error calling API:", error);
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -335,6 +335,7 @@ export class ProfileEditController extends Controller {
|
|||
}
|
||||
const orgRoot = await this.orgRootRepo.findOne({
|
||||
select: {
|
||||
id: true,
|
||||
isDeputy: true
|
||||
},
|
||||
where: {
|
||||
|
|
@ -363,7 +364,8 @@ export class ProfileEditController extends Controller {
|
|||
posLevelName: profile.posLevel.posLevelName,
|
||||
posTypeName: profile.posType.posTypeName,
|
||||
fullName: `${profile.prefix}${profile.firstName} ${profile.lastName}`,
|
||||
isDeputy: orgRoot?.isDeputy ?? false
|
||||
isDeputy: orgRoot?.isDeputy ?? false,
|
||||
orgRootId: orgRoot?.id ?? null
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Error calling API:", error);
|
||||
|
|
|
|||
|
|
@ -336,6 +336,7 @@ export class ProfileEditEmployeeController extends Controller {
|
|||
}
|
||||
const orgRoot = await this.orgRootRepo.findOne({
|
||||
select: {
|
||||
id: true,
|
||||
isDeputy: true
|
||||
},
|
||||
where: {
|
||||
|
|
@ -363,7 +364,8 @@ export class ProfileEditEmployeeController extends Controller {
|
|||
posLevelName: "EMP",
|
||||
posTypeName: "EMP",
|
||||
fullName: `${profile.prefix}${profile.firstName} ${profile.lastName}`,
|
||||
isDeputy: orgRoot?.isDeputy ?? false
|
||||
isDeputy: orgRoot?.isDeputy ?? false,
|
||||
orgRootId: orgRoot?.id ?? null
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Error calling API:", error);
|
||||
|
|
|
|||
|
|
@ -605,7 +605,7 @@ export class ProfileSalaryController extends Controller {
|
|||
// Recalculate year, month, and day
|
||||
existing.year = Math.floor(existing.days / 365.2524);
|
||||
existing.month = Math.floor((existing.days / 30.4375) % 12);
|
||||
existing.day = Math.floor(existing.days % 30.4375);
|
||||
existing.day = Math.ceil(existing.days % 30.4375);
|
||||
|
||||
return acc;
|
||||
},
|
||||
|
|
@ -644,7 +644,7 @@ export class ProfileSalaryController extends Controller {
|
|||
// Recalculate year, month, and day
|
||||
existing.year = Math.floor(existing.days / 365.2524);
|
||||
existing.month = Math.floor((existing.days / 30.4375) % 12);
|
||||
existing.day = Math.floor(existing.days % 30.4375);
|
||||
existing.day = Math.ceil(existing.days % 30.4375);
|
||||
|
||||
return acc;
|
||||
},
|
||||
|
|
@ -678,7 +678,7 @@ export class ProfileSalaryController extends Controller {
|
|||
// Recalculate year, month, and day
|
||||
existing.year = Math.floor(existing.days / 365.2524);
|
||||
existing.month = Math.floor((existing.days / 30.4375) % 12);
|
||||
existing.day = Math.floor(existing.days % 30.4375);
|
||||
existing.day = Math.ceil(existing.days % 30.4375);
|
||||
|
||||
return acc;
|
||||
},
|
||||
|
|
@ -742,7 +742,7 @@ export class ProfileSalaryController extends Controller {
|
|||
// Recalculate year, month, and day
|
||||
existing.year = Math.floor(existing.days / 365.2524);
|
||||
existing.month = Math.floor((existing.days / 30.4375) % 12);
|
||||
existing.day = Math.floor(existing.days % 30.4375);
|
||||
existing.day = Math.ceil(existing.days % 30.4375);
|
||||
|
||||
return acc;
|
||||
},
|
||||
|
|
@ -785,7 +785,7 @@ export class ProfileSalaryController extends Controller {
|
|||
// Recalculate year, month, and day
|
||||
existing.year = Math.floor(existing.days / 365.2524);
|
||||
existing.month = Math.floor((existing.days / 30.4375) % 12);
|
||||
existing.day = Math.floor(existing.days % 30.4375);
|
||||
existing.day = Math.ceil(existing.days % 30.4375);
|
||||
|
||||
return acc;
|
||||
},
|
||||
|
|
@ -822,7 +822,7 @@ export class ProfileSalaryController extends Controller {
|
|||
// Recalculate year, month, and day
|
||||
existing.year = Math.floor(existing.days / 365.2524);
|
||||
existing.month = Math.floor((existing.days / 30.4375) % 12);
|
||||
existing.day = Math.floor(existing.days % 30.4375);
|
||||
existing.day = Math.ceil(existing.days % 30.4375);
|
||||
|
||||
return acc;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
|
||||
existing.year = Math.floor(existing.days / 365.2524);
|
||||
existing.month = Math.floor((existing.days / 30.4375) % 12);
|
||||
existing.day = Math.floor(existing.days % 30.4375);
|
||||
existing.day = Math.ceil(existing.days % 30.4375);
|
||||
|
||||
return acc;
|
||||
},
|
||||
|
|
@ -213,7 +213,7 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
|
||||
existing.year = Math.floor(existing.days / 365.2524);
|
||||
existing.month = Math.floor((existing.days / 30.4375) % 12);
|
||||
existing.day = Math.floor(existing.days % 30.4375);
|
||||
existing.day = Math.ceil(existing.days % 30.4375);
|
||||
|
||||
return acc;
|
||||
},
|
||||
|
|
@ -268,7 +268,7 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
|
||||
existing.year = Math.floor(existing.days / 365.2524);
|
||||
existing.month = Math.floor((existing.days / 30.4375) % 12);
|
||||
existing.day = Math.floor(existing.days % 30.4375);
|
||||
existing.day = Math.ceil(existing.days % 30.4375);
|
||||
|
||||
return acc;
|
||||
},
|
||||
|
|
@ -304,7 +304,7 @@ export class ProfileSalaryEmployeeController extends Controller {
|
|||
|
||||
existing.year = Math.floor(existing.days / 365.2524);
|
||||
existing.month = Math.floor((existing.days / 30.4375) % 12);
|
||||
existing.day = Math.floor(existing.days % 30.4375);
|
||||
existing.day = Math.ceil(existing.days % 30.4375);
|
||||
|
||||
return acc;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ export class WorkflowController extends Controller {
|
|||
posTypeName: string;
|
||||
fullName?: string | null;
|
||||
isDeputy?: boolean | null;
|
||||
orgRootId?: string | null;
|
||||
},
|
||||
) {
|
||||
// ขั้นที่ 1: ทำการค้นหา profile และ metaWorkflow แบบ parallel
|
||||
|
|
@ -203,9 +204,10 @@ export class WorkflowController extends Controller {
|
|||
posMasterAssigns: { assignId: body.sysName },
|
||||
orgRevision: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true },
|
||||
current_holderId: Not(IsNull()), // เพิ่มเงื่อนไขนี้เพื่อกรองเฉพาะที่มี current_holder
|
||||
...(body.orgRootId && { orgRootId: body.orgRootId }), // กรองเฉพาะที่อยู่ในสำนักเดียวกัน (ถ้าส่งมา)
|
||||
},
|
||||
relations: ["orgChild1"],
|
||||
select: ["current_holderId", "orgChild1"], // เลือกเฉพาะ field ที่จำเป็น
|
||||
// select: ["current_holderId", "orgChild1"], // เลือกเฉพาะ field ที่จำเป็น
|
||||
});
|
||||
|
||||
// สร้าง StateOperatorUsers สำหรับ officers
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue