fixed bug api service leave type name
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m10s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m10s
This commit is contained in:
parent
0aa788fe0b
commit
c87b604685
1 changed files with 25 additions and 17 deletions
|
|
@ -525,20 +525,19 @@ export class ApiWebServiceController extends Controller {
|
||||||
|
|
||||||
// สำหรับ ProfileLeave: ตรวจสอบฟิลด์ที่ต้องการ join และแปลง propertyKey
|
// สำหรับ ProfileLeave: ตรวจสอบฟิลด์ที่ต้องการ join และแปลง propertyKey
|
||||||
const profileLeaveFieldJoins: Record<string, string> = {}; // alias -> relationName
|
const profileLeaveFieldJoins: Record<string, string> = {}; // alias -> relationName
|
||||||
if (tbMain === "ProfileLeave") {
|
// Process ProfileLeave fields regardless of main table
|
||||||
propertyKey = propertyKey.map((key) => {
|
propertyKey = propertyKey.map((key) => {
|
||||||
const [table, field] = key.split(".");
|
const [table, field] = key.split(".");
|
||||||
if (table === "ProfileLeave") {
|
if (table === "ProfileLeave") {
|
||||||
const replacement = this.PROFILELEAVE_FIELD_REPLACEMENTS[field];
|
const replacement = this.PROFILELEAVE_FIELD_REPLACEMENTS[field];
|
||||||
if (replacement) {
|
if (replacement) {
|
||||||
const alias = `${table}_${replacement.joinRelation}`;
|
const alias = `${table}_${replacement.joinRelation}`;
|
||||||
profileLeaveFieldJoins[alias] = replacement.joinRelation;
|
profileLeaveFieldJoins[alias] = replacement.joinRelation;
|
||||||
return `${alias}.${replacement.joinField}`;
|
return `${alias}.${replacement.joinField}`;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return key;
|
}
|
||||||
});
|
return key;
|
||||||
}
|
});
|
||||||
|
|
||||||
const queryBuilder = repo.createQueryBuilder(tbMain);
|
const queryBuilder = repo.createQueryBuilder(tbMain);
|
||||||
|
|
||||||
|
|
@ -615,10 +614,19 @@ export class ApiWebServiceController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
// join สำหรับฟิลด์ ProfileLeave ที่ต้องการดึงค่าจากตารางอื่น
|
// join สำหรับฟิลด์ ProfileLeave ที่ต้องการดึงค่าจากตารางอื่น
|
||||||
if (tbMain === "ProfileLeave" && Object.keys(profileLeaveFieldJoins).length > 0) {
|
if (Object.keys(profileLeaveFieldJoins).length > 0) {
|
||||||
Object.entries(profileLeaveFieldJoins).forEach(([alias, relationName]) => {
|
if (tbMain === "ProfileLeave") {
|
||||||
queryBuilder.leftJoin(`${tbMain}.${relationName}`, alias);
|
// ProfileLeave is the main table - direct join
|
||||||
});
|
Object.entries(profileLeaveFieldJoins).forEach(([alias, relationName]) => {
|
||||||
|
queryBuilder.leftJoin(`${tbMain}.${relationName}`, alias);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// ProfileLeave is a related table - the base join is already created by propertyOtherKey logic
|
||||||
|
// Join from the ProfileLeave alias (not from nested path)
|
||||||
|
Object.entries(profileLeaveFieldJoins).forEach(([alias, relationName]) => {
|
||||||
|
queryBuilder.leftJoin(`ProfileLeave.${relationName}`, alias);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// join สำหรับ PosMaster เมื่อต้องการดึงค่าจาก Profile (ข้อมูลคนครอง)
|
// join สำหรับ PosMaster เมื่อต้องการดึงค่าจาก Profile (ข้อมูลคนครอง)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue