แก้ query โครงสร้างตำแหน่ง

This commit is contained in:
kittapath 2024-09-16 18:18:01 +07:00
parent 52fd0d2634
commit 471307cf3f

View file

@ -1296,51 +1296,55 @@ export class PositionController extends Controller {
child4: _data.child4, child4: _data.child4,
}, },
) )
// .orWhere( .andWhere(
// new Brackets((qb) => { new Brackets((qb) => {
// qb.andWhere( qb.orWhere(
// body.keyword != null && body.keyword != "" new Brackets((qb) => {
// ? body.isAll == false qb.andWhere(
// ? searchShortName body.keyword != null && body.keyword != ""
// : `CASE WHEN posMaster.orgChild1 is null THEN ${searchShortName0} WHEN posMaster.orgChild2 is null THEN ${searchShortName1} WHEN posMaster.orgChild3 is null THEN ${searchShortName2} WHEN posMaster.orgChild4 is null THEN ${searchShortName3} ELSE ${searchShortName4} END LIKE '%${body.keyword}%'` ? body.isAll == false
// : "1=1", ? searchShortName
// ) : `CASE WHEN posMaster.orgChild1 is null THEN ${searchShortName0} WHEN posMaster.orgChild2 is null THEN ${searchShortName1} WHEN posMaster.orgChild3 is null THEN ${searchShortName2} WHEN posMaster.orgChild4 is null THEN ${searchShortName3} ELSE ${searchShortName4} END LIKE '%${body.keyword}%'`
// .andWhere(checkChildConditions) : "1=1",
// .andWhere(typeCondition) )
// .andWhere(revisionCondition); .andWhere(checkChildConditions)
// }), .andWhere(typeCondition)
// ) .andWhere(revisionCondition);
// .orWhere( }),
// new Brackets((qb) => { )
// qb.andWhere( .orWhere(
// body.keyword != null && body.keyword != "" new Brackets((qb) => {
// ? `CONCAT(current_holder.prefix, current_holder.firstName," ",current_holder.lastName) like '%${body.keyword}%'` qb.andWhere(
// : "1=1", body.keyword != null && body.keyword != ""
// { ? `CONCAT(current_holder.prefix, current_holder.firstName," ",current_holder.lastName) like '%${body.keyword}%'`
// keyword: `%${body.keyword}%`, : "1=1",
// }, {
// ) keyword: `%${body.keyword}%`,
// .andWhere(checkChildConditions) },
// .andWhere(typeCondition) )
// .andWhere(revisionCondition); .andWhere(checkChildConditions)
// }), .andWhere(typeCondition)
// ) .andWhere(revisionCondition);
// .orWhere( }),
// new Brackets((qb) => { )
// qb.andWhere( .orWhere(
// body.keyword != null && body.keyword != "" new Brackets((qb) => {
// ? `CASE WHEN orgRevision.orgRevisionIsDraft = true THEN CONCAT(next_holder.prefix, next_holder.firstName,' ', next_holder.lastName) ELSE CONCAT(current_holder.prefix, current_holder.firstName,' ' , current_holder.lastName) END LIKE '%${body.keyword}%'` qb.andWhere(
// : "1=1", body.keyword != null && body.keyword != ""
// { ? `CASE WHEN orgRevision.orgRevisionIsDraft = true THEN CONCAT(next_holder.prefix, next_holder.firstName,' ', next_holder.lastName) ELSE CONCAT(current_holder.prefix, current_holder.firstName,' ' , current_holder.lastName) END LIKE '%${body.keyword}%'`
// keyword: `%${body.keyword}%`, : "1=1",
// }, {
// ) keyword: `%${body.keyword}%`,
// .andWhere(checkChildConditions) },
// .andWhere(typeCondition) )
// .andWhere(revisionCondition); .andWhere(checkChildConditions)
// }), .andWhere(typeCondition)
// ) .andWhere(revisionCondition);
// .orderBy("posMaster.posMasterOrder", "ASC") }),
);
}),
)
.orderBy("posMaster.posMasterOrder", "ASC")
.skip((body.page - 1) * body.pageSize) .skip((body.page - 1) * body.pageSize)
.take(body.pageSize) .take(body.pageSize)
.getManyAndCount(); .getManyAndCount();