ads367 / yj_portal star
ads367 04-26
2024-04-25 공통코드, 부서 정보 수정
@7210d9e36bbb77ecf3f4ab78b986e1b90c8ae104
src/main/java/com/takensoft/cms/codeManage/dao/CodeManageDAO.java
--- src/main/java/com/takensoft/cms/codeManage/dao/CodeManageDAO.java
+++ src/main/java/com/takensoft/cms/codeManage/dao/CodeManageDAO.java
@@ -37,6 +37,13 @@
 
     /**
      * @author takensoft
+     * @since 2024.04.26
+     * 상위코드가 수정됨에 따라 하위코드의 상위코드값 변경
+     */
+    int updateUpCd(CodeManageVO codeManageVO);
+
+    /**
+     * @author takensoft
      * @since 2024.04.09
      * 코드 깊이 조회
      */
src/main/java/com/takensoft/cms/codeManage/service/Impl/CodeManageServiceImpl.java
--- src/main/java/com/takensoft/cms/codeManage/service/Impl/CodeManageServiceImpl.java
+++ src/main/java/com/takensoft/cms/codeManage/service/Impl/CodeManageServiceImpl.java
@@ -73,7 +73,11 @@
     public int cdUpdate(CodeManageVO codeManageVO) throws Exception {
         // 등록된 토큰에서 사용자 정보 조회
         codeManageVO.setMdfr(jwtUtil.getWriter());
-        return codeManageDAO.update(codeManageVO);
+        // 코드 수정
+        int result = codeManageDAO.update(codeManageVO);
+        // 해당 코드가 변경됨에 따라 하위 코드의 상위코드값 변경
+        result += codeManageDAO.updateUpCd(codeManageVO);
+        return result;
     }
 
     /**
src/main/java/com/takensoft/cms/dept/dao/DeptDAO.java
--- src/main/java/com/takensoft/cms/dept/dao/DeptDAO.java
+++ src/main/java/com/takensoft/cms/dept/dao/DeptDAO.java
@@ -64,4 +64,18 @@
      * 부서 정보 조회
      */
     DeptVO findByDept(String deptId);
+
+    /**
+     * @author takensoft
+     * @since 2024.04.26
+     * 부서 정보 수정
+     */
+    int update(DeptVO deptVO);
+
+    /**
+     * @author takensoft
+     * @since 2024.04.26
+     * 부서 권한 삭제
+     */
+    int deleteAuth(String deptId);
 }
src/main/java/com/takensoft/cms/dept/service/DeptService.java
--- src/main/java/com/takensoft/cms/dept/service/DeptService.java
+++ src/main/java/com/takensoft/cms/dept/service/DeptService.java
@@ -41,4 +41,11 @@
      * 부서 정보 조회
      */
     public DeptVO findByDept(HashMap<String, Object> params) throws Exception;
+
+    /**
+     * @author takensoft
+     * @since 2024.04.26
+     * 부서 정보 수정
+     */
+    public int deptUpdate(DeptVO deptVO) throws Exception;
 }
src/main/java/com/takensoft/cms/dept/service/Impl/DeptServiceImpl.java
--- src/main/java/com/takensoft/cms/dept/service/Impl/DeptServiceImpl.java
+++ src/main/java/com/takensoft/cms/dept/service/Impl/DeptServiceImpl.java
@@ -98,7 +98,7 @@
         List<HierachyVO> childList = deptDAO.findChildNode(id);
         for(HierachyVO vo : childList) {
             List<HierachyVO> child = findChildNode(vo.getId());
-            vo.setChildList(childList);
+            vo.setChildList(child);
         }
         return childList;
     }
@@ -114,4 +114,31 @@
         String deptId = params.get("deptId").toString();
         return deptDAO.findByDept(deptId);
     }
+
+    /**
+     * @author takensoft
+     * @since 2024.04.26
+     * 부서 정보 수정
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int deptUpdate(DeptVO deptVO) throws Exception {
+        // 토큰에서 사용자 정보 추출
+        deptVO.setMdfr(jwtUtil.getWriter());
+        // 부서정보 수정
+        int result = deptDAO.update(deptVO);
+
+        // 부서 권한 삭제
+        result += deptDAO.deleteAuth(deptVO.getDeptId());
+
+        // 부서 권한 등록
+        if(deptVO.getAuthrtList().size() > 0) {
+            for(DeptAuthrtVO vo : deptVO.getAuthrtList()) {
+                vo.setDeptId(deptVO.getDeptId());
+                vo.setRgtr(jwtUtil.getWriter());
+                result += deptDAO.authrtSave(vo);
+            }
+        }
+        return result;
+    }
 }
src/main/java/com/takensoft/cms/dept/web/DeptController.java
--- src/main/java/com/takensoft/cms/dept/web/DeptController.java
+++ src/main/java/com/takensoft/cms/dept/web/DeptController.java
@@ -45,9 +45,6 @@
      */
     @PostMapping("/saveProc.json")
     public ResponseEntity<?> saveProc(@RequestBody DeptVO deptVO) throws Exception {
-
-
-
         // 부서 등록
         int result = deptService.deptSave(deptVO);
 
@@ -125,4 +122,34 @@
         return new ResponseEntity<>(responseData, headers, HttpStatus.OK);
     }
 
+    /**
+     * @author takensoft
+     * @since 2024.04.26
+     * @param deptVO
+     * @return
+     * @throws Exception
+     *
+     * 부서 수정
+     */
+    @PostMapping(value = "/updateProc.json")
+    public ResponseEntity<?> updateProc(@RequestBody DeptVO deptVO) throws Exception {
+        // 부서 등록
+        int result = deptService.deptUpdate(deptVO);
+
+        // 응답 처리
+        HttpHeaders headers = new HttpHeaders();
+        headers.setContentType(new MediaType("application", "json", Charset.forName("UTF-8")));
+        ResponseData responseData = new ResponseData();
+
+        if(result > 0) {
+            responseData.setStatus(HttpStatus.OK);
+            responseData.setMessage("정상적으로 등록 처리되었습니다.");
+            return new ResponseEntity<>(responseData, headers, HttpStatus.OK);
+        } else {
+            responseData.setStatus(HttpStatus.INTERNAL_SERVER_ERROR);
+            responseData.setMessage("등록에 실패하였습니다.\n담당자에게 문의하세요.");
+            return new ResponseEntity<>(responseData, headers, HttpStatus.INTERNAL_SERVER_ERROR);
+        }
+    }
+
 }
src/main/resources/mybatis/mapper/codeManage/codeManage-SQL.xml
--- src/main/resources/mybatis/mapper/codeManage/codeManage-SQL.xml
+++ src/main/resources/mybatis/mapper/codeManage/codeManage-SQL.xml
@@ -182,6 +182,17 @@
 
     <!--
         작성자 : takensoft
+        작성일 : 2024.04.26
+        내 용 : 상위코드가 수정됨에 따라 하위코드의 상위코드값 변경
+    -->
+    <update id="updateUpCd" parameterType="CodeManageVO">
+        UPDATE cd_mng
+           SET up_cd = #{cd}
+         WHERE up_cd = #{originCd}
+    </update>
+
+    <!--
+        작성자 : takensoft
         작성일 : 2024.04.23
         내 용 : 코드 삭제
     -->
src/main/resources/mybatis/mapper/dept/dept-SQL.xml
--- src/main/resources/mybatis/mapper/dept/dept-SQL.xml
+++ src/main/resources/mybatis/mapper/dept/dept-SQL.xml
@@ -125,6 +125,7 @@
     <select id="findByTopNode" resultType="HierachyVO">
         <include refid="selecteNode" />
         WHERE up_dept_id IS NULL
+          AND use_yn = 'Y'
      ORDER BY dept_sn
     </select>
     <!--
@@ -135,6 +136,7 @@
     <select id="findChildNode" parameterType="String" resultType="HierachyVO">
         <include refid="selecteNode" />
         WHERE up_dept_id = #{id}
+          AND use_yn = 'Y'
      ORDER BY dept_sn
     </select>
     <!--  부서 관리(관리자 페이지 Tree 호출용)   -->
@@ -176,4 +178,33 @@
           FROM dept_authrt_info dai
          WHERE dai.dept_id = #{deptId}
     </select>
+
+    <!--
+        작성자 : takensoft
+        작성일 : 2024.04.26
+        내 용 : 부서정보 수정
+    -->
+    <update id="update" parameterType="DeptVO">
+        UPDATE dept_info
+           SET up_dept_id = #{upDeptId}
+             , dept_nm = #{deptNm}
+             , dept_expln = #{deptExpln}
+             , dept_grd = #{deptGrd}
+             , dept_sn = #{deptSn}
+             , use_yn = #{useYn}
+             , mdfr = #{mdfr}
+             , mdfcn_dt = NOW()
+         WHERE dept_id = #{deptId}
+    </update>
+
+    <!--
+        작성자 : takensoft
+        작성일 : 2024.04.26
+        내 용 : 부서권한 삭제
+    -->
+    <delete id="deleteAuth" parameterType="String">
+        DELETE
+          FROM dept_authrt_info
+         WHERE dept_id = #{deptId}
+    </delete>
 </mapper>
(파일 끝에 줄바꿈 문자 없음)
Add a comment
List