no message

This commit is contained in:
Kittapath 2024-02-08 15:47:22 +07:00
parent 9e8ab0ae26
commit 81ae8876d4
2 changed files with 109 additions and 124 deletions

View file

@ -742,25 +742,46 @@ export class PositionController extends Controller {
relations: ["posLevel", "posType", "posExecutive"],
});
if(body.isAll === true) {
if(posMaster.orgRootId !== null && posMaster.orgChild1Id == null && posMaster.orgChild2Id == null
&& posMaster.orgChild2Id == null && posMaster.orgChild3Id == null) {
if (body.isAll === true) {
if (
posMaster.orgRootId !== null &&
posMaster.orgChild1Id == null &&
posMaster.orgChild2Id == null &&
posMaster.orgChild2Id == null &&
posMaster.orgChild3Id == null
) {
body.type = 0;
}
else if(posMaster.orgRootId !== null && posMaster.orgChild1Id !== null && posMaster.orgChild2Id == null
&& posMaster.orgChild2Id == null && posMaster.orgChild3Id == null) {
} else if (
posMaster.orgRootId !== null &&
posMaster.orgChild1Id !== null &&
posMaster.orgChild2Id == null &&
posMaster.orgChild2Id == null &&
posMaster.orgChild3Id == null
) {
body.type = 1;
}
else if(posMaster.orgRootId !== null && posMaster.orgChild1Id !== null && posMaster.orgChild2Id !== null
&& posMaster.orgChild2Id == null && posMaster.orgChild3Id == null) {
} else if (
posMaster.orgRootId !== null &&
posMaster.orgChild1Id !== null &&
posMaster.orgChild2Id !== null &&
posMaster.orgChild2Id == null &&
posMaster.orgChild3Id == null
) {
body.type = 2;
}
else if(posMaster.orgRootId !== null && posMaster.orgChild1Id !== null && posMaster.orgChild2Id !== null
&& posMaster.orgChild2Id !== null && posMaster.orgChild3Id == null) {
} else if (
posMaster.orgRootId !== null &&
posMaster.orgChild1Id !== null &&
posMaster.orgChild2Id !== null &&
posMaster.orgChild2Id !== null &&
posMaster.orgChild3Id == null
) {
body.type = 3;
}
else if(posMaster.orgRootId !== null && posMaster.orgChild1Id !== null && posMaster.orgChild2Id !== null
&& posMaster.orgChild2Id !== null && posMaster.orgChild3Id !== null) {
} else if (
posMaster.orgRootId !== null &&
posMaster.orgChild1Id !== null &&
posMaster.orgChild2Id !== null &&
posMaster.orgChild2Id !== null &&
posMaster.orgChild3Id !== null
) {
body.type = 4;
}
}
@ -1337,4 +1358,77 @@ export class PositionController extends Controller {
return error;
}
}
/**
* API
*
* @summary ORG_065 - (ADMIN) #70
*
*/
@Post("profile")
async createHolder(
@Body() requestBody: { posMaster: string; position: string; profileId: string; isSit: boolean },
) {
const dataMaster = await this.posMasterRepository.findOne({
where: { id: requestBody.posMaster },
relations: ["positions"],
});
if (!dataMaster) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลไอดีนี้ : " + requestBody.posMaster,
);
}
try {
dataMaster.positions.forEach(async (position) => {
if (position.id === requestBody.position) {
position.positionIsSelected = true;
} else {
position.positionIsSelected = false;
}
await this.positionRepository.save(position);
});
dataMaster.isSit = requestBody.isSit;
dataMaster.next_holderId = requestBody.profileId;
await this.posMasterRepository.save(dataMaster);
return new HttpSuccess();
} catch (error) {
return error;
}
}
/**
* API
*
* @summary ORG_066 - (ADMIN) #71
*
* @param {string} id *Id posMaster
*/
@Post("profile/delete/{id}")
async deleteHolder(@Path() id: string) {
const dataMaster = await this.posMasterRepository.findOne({
where: { id: id },
relations: ["positions"],
});
if (!dataMaster) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id);
}
try {
await this.posMasterRepository.update(id, {
isSit: false,
next_holderId: null,
});
dataMaster.positions.forEach(async (position) => {
await this.positionRepository.update(position.id, {
positionIsSelected: false,
});
});
return new HttpSuccess();
} catch (error) {
return error;
}
}
}