From 70481502f33ace008857d504c97293f8cf3452af Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 13 Mar 2024 11:36:17 +0700 Subject: [PATCH 1/2] no message --- src/controllers/EmployeePosLevelController.ts | 4 +-- src/controllers/EmployeePosTypeController.ts | 36 +++++++++---------- tsoa.json | 2 +- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/controllers/EmployeePosLevelController.ts b/src/controllers/EmployeePosLevelController.ts index 09a70f2d..8f6a654f 100644 --- a/src/controllers/EmployeePosLevelController.ts +++ b/src/controllers/EmployeePosLevelController.ts @@ -57,7 +57,7 @@ export class EmployeePosLevelController extends Controller { where: { id: requestBody.employeePosTypeId } }); if (!EmpPosType) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทกลุ่มงานลูกจ้างประจำนี้"); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงานลูกจ้างประจำนี้"); } const chkEmpPosLevelName = await this.employeePosLevelRepository.findOne({ @@ -102,7 +102,7 @@ export class EmployeePosLevelController extends Controller { where: { id: requestBody.employeePosTypeId } }); if (!EmpPosType) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทกลุ่มงานลูกจ้างประจำนี้"); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงานลูกจ้างประจำนี้"); } const chkEmpPosLevel = await this.employeePosLevelRepository.findOne({ diff --git a/src/controllers/EmployeePosTypeController.ts b/src/controllers/EmployeePosTypeController.ts index 24ef06ed..4545594a 100644 --- a/src/controllers/EmployeePosTypeController.ts +++ b/src/controllers/EmployeePosTypeController.ts @@ -37,9 +37,9 @@ export class EmployeePosTypeController extends Controller { private employeePosLevelRepository = AppDataSource.getRepository(EmployeePosLevel); /** - * API เพิ่มประเภทกลุ่มงานลูกจ้างประจำ + * API เพิ่มกลุ่มงานลูกจ้างประจำ * - * @summary ORG_ - เพิ่มประเภทกลุ่มงานลูกจ้างประจำ (ADMIN) # + * @summary ORG_ - เพิ่มกลุ่มงานลูกจ้างประจำ (ADMIN) # * */ @Post() @@ -61,7 +61,7 @@ export class EmployeePosTypeController extends Controller { if (chkEmpPosTypeName) { throw new HttpError( HttpStatusCode.NOT_FOUND, - "ชื่อประเภทกลุ่มงานลูกจ้างประจำนี้มีอยู่ในระบบแล้ว", + "ชื่อกลุ่มงานลูกจ้างประจำนี้มีอยู่ในระบบแล้ว", ); } EmpPosType.createdUserId = request.user.sub; @@ -73,11 +73,11 @@ export class EmployeePosTypeController extends Controller { } /** - * API แก้ไขประเภทกลุ่มงานลูกจ้างประจำ + * API แก้ไขกลุ่มงานลูกจ้างประจำ * - * @summary ORG_ - แก้ไขประเภทกลุ่มงานลูกจ้างประจำ (ADMIN) # + * @summary ORG_ - แก้ไขกลุ่มงานลูกจ้างประจำ (ADMIN) # * - * @param {string} id Id ประเภทกลุ่มงานลูกจ้างประจำ + * @param {string} id Id กลุ่มงานลูกจ้างประจำ */ @Put("{id}") async EditEmpType( @@ -87,7 +87,7 @@ export class EmployeePosTypeController extends Controller { ) { const EmpPosType = await this.employeePosTypeRepository.findOne({ where: { id } }); if (!EmpPosType) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทกลุ่มงานลูกจ้างประจำนี้"); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงานลูกจ้างประจำนี้"); } const chkEmpPosType = await this.employeePosTypeRepository.findOne({ where: { @@ -98,7 +98,7 @@ export class EmployeePosTypeController extends Controller { if (chkEmpPosType) { throw new HttpError( HttpStatusCode.NOT_FOUND, - "ชื่อประเภทกลุ่มงานลูกจ้างประจำนี้มีอยู่ในระบบแล้ว", + "ชื่อกลุ่มงานลูกจ้างประจำนี้มีอยู่ในระบบแล้ว", ); } EmpPosType.lastUpdateUserId = request.user.sub; @@ -109,17 +109,17 @@ export class EmployeePosTypeController extends Controller { } /** - * API ลบประเภทกลุ่มงานลูกจ้างประจำ + * API ลบกลุ่มงานลูกจ้างประจำ * - * @summary ORG_ - ลบประเภทกลุ่มงานลูกจ้างประจำ (ADMIN) # + * @summary ORG_ - ลบกลุ่มงานลูกจ้างประจำ (ADMIN) # * - * @param {string} id Id ประเภทกลุ่มงานลูกจ้างประจำ + * @param {string} id Id กลุ่มงานลูกจ้างประจำ */ @Delete("{id}") async deleteType(@Path() id: string) { const delEmpPosType = await this.employeePosTypeRepository.findOne({ where: { id } }); if (!delEmpPosType) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทกลุ่มงานลูกจ้างประจำนี้"); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงานลูกจ้างประจำนี้"); } //ตารางระดับชั้นงาน const EmpPosLevel = await this.employeePosLevelRepository.find({ @@ -147,11 +147,11 @@ export class EmployeePosTypeController extends Controller { } /** - * API รายละเอียดประเภทกลุ่มงานลูกจ้างประจำ + * API รายละเอียดกลุ่มงานลูกจ้างประจำ * - * @summary ORG_ - รายละเอียดประเภทกลุ่มงานลูกจ้างประจำ (ADMIN) # + * @summary ORG_ - รายละเอียดกลุ่มงานลูกจ้างประจำ (ADMIN) # * - * @param {string} id Id ประเภทกลุ่มงานลูกจ้างประจำ + * @param {string} id Id กลุ่มงานลูกจ้างประจำ */ @Get("{id}") async GetEmpTypeById(@Path() id: string) { @@ -161,7 +161,7 @@ export class EmployeePosTypeController extends Controller { where: { id: id }, }); if (!getEmpPosType) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลประเภทกลุ่มงานลูกจ้างประจำนี้"); + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลกลุ่มงานลูกจ้างประจำนี้"); } const mapGetEmpPosType = { @@ -179,9 +179,9 @@ export class EmployeePosTypeController extends Controller { } /** - * API รายการประเภทกลุ่มงานลูกจ้างประจำ + * API รายการกลุ่มงานลูกจ้างประจำ * - * @summary ORG_ - รายการประเภทกลุ่มงานลูกจ้างประจำ (ADMIN) # + * @summary ORG_ - รายการกลุ่มงานลูกจ้างประจำ (ADMIN) # * */ @Get() diff --git a/tsoa.json b/tsoa.json index 25ecac0c..f83c7074 100644 --- a/tsoa.json +++ b/tsoa.json @@ -84,7 +84,7 @@ "name": "Employee", "description": "ตำแหน่งลูกจ้างประจำ" }, { - "name": "EmployeePosType", "description": "ประเภทกลุ่มงานลูกจ้างประจำ" + "name": "EmployeePosType", "description": "กลุ่มงานลูกจ้างประจำ" }, { "name": "EmployeePosLevel", "description": "ระดับชั้นงานลูกจ้างประจำ" From 3e278b173cebcc670446916bceaee6eb34b54f5e Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 13 Mar 2024 12:06:11 +0700 Subject: [PATCH 2/2] =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B1=E0=B8=9A?= =?UTF-8?q?=E0=B8=A3=E0=B8=B0=E0=B8=94=E0=B8=B1=E0=B8=9A=E0=B8=8A=E0=B8=B1?= =?UTF-8?q?=E0=B9=89=E0=B8=99=E0=B8=87=E0=B8=B2=E0=B8=99=E0=B8=95=E0=B8=B2?= =?UTF-8?q?=E0=B8=A1=20ui?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/EmployeePosLevelController.ts | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/controllers/EmployeePosLevelController.ts b/src/controllers/EmployeePosLevelController.ts index 8f6a654f..9351c0c8 100644 --- a/src/controllers/EmployeePosLevelController.ts +++ b/src/controllers/EmployeePosLevelController.ts @@ -163,14 +163,20 @@ export class EmployeePosLevelController extends Controller { @Get("{id}") async GetEmpLevelById(@Path() id: string) { const getEmpPosLevel = await this.employeePosLevelRepository.findOne({ + relations: ["employeePosType"], select: ["id", "posLevelName", "posLevelRank",], where: { id: id }, }); if (!getEmpPosLevel) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลระดับชั้นงานลูกจ้างประจำนี้"); } - - return new HttpSuccess(getEmpPosLevel); + const mapEmpPosLevel = { + id: getEmpPosLevel.id, + posLevelName: getEmpPosLevel.posLevelName, + posTypeName: getEmpPosLevel.employeePosType == null ? null : getEmpPosLevel.employeePosType.posTypeName, //กลุ่มงาน + commander: null //ผู้มีอำนาจสั่งบรรจุ + } + return new HttpSuccess(mapEmpPosLevel); } /** @@ -182,9 +188,15 @@ export class EmployeePosLevelController extends Controller { @Get() async GetEmpPosLevel() { const empPosLevel = await this.employeePosLevelRepository.find({ + relations: ["employeePosType"], select: ["id","posLevelName", "posLevelRank",], }); - - return new HttpSuccess(empPosLevel); + const mapEmpPosLevel = empPosLevel.map((item) => ({ + id: item.id, + posLevelName: item.posLevelName, + posTypeName: item.employeePosType == null ? null : item.employeePosType.posTypeName, //กลุ่มงาน + commander: null //ผู้มีอำนาจสั่งบรรจุ + })); + return new HttpSuccess(mapEmpPosLevel); } } \ No newline at end of file