Merge branch 'develop' into adiDev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m14s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m14s
This commit is contained in:
commit
9288c9e833
2 changed files with 29 additions and 27 deletions
|
|
@ -525,7 +525,7 @@ 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") {
|
||||||
|
|
@ -538,7 +538,6 @@ export class ApiWebServiceController extends Controller {
|
||||||
}
|
}
|
||||||
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) {
|
||||||
|
if (tbMain === "ProfileLeave") {
|
||||||
|
// ProfileLeave is the main table - direct join
|
||||||
Object.entries(profileLeaveFieldJoins).forEach(([alias, relationName]) => {
|
Object.entries(profileLeaveFieldJoins).forEach(([alias, relationName]) => {
|
||||||
queryBuilder.leftJoin(`${tbMain}.${relationName}`, alias);
|
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 (ข้อมูลคนครอง)
|
||||||
|
|
|
||||||
|
|
@ -343,9 +343,11 @@ export class CommandController extends Controller {
|
||||||
.andWhere(
|
.andWhere(
|
||||||
new Brackets((qb) => {
|
new Brackets((qb) => {
|
||||||
qb.where(
|
qb.where(
|
||||||
keyword != null && keyword != "" ? "command.commandNo LIKE :baseKeyword" : "1=1",
|
keyword != null && keyword != ""
|
||||||
|
? "TRIM(CONCAT(COALESCE(command.shortName, ''), ' ', command.commandNo, '/', command.commandYear + 543)) LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
{
|
{
|
||||||
baseKeyword: `%${baseKeyword}%`,
|
keyword: `%${keyword}%`,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.orWhere(keyword != null && keyword != "" ? "command.issue LIKE :keyword" : "1=1", {
|
.orWhere(keyword != null && keyword != "" ? "command.issue LIKE :keyword" : "1=1", {
|
||||||
|
|
@ -356,14 +358,6 @@ export class CommandController extends Controller {
|
||||||
{
|
{
|
||||||
keyword: `%${keyword}%`,
|
keyword: `%${keyword}%`,
|
||||||
},
|
},
|
||||||
)
|
|
||||||
.orWhere(
|
|
||||||
keyword != null && keyword != ""
|
|
||||||
? "CONCAT(command.shortName, ' ', command.commandNo) LIKE :keyword"
|
|
||||||
: "1=1",
|
|
||||||
{
|
|
||||||
keyword: `%${keyword}%`,
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue