fix api web service
This commit is contained in:
parent
8c9a62a378
commit
d3f01165ae
2 changed files with 367 additions and 36 deletions
|
|
@ -316,12 +316,12 @@ export class ApiManageController extends Controller {
|
|||
description: "ข้อมูลส่วนราชการ ระดับที่ 4",
|
||||
system: ["position"],
|
||||
},
|
||||
{
|
||||
name: "Profile",
|
||||
repository: this.profileRepository,
|
||||
description: "ข้อมูลคนครอง",
|
||||
system: ["position"],
|
||||
},
|
||||
// {
|
||||
// name: "Profile",
|
||||
// repository: this.profileRepository,
|
||||
// description: "ข้อมูลคนครอง",
|
||||
// system: ["position"],
|
||||
// },
|
||||
];
|
||||
|
||||
private readonly DEFAULT_PAGE_SIZE = 10; // ขนาดหน้าเริ่มต้น
|
||||
|
|
@ -443,6 +443,27 @@ export class ApiManageController extends Controller {
|
|||
},
|
||||
};
|
||||
|
||||
// การแทนที่ฟิลด์ ID ด้วยฟิลด์ Name สำหรับ ProfileEmployee entity
|
||||
private readonly PROFILEEMPLOYEE_FIELD_REPLACEMENTS: Record<
|
||||
string,
|
||||
{ propertyName: string; type: string; comment: string; joinTable: string; joinField: string }
|
||||
> = {
|
||||
posLevelId: {
|
||||
propertyName: "posLevelName",
|
||||
type: "string",
|
||||
comment: "ระดับชั้นงาน",
|
||||
joinTable: "EmployeePosLevel",
|
||||
joinField: "posLevelName",
|
||||
},
|
||||
posTypeId: {
|
||||
propertyName: "posTypeName",
|
||||
type: "string",
|
||||
comment: "กลุ่มงาน",
|
||||
joinTable: "EmployeePosType",
|
||||
joinField: "posTypeName",
|
||||
},
|
||||
};
|
||||
|
||||
private validateSuperAdminRole(user: any): void {
|
||||
if (!user.role.includes("SUPER_ADMIN")) {
|
||||
throw new HttpError(HttpStatusCode.FORBIDDEN, "คุณไม่มีสิทธิ์ในการเข้าถึงข้อมูลนี้");
|
||||
|
|
@ -533,6 +554,26 @@ export class ApiManageController extends Controller {
|
|||
columns = [...columns, ...nameFields];
|
||||
}
|
||||
|
||||
// Special handling for ProfileEmployee entity - replace ID fields with name fields
|
||||
if (name === "ProfileEmployee") {
|
||||
const replacementKeys = Object.keys(this.PROFILEEMPLOYEE_FIELD_REPLACEMENTS);
|
||||
|
||||
// Remove ID fields that should be replaced
|
||||
columns = columns.filter(
|
||||
(col: { propertyName: string }) => !replacementKeys.includes(col.propertyName),
|
||||
);
|
||||
|
||||
// Add the corresponding name fields
|
||||
const nameFields = replacementKeys.map((key) => ({
|
||||
propertyName: this.PROFILEEMPLOYEE_FIELD_REPLACEMENTS[key].propertyName,
|
||||
type: "string",
|
||||
comment: this.PROFILEEMPLOYEE_FIELD_REPLACEMENTS[key].comment,
|
||||
key: this.PROFILEEMPLOYEE_FIELD_REPLACEMENTS[key].propertyName,
|
||||
}));
|
||||
|
||||
columns = [...columns, ...nameFields];
|
||||
}
|
||||
|
||||
// Special handling for PosMaster entity - add Profile fields for holder information
|
||||
if (name === "PosMaster") {
|
||||
// Add Profile fields that are accessible via current_holder relation
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue