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) {