Merge branch 'develop' into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 55s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 55s
This commit is contained in:
commit
3351e4800f
3 changed files with 56 additions and 26 deletions
|
|
@ -1328,23 +1328,23 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
|
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// await new CallAPI()
|
await new CallAPI()
|
||||||
// .PostData(request, "/placement/noti/profiles", {
|
.PostData(request, "/placement/noti/profiles", {
|
||||||
// subject: `${kpiUserEvaluation.prefix}${kpiUserEvaluation.firstName} ${kpiUserEvaluation.lastName} มีความเห็นต่างเนื่องจาก: ${requestBody.reason}`,
|
subject: `${kpiUserEvaluation.prefix}${kpiUserEvaluation.firstName} ${kpiUserEvaluation.lastName} มีความเห็นต่างเนื่องจาก: ${requestBody.reason}`,
|
||||||
// body: `${kpiUserEvaluation.prefix}${kpiUserEvaluation.firstName} ${kpiUserEvaluation.lastName} มีความเห็นต่างเนื่องจาก: ${requestBody.reason}`,
|
body: `${kpiUserEvaluation.prefix}${kpiUserEvaluation.firstName} ${kpiUserEvaluation.lastName} มีความเห็นต่างเนื่องจาก: ${requestBody.reason}`,
|
||||||
// receiverUserIds: [
|
receiverUserIds: [
|
||||||
// {
|
{
|
||||||
// receiverUserId: kpiUserEvaluation.evaluatorId,
|
receiverUserId: kpiUserEvaluation.evaluatorId,
|
||||||
// notiLink: `${process.env.VITE_URL_USER}/KPI-evaluator/${kpiUserEvaluation.id}`,
|
notiLink: `${process.env.VITE_URL_USER}/KPI-evaluator/${kpiUserEvaluation.id}`,
|
||||||
// },
|
},
|
||||||
// ],
|
],
|
||||||
// payload: "",
|
payload: "",
|
||||||
// isSendMail: true,
|
isSendMail: true,
|
||||||
// isSendInbox: true,
|
isSendInbox: true,
|
||||||
// isSendNotification: true,
|
isSendNotification: true,
|
||||||
// })
|
})
|
||||||
// .then(() => {})
|
.then(() => {})
|
||||||
// .catch(() => {});
|
.catch(() => {});
|
||||||
const before = structuredClone(kpiUserEvaluation);
|
const before = structuredClone(kpiUserEvaluation);
|
||||||
let _null: any = null;
|
let _null: any = null;
|
||||||
kpiUserEvaluation.evaluationStatus = "EVALUATING_EVALUATOR";
|
kpiUserEvaluation.evaluationStatus = "EVALUATING_EVALUATOR";
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import {
|
||||||
Path,
|
Path,
|
||||||
} from "tsoa";
|
} from "tsoa";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { addLogSequence } from "./utils";
|
import { addLogSequence, safeStringify } from "./utils";
|
||||||
|
|
||||||
class CallAPI {
|
class CallAPI {
|
||||||
//Get
|
//Get
|
||||||
|
|
@ -34,7 +34,7 @@ class CallAPI {
|
||||||
request: {
|
request: {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: url,
|
url: url,
|
||||||
response: JSON.stringify(response.data.result),
|
response: safeStringify(response.data.result),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return response.data.result;
|
return response.data.result;
|
||||||
|
|
@ -46,7 +46,7 @@ class CallAPI {
|
||||||
request: {
|
request: {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
url: url,
|
url: url,
|
||||||
response: JSON.stringify(error),
|
response: safeStringify(error),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
throw error;
|
throw error;
|
||||||
|
|
@ -71,8 +71,8 @@ class CallAPI {
|
||||||
request: {
|
request: {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: url,
|
url: url,
|
||||||
payload: JSON.stringify(sendData),
|
payload: safeStringify(sendData),
|
||||||
response: JSON.stringify(response.data.result),
|
response: safeStringify(response.data.result),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return response.data.result;
|
return response.data.result;
|
||||||
|
|
@ -84,8 +84,8 @@ class CallAPI {
|
||||||
request: {
|
request: {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
url: url,
|
url: url,
|
||||||
payload: JSON.stringify(sendData),
|
payload: safeStringify(sendData),
|
||||||
response: JSON.stringify(error),
|
response: safeStringify(error),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
throw error;
|
throw error;
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,8 @@ export function setLogDataDiff(req: RequestWithUser, data: DataDiff) {
|
||||||
typeof data.after === "object"
|
typeof data.after === "object"
|
||||||
) {
|
) {
|
||||||
req.app.locals.logData.dataDiff = {
|
req.app.locals.logData.dataDiff = {
|
||||||
before: JSON.stringify(data.before),
|
before: safeStringify(data.before),
|
||||||
after: JSON.stringify(data.after),
|
after: safeStringify(data.after),
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
console.error("Invalid data provided: both before and after must be valid objects.");
|
console.error("Invalid data provided: both before and after must be valid objects.");
|
||||||
|
|
@ -45,3 +45,33 @@ export function addLogSequence(req: RequestWithUser, data: LogSequence) {
|
||||||
export function editLogSequence(req: RequestWithUser, index: number, data: LogSequence) {
|
export function editLogSequence(req: RequestWithUser, index: number, data: LogSequence) {
|
||||||
req.app.locals.logData.sequence[index] = data;
|
req.app.locals.logData.sequence[index] = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ปลอดภัยกว่า JSON.stringify()
|
||||||
|
* - กัน circular reference
|
||||||
|
* - จำกัดความลึก
|
||||||
|
* - return string แน่นอนเสมอ
|
||||||
|
*/
|
||||||
|
export function safeStringify(obj: any, space?: number): string {
|
||||||
|
const cache = new WeakSet();
|
||||||
|
|
||||||
|
try {
|
||||||
|
return JSON.stringify(
|
||||||
|
obj,
|
||||||
|
(key, value) => {
|
||||||
|
// ป้องกัน circular reference
|
||||||
|
if (typeof value === "object" && value !== null) {
|
||||||
|
if (cache.has(value)) {
|
||||||
|
return "[Circular]";
|
||||||
|
}
|
||||||
|
cache.add(value);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
},
|
||||||
|
space,
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
console.error("⚠️ safeStringify error:", err);
|
||||||
|
return "[Unserializable object]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue