api รายละเอียดโครงสร้างระดับ root, ระดับ1-2
This commit is contained in:
parent
7cd4ae2b5f
commit
5b8e4cc3ad
3 changed files with 90 additions and 49 deletions
|
|
@ -38,60 +38,37 @@ export class OrgChild1Controller {
|
|||
private child3Repository = AppDataSource.getRepository(OrgChild3);
|
||||
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
||||
|
||||
|
||||
/**
|
||||
* API รายละเอียดโครงสร้างระดับ1
|
||||
* API รายละเอียดโครงสร้างระดับ 1
|
||||
*
|
||||
* @summary ORG_017 - รายละเอียดโครงสร้างระดับ1 (ADMIN) #17
|
||||
*
|
||||
* @param {string} id id โครงสร้างระดับ1
|
||||
* @param {string} id Id Child1
|
||||
*/
|
||||
// @Get("{id}")
|
||||
// async Get(@Path() id: string) {
|
||||
// try {
|
||||
// const child2s = await this.child2Repository.find({
|
||||
// where: {
|
||||
// orgChild1Id: id,
|
||||
// },
|
||||
// select: ["id", "orgChild2Name", "orgChild2ShortName", "orgChild2Code", "orgChild2Order", "orgRootId"],
|
||||
// order: {
|
||||
// orgChild2Order: "ASC",
|
||||
// },
|
||||
// });
|
||||
|
||||
// const orgRoots = await Promise.all(child2s.map(async (child2) => {
|
||||
// const orgRoot = await this.orgRootRepository.findOne({
|
||||
// where: {
|
||||
// id: child2.orgRootId,
|
||||
// },
|
||||
// select: ["orgRootCode"],
|
||||
// });
|
||||
|
||||
// const orgChild3s = await this.child3Repository.find({
|
||||
// where: {
|
||||
// orgChild2Id: child2.id,
|
||||
// },
|
||||
// select: ["id"],
|
||||
// });
|
||||
|
||||
// const orgChild3Ids = orgChild3s.map((orgChild3) => orgChild3.id);
|
||||
|
||||
// return {
|
||||
// orgChild2Id: child2.id,
|
||||
// orgChild3Id: orgChild3Ids,
|
||||
// orgChild2Name: child2.orgChild2Name,
|
||||
// orgChild2ShortName: child2.orgChild2ShortName,
|
||||
// orgChild2Code: child2.orgChild2Code,
|
||||
// orgChild2Order: child2.orgChild2Order,
|
||||
// orgRootCode: orgRoot?.orgRootCode,
|
||||
// };
|
||||
// }));
|
||||
|
||||
// return new HttpSuccess(orgRoots);
|
||||
// } catch (error) {
|
||||
// return error;
|
||||
// }
|
||||
// }
|
||||
@Get("{id}")
|
||||
async GetChild1(@Path() id: string) {
|
||||
try {
|
||||
const orgChild1 = await this.child1Repository.findOne({ where: { id } });
|
||||
if (!orgChild1) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
const getOrgChild1 = {
|
||||
"orgChild1Id" : orgChild1.id,
|
||||
"orgChild1Name" : orgChild1.orgChild1Name,
|
||||
"orgChild1ShortName" : orgChild1.orgChild1ShortName,
|
||||
"orgChild1Code" : orgChild1.orgChild1Code,
|
||||
"orgChild1Order" : orgChild1.orgChild1Order,
|
||||
"orgChild1PhoneEx" : orgChild1.orgChild1PhoneEx,
|
||||
"orgChild1PhoneIn" : orgChild1.orgChild1PhoneIn,
|
||||
"orgChild1Fax" : orgChild1.orgChild1Fax,
|
||||
"orgRevisionId" : orgChild1.orgRevisionId,
|
||||
"orgCode" : orgChild1.orgChild1Code+"00"
|
||||
}
|
||||
return new HttpSuccess(getOrgChild1);
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* API สร้างโครงสร้างระดับ1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue