แก้ parent
This commit is contained in:
parent
f814454003
commit
a8bb884564
4 changed files with 89 additions and 89 deletions
|
|
@ -1154,7 +1154,7 @@ export class EmployeePositionController extends Controller {
|
||||||
_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 null`
|
: `posMaster.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
|
||||||
: "1=1",
|
: "1=1",
|
||||||
{
|
{
|
||||||
child1: _data.child1,
|
child1: _data.child1,
|
||||||
|
|
@ -1381,24 +1381,22 @@ export class EmployeePositionController extends Controller {
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
if(_data.privilege === 'NORMAL'|| _data.privilege === 'PARENT'|| _data.privilege === 'CHILD'){ //PARENT จะไม่มีทางเห็น ROOT , CHILD ยึดจาก CHILD ที่อยู่ลงไปข้างล่างและจะไม่เห็น CHILD ที่อยู่เหนือกว่า
|
if (_data.privilege === "NORMAL" || _data.privilege === "CHILD") {
|
||||||
const nextChildMap:any = { //เอาไวเช็ค CHILD ถัดไป
|
//PARENT จะไม่มีทางเห็น ROOT , CHILD ยึดจาก CHILD ที่อยู่ลงไปข้างล่างและจะไม่เห็น CHILD ที่อยู่เหนือกว่า
|
||||||
|
const nextChildMap: any = {
|
||||||
|
//เอาไวเช็ค CHILD ถัดไป
|
||||||
0: _data.child1,
|
0: _data.child1,
|
||||||
1: _data.child2,
|
1: _data.child2,
|
||||||
2: _data.child3,
|
2: _data.child3,
|
||||||
3: _data.child4,
|
3: _data.child4,
|
||||||
};
|
};
|
||||||
const childValue = nextChildMap[body.type];
|
const childValue = nextChildMap[body.type];
|
||||||
if(_data.privilege === 'NORMAL'){
|
if (_data.privilege === "NORMAL") {
|
||||||
if (Array.isArray(childValue) && childValue.some(item => item != null)) {
|
if (Array.isArray(childValue) && childValue.some((item) => item != null)) {
|
||||||
return new HttpSuccess({ data: [], total: 0 });
|
return new HttpSuccess({ data: [], total: 0 });
|
||||||
}
|
}
|
||||||
}else if(_data.privilege === 'PARENT'){
|
} else if (_data.privilege === "CHILD") {
|
||||||
if (body.type == 0){
|
|
||||||
return new HttpSuccess({ data: [], total: 0 });
|
|
||||||
}
|
|
||||||
} else if (_data.privilege === 'CHILD') {
|
|
||||||
const higherChildChecks = [
|
const higherChildChecks = [
|
||||||
{ type: [0], child: _data.child1, next: _data.child2 },
|
{ type: [0], child: _data.child1, next: _data.child2 },
|
||||||
{ type: [0, 1], child: _data.child2, next: _data.child3 },
|
{ type: [0, 1], child: _data.child2, next: _data.child3 },
|
||||||
|
|
|
||||||
|
|
@ -902,7 +902,7 @@ export class EmployeeTempPositionController extends Controller {
|
||||||
_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 null`
|
: `posMaster.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
|
||||||
: "1=1",
|
: "1=1",
|
||||||
{
|
{
|
||||||
child1: _data.child1,
|
child1: _data.child1,
|
||||||
|
|
@ -1129,23 +1129,21 @@ export class EmployeeTempPositionController extends Controller {
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
if(_data.privilege === 'NORMAL'|| _data.privilege === 'PARENT'|| _data.privilege === 'CHILD'){ //PARENT จะไม่มีทางเห็น ROOT , CHILD ยึดจาก CHILD ที่อยู่ลงไปข้างล่างและจะไม่เห็น CHILD ที่อยู่เหนือกว่า
|
if (_data.privilege === "NORMAL" || _data.privilege === "CHILD") {
|
||||||
const nextChildMap:any = { //เอาไวเช็ค CHILD ถัดไป
|
//PARENT จะไม่มีทางเห็น ROOT , CHILD ยึดจาก CHILD ที่อยู่ลงไปข้างล่างและจะไม่เห็น CHILD ที่อยู่เหนือกว่า
|
||||||
|
const nextChildMap: any = {
|
||||||
|
//เอาไวเช็ค CHILD ถัดไป
|
||||||
0: _data.child1,
|
0: _data.child1,
|
||||||
1: _data.child2,
|
1: _data.child2,
|
||||||
2: _data.child3,
|
2: _data.child3,
|
||||||
3: _data.child4,
|
3: _data.child4,
|
||||||
};
|
};
|
||||||
const childValue = nextChildMap[body.type];
|
const childValue = nextChildMap[body.type];
|
||||||
if(_data.privilege === 'NORMAL'){
|
if (_data.privilege === "NORMAL") {
|
||||||
if (Array.isArray(childValue) && childValue.some(item => item != null)) {
|
if (Array.isArray(childValue) && childValue.some((item) => item != null)) {
|
||||||
return new HttpSuccess({ data: [], total: 0 });
|
return new HttpSuccess({ data: [], total: 0 });
|
||||||
}
|
}
|
||||||
}else if(_data.privilege === 'PARENT'){
|
} else if (_data.privilege === "CHILD") {
|
||||||
if (body.type == 0){
|
|
||||||
return new HttpSuccess({ data: [], total: 0 });
|
|
||||||
}
|
|
||||||
} else if (_data.privilege === 'CHILD') {
|
|
||||||
const higherChildChecks = [
|
const higherChildChecks = [
|
||||||
{ type: [0], child: _data.child1, next: _data.child2 },
|
{ type: [0], child: _data.child1, next: _data.child2 },
|
||||||
{ type: [0, 1], child: _data.child2, next: _data.child3 },
|
{ type: [0, 1], child: _data.child2, next: _data.child3 },
|
||||||
|
|
|
||||||
|
|
@ -963,40 +963,40 @@ export class PositionController extends Controller {
|
||||||
}
|
}
|
||||||
let orgRoot: any = null;
|
let orgRoot: any = null;
|
||||||
let SName: any = null;
|
let SName: any = null;
|
||||||
let revisionId:any = null;
|
let revisionId: any = null;
|
||||||
if (requestBody.orgRootId != null)
|
if (requestBody.orgRootId != null)
|
||||||
orgRoot = await this.orgRootRepository.findOne({
|
orgRoot = await this.orgRootRepository.findOne({
|
||||||
where: { id: requestBody.orgRootId },
|
where: { id: requestBody.orgRootId },
|
||||||
});
|
});
|
||||||
revisionId = orgRoot?.orgRevisionId;
|
revisionId = orgRoot?.orgRevisionId;
|
||||||
if (!orgRoot) {
|
if (!orgRoot) {
|
||||||
let orgChild1: any = null;
|
let orgChild1: any = null;
|
||||||
if (requestBody.orgChild1Id != null)
|
if (requestBody.orgChild1Id != null)
|
||||||
orgChild1 = await this.child1Repository.findOne({
|
orgChild1 = await this.child1Repository.findOne({
|
||||||
where: { id: requestBody.orgChild1Id },
|
where: { id: requestBody.orgChild1Id },
|
||||||
});
|
});
|
||||||
revisionId = orgChild1?.orgRevisionId;
|
revisionId = orgChild1?.orgRevisionId;
|
||||||
if (!orgChild1) {
|
if (!orgChild1) {
|
||||||
let orgChild2: any = null;
|
let orgChild2: any = null;
|
||||||
if (requestBody.orgChild2Id != null)
|
if (requestBody.orgChild2Id != null)
|
||||||
orgChild2 = await this.child2Repository.findOne({
|
orgChild2 = await this.child2Repository.findOne({
|
||||||
where: { id: requestBody.orgChild2Id },
|
where: { id: requestBody.orgChild2Id },
|
||||||
});
|
});
|
||||||
revisionId = orgChild2?.orgRevisionId;
|
revisionId = orgChild2?.orgRevisionId;
|
||||||
if (!orgChild2) {
|
if (!orgChild2) {
|
||||||
let orgChild3: any = null;
|
let orgChild3: any = null;
|
||||||
if (requestBody.orgChild3Id != null)
|
if (requestBody.orgChild3Id != null)
|
||||||
orgChild3 = await this.child3Repository.findOne({
|
orgChild3 = await this.child3Repository.findOne({
|
||||||
where: { id: requestBody.orgChild3Id },
|
where: { id: requestBody.orgChild3Id },
|
||||||
});
|
});
|
||||||
revisionId = orgChild3?.orgRevisionId;
|
revisionId = orgChild3?.orgRevisionId;
|
||||||
if (!orgChild3) {
|
if (!orgChild3) {
|
||||||
let orgChild4: any = null;
|
let orgChild4: any = null;
|
||||||
if (requestBody.orgChild4Id != null)
|
if (requestBody.orgChild4Id != null)
|
||||||
orgChild4 = await this.child4Repository.findOne({
|
orgChild4 = await this.child4Repository.findOne({
|
||||||
where: { id: requestBody.orgChild4Id },
|
where: { id: requestBody.orgChild4Id },
|
||||||
});
|
});
|
||||||
revisionId = orgChild4?.orgRevisionId;
|
revisionId = orgChild4?.orgRevisionId;
|
||||||
if (!orgChild4) {
|
if (!orgChild4) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงสร้าง");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงสร้าง");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1169,9 +1169,9 @@ export class PositionController extends Controller {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const before = null;
|
const before = null;
|
||||||
let chkRevision:any = null;
|
let chkRevision: any = null;
|
||||||
if(revisionId){
|
if (revisionId) {
|
||||||
chkRevision = await this.orgRevisionRepository.findOne({
|
chkRevision = await this.orgRevisionRepository.findOne({
|
||||||
where: { id: revisionId },
|
where: { id: revisionId },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -2265,7 +2265,7 @@ export class PositionController extends Controller {
|
||||||
_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 null`
|
: `posMaster.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
|
||||||
: "1=1",
|
: "1=1",
|
||||||
{
|
{
|
||||||
child1: _data.child1,
|
child1: _data.child1,
|
||||||
|
|
@ -2301,48 +2301,52 @@ 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}%'`
|
||||||
|
: "1=1",
|
||||||
|
)
|
||||||
|
.andWhere(checkChildConditions)
|
||||||
|
.andWhere(typeCondition)
|
||||||
|
.andWhere(revisionCondition);
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
.andWhere(checkChildConditions)
|
.orWhere(
|
||||||
.andWhere(typeCondition)
|
new Brackets((qb) => {
|
||||||
.andWhere(revisionCondition);
|
qb.andWhere(
|
||||||
}),
|
body.keyword != null && body.keyword != ""
|
||||||
)
|
? `CONCAT(current_holder.prefix, current_holder.firstName," ",current_holder.lastName) like '%${body.keyword}%'`
|
||||||
.orWhere(
|
: "1=1",
|
||||||
new Brackets((qb) => {
|
{
|
||||||
qb.andWhere(
|
keyword: `%${body.keyword}%`,
|
||||||
body.keyword != null && body.keyword != ""
|
},
|
||||||
? `CONCAT(current_holder.prefix, current_holder.firstName," ",current_holder.lastName) like '%${body.keyword}%'`
|
)
|
||||||
: "1=1",
|
.andWhere(checkChildConditions)
|
||||||
{
|
.andWhere(typeCondition)
|
||||||
keyword: `%${body.keyword}%`,
|
.andWhere(revisionCondition);
|
||||||
},
|
}),
|
||||||
)
|
)
|
||||||
.andWhere(checkChildConditions)
|
.orWhere(
|
||||||
.andWhere(typeCondition)
|
new Brackets((qb) => {
|
||||||
.andWhere(revisionCondition);
|
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}%'`
|
||||||
.orWhere(
|
: "1=1",
|
||||||
new Brackets((qb) => {
|
{
|
||||||
qb.andWhere(
|
keyword: `%${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}%'`
|
)
|
||||||
: "1=1",
|
.andWhere(checkChildConditions)
|
||||||
{
|
.andWhere(typeCondition)
|
||||||
keyword: `%${body.keyword}%`,
|
.andWhere(revisionCondition);
|
||||||
},
|
}),
|
||||||
)
|
);
|
||||||
.andWhere(checkChildConditions)
|
|
||||||
.andWhere(typeCondition)
|
|
||||||
.andWhere(revisionCondition);
|
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.orderBy("orgRoot.orgRootOrder", "ASC")
|
.orderBy("orgRoot.orgRootOrder", "ASC")
|
||||||
|
|
@ -2520,24 +2524,22 @@ export class PositionController extends Controller {
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
if(_data.privilege === 'NORMAL'|| _data.privilege === 'PARENT'|| _data.privilege === 'CHILD'){ //PARENT จะไม่มีทางเห็น ROOT , CHILD ยึดจาก CHILD ที่อยู่ลงไปข้างล่างและจะไม่เห็น CHILD ที่อยู่เหนือกว่า
|
if (_data.privilege === "NORMAL" || _data.privilege === "CHILD") {
|
||||||
const nextChildMap:any = { //เอาไวเช็ค CHILD ถัดไป
|
//PARENT จะไม่มีทางเห็น ROOT , CHILD ยึดจาก CHILD ที่อยู่ลงไปข้างล่างและจะไม่เห็น CHILD ที่อยู่เหนือกว่า
|
||||||
|
const nextChildMap: any = {
|
||||||
|
//เอาไวเช็ค CHILD ถัดไป
|
||||||
0: _data.child1,
|
0: _data.child1,
|
||||||
1: _data.child2,
|
1: _data.child2,
|
||||||
2: _data.child3,
|
2: _data.child3,
|
||||||
3: _data.child4,
|
3: _data.child4,
|
||||||
};
|
};
|
||||||
const childValue = nextChildMap[body.type];
|
const childValue = nextChildMap[body.type];
|
||||||
if(_data.privilege === 'NORMAL'){
|
if (_data.privilege === "NORMAL") {
|
||||||
if (Array.isArray(childValue) && childValue.some(item => item != null)) {
|
if (Array.isArray(childValue) && childValue.some((item) => item != null)) {
|
||||||
return new HttpSuccess({ data: [], total: 0 });
|
return new HttpSuccess({ data: [], total: 0 });
|
||||||
}
|
}
|
||||||
}else if(_data.privilege === 'PARENT'){
|
} else if (_data.privilege === "CHILD") {
|
||||||
if (body.type == 0){
|
|
||||||
return new HttpSuccess({ data: [], total: 0 });
|
|
||||||
}
|
|
||||||
} else if (_data.privilege === 'CHILD') {
|
|
||||||
const higherChildChecks = [
|
const higherChildChecks = [
|
||||||
{ type: [0], child: _data.child1, next: _data.child2 },
|
{ type: [0], child: _data.child1, next: _data.child2 },
|
||||||
{ type: [0, 1], child: _data.child2, next: _data.child3 },
|
{ type: [0, 1], child: _data.child2, next: _data.child3 },
|
||||||
|
|
@ -3751,7 +3753,6 @@ export class PositionController extends Controller {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// //เช็คถ้า revision ปัจจุบันให้ปั๊มที่ profile
|
// //เช็คถ้า revision ปัจจุบันให้ปั๊มที่ profile
|
||||||
// const chkRevision = await this.orgRevisionRepository.findOne({
|
// const chkRevision = await this.orgRevisionRepository.findOne({
|
||||||
// where: { id: dataMaster.orgRevisionId },
|
// where: { id: dataMaster.orgRevisionId },
|
||||||
|
|
@ -5290,7 +5291,7 @@ export class PositionController extends Controller {
|
||||||
_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 null`
|
: `posMaster.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
|
||||||
: "1=1",
|
: "1=1",
|
||||||
{
|
{
|
||||||
child1: _data.child1,
|
child1: _data.child1,
|
||||||
|
|
|
||||||
|
|
@ -1028,12 +1028,15 @@ export class ProfileEmployeeTempController extends Controller {
|
||||||
if (!result) {
|
if (!result) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try {
|
||||||
await this.informationHistoryRepository.delete({ profileEmployeeId: id });
|
await this.informationHistoryRepository.delete({ profileEmployeeId: id });
|
||||||
await this.profileRepo.remove(result);
|
await this.profileRepo.remove(result);
|
||||||
} catch {
|
} catch {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถลบข้อมูลได้ เนื่องจากข้อมูลนี้ถูกใช้งานในระบบอื่น");
|
throw new HttpError(
|
||||||
|
HttpStatusCode.NOT_FOUND,
|
||||||
|
"ไม่สามารถลบข้อมูลได้ เนื่องจากข้อมูลนี้ถูกใช้งานในระบบอื่น",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
@ -1106,7 +1109,7 @@ export class ProfileEmployeeTempController extends Controller {
|
||||||
_dataOrg.child1 != undefined && _dataOrg.child1 != null
|
_dataOrg.child1 != undefined && _dataOrg.child1 != null
|
||||||
? _dataOrg.child1[0] != null
|
? _dataOrg.child1[0] != null
|
||||||
? `current_holderTemps.orgChild1Id IN (:...child1)`
|
? `current_holderTemps.orgChild1Id IN (:...child1)`
|
||||||
: `current_holderTemps.orgChild1Id is null`
|
: `current_holderTemps.orgChild1Id is ${_dataOrg.privilege == "PARENT" ? "not null" : "null"}`
|
||||||
: "1=1",
|
: "1=1",
|
||||||
{
|
{
|
||||||
child1: _dataOrg.child1,
|
child1: _dataOrg.child1,
|
||||||
|
|
@ -1561,7 +1564,7 @@ export class ProfileEmployeeTempController extends Controller {
|
||||||
_data.child1 != undefined && _data.child1 != null
|
_data.child1 != undefined && _data.child1 != null
|
||||||
? _data.child1[0] != null
|
? _data.child1[0] != null
|
||||||
? `current_holderTemps.orgChild1Id IN (:...child1)`
|
? `current_holderTemps.orgChild1Id IN (:...child1)`
|
||||||
: `current_holderTemps.orgChild1Id is null`
|
: `current_holderTemps.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
|
||||||
: "1=1",
|
: "1=1",
|
||||||
{
|
{
|
||||||
child1: _data.child1,
|
child1: _data.child1,
|
||||||
|
|
@ -2270,7 +2273,7 @@ export class ProfileEmployeeTempController extends Controller {
|
||||||
_data.child1 != undefined && _data.child1 != null
|
_data.child1 != undefined && _data.child1 != null
|
||||||
? _data.child1[0] != null
|
? _data.child1[0] != null
|
||||||
? `current_holderTemps.orgChild1Id IN (:...child1)`
|
? `current_holderTemps.orgChild1Id IN (:...child1)`
|
||||||
: `current_holderTemps.orgChild1Id is null`
|
: `current_holderTemps.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
|
||||||
: "1=1",
|
: "1=1",
|
||||||
{ child1: _data.child1 },
|
{ child1: _data.child1 },
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue