From b7150fd225d773284182303c03a32c90c862df3a Mon Sep 17 00:00:00 2001 From: kittapath Date: Fri, 6 Sep 2024 13:56:01 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=20data=20profileId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/PermissionOrgController.ts | 47 ++++++++++------------ 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/src/controllers/PermissionOrgController.ts b/src/controllers/PermissionOrgController.ts index b7bc17c9..25678eac 100644 --- a/src/controllers/PermissionOrgController.ts +++ b/src/controllers/PermissionOrgController.ts @@ -387,7 +387,10 @@ export class PermissionOrgController extends Controller { let _child4 = child4 == null ? "" : `${child4.orgChild4Name}/`; return { - id: _data.profileTree.id, + id: _data.id, + profileId: _data.profileTree.id, + orgRootId: _data.orgRootTree.id, + orgNew: _data.orgRootTree.orgRootName, avatar: _data.profileTree.avatar, avatarName: _data.profileTree.avatarName, prefix: _data.profileTree.prefix, @@ -395,7 +398,6 @@ export class PermissionOrgController extends Controller { firstName: _data.profileTree.firstName, lastName: _data.profileTree.lastName, org: `${_child4}${_child3}${_child2}${_child1}${root?.orgRootName ?? ""}`, - orgNew: _data.orgRootTree.orgRootName, posNo: shortName, position: _data.profileTree.position, posType: _data.profileTree.posType == null ? null : _data.profileTree.posType.posTypeName, @@ -465,35 +467,28 @@ export class PermissionOrgController extends Controller { * * @param {string} id Id สิทธิ์โครงสร้าง */ - @Delete("{nodeId}/{personId}") - async Delete( - @Request() request: RequestWithUser, - @Path() nodeId: string, - @Path() personId: string, - ) { + @Delete("{id}") + async Delete(@Request() request: RequestWithUser, @Path() id: string) { if (!request.user.role.includes("SUPER_ADMIN")) { throw new HttpError(HttpStatus.FORBIDDEN, "ไม่มีสิทธิ์ใช้งานระบบนี้"); } - const orgRoot = await this.orgRootRepository.findOne({ - where: { id: nodeId }, - relations: ["permissionOrgRoots"], - }); - if (!orgRoot) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลสำนัก"); - } - const profile = await this.profileRepository.findOne({ - where: { id: personId }, - relations: ["permissionOrgRoots"], - }); - if (!profile) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัติ"); - } + // const orgRoot = await this.orgRootRepository.findOne({ + // where: { id: nodeId }, + // relations: ["permissionOrgRoots"], + // }); + // if (!orgRoot) { + // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลสำนัก"); + // } + // const profile = await this.profileRepository.findOne({ + // where: { id: personId }, + // relations: ["permissionOrgRoots"], + // }); + // if (!profile) { + // throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัติ"); + // } const _delPermissionOrg = await this.permissionOrgRepository.findOne({ - where: { - orgRootTree: { id: nodeId }, - profileTree: { id: personId }, - }, + where: { id: id }, }); if (!_delPermissionOrg) {