From 29215ccaae38a123a8e23ea3fee2ec02d27325ca Mon Sep 17 00:00:00 2001 From: thkim Date: Thu, 29 Feb 2024 16:08:49 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=EA=B4=80=EB=A6=AC=EC=9E=90=20-=20?= =?UTF-8?q?=ED=99=98=EA=B2=BD=EC=84=A4=EC=A0=95=20-=20=EC=9C=84=EC=9B=90?= =?UTF-8?q?=ED=9A=8C=20=EC=BD=94=EB=93=9C=EA=B4=80=EB=A6=AC=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=EC=8B=9C,=20=EC=84=A0=ED=83=9D=20=EC=95=88=20?= =?UTF-8?q?=EB=90=9C=20=ED=95=AD=EB=AA=A9=20=EC=82=AD=EC=A0=9C=20=EC=95=88?= =?UTF-8?q?=20=EB=90=98=EB=8A=94=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=20=EA=B1=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../list/ListCreateUpdateDelete.jsx | 20 ++++- .../pages/admin/config/CommitteeCodeMgt.jsx | 77 +++++++++++++++++-- .../CommitteeCodeRegistrationPopup.jsx | 1 - 3 files changed, 89 insertions(+), 9 deletions(-) diff --git a/egovframe-template-simple-react-contribution/src/components/list/ListCreateUpdateDelete.jsx b/egovframe-template-simple-react-contribution/src/components/list/ListCreateUpdateDelete.jsx index eaeb9ca..4701648 100644 --- a/egovframe-template-simple-react-contribution/src/components/list/ListCreateUpdateDelete.jsx +++ b/egovframe-template-simple-react-contribution/src/components/list/ListCreateUpdateDelete.jsx @@ -15,6 +15,9 @@ import AddIcon from '@mui/icons-material/Add'; import styledComponent from "styled-components"; +import * as EgovNet from 'api/egovFetch'; + + const StyledDiv = styledComponent.div` .text-item.active { background-color: #676767; @@ -27,10 +30,14 @@ function generate(items, element, onClickListner,nameKey, let returnValue = []; let nIndex = 0; Object.keys(items).forEach(function(key) { + + returnValue = [ ...returnValue, React.cloneElement(element, { key, + 'data-key' : key, + 'data-index' : nIndex, }, {onClickListner(e, key);}}> @@ -114,10 +121,19 @@ function ListCreateUpdateDelete(props) { - + {alert('수정 클릭')}}> - + { + const dataKey = Number(e.currentTarget.parentNode.parentNode.parentNode.getAttribute('data-key')); + + let paramCodeGroup = null; + if( props.depthSelectedArrayIndex > 0 ) { + paramCodeGroup = props.itemIndex[props.depthSelectedArrayIndex-1]; + } + + props.onClickDeleteItem(e, paramCodeGroup, props.paramCodeLevel, props.depthSelectedArrayIndex, props.items[dataKey]); + }}> diff --git a/egovframe-template-simple-react-contribution/src/pages/admin/config/CommitteeCodeMgt.jsx b/egovframe-template-simple-react-contribution/src/pages/admin/config/CommitteeCodeMgt.jsx index 3422ad1..3273219 100644 --- a/egovframe-template-simple-react-contribution/src/pages/admin/config/CommitteeCodeMgt.jsx +++ b/egovframe-template-simple-react-contribution/src/pages/admin/config/CommitteeCodeMgt.jsx @@ -4,15 +4,10 @@ import Box from '@mui/material/Box'; import * as EgovNet from 'api/egovFetch'; - - - import CommitteeCodeRegistrationPopup from './CommitteeCodeMgt/CommitteeCodeRegistrationPopup'; - import ListCreateUpdateDelete from '../../../components/list/ListCreateUpdateDelete' import ListLabelInputs from '../../../components/list/ListLabelInputs' - import URL from 'constants/url'; import { default as EgovLeftNav } from 'components/leftmenu/EgovLeftNavAdmin'; @@ -37,7 +32,7 @@ function CommitteeCodeMgt(props) { // '중앙건설기술심의'에서 특정 item선택 시, 하위 '총괄위원회'목록을 불러온다. useEffect(function () { - if( typeof depthSelectedIndex[0] !== "undefined" && depth01List[depthSelectedIndex[0]].orgId !== undefined) { + if( typeof depthSelectedIndex[0] !== "undefined" && depth01List[depthSelectedIndex[0]] && depth01List[depthSelectedIndex[0]].orgId !== undefined) { setSearchCondition({ paramCodeGroup: depth01List[depthSelectedIndex[0]].orgId, paramCodeLevel: 'LV_02' }); setDepth02List({}); setDepth03List({}); @@ -153,6 +148,66 @@ function CommitteeCodeMgt(props) { ]); + const onClickDeleteItem = (e, paramCodeGroup, paramCodeLevel, depthSelectedArrayIndex, deleteItem) => { + + if( deleteItem.orgId === undefined ) { + alert('삭제 대상이 존재하지 않습니다.'); + return false; + } + + const requestOptions = { + method: "DELETE", + headers: { + 'Content-type': 'application/json', + } + }; + + EgovNet.requestFetch(`/admin/config/committee-code-management/${deleteItem.orgId}`, + requestOptions, + function (resp) { + //방금 삭제한 것만 새로 읽어 드린다. + let forChangeObject = {...searchCondition, paramCodeGroup, paramCodeLevel}; + setSearchCondition(forChangeObject); + + //현재 선택된 아이템을 삭제한 경우 그 하위 목록을 모두 비운다. + + //현재 선택된 아이템을 삭제 했는지 체크한다 + // 여기에 현재 선택된 아이템을 삭제 했는지 체크하는 로직을 추가해주세요. + if( Number(depthSelectedIndex[depthSelectedArrayIndex]) === Number(deleteItem.orgId) ) { + // 맞다면 + //그 하위 목록을 비운다. + + for( let i = depthSelectedArrayIndex + 1; i<4; i++ ) { + //setSearchCondition({...searchCondition, paramCodeLevel : createCondition.paramCodeLevel}); + depthSelectedIndex[i] = undefined; + } + let forChangeObject = [...depthSelectedIndex]; + setDepthSelectedIndex(forChangeObject); + + // eslint-disable-next-line default-case + switch(depthSelectedArrayIndex) { + case 0: + setDepth02List({}); + // eslint-disable-next-line no-fallthrough + case 1: + setDepth03List({}); + // eslint-disable-next-line no-fallthrough + case 2: + setDepth04List({}); + } + + + + + + } + + + alert('삭제 되었습니다.'); + } + ); + } + const Location = React.memo(function Location() { return (
@@ -211,6 +266,7 @@ function CommitteeCodeMgt(props) { idKey="orgId" isPopupOpen = {isCommitteeCodeRegistrationPopupOpen} setIsPopupOpen = {setIsCommitteeCodeRegistrationPopupOpen} + onClickDeleteItem={onClickDeleteItem} /> diff --git a/egovframe-template-simple-react-contribution/src/pages/admin/config/CommitteeCodeMgt/CommitteeCodeRegistrationPopup.jsx b/egovframe-template-simple-react-contribution/src/pages/admin/config/CommitteeCodeMgt/CommitteeCodeRegistrationPopup.jsx index 2a7061d..2037054 100644 --- a/egovframe-template-simple-react-contribution/src/pages/admin/config/CommitteeCodeMgt/CommitteeCodeRegistrationPopup.jsx +++ b/egovframe-template-simple-react-contribution/src/pages/admin/config/CommitteeCodeMgt/CommitteeCodeRegistrationPopup.jsx @@ -28,7 +28,6 @@ function CommitteeCodeRegistrationPopup(props) { EgovNet.requestFetch(`/admin/config/committee-code-management`, requestOptions, function (resp) { - //window.location.reload(); //방금 추가한 것만 새로 읽어 드린다. props.setSearchCondition({...props.searchCondition, paramCodeLevel : props.createCondition.paramCodeLevel}); From d98798e7b5401c5046bedee47973f5c4fd076943 Mon Sep 17 00:00:00 2001 From: thkim Date: Thu, 29 Feb 2024 16:10:21 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=EA=B4=80=EB=A6=AC=EC=9E=90=20-=20?= =?UTF-8?q?=ED=99=98=EA=B2=BD=EC=84=A4=EC=A0=95=20-=20=EC=9C=84=EC=9B=90?= =?UTF-8?q?=ED=9A=8C=20=EC=BD=94=EB=93=9C=EA=B4=80=EB=A6=AC=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84=20-=20backe?= =?UTF-8?q?nd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/config/AdminConfigController.java | 39 ++++++++++++++ ...minCommitteeCodeManagementServiceImpl.java | 54 ++++++++++++++++++- .../repository/TnCmtOrgRepository.java | 25 +++++++++ 3 files changed, 116 insertions(+), 2 deletions(-) diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/AdminConfigController.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/AdminConfigController.java index ce6b294..98b9244 100644 --- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/AdminConfigController.java +++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/AdminConfigController.java @@ -445,4 +445,43 @@ public class AdminConfigController extends BaseController { return resultVO; } + @Operation( + summary = "'위원회 코드 관리' 페이지에서 위원회 코드 삭제하는 API", + description = "관리자 단에서 '환경설정' > '위원회코드 관리' 페이지에서 휴지통 모양 삭제 버튼으로 항목 삭제하는 API", + tags = {"AdminConfigController"} + ) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "등록 성공"), + @ApiResponse(responseCode = "403", description = "인가된 사용자가 아님") + }) + @DeleteMapping(value = "/committee-code-management/{orgId}") + public ResultVO deleteSchedule + ( + @AuthenticationPrincipal LoginVO user, + HttpServletRequest request, + @PathVariable("orgId") String strOrgId + ) throws Exception { + + ResultVO resultVO = new ResultVO(); + Long orgId = Long.valueOf(strOrgId); + try { + resultVO = adminCommitteeCodeManagementService.deleteCommitteeCodeManagement(resultVO, request, user, orgId); + } catch (Exception e) { + resultVO.setResultCode(ResponseCode.FAILED.getCode()); + resultVO.setResultMessage(e.getMessage()); + } + + + System.out.println( + "\n--------------------------------------------------------------\n" + + request.getRequestURI() + " OUT:" + + "\n--------------------------------------------------------------\n" + + "resultVO.toString():" + "\n" + + resultVO.toString() + "\n" + + "\n--------------------------------------------------------------\n" + ); + + return resultVO; + } + } diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/service/impl/AdminCommitteeCodeManagementServiceImpl.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/service/impl/AdminCommitteeCodeManagementServiceImpl.java index 5970a59..b09d5c3 100644 --- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/service/impl/AdminCommitteeCodeManagementServiceImpl.java +++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/service/impl/AdminCommitteeCodeManagementServiceImpl.java @@ -5,6 +5,7 @@ import com.dbnt.kcscbackend.admin.config.service.AdminCommitteeCodeManagementSer import com.dbnt.kcscbackend.admin.standardResearch.model.CreateStandardResearchVO; import com.dbnt.kcscbackend.admin.standardResearch.model.UpdateStandardResearchVO; import com.dbnt.kcscbackend.auth.entity.LoginVO; +import com.dbnt.kcscbackend.commonCode.entity.TnCmtOrg; import com.dbnt.kcscbackend.commonCode.repository.TnCmtOrgRepository; import com.dbnt.kcscbackend.config.common.ResponseCode; import com.dbnt.kcscbackend.config.common.ResultVO; @@ -110,7 +111,56 @@ public class AdminCommitteeCodeManagementServiceImpl extends EgovAbstractService } @Override - public ResultVO deleteCommitteeCodeManagement(ResultVO resultVO, HttpServletRequest request, LoginVO user, Long popupId) throws Exception { - return null; + public ResultVO deleteCommitteeCodeManagement(ResultVO resultVO, HttpServletRequest request, LoginVO user, Long cmtSeq) throws Exception { + System.out.println( + "\n--------------------------------------------------------------\n" + + request.getRequestURI() + " IN:" + + "\n--------------------------------------------------------------\n" + + "cmtSeq:" + "\n" + + cmtSeq + "\n" + + "\n--------------------------------------------------------------\n" + ); + + + Map response = tnCmtOrgRepository.spDeleteTnCmtOrg( + cmtSeq.intValue(), + user.getId(), + null, + null, + null + ); + + // 자식 코드들을 모두 제거한다. + getChildrenOrg(user, cmtSeq); + + + Map dto = new HashMap(); + dto.put("errorMessage", response.get("_error_message") ); + dto.put("orgId", cmtSeq ); + + resultVO.setResult(dto); + resultVO.setResultCode(ResponseCode.SUCCESS.getCode()); + resultVO.setResultMessage(ResponseCode.SUCCESS.getMessage()); + + return resultVO; + } + + private void getChildrenOrg(LoginVO user, Long upCmtSeq) { + List> list = tnCmtOrgRepository.findByUpCmtSeq(upCmtSeq).stream() + .map(item -> { + Map returnMap = new HashMap<>(); + returnMap.put("cmtSeq", item.getCmtSeq()); + getChildrenOrg( user, item.getCmtSeq() ); + Map response = tnCmtOrgRepository.spDeleteTnCmtOrg( + item.getCmtSeq().intValue(), + user.getId(), + null, + null, + null + ); + return returnMap; + }).collect(Collectors.toList()); + + System.out.println("for Debugging"); } } diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/commonCode/repository/TnCmtOrgRepository.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/commonCode/repository/TnCmtOrgRepository.java index 5ab14c3..a08b36d 100644 --- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/commonCode/repository/TnCmtOrgRepository.java +++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/commonCode/repository/TnCmtOrgRepository.java @@ -3,6 +3,7 @@ package com.dbnt.kcscbackend.commonCode.repository; import com.dbnt.kcscbackend.commonCode.entity.TnCmtOrg; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.jpa.repository.query.Procedure; import org.springframework.data.repository.query.Param; import java.util.List; @@ -40,4 +41,28 @@ public interface TnCmtOrgRepository extends JpaRepository spDeleteTnCmtOrg( + @Param("_cmt_seq") Integer cmtSeq, + @Param("_modi_id") String modiId, + @Param("_result_count") Integer resultCount, + @Param("_result_code") String resultCode, + @Param("_error_message") String errorMessage + ); + + @Procedure("sp_is_valid_tn_cmt_org_id") + int spIsValidTnCmtOrgId( Integer cmtSeq ); + + TnCmtOrg findByCmtSeq(Long cmtSeq); + List findByUpCmtSeq(Long upCmtSeq); + + } From 0ea10e7313c5c8e993e06fc10dc89e7746bcdc85 Mon Sep 17 00:00:00 2001 From: thkim Date: Thu, 29 Feb 2024 17:30:28 +0900 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20=EA=B4=80=EB=A6=AC=EC=9E=90=20-=20?= =?UTF-8?q?=ED=99=98=EA=B2=BD=EC=84=A4=EC=A0=95=20-=20=EC=9C=84=EC=9B=90?= =?UTF-8?q?=ED=9A=8C=20=EC=BD=94=EB=93=9C=EA=B4=80=EB=A6=AC=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=EC=8B=9C,=20=EC=82=AD=EC=A0=9C=20=EC=97=AC?= =?UTF-8?q?=EB=B6=80=20=ED=99=95=EC=9D=B8=20=ED=9B=84=20=EC=82=AD=EC=A0=9C?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/admin/config/CommitteeCodeMgt.jsx | 79 ++++++++++--------- .../CommitteeCodeRegistrationPopup.jsx | 6 +- ...minCommitteeCodeManagementServiceImpl.java | 1 + 3 files changed, 48 insertions(+), 38 deletions(-) diff --git a/egovframe-template-simple-react-contribution/src/pages/admin/config/CommitteeCodeMgt.jsx b/egovframe-template-simple-react-contribution/src/pages/admin/config/CommitteeCodeMgt.jsx index 3273219..6761a63 100644 --- a/egovframe-template-simple-react-contribution/src/pages/admin/config/CommitteeCodeMgt.jsx +++ b/egovframe-template-simple-react-contribution/src/pages/admin/config/CommitteeCodeMgt.jsx @@ -8,6 +8,8 @@ import CommitteeCodeRegistrationPopup from './CommitteeCodeMgt/CommitteeCodeRegi import ListCreateUpdateDelete from '../../../components/list/ListCreateUpdateDelete' import ListLabelInputs from '../../../components/list/ListLabelInputs' +import AlertDialogSlide from "../../../components/alert/AlertDialogSlide"; + import URL from 'constants/url'; import { default as EgovLeftNav } from 'components/leftmenu/EgovLeftNavAdmin'; @@ -25,6 +27,9 @@ function CommitteeCodeMgt(props) { const [summaryArray, setSummaryArray] = useState({}); const [depthSelectedIndex, setDepthSelectedIndex] = useState([]); + + const [confirm, setConfirm] = React.useState(); + // 위원회 코드 등록 팝업을 보이거나 닫는다. const [isCommitteeCodeRegistrationPopupOpen, setIsCommitteeCodeRegistrationPopupOpen] = React.useState(false); @@ -161,51 +166,49 @@ function CommitteeCodeMgt(props) { 'Content-type': 'application/json', } }; + - EgovNet.requestFetch(`/admin/config/committee-code-management/${deleteItem.orgId}`, - requestOptions, - function (resp) { - //방금 삭제한 것만 새로 읽어 드린다. - let forChangeObject = {...searchCondition, paramCodeGroup, paramCodeLevel}; - setSearchCondition(forChangeObject); + const requestTask = () => { + EgovNet.requestFetch(`/admin/config/committee-code-management/${deleteItem.orgId}`, + requestOptions, + function (resp) { + let forChangeObject = {...searchCondition, paramCodeGroup, paramCodeLevel}; + setSearchCondition(forChangeObject); - //현재 선택된 아이템을 삭제한 경우 그 하위 목록을 모두 비운다. + //현재 선택된 아이템을 삭제한 경우 그 하위 목록을 모두 비운다. + if( Number(depthSelectedIndex[depthSelectedArrayIndex]) === Number(deleteItem.orgId) ) { + + for( let i = depthSelectedArrayIndex + 1; i<4; i++ ) { + //setSearchCondition({...searchCondition, paramCodeLevel : createCondition.paramCodeLevel}); + depthSelectedIndex[i] = undefined; + } + let forChangeObject = [...depthSelectedIndex]; + setDepthSelectedIndex(forChangeObject); + + // eslint-disable-next-line default-case + switch(depthSelectedArrayIndex) { + case 0: + setDepth02List({}); + // eslint-disable-next-line no-fallthrough + case 1: + setDepth03List({}); + // eslint-disable-next-line no-fallthrough + case 2: + setDepth04List({}); + } + + + - //현재 선택된 아이템을 삭제 했는지 체크한다 - // 여기에 현재 선택된 아이템을 삭제 했는지 체크하는 로직을 추가해주세요. - if( Number(depthSelectedIndex[depthSelectedArrayIndex]) === Number(deleteItem.orgId) ) { - // 맞다면 - //그 하위 목록을 비운다. - for( let i = depthSelectedArrayIndex + 1; i<4; i++ ) { - //setSearchCondition({...searchCondition, paramCodeLevel : createCondition.paramCodeLevel}); - depthSelectedIndex[i] = undefined; - } - let forChangeObject = [...depthSelectedIndex]; - setDepthSelectedIndex(forChangeObject); - - // eslint-disable-next-line default-case - switch(depthSelectedArrayIndex) { - case 0: - setDepth02List({}); - // eslint-disable-next-line no-fallthrough - case 1: - setDepth03List({}); - // eslint-disable-next-line no-fallthrough - case 2: - setDepth04List({}); } - - - + alert('삭제 되었습니다.'); } - - - alert('삭제 되었습니다.'); - } - ); + ); + }; + setConfirm({...confirm, open: true, body: "삭제하시겠습니까?", yesCallback: requestTask}); } const Location = React.memo(function Location() { @@ -344,6 +347,8 @@ function CommitteeCodeMgt(props) { searchCondition={searchCondition} setSearchCondition={setSearchCondition} /> + + {/* */}
diff --git a/egovframe-template-simple-react-contribution/src/pages/admin/config/CommitteeCodeMgt/CommitteeCodeRegistrationPopup.jsx b/egovframe-template-simple-react-contribution/src/pages/admin/config/CommitteeCodeMgt/CommitteeCodeRegistrationPopup.jsx index 2037054..61ad200 100644 --- a/egovframe-template-simple-react-contribution/src/pages/admin/config/CommitteeCodeMgt/CommitteeCodeRegistrationPopup.jsx +++ b/egovframe-template-simple-react-contribution/src/pages/admin/config/CommitteeCodeMgt/CommitteeCodeRegistrationPopup.jsx @@ -29,7 +29,11 @@ function CommitteeCodeRegistrationPopup(props) { requestOptions, function (resp) { //방금 추가한 것만 새로 읽어 드린다. - props.setSearchCondition({...props.searchCondition, paramCodeLevel : props.createCondition.paramCodeLevel}); + let paramCodeGroup = props.createCondition.paramOrgId; + if( paramCodeGroup === "00" ) { + paramCodeGroup = null; + } + props.setSearchCondition({...props.searchCondition, paramCodeGroup, paramCodeLevel : props.createCondition.paramCodeLevel}); props.setOpen(false); } diff --git a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/service/impl/AdminCommitteeCodeManagementServiceImpl.java b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/service/impl/AdminCommitteeCodeManagementServiceImpl.java index b09d5c3..244a8c8 100644 --- a/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/service/impl/AdminCommitteeCodeManagementServiceImpl.java +++ b/kcsc-back-end/src/main/java/com/dbnt/kcscbackend/admin/config/service/impl/AdminCommitteeCodeManagementServiceImpl.java @@ -92,6 +92,7 @@ public class AdminCommitteeCodeManagementServiceImpl extends EgovAbstractService returnMap.put("orgNm", item.getCmtNm()); returnMap.put("orgDesc", item.getCmtDesc()); returnMap.put("omtOrder", item.getCmtOrder()); + returnMap.put("upCmtSeq", item.getUpCmtSeq()); return returnMap; }) .collect(Collectors.toList());