remove try catch

This commit is contained in:
AdisakKanthawilang 2024-02-28 11:31:01 +07:00
parent 039b11d1c3
commit e9ed8ff3f4
8 changed files with 1575 additions and 1744 deletions

View file

@ -60,26 +60,22 @@ export class OrgChild1Controller {
if (!orgChild1) { if (!orgChild1) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล โครงสร้างระดับ 1"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล โครงสร้างระดับ 1");
} }
try { const getOrgChild1 = {
const getOrgChild1 = { orgChild1Id: orgChild1.id,
orgChild1Id: orgChild1.id, orgRootName: orgChild1.orgRoot.orgRootName,
orgRootName: orgChild1.orgRoot.orgRootName, orgName: `${orgChild1.orgChild1Name}/${orgChild1.orgRoot.orgRootName}`,
orgName: `${orgChild1.orgChild1Name}/${orgChild1.orgRoot.orgRootName}`, orgChild1Name: orgChild1.orgChild1Name,
orgChild1Name: orgChild1.orgChild1Name, orgChild1ShortName: orgChild1.orgChild1ShortName,
orgChild1ShortName: orgChild1.orgChild1ShortName, orgChild1Code: orgChild1.orgChild1Code,
orgChild1Code: orgChild1.orgChild1Code, orgChild1Rank: orgChild1.orgChild1Rank,
orgChild1Rank: orgChild1.orgChild1Rank, orgChild1Order: orgChild1.orgChild1Order,
orgChild1Order: orgChild1.orgChild1Order, orgChild1PhoneEx: orgChild1.orgChild1PhoneEx,
orgChild1PhoneEx: orgChild1.orgChild1PhoneEx, orgChild1PhoneIn: orgChild1.orgChild1PhoneIn,
orgChild1PhoneIn: orgChild1.orgChild1PhoneIn, orgChild1Fax: orgChild1.orgChild1Fax,
orgChild1Fax: orgChild1.orgChild1Fax, orgRevisionId: orgChild1.orgRevisionId,
orgRevisionId: orgChild1.orgRevisionId, orgCode: orgChild1.orgRoot.orgRootCode + orgChild1.orgChild1Code,
orgCode: orgChild1.orgRoot.orgRootCode + orgChild1.orgChild1Code, };
}; return new HttpSuccess(getOrgChild1);
return new HttpSuccess(getOrgChild1);
} catch (error) {
return error;
}
} }
/** /**
@ -136,22 +132,18 @@ export class OrgChild1Controller {
}, },
order: { orgChild1Order: "DESC" }, order: { orgChild1Order: "DESC" },
}); });
try { const child1 = Object.assign(new OrgChild1(), requestBody) as OrgChild1;
const child1 = Object.assign(new OrgChild1(), requestBody) as OrgChild1; child1.orgChild1Name = requestBody.orgChild1Name;
child1.orgChild1Name = requestBody.orgChild1Name; child1.createdUserId = request.user.sub;
child1.createdUserId = request.user.sub; child1.createdFullName = request.user.name;
child1.createdFullName = request.user.name; child1.lastUpdateUserId = request.user.sub;
child1.lastUpdateUserId = request.user.sub; child1.lastUpdateFullName = request.user.name;
child1.lastUpdateFullName = request.user.name; child1.orgRevisionId = String(rootIdExits?.orgRevisionId);
child1.orgRevisionId = String(rootIdExits?.orgRevisionId); child1.orgRootId = String(rootIdExits?.id);
child1.orgRootId = String(rootIdExits?.id); child1.orgChild1Order =
child1.orgChild1Order = order == null || order.orgChild1Order == null ? 1 : order.orgChild1Order + 1;
order == null || order.orgChild1Order == null ? 1 : order.orgChild1Order + 1; await this.child1Repository.save(child1);
await this.child1Repository.save(child1); return new HttpSuccess();
return new HttpSuccess();
} catch (error) {
return error;
}
} }
/** /**
@ -212,18 +204,14 @@ export class OrgChild1Controller {
if (chkCode != null) { if (chkCode != null) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "รหัสหน่วยงานนี้มีอยู่ในระบบแล้ว"); throw new HttpError(HttpStatusCode.NOT_FOUND, "รหัสหน่วยงานนี้มีอยู่ในระบบแล้ว");
} }
try { child1.lastUpdateUserId = request.user.sub;
child1.lastUpdateUserId = request.user.sub; child1.lastUpdateFullName = request.user.name;
child1.lastUpdateFullName = request.user.name; child1.lastUpdatedAt = new Date();
child1.lastUpdatedAt = new Date(); child1.orgRevisionId = String(rootIdExits?.orgRevisionId);
child1.orgRevisionId = String(rootIdExits?.orgRevisionId); child1.orgRootId = String(rootIdExits?.id);
child1.orgRootId = String(rootIdExits?.id); this.child1Repository.merge(child1, requestBody);
this.child1Repository.merge(child1, requestBody); await this.child1Repository.save(child1);
await this.child1Repository.save(child1); return new HttpSuccess();
return new HttpSuccess();
} catch (error) {
return error;
}
} }
/** /**
@ -261,23 +249,19 @@ export class OrgChild1Controller {
// "ไม่สามารถลบได้ เนื่องจาก id ผูกกับโครงสร้างระดับ2", // "ไม่สามารถลบได้ เนื่องจาก id ผูกกับโครงสร้างระดับ2",
// ); // );
// } // }
try { const posMasters = await this.posMasterRepository.find({
const posMasters = await this.posMasterRepository.find({ where: { orgChild1Id: id },
where: { orgChild1Id: id }, });
}); const positions = await this.positionRepository.find({
const positions = await this.positionRepository.find({ where: [{ posMasterId: In(posMasters.map((x) => x.id)) }],
where: [{ posMasterId: In(posMasters.map((x) => x.id)) }], });
});
await this.positionRepository.remove(positions); await this.positionRepository.remove(positions);
await this.posMasterRepository.remove(posMasters); await this.posMasterRepository.remove(posMasters);
await this.child4Repository.delete({ orgChild1Id: id }); await this.child4Repository.delete({ orgChild1Id: id });
await this.child3Repository.delete({ orgChild1Id: id }); await this.child3Repository.delete({ orgChild1Id: id });
await this.child2Repository.delete({ orgChild1Id: id }); await this.child2Repository.delete({ orgChild1Id: id });
await this.child1Repository.delete({ id }); await this.child1Repository.delete({ id });
return new HttpSuccess(); return new HttpSuccess();
} catch (error) {
return error;
}
} }
} }

View file

@ -62,26 +62,22 @@ export class OrgChild2Controller extends Controller {
if (!orgChild2) { if (!orgChild2) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล โครงสร้างระดับ 2"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล โครงสร้างระดับ 2");
} }
try { const getOrgChild2 = {
const getOrgChild2 = { orgChild2Id: orgChild2.id,
orgChild2Id: orgChild2.id, orgRootName: orgChild2.orgRoot.orgRootName,
orgRootName: orgChild2.orgRoot.orgRootName, orgName: `${orgChild2.orgChild2Name}/${orgChild2.orgChild1.orgChild1Name}/${orgChild2.orgRoot.orgRootName}`,
orgName: `${orgChild2.orgChild2Name}/${orgChild2.orgChild1.orgChild1Name}/${orgChild2.orgRoot.orgRootName}`, orgChild2Name: orgChild2.orgChild2Name,
orgChild2Name: orgChild2.orgChild2Name, orgChild2ShortName: orgChild2.orgChild2ShortName,
orgChild2ShortName: orgChild2.orgChild2ShortName, orgChild2Code: orgChild2.orgChild2Code,
orgChild2Code: orgChild2.orgChild2Code, orgChild2Rank: orgChild2.orgChild2Rank,
orgChild2Rank: orgChild2.orgChild2Rank, orgChild2Order: orgChild2.orgChild2Order,
orgChild2Order: orgChild2.orgChild2Order, orgChild2PhoneEx: orgChild2.orgChild2PhoneEx,
orgChild2PhoneEx: orgChild2.orgChild2PhoneEx, orgChild2PhoneIn: orgChild2.orgChild2PhoneIn,
orgChild2PhoneIn: orgChild2.orgChild2PhoneIn, orgChild2Fax: orgChild2.orgChild2Fax,
orgChild2Fax: orgChild2.orgChild2Fax, orgRevisionId: orgChild2.orgRevisionId,
orgRevisionId: orgChild2.orgRevisionId, orgCode: orgChild2.orgRoot.orgRootCode + orgChild2.orgChild2Code,
orgCode: orgChild2.orgRoot.orgRootCode + orgChild2.orgChild2Code, };
}; return new HttpSuccess(getOrgChild2);
return new HttpSuccess(getOrgChild2);
} catch (error) {
return error;
}
} }
/** /**
@ -142,23 +138,19 @@ export class OrgChild2Controller extends Controller {
}, },
order: { orgChild2Order: "DESC" }, order: { orgChild2Order: "DESC" },
}); });
try { const child2 = Object.assign(new OrgChild2(), requestBody) as OrgChild2;
const child2 = Object.assign(new OrgChild2(), requestBody) as OrgChild2; child2.orgChild2Name = requestBody.orgChild2Name;
child2.orgChild2Name = requestBody.orgChild2Name; child2.createdUserId = request.user.sub;
child2.createdUserId = request.user.sub; child2.createdFullName = request.user.name;
child2.createdFullName = request.user.name; child2.lastUpdateUserId = request.user.sub;
child2.lastUpdateUserId = request.user.sub; child2.lastUpdateFullName = request.user.name;
child2.lastUpdateFullName = request.user.name; child2.orgRootId = String(child1?.orgRootId);
child2.orgRootId = String(child1?.orgRootId); child2.orgRevisionId = String(child1?.orgRevisionId);
child2.orgRevisionId = String(child1?.orgRevisionId); child2.orgChild1Id = String(child1?.id);
child2.orgChild1Id = String(child1?.id); child2.orgChild2Order =
child2.orgChild2Order = order == null || order.orgChild2Order == null ? 1 : order.orgChild2Order + 1;
order == null || order.orgChild2Order == null ? 1 : order.orgChild2Order + 1; await this.child2Repository.save(child2);
await this.child2Repository.save(child2); return new HttpSuccess();
return new HttpSuccess();
} catch (error) {
return error;
}
} }
/** /**
@ -223,19 +215,15 @@ export class OrgChild2Controller extends Controller {
if (!child2) { if (!child2) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found."); throw new HttpError(HttpStatusCode.NOT_FOUND, "not found.");
} }
try { child2.lastUpdateUserId = request.user.sub;
child2.lastUpdateUserId = request.user.sub; child2.lastUpdateFullName = request.user.name;
child2.lastUpdateFullName = request.user.name; child2.lastUpdatedAt = new Date();
child2.lastUpdatedAt = new Date(); child2.orgRootId = String(child1IdExits?.orgRootId);
child2.orgRootId = String(child1IdExits?.orgRootId); child2.orgRevisionId = String(child1IdExits?.orgRevisionId);
child2.orgRevisionId = String(child1IdExits?.orgRevisionId); child2.orgChild1Id = String(child1IdExits?.id);
child2.orgChild1Id = String(child1IdExits?.id); this.child2Repository.merge(child2, requestBody);
this.child2Repository.merge(child2, requestBody); await this.child2Repository.save(child2);
await this.child2Repository.save(child2); return new HttpSuccess();
return new HttpSuccess();
} catch (error) {
return error;
}
} }
/** /**
@ -275,22 +263,18 @@ export class OrgChild2Controller extends Controller {
// "ไม่สามารถลบได้ เนื่องจาก id ผูกกับโครงสร้างระดับ4", // "ไม่สามารถลบได้ เนื่องจาก id ผูกกับโครงสร้างระดับ4",
// ); // );
// } // }
try { const posMasters = await this.posMasterRepository.find({
const posMasters = await this.posMasterRepository.find({ where: { orgChild2Id: id },
where: { orgChild2Id: id }, });
}); const positions = await this.positionRepository.find({
const positions = await this.positionRepository.find({ where: [{ posMasterId: In(posMasters.map((x) => x.id)) }],
where: [{ posMasterId: In(posMasters.map((x) => x.id)) }], });
});
await this.positionRepository.remove(positions); await this.positionRepository.remove(positions);
await this.posMasterRepository.remove(posMasters); await this.posMasterRepository.remove(posMasters);
await this.child4Repository.delete({ orgChild2Id: id }); await this.child4Repository.delete({ orgChild2Id: id });
await this.child3Repository.delete({ orgChild2Id: id }); await this.child3Repository.delete({ orgChild2Id: id });
await this.child2Repository.delete({ id }); await this.child2Repository.delete({ id });
return new HttpSuccess(); return new HttpSuccess();
} catch (error) {
return error;
}
} }
} }

View file

@ -58,26 +58,22 @@ export class OrgChild3Controller {
if (!orgChild3) { if (!orgChild3) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล โครงสร้างระดับ 3"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล โครงสร้างระดับ 3");
} }
try { const getOrgChild3 = {
const getOrgChild3 = { orgChild3Id: orgChild3.id,
orgChild3Id: orgChild3.id, orgRootName: orgChild3.orgRoot.orgRootName,
orgRootName: orgChild3.orgRoot.orgRootName, orgName: `${orgChild3.orgChild3Name}/${orgChild3.orgChild2.orgChild2Name}/${orgChild3.orgChild1.orgChild1Name}/${orgChild3.orgRoot.orgRootName}`,
orgName: `${orgChild3.orgChild3Name}/${orgChild3.orgChild2.orgChild2Name}/${orgChild3.orgChild1.orgChild1Name}/${orgChild3.orgRoot.orgRootName}`, orgChild3Name: orgChild3.orgChild3Name,
orgChild3Name: orgChild3.orgChild3Name, orgChild3ShortName: orgChild3.orgChild3ShortName,
orgChild3ShortName: orgChild3.orgChild3ShortName, orgChild3Code: orgChild3.orgChild3Code,
orgChild3Code: orgChild3.orgChild3Code, orgChild3Rank: orgChild3.orgChild3Rank,
orgChild3Rank: orgChild3.orgChild3Rank, orgChild3Order: orgChild3.orgChild3Order,
orgChild3Order: orgChild3.orgChild3Order, orgChild3PhoneEx: orgChild3.orgChild3PhoneEx,
orgChild3PhoneEx: orgChild3.orgChild3PhoneEx, orgChild3PhoneIn: orgChild3.orgChild3PhoneIn,
orgChild3PhoneIn: orgChild3.orgChild3PhoneIn, orgChild3Fax: orgChild3.orgChild3Fax,
orgChild3Fax: orgChild3.orgChild3Fax, orgRevisionId: orgChild3.orgRevisionId,
orgRevisionId: orgChild3.orgRevisionId, orgCode: orgChild3.orgRoot.orgRootCode + orgChild3.orgChild3Code,
orgCode: orgChild3.orgRoot.orgRootCode + orgChild3.orgChild3Code, };
}; return new HttpSuccess(getOrgChild3);
return new HttpSuccess(getOrgChild3);
} catch (error) {
return error;
}
} }
/** /**
@ -124,24 +120,20 @@ export class OrgChild3Controller {
}, },
order: { orgChild3Order: "DESC" }, order: { orgChild3Order: "DESC" },
}); });
try { const child3 = Object.assign(new OrgChild3(), requestBody) as OrgChild3;
const child3 = Object.assign(new OrgChild3(), requestBody) as OrgChild3; child3.orgChild3Name = requestBody.orgChild3Name;
child3.orgChild3Name = requestBody.orgChild3Name; child3.createdUserId = request.user.sub;
child3.createdUserId = request.user.sub; child3.createdFullName = request.user.name;
child3.createdFullName = request.user.name; child3.lastUpdateUserId = request.user.sub;
child3.lastUpdateUserId = request.user.sub; child3.lastUpdateFullName = request.user.name;
child3.lastUpdateFullName = request.user.name; child3.orgRootId = String(child2?.orgRootId);
child3.orgRootId = String(child2?.orgRootId); child3.orgChild1Id = String(child2?.orgChild1Id);
child3.orgChild1Id = String(child2?.orgChild1Id); child3.orgRevisionId = String(child2?.orgRevisionId);
child3.orgRevisionId = String(child2?.orgRevisionId); child3.orgChild2Id = String(child2?.id);
child3.orgChild2Id = String(child2?.id); child3.orgChild3Order =
child3.orgChild3Order = order == null || order.orgChild3Order == null ? 1 : order.orgChild3Order + 1;
order == null || order.orgChild3Order == null ? 1 : order.orgChild3Order + 1; await this.child3Repository.save(child3);
await this.child3Repository.save(child3); return new HttpSuccess();
return new HttpSuccess();
} catch (error) {
return error;
}
} }
/** /**
@ -192,20 +184,16 @@ export class OrgChild3Controller {
if (!child3) { if (!child3) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found."); throw new HttpError(HttpStatusCode.NOT_FOUND, "not found.");
} }
try { child3.lastUpdateUserId = request.user.sub;
child3.lastUpdateUserId = request.user.sub; child3.lastUpdateFullName = request.user.name;
child3.lastUpdateFullName = request.user.name; child3.lastUpdatedAt = new Date();
child3.lastUpdatedAt = new Date(); child3.orgRootId = String(child2IdExits?.orgRootId);
child3.orgRootId = String(child2IdExits?.orgRootId); child3.orgChild1Id = String(child2IdExits?.orgChild1Id);
child3.orgChild1Id = String(child2IdExits?.orgChild1Id); child3.orgRevisionId = String(child2IdExits?.orgRevisionId);
child3.orgRevisionId = String(child2IdExits?.orgRevisionId); child3.orgChild2Id = String(child2IdExits?.id);
child3.orgChild2Id = String(child2IdExits?.id); this.child3Repository.merge(child3, requestBody);
this.child3Repository.merge(child3, requestBody); await this.child3Repository.save(child3);
await this.child3Repository.save(child3); return new HttpSuccess();
return new HttpSuccess();
} catch (error) {
return error;
}
} }
/** /**
@ -245,21 +233,17 @@ export class OrgChild3Controller {
// "ไม่สามารถลบได้ เนื่องจาก id ผูกกับโครงสร้างระดับ4", // "ไม่สามารถลบได้ เนื่องจาก id ผูกกับโครงสร้างระดับ4",
// ); // );
// } // }
try { const posMasters = await this.posMasterRepository.find({
const posMasters = await this.posMasterRepository.find({ where: { orgChild3Id: id },
where: { orgChild3Id: id }, });
}); const positions = await this.positionRepository.find({
const positions = await this.positionRepository.find({ where: [{ posMasterId: In(posMasters.map((x) => x.id)) }],
where: [{ posMasterId: In(posMasters.map((x) => x.id)) }], });
});
await this.positionRepository.remove(positions); await this.positionRepository.remove(positions);
await this.posMasterRepository.remove(posMasters); await this.posMasterRepository.remove(posMasters);
await this.child4Repository.delete({ orgChild3Id: id }); await this.child4Repository.delete({ orgChild3Id: id });
await this.child3Repository.delete(id); await this.child3Repository.delete(id);
return new HttpSuccess(); return new HttpSuccess();
} catch (error) {
return error;
}
} }
} }

View file

@ -60,26 +60,22 @@ export class OrgChild4Controller extends Controller {
if (!orgChild4) { if (!orgChild4) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล โครงสร้างระดับ 4"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล โครงสร้างระดับ 4");
} }
try { const getOrgChild4 = {
const getOrgChild4 = { orgChild4Id: orgChild4.id,
orgChild4Id: orgChild4.id, orgRootName: orgChild4.orgRoot.orgRootName,
orgRootName: orgChild4.orgRoot.orgRootName, orgName: `${orgChild4.orgChild4Name}/${orgChild4.orgChild3.orgChild3Name}/${orgChild4.orgChild2.orgChild2Name}/${orgChild4.orgChild1.orgChild1Name}/${orgChild4.orgRoot.orgRootName}`,
orgName: `${orgChild4.orgChild4Name}/${orgChild4.orgChild3.orgChild3Name}/${orgChild4.orgChild2.orgChild2Name}/${orgChild4.orgChild1.orgChild1Name}/${orgChild4.orgRoot.orgRootName}`, orgChild4Name: orgChild4.orgChild4Name,
orgChild4Name: orgChild4.orgChild4Name, orgChild4ShortName: orgChild4.orgChild4ShortName,
orgChild4ShortName: orgChild4.orgChild4ShortName, orgChild4Code: orgChild4.orgChild4Code,
orgChild4Code: orgChild4.orgChild4Code, orgChild4Rank: orgChild4.orgChild4Rank,
orgChild4Rank: orgChild4.orgChild4Rank, orgChild4Order: orgChild4.orgChild4Order,
orgChild4Order: orgChild4.orgChild4Order, orgChild4PhoneEx: orgChild4.orgChild4PhoneEx,
orgChild4PhoneEx: orgChild4.orgChild4PhoneEx, orgChild4PhoneIn: orgChild4.orgChild4PhoneIn,
orgChild4PhoneIn: orgChild4.orgChild4PhoneIn, orgChild4Fax: orgChild4.orgChild4Fax,
orgChild4Fax: orgChild4.orgChild4Fax, orgRevisionId: orgChild4.orgRevisionId,
orgRevisionId: orgChild4.orgRevisionId, orgCode: orgChild4.orgRoot.orgRootCode + orgChild4.orgChild4Code,
orgCode: orgChild4.orgRoot.orgRootCode + orgChild4.orgChild4Code, };
}; return new HttpSuccess(getOrgChild4);
return new HttpSuccess(getOrgChild4);
} catch (error) {
return error;
}
} }
/** /**
@ -140,26 +136,22 @@ export class OrgChild4Controller extends Controller {
}, },
order: { orgChild4Order: "DESC" }, order: { orgChild4Order: "DESC" },
}); });
try { const child4 = Object.assign(new OrgChild4(), requestBody) as OrgChild4;
const child4 = Object.assign(new OrgChild4(), requestBody) as OrgChild4; child4.orgChild4Name = requestBody.orgChild4Name;
child4.orgChild4Name = requestBody.orgChild4Name; child4.createdUserId = request.user.sub;
child4.createdUserId = request.user.sub; child4.createdFullName = request.user.name;
child4.createdFullName = request.user.name; child4.lastUpdateUserId = request.user.sub;
child4.lastUpdateUserId = request.user.sub; child4.lastUpdateFullName = request.user.name;
child4.lastUpdateFullName = request.user.name; child4.orgRootId = String(child3?.orgRootId);
child4.orgRootId = String(child3?.orgRootId); child4.orgChild1Id = String(child3?.orgChild1Id);
child4.orgChild1Id = String(child3?.orgChild1Id); child4.orgChild2Id = String(child3?.orgChild2Id);
child4.orgChild2Id = String(child3?.orgChild2Id); child4.orgRevisionId = String(child3?.orgRevisionId);
child4.orgRevisionId = String(child3?.orgRevisionId); child4.orgChild3Id = String(child3?.id);
child4.orgChild3Id = String(child3?.id); child4.orgChild4Order =
child4.orgChild4Order = order == null || order.orgChild4Order == null ? 1 : order.orgChild4Order + 1;
order == null || order.orgChild4Order == null ? 1 : order.orgChild4Order + 1; await this.child4Repository.save(child4);
await this.child4Repository.save(child4);
return new HttpSuccess(); return new HttpSuccess();
} catch (error) {
return error;
}
} }
/** /**
@ -224,21 +216,17 @@ export class OrgChild4Controller extends Controller {
if (!child4) { if (!child4) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found."); throw new HttpError(HttpStatusCode.NOT_FOUND, "not found.");
} }
try { child4.lastUpdateUserId = request.user.sub;
child4.lastUpdateUserId = request.user.sub; child4.lastUpdateFullName = request.user.name;
child4.lastUpdateFullName = request.user.name; child4.lastUpdatedAt = new Date();
child4.lastUpdatedAt = new Date(); child4.orgRootId = String(child3IdExits?.orgRootId);
child4.orgRootId = String(child3IdExits?.orgRootId); child4.orgChild1Id = String(child3IdExits?.orgChild1Id);
child4.orgChild1Id = String(child3IdExits?.orgChild1Id); child4.orgChild2Id = String(child3IdExits?.orgChild2Id);
child4.orgChild2Id = String(child3IdExits?.orgChild2Id); child4.orgRevisionId = String(child3IdExits?.orgRevisionId);
child4.orgRevisionId = String(child3IdExits?.orgRevisionId); child4.orgChild3Id = String(child3IdExits?.id);
child4.orgChild3Id = String(child3IdExits?.id); this.child4Repository.merge(child4, requestBody);
this.child4Repository.merge(child4, requestBody); await this.child4Repository.save(child4);
await this.child4Repository.save(child4); return new HttpSuccess();
return new HttpSuccess();
} catch (error) {
return error;
}
} }
/** /**
@ -270,20 +258,16 @@ export class OrgChild4Controller extends Controller {
"not found. orgRevisionIsDraft:true, orgRevisionIsCurrent:false", "not found. orgRevisionIsDraft:true, orgRevisionIsCurrent:false",
); );
} }
try { const posMasters = await this.posMasterRepository.find({
const posMasters = await this.posMasterRepository.find({ where: { orgChild4Id: id },
where: { orgChild4Id: id }, });
}); const positions = await this.positionRepository.find({
const positions = await this.positionRepository.find({ where: [{ posMasterId: In(posMasters.map((x) => x.id)) }],
where: [{ posMasterId: In(posMasters.map((x) => x.id)) }], });
});
await this.positionRepository.remove(positions); await this.positionRepository.remove(positions);
await this.posMasterRepository.remove(posMasters); await this.posMasterRepository.remove(posMasters);
await this.child4Repository.delete(id); await this.child4Repository.delete(id);
return new HttpSuccess(); return new HttpSuccess();
} catch (error) {
return error;
}
} }
} }

View file

@ -53,25 +53,21 @@ export class OrgRootController extends Controller {
if (!orgRoot) { if (!orgRoot) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล โครงสร้างระดับ Root"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล โครงสร้างระดับ Root");
} }
try { const getOrgRoot = {
const getOrgRoot = { orgRootId: orgRoot.id,
orgRootId: orgRoot.id, orgRootName: orgRoot.orgRootName,
orgRootName: orgRoot.orgRootName, orgName: "-",
orgName: "-", orgRootShortName: orgRoot.orgRootShortName,
orgRootShortName: orgRoot.orgRootShortName, orgRootCode: orgRoot.orgRootCode,
orgRootCode: orgRoot.orgRootCode, orgRootRank: orgRoot.orgRootRank,
orgRootRank: orgRoot.orgRootRank, orgRootOrder: orgRoot.orgRootOrder,
orgRootOrder: orgRoot.orgRootOrder, orgRootPhoneEx: orgRoot.orgRootPhoneEx,
orgRootPhoneEx: orgRoot.orgRootPhoneEx, orgRootPhoneIn: orgRoot.orgRootPhoneIn,
orgRootPhoneIn: orgRoot.orgRootPhoneIn, orgRootFax: orgRoot.orgRootFax,
orgRootFax: orgRoot.orgRootFax, orgRevisionId: orgRoot.orgRevisionId,
orgRevisionId: orgRoot.orgRevisionId, orgCode: orgRoot.orgRootCode + "00",
orgCode: orgRoot.orgRootCode + "00", };
}; return new HttpSuccess(getOrgRoot);
return new HttpSuccess(getOrgRoot);
} catch (error) {
return error;
}
} }
/** /**
@ -134,19 +130,14 @@ export class OrgRootController extends Controller {
}, },
order: { orgRootOrder: "DESC" }, order: { orgRootOrder: "DESC" },
}); });
try { orgRoot.createdUserId = request.user.sub;
orgRoot.createdUserId = request.user.sub; orgRoot.createdFullName = request.user.name;
orgRoot.createdFullName = request.user.name; orgRoot.lastUpdateUserId = request.user.sub;
orgRoot.lastUpdateUserId = request.user.sub; orgRoot.lastUpdateFullName = request.user.name;
orgRoot.lastUpdateFullName = request.user.name; orgRoot.orgRootOrder = order == null || order.orgRootOrder == null ? 1 : order.orgRootOrder + 1;
orgRoot.orgRootOrder = await this.orgRootRepository.save(orgRoot);
order == null || order.orgRootOrder == null ? 1 : order.orgRootOrder + 1;
await this.orgRootRepository.save(orgRoot);
return new HttpSuccess(); return new HttpSuccess();
} catch (error) {
return error;
}
} }
/** /**
@ -209,17 +200,13 @@ export class OrgRootController extends Controller {
"ไม่พบข้อมูลโครงสร้างระดับ Root ตามไอดีนี้ :" + id, "ไม่พบข้อมูลโครงสร้างระดับ Root ตามไอดีนี้ :" + id,
); );
} }
try { orgRoot.lastUpdateUserId = request.user.sub;
orgRoot.lastUpdateUserId = request.user.sub; orgRoot.lastUpdateFullName = request.user.name;
orgRoot.lastUpdateFullName = request.user.name; orgRoot.lastUpdatedAt = new Date();
orgRoot.lastUpdatedAt = new Date(); this.orgRootRepository.merge(orgRoot, requestBody);
this.orgRootRepository.merge(orgRoot, requestBody); await this.orgRootRepository.save(orgRoot);
await this.orgRootRepository.save(orgRoot);
return new HttpSuccess(); return new HttpSuccess();
} catch (error) {
return error;
}
} }
/** /**
@ -262,25 +249,21 @@ export class OrgRootController extends Controller {
"not found. orgRevisionIsDraft:true, orgRevisionIsCurrent:false", "not found. orgRevisionIsDraft:true, orgRevisionIsCurrent:false",
); );
} }
try { const posMasters = await this.posMasterRepository.find({
const posMasters = await this.posMasterRepository.find({ where: { orgRootId: id },
where: { orgRootId: id }, });
}); const positions = await this.positionRepository.find({
const positions = await this.positionRepository.find({ where: [{ posMasterId: In(posMasters.map((x) => x.id)) }],
where: [{ posMasterId: In(posMasters.map((x) => x.id)) }], });
});
await this.positionRepository.remove(positions); await this.positionRepository.remove(positions);
await this.posMasterRepository.remove(posMasters); await this.posMasterRepository.remove(posMasters);
await this.orgChild4Repository.delete({ orgRootId: id }); await this.orgChild4Repository.delete({ orgRootId: id });
await this.orgChild3Repository.delete({ orgRootId: id }); await this.orgChild3Repository.delete({ orgRootId: id });
await this.orgChild2Repository.delete({ orgRootId: id }); await this.orgChild2Repository.delete({ orgRootId: id });
await this.orgChild1Repository.delete({ orgRootId: id }); await this.orgChild1Repository.delete({ orgRootId: id });
await this.orgRootRepository.delete({ id }); await this.orgRootRepository.delete({ id });
return new HttpSuccess(); return new HttpSuccess();
} catch (error) {
return error;
}
} }
} }

View file

@ -12,7 +12,7 @@ import {
SuccessResponse, SuccessResponse,
Response, Response,
Get, Get,
Example Example,
} from "tsoa"; } from "tsoa";
import { AppDataSource } from "../database/data-source"; import { AppDataSource } from "../database/data-source";
import HttpSuccess from "../interfaces/http-success"; import HttpSuccess from "../interfaces/http-success";
@ -44,7 +44,6 @@ export class PosExecutiveController extends Controller {
requestBody: CreatePosExecutive, requestBody: CreatePosExecutive,
@Request() request: { user: Record<string, any> }, @Request() request: { user: Record<string, any> },
) { ) {
const checkName = await this.posExecutiveRepository.findOne({ const checkName = await this.posExecutiveRepository.findOne({
where: { posExecutiveName: requestBody.posExecutiveName }, where: { posExecutiveName: requestBody.posExecutiveName },
}); });
@ -53,17 +52,13 @@ export class PosExecutiveController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว");
} }
try { const posExecutive = Object.assign(new PosExecutive(), requestBody);
const posExecutive = Object.assign(new PosExecutive(), requestBody); posExecutive.createdUserId = request.user.sub;
posExecutive.createdUserId = request.user.sub; posExecutive.createdFullName = request.user.name;
posExecutive.createdFullName = request.user.name; posExecutive.lastUpdateUserId = request.user.sub;
posExecutive.lastUpdateUserId = request.user.sub; posExecutive.lastUpdateFullName = request.user.name;
posExecutive.lastUpdateFullName = request.user.name; await this.posExecutiveRepository.save(posExecutive);
await this.posExecutiveRepository.save(posExecutive); return new HttpSuccess();
return new HttpSuccess();
} catch (error) {
return error;
}
} }
/** /**
@ -80,7 +75,7 @@ export class PosExecutiveController extends Controller {
requestBody: CreatePosExecutive, requestBody: CreatePosExecutive,
@Request() request: { user: Record<string, any> }, @Request() request: { user: Record<string, any> },
) { ) {
const posExecutive = await this.posExecutiveRepository.findOne({where: {id: id}}); const posExecutive = await this.posExecutiveRepository.findOne({ where: { id: id } });
if (!posExecutive) { if (!posExecutive) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id);
} }
@ -93,15 +88,11 @@ export class PosExecutiveController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว");
} }
try { posExecutive.lastUpdateUserId = request.user.sub;
posExecutive.lastUpdateUserId = request.user.sub; posExecutive.lastUpdateFullName = request.user.name;
posExecutive.lastUpdateFullName = request.user.name; this.posExecutiveRepository.merge(posExecutive, requestBody);
this.posExecutiveRepository.merge(posExecutive, requestBody); await this.posExecutiveRepository.save(posExecutive);
await this.posExecutiveRepository.save(posExecutive); return new HttpSuccess();
return new HttpSuccess();
} catch (error) {
return error;
}
} }
/** /**
@ -119,44 +110,31 @@ export class PosExecutiveController extends Controller {
if (!delPosExecutive) { if (!delPosExecutive) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่งตามไอดีนี้ : " + id); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่งตามไอดีนี้ : " + id);
} }
try { await this.positionRepository.delete({ posExecutiveId: id });
await this.positionRepository.delete({ posExecutiveId: id }); await this.posExecutiveRepository.delete({ id });
await this.posExecutiveRepository.delete({ id }); return new HttpSuccess();
return new HttpSuccess();
} catch (error) {
return error;
}
} }
/** /**
* API * API
* *
* @summary ORG_044 - (ADMIN) #47 * @summary ORG_044 - (ADMIN) #47
* *
* @param {string} id Id * @param {string} id Id
*/ */
@Get("{id}") @Get("{id}")
async detailPosExecutive(@Path() id: string) { async detailPosExecutive(@Path() id: string) {
const posExecutive = await this.posExecutiveRepository.findOne({ const posExecutive = await this.posExecutiveRepository.findOne({
where: { id }, where: { id },
select:[ select: ["id", "posExecutiveName", "posExecutivePriority"],
"id",
"posExecutiveName",
"posExecutivePriority"
]
}); });
if (!posExecutive) { if (!posExecutive) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} }
try { return new HttpSuccess(posExecutive);
return new HttpSuccess(posExecutive); }
} catch (error) {
return error;
}
}
/** /**
* API * API
* *
* @summary ORG_026 - (ADMIN) #28 * @summary ORG_026 - (ADMIN) #28
@ -171,16 +149,12 @@ export class PosExecutiveController extends Controller {
}, },
]) ])
async GetPosExecutive() { async GetPosExecutive() {
try { const posExecutive = await this.posExecutiveRepository.find({
const posExecutive = await this.posExecutiveRepository.find({ select: ["id", "posExecutiveName", "posExecutivePriority"],
select: ["id", "posExecutiveName", "posExecutivePriority"], });
}); if (!posExecutive) {
if (!posExecutive) { return new HttpSuccess([]);
return new HttpSuccess([]);
}
return new HttpSuccess(posExecutive);
} catch (error) {
return error;
} }
return new HttpSuccess(posExecutive);
} }
} }

View file

@ -32,9 +32,7 @@ import { Not } from "typeorm";
"เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง", "เกิดข้อผิดพลาด ไม่สามารถแสดงรายการได้ กรุณาลองใหม่ในภายหลัง",
) )
@SuccessResponse(HttpStatusCode.OK, "สำเร็จ") @SuccessResponse(HttpStatusCode.OK, "สำเร็จ")
export class PosLevelController extends Controller { export class PosLevelController extends Controller {
private posTypeRepository = AppDataSource.getRepository(PosType); private posTypeRepository = AppDataSource.getRepository(PosType);
private posLevelRepository = AppDataSource.getRepository(PosLevel); private posLevelRepository = AppDataSource.getRepository(PosLevel);
@ -45,14 +43,12 @@ export class PosLevelController extends Controller {
* *
*/ */
@Post() @Post()
@Example( @Example({
{ posLevelName: "นักบริหาร",
posLevelName: "นักบริหาร", posLevelRank: 1,
posLevelRank: 1, posLevelAuthority: "HEAD",
posLevelAuthority: "HEAD", posTypeId: "08db9e81-fc46-4e95-8b33-be4ca0016abf",
posTypeId: "08db9e81-fc46-4e95-8b33-be4ca0016abf" })
},
)
async createLevel( async createLevel(
@Body() @Body()
requestBody: CreatePosLevel, requestBody: CreatePosLevel,
@ -62,19 +58,29 @@ export class PosLevelController extends Controller {
if (!posLevel) { if (!posLevel) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
} }
const chkPosTypeId = await this.posTypeRepository.findOne({ where: { const chkPosTypeId = await this.posTypeRepository.findOne({
id: requestBody.posTypeId } where: {
}) id: requestBody.posTypeId,
if(!chkPosTypeId){ },
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล posTypeId ไอดีนี้ : " + requestBody.posTypeId); });
if (!chkPosTypeId) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูล posTypeId ไอดีนี้ : " + requestBody.posTypeId,
);
} }
const chkPosLevelName = await this.posLevelRepository.findOne({ where: { const chkPosLevelName = await this.posLevelRepository.findOne({
posTypeId: requestBody.posTypeId, //ระดับประเภทเดียวกัน ชื่อระดับตำแหน่ง ห้ามซ้ำ where: {
posLevelName: requestBody.posLevelName } posTypeId: requestBody.posTypeId, //ระดับประเภทเดียวกัน ชื่อระดับตำแหน่ง ห้ามซ้ำ
}) posLevelName: requestBody.posLevelName,
if(chkPosLevelName){ },
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อระดับตำแหน่ง: " + requestBody.posLevelName + " มีอยู่ในระบบแล้ว"); });
if (chkPosLevelName) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ชื่อระดับตำแหน่ง: " + requestBody.posLevelName + " มีอยู่ในระบบแล้ว",
);
} }
const validPosLevelAuthority = ["HEAD", "DEPUTY", "GOVERNOR"]; const validPosLevelAuthority = ["HEAD", "DEPUTY", "GOVERNOR"];
@ -85,16 +91,12 @@ export class PosLevelController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. posLevelAuthority"); throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. posLevelAuthority");
} }
try { posLevel.createdUserId = request.user.sub;
posLevel.createdUserId = request.user.sub; posLevel.createdFullName = request.user.name;
posLevel.createdFullName = request.user.name; posLevel.lastUpdateUserId = request.user.sub;
posLevel.lastUpdateUserId = request.user.sub; posLevel.lastUpdateFullName = request.user.name;
posLevel.lastUpdateFullName = request.user.name; await this.posLevelRepository.save(posLevel);
await this.posLevelRepository.save(posLevel); return new HttpSuccess(posLevel);
return new HttpSuccess(posLevel);
} catch (error) {
return error;
}
} }
/** /**
@ -105,12 +107,10 @@ export class PosLevelController extends Controller {
* @param {string} id Id * @param {string} id Id
*/ */
@Put("{id}") @Put("{id}")
@Example( @Example({
{ positionName: "นักบริหาร",
positionName: "นักบริหาร", posTypeRank: 1,
posTypeRank: 1, })
},
)
async editLevel( async editLevel(
@Path() id: string, @Path() id: string,
@Body() requestBody: UpdatePosLevel, @Body() requestBody: UpdatePosLevel,
@ -121,20 +121,30 @@ export class PosLevelController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id);
} }
const chkPosTypeId = await this.posTypeRepository.findOne({ where: { const chkPosTypeId = await this.posTypeRepository.findOne({
id: requestBody.posTypeId } where: {
}) id: requestBody.posTypeId,
if(!chkPosTypeId){ },
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล posTypeId ไอดีนี้ : " + requestBody.posTypeId); });
if (!chkPosTypeId) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูล posTypeId ไอดีนี้ : " + requestBody.posTypeId,
);
} }
const chkPosLevelName = await this.posLevelRepository.findOne({ where: { const chkPosLevelName = await this.posLevelRepository.findOne({
id: Not(id), where: {
posTypeId: requestBody.posTypeId, id: Not(id),
posLevelName: requestBody.posLevelName } posTypeId: requestBody.posTypeId,
}) posLevelName: requestBody.posLevelName,
if(chkPosLevelName){ },
throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อระดับตำแหน่ง: " + requestBody.posLevelName + " มีอยู่ในระบบแล้ว"); });
if (chkPosLevelName) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ชื่อระดับตำแหน่ง: " + requestBody.posLevelName + " มีอยู่ในระบบแล้ว",
);
} }
const validPosLevelAuthority = ["HEAD", "DEPUTY", "GOVERNOR"]; const validPosLevelAuthority = ["HEAD", "DEPUTY", "GOVERNOR"];
if ( if (
@ -144,15 +154,11 @@ export class PosLevelController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. posLevelAuthority"); throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. posLevelAuthority");
} }
try { posLevel.lastUpdateUserId = request.user.sub;
posLevel.lastUpdateUserId = request.user.sub; posLevel.lastUpdateFullName = request.user.name;
posLevel.lastUpdateFullName = request.user.name; this.posLevelRepository.merge(posLevel, requestBody);
this.posLevelRepository.merge(posLevel, requestBody); await this.posLevelRepository.save(posLevel);
await this.posLevelRepository.save(posLevel); return new HttpSuccess(posLevel.id);
return new HttpSuccess(posLevel.id);
} catch (error) {
return error;
}
} }
/** /**
@ -168,12 +174,8 @@ export class PosLevelController extends Controller {
if (!delPosLevel) { if (!delPosLevel) {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id); throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id);
} }
try { await this.posLevelRepository.remove(delPosLevel);
await this.posLevelRepository.remove(delPosLevel); return new HttpSuccess();
return new HttpSuccess();
} catch (error) {
return error;
}
} }
/** /**
@ -184,46 +186,40 @@ export class PosLevelController extends Controller {
* @param {string} id Id * @param {string} id Id
*/ */
@Get("{id}") @Get("{id}")
@Example( @Example({
{ id: "00000000-0000-0000-0000-000000000000",
posLevelName: "นักบริหาร",
posLevelRank: 1,
posLevelAuthority: "HEAD",
posTypes: {
id: "00000000-0000-0000-0000-000000000000", id: "00000000-0000-0000-0000-000000000000",
posLevelName: "นักบริหาร", posTypeName: "นักบริหาร",
posLevelRank: 1, posTypeRank: 1,
posLevelAuthority: "HEAD",
posTypes: {
id: "00000000-0000-0000-0000-000000000000",
posTypeName: "นักบริหาร",
posTypeRank: 1,
},
}, },
) })
async GetLevelDetail(@Path() id: string) { async GetLevelDetail(@Path() id: string) {
try { const getPosType = await this.posLevelRepository.findOne({
const getPosType = await this.posLevelRepository.findOne({ select: ["id", "posLevelName", "posLevelRank", "posLevelAuthority"],
select: ["id", "posLevelName", "posLevelRank", "posLevelAuthority"], relations: ["posType"],
relations: ["posType"], where: { id: id },
where: { id: id } });
}); if (!getPosType) {
if (!getPosType) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id);
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้ : " + id);
}
const mapPosLevel = {
id: getPosType.id,
posLevelName: getPosType.posLevelName,
posLevelRank: getPosType.posLevelRank,
posLevelAuthority: getPosType.posLevelAuthority,
posTypes:{
id: getPosType.posType.id,
posTypeName: getPosType.posType.posTypeName,
posTypeRank: getPosType.posType.posTypeRank
}
}
return new HttpSuccess(mapPosLevel);
} catch (error) {
return error;
} }
const mapPosLevel = {
id: getPosType.id,
posLevelName: getPosType.posLevelName,
posLevelRank: getPosType.posLevelRank,
posLevelAuthority: getPosType.posLevelAuthority,
posTypes: {
id: getPosType.posType.id,
posTypeName: getPosType.posType.posTypeName,
posTypeRank: getPosType.posType.posTypeRank,
},
};
return new HttpSuccess(mapPosLevel);
} }
/** /**
@ -247,28 +243,24 @@ export class PosLevelController extends Controller {
}, },
]) ])
async GetPosLevel() { async GetPosLevel() {
try { const posLevel = await this.posLevelRepository.find({
const posLevel = await this.posLevelRepository.find({ select: ["id", "posLevelName", "posLevelRank", "posLevelAuthority", "posTypeId"],
select: ["id", "posLevelName", "posLevelRank", "posLevelAuthority", "posTypeId"], relations: ["posType"],
relations: ["posType"], });
}); if (!posLevel) {
if (!posLevel) { return new HttpSuccess([]);
return new HttpSuccess([]);
}
const mapPosLevel = posLevel.map((item) => ({
id: item.id,
posLevelName: item.posLevelName,
posLevelRank: item.posLevelRank,
posLevelAuthority: item.posLevelAuthority,
posTypes: {
id: item.posType.id,
posTypeName: item.posType.posTypeName,
posTypeRank: item.posType.posTypeRank,
}
}));
return new HttpSuccess(mapPosLevel);
} catch (error) {
return error;
} }
const mapPosLevel = posLevel.map((item) => ({
id: item.id,
posLevelName: item.posLevelName,
posLevelRank: item.posLevelRank,
posLevelAuthority: item.posLevelAuthority,
posTypes: {
id: item.posType.id,
posTypeName: item.posType.posTypeName,
posTypeRank: item.posType.posTypeRank,
},
}));
return new HttpSuccess(mapPosLevel);
} }
} }

File diff suppressed because it is too large Load diff