Merge branch 'develop' into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 57s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 57s
This commit is contained in:
commit
e93275ecd0
1 changed files with 167 additions and 71 deletions
|
|
@ -2240,7 +2240,129 @@ export class PositionController extends Controller {
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
let [posMaster, total] = await AppDataSource.getRepository(PosMaster)
|
//Old
|
||||||
|
// let [posMaster, total] = await AppDataSource.getRepository(PosMaster)
|
||||||
|
// .createQueryBuilder("posMaster")
|
||||||
|
// .leftJoinAndSelect("posMaster.orgRoot", "orgRoot")
|
||||||
|
// .leftJoinAndSelect("posMaster.orgChild1", "orgChild1")
|
||||||
|
// .leftJoinAndSelect("posMaster.orgChild2", "orgChild2")
|
||||||
|
// .leftJoinAndSelect("posMaster.orgChild3", "orgChild3")
|
||||||
|
// .leftJoinAndSelect("posMaster.orgChild4", "orgChild4")
|
||||||
|
// .leftJoinAndSelect("posMaster.current_holder", "current_holder")
|
||||||
|
// .leftJoinAndSelect("posMaster.next_holder", "next_holder")
|
||||||
|
// .leftJoinAndSelect("posMaster.orgRevision", "orgRevision")
|
||||||
|
// .where(conditions)
|
||||||
|
// .andWhere(
|
||||||
|
// _data.root != undefined && _data.root != null
|
||||||
|
// ? _data.root[0] != null
|
||||||
|
// ? `posMaster.orgRootId IN (:...root)`
|
||||||
|
// : `posMaster.orgRootId is null`
|
||||||
|
// : "1=1",
|
||||||
|
// {
|
||||||
|
// root: _data.root,
|
||||||
|
// },
|
||||||
|
// )
|
||||||
|
// .andWhere(
|
||||||
|
// _data.child1 != undefined && _data.child1 != null
|
||||||
|
// ? _data.child1[0] != null
|
||||||
|
// ? `posMaster.orgChild1Id IN (:...child1)`
|
||||||
|
// : `posMaster.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
|
||||||
|
// : "1=1",
|
||||||
|
// {
|
||||||
|
// child1: _data.child1,
|
||||||
|
// },
|
||||||
|
// )
|
||||||
|
// .andWhere(
|
||||||
|
// _data.child2 != undefined && _data.child2 != null
|
||||||
|
// ? _data.child2[0] != null
|
||||||
|
// ? `posMaster.orgChild2Id IN (:...child2)`
|
||||||
|
// : `posMaster.orgChild2Id is null`
|
||||||
|
// : "1=1",
|
||||||
|
// {
|
||||||
|
// child2: _data.child2,
|
||||||
|
// },
|
||||||
|
// )
|
||||||
|
// .andWhere(
|
||||||
|
// _data.child3 != undefined && _data.child3 != null
|
||||||
|
// ? _data.child3[0] != null
|
||||||
|
// ? `posMaster.orgChild3Id IN (:...child3)`
|
||||||
|
// : `posMaster.orgChild3Id is null`
|
||||||
|
// : "1=1",
|
||||||
|
// {
|
||||||
|
// child3: _data.child3,
|
||||||
|
// },
|
||||||
|
// )
|
||||||
|
// .andWhere(
|
||||||
|
// _data.child4 != undefined && _data.child4 != null
|
||||||
|
// ? _data.child4[0] != null
|
||||||
|
// ? `posMaster.orgChild4Id IN (:...child4)`
|
||||||
|
// : `posMaster.orgChild4Id is null`
|
||||||
|
// : "1=1",
|
||||||
|
// {
|
||||||
|
// child4: _data.child4,
|
||||||
|
// },
|
||||||
|
// )
|
||||||
|
// .andWhere(
|
||||||
|
// new Brackets((qb) => {
|
||||||
|
// qb.orWhere(
|
||||||
|
// new Brackets((qb) => {
|
||||||
|
// qb.andWhere(
|
||||||
|
// body.keyword != null && body.keyword != ""
|
||||||
|
// ? body.isAll == false
|
||||||
|
// ? 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}%'`
|
||||||
|
// : "1=1",
|
||||||
|
// )
|
||||||
|
// .andWhere(checkChildConditions)
|
||||||
|
// .andWhere(typeCondition)
|
||||||
|
// .andWhere(revisionCondition);
|
||||||
|
// }),
|
||||||
|
// )
|
||||||
|
// .orWhere(
|
||||||
|
// new Brackets((qb) => {
|
||||||
|
// qb.andWhere(
|
||||||
|
// body.keyword != null && body.keyword != ""
|
||||||
|
// ? `CONCAT(current_holder.prefix, current_holder.firstName," ",current_holder.lastName) like '%${body.keyword}%'`
|
||||||
|
// : "1=1",
|
||||||
|
// {
|
||||||
|
// keyword: `%${body.keyword}%`,
|
||||||
|
// },
|
||||||
|
// )
|
||||||
|
// .andWhere(checkChildConditions)
|
||||||
|
// .andWhere(typeCondition)
|
||||||
|
// .andWhere(revisionCondition);
|
||||||
|
// }),
|
||||||
|
// )
|
||||||
|
// .orWhere(
|
||||||
|
// new Brackets((qb) => {
|
||||||
|
// qb.andWhere(
|
||||||
|
// 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}%'`
|
||||||
|
// : "1=1",
|
||||||
|
// {
|
||||||
|
// keyword: `%${body.keyword}%`,
|
||||||
|
// },
|
||||||
|
// )
|
||||||
|
// .andWhere(checkChildConditions)
|
||||||
|
// .andWhere(typeCondition)
|
||||||
|
// .andWhere(revisionCondition);
|
||||||
|
// }),
|
||||||
|
// );
|
||||||
|
// }),
|
||||||
|
// )
|
||||||
|
// .orderBy("orgRoot.orgRootOrder", "ASC")
|
||||||
|
// .addOrderBy("orgChild1.orgChild1Order", "ASC")
|
||||||
|
// .addOrderBy("orgChild2.orgChild2Order", "ASC")
|
||||||
|
// .addOrderBy("orgChild3.orgChild3Order", "ASC")
|
||||||
|
// .addOrderBy("orgChild4.orgChild4Order", "ASC")
|
||||||
|
// .addOrderBy("posMaster.posMasterOrder", "ASC")
|
||||||
|
// .addOrderBy("posMaster.posMasterCreatedAt", "ASC")
|
||||||
|
// .skip((body.page - 1) * body.pageSize)
|
||||||
|
// .take(body.pageSize)
|
||||||
|
// .getManyAndCount();
|
||||||
|
|
||||||
|
//New
|
||||||
|
let query = AppDataSource.getRepository(PosMaster)
|
||||||
.createQueryBuilder("posMaster")
|
.createQueryBuilder("posMaster")
|
||||||
.leftJoinAndSelect("posMaster.orgRoot", "orgRoot")
|
.leftJoinAndSelect("posMaster.orgRoot", "orgRoot")
|
||||||
.leftJoinAndSelect("posMaster.orgChild1", "orgChild1")
|
.leftJoinAndSelect("posMaster.orgChild1", "orgChild1")
|
||||||
|
|
@ -2254,54 +2376,25 @@ export class PositionController extends Controller {
|
||||||
.andWhere(
|
.andWhere(
|
||||||
_data.root != undefined && _data.root != null
|
_data.root != undefined && _data.root != null
|
||||||
? _data.root[0] != null
|
? _data.root[0] != null
|
||||||
? `posMaster.orgRootId IN (:...root)`
|
? "posMaster.orgRootId IN (:...root)"
|
||||||
: `posMaster.orgRootId is null`
|
: "posMaster.orgRootId is null"
|
||||||
: "1=1",
|
: "1=1",
|
||||||
{
|
{ root: _data.root }
|
||||||
root: _data.root,
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
.andWhere(
|
.andWhere(
|
||||||
_data.child1 != undefined && _data.child1 != null
|
_data.child1 != undefined && _data.child1 != null
|
||||||
? _data.child1[0] != null
|
? _data.child1[0] != null
|
||||||
? `posMaster.orgChild1Id IN (:...child1)`
|
? "posMaster.orgChild1Id IN (:...child1)"
|
||||||
: `posMaster.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
|
: `posMaster.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
|
||||||
: "1=1",
|
: "1=1",
|
||||||
{
|
{ child1: _data.child1 }
|
||||||
child1: _data.child1,
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
.andWhere(
|
// .andWhere(checkChildConditions)
|
||||||
_data.child2 != undefined && _data.child2 != null
|
// .andWhere(typeCondition)
|
||||||
? _data.child2[0] != null
|
// .andWhere(revisionCondition);
|
||||||
? `posMaster.orgChild2Id IN (:...child2)`
|
|
||||||
: `posMaster.orgChild2Id is null`
|
if (body.keyword != null && body.keyword != "") {
|
||||||
: "1=1",
|
query.orWhere(
|
||||||
{
|
|
||||||
child2: _data.child2,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.andWhere(
|
|
||||||
_data.child3 != undefined && _data.child3 != null
|
|
||||||
? _data.child3[0] != null
|
|
||||||
? `posMaster.orgChild3Id IN (:...child3)`
|
|
||||||
: `posMaster.orgChild3Id is null`
|
|
||||||
: "1=1",
|
|
||||||
{
|
|
||||||
child3: _data.child3,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.andWhere(
|
|
||||||
_data.child4 != undefined && _data.child4 != null
|
|
||||||
? _data.child4[0] != null
|
|
||||||
? `posMaster.orgChild4Id IN (:...child4)`
|
|
||||||
: `posMaster.orgChild4Id is null`
|
|
||||||
: "1=1",
|
|
||||||
{
|
|
||||||
child4: _data.child4,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.orWhere(
|
|
||||||
new Brackets((qb) => {
|
new Brackets((qb) => {
|
||||||
qb.andWhere(
|
qb.andWhere(
|
||||||
body.keyword != null && body.keyword != ""
|
body.keyword != null && body.keyword != ""
|
||||||
|
|
@ -2315,36 +2408,39 @@ export class PositionController extends Controller {
|
||||||
.andWhere(revisionCondition);
|
.andWhere(revisionCondition);
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.orWhere(
|
.orWhere(
|
||||||
new Brackets((qb) => {
|
new Brackets((qb) => {
|
||||||
qb.andWhere(
|
qb.andWhere(
|
||||||
body.keyword != null && body.keyword != ""
|
body.keyword != null && body.keyword != ""
|
||||||
? `CONCAT(current_holder.prefix, current_holder.firstName," ",current_holder.lastName) like '%${body.keyword}%'`
|
? `CONCAT(current_holder.prefix, current_holder.firstName," ",current_holder.lastName) like '%${body.keyword}%'`
|
||||||
: "1=1",
|
: "1=1",
|
||||||
{
|
{
|
||||||
keyword: `%${body.keyword}%`,
|
keyword: `%${body.keyword}%`,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.andWhere(checkChildConditions)
|
.andWhere(checkChildConditions)
|
||||||
.andWhere(typeCondition)
|
.andWhere(typeCondition)
|
||||||
.andWhere(revisionCondition);
|
.andWhere(revisionCondition);
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.orWhere(
|
.orWhere(
|
||||||
new Brackets((qb) => {
|
new Brackets((qb) => {
|
||||||
qb.andWhere(
|
qb.andWhere(
|
||||||
body.keyword != null && body.keyword != ""
|
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}%'`
|
? `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}%'`
|
||||||
: "1=1",
|
: "1=1",
|
||||||
{
|
{
|
||||||
keyword: `%${body.keyword}%`,
|
keyword: `%${body.keyword}%`,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.andWhere(checkChildConditions)
|
.andWhere(checkChildConditions)
|
||||||
.andWhere(typeCondition)
|
.andWhere(typeCondition)
|
||||||
.andWhere(revisionCondition);
|
.andWhere(revisionCondition);
|
||||||
}),
|
}),
|
||||||
)
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
let [posMaster, total] = await query
|
||||||
.orderBy("orgRoot.orgRootOrder", "ASC")
|
.orderBy("orgRoot.orgRootOrder", "ASC")
|
||||||
.addOrderBy("orgChild1.orgChild1Order", "ASC")
|
.addOrderBy("orgChild1.orgChild1Order", "ASC")
|
||||||
.addOrderBy("orgChild2.orgChild2Order", "ASC")
|
.addOrderBy("orgChild2.orgChild2Order", "ASC")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue