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
|
||||
|
|
|
|||
|
|
@ -37,6 +37,38 @@ export class OrgChild2Controller extends Controller {
|
|||
private child3Repository = AppDataSource.getRepository(OrgChild3);
|
||||
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
||||
|
||||
/**
|
||||
* API รายละเอียดโครงสร้างระดับ 2
|
||||
*
|
||||
* @summary ORG_018 - รายละเอียดโครงสร้างระดับ2 (ADMIN) #20
|
||||
*
|
||||
* @param {string} id Id Child2
|
||||
*/
|
||||
@Get("{id}")
|
||||
async GetChild2(@Path() id: string) {
|
||||
try {
|
||||
const orgChild2 = await this.child2Repository.findOne({ where: { id } });
|
||||
if (!orgChild2) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
const getOrgChild2 = {
|
||||
"orgChild2Id" : orgChild2.id,
|
||||
"orgChild2Name" : orgChild2.orgChild2Name,
|
||||
"orgChild2ShortName" : orgChild2.orgChild2ShortName,
|
||||
"orgChild2Code" : orgChild2.orgChild2Code,
|
||||
"orgChild2Order" : orgChild2.orgChild2Order,
|
||||
"orgChild2PhoneEx" : orgChild2.orgChild2PhoneEx,
|
||||
"orgChild2PhoneIn" : orgChild2.orgChild2PhoneIn,
|
||||
"orgChild2Fax" : orgChild2.orgChild2Fax,
|
||||
"orgRevisionId" : orgChild2.orgRevisionId,
|
||||
"orgCode" : orgChild2.orgChild2Code+"00"
|
||||
}
|
||||
return new HttpSuccess(getOrgChild2);
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* สร้างโครงสร้างระดับ2 Child2
|
||||
*
|
||||
|
|
|
|||
|
|
@ -29,6 +29,38 @@ export class OrgRootController extends Controller {
|
|||
private orgChild1Repository = AppDataSource.getRepository(OrgChild1);
|
||||
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
||||
|
||||
/**
|
||||
* API รายละเอียดโครงสร้างระดับ Root
|
||||
*
|
||||
* @summary ORG_016 - รายละเอียดโครงสร้างระดับ Root (ADMIN) #16
|
||||
*
|
||||
* @param {string} id Id Root
|
||||
*/
|
||||
@Get("root/{id}")
|
||||
async GetRoot(@Path() id: string) {
|
||||
try {
|
||||
const orgRoot = await this.orgRootRepository.findOne({ where: { id } });
|
||||
if (!orgRoot) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
const getOrgRoot = {
|
||||
"orgRootId" : orgRoot.id,
|
||||
"orgRootName" : orgRoot.orgRootName,
|
||||
"orgRootShortName" : orgRoot.orgRootShortName,
|
||||
"orgRootCode" : orgRoot.orgRootCode,
|
||||
"orgRootOrder" : orgRoot.orgRootOrder,
|
||||
"orgRootPhoneEx" : orgRoot.orgRootPhoneEx,
|
||||
"orgRootPhoneIn" : orgRoot.orgRootPhoneIn,
|
||||
"orgRootFax" : orgRoot.orgRootFax,
|
||||
"orgRevisionId" : orgRoot.orgRevisionId,
|
||||
"orgCode" : orgRoot.orgRootCode+"00"
|
||||
}
|
||||
return new HttpSuccess(getOrgRoot);
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* สร้างโครงสร้างระดับ Root
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue