
250519 하석형 콘텐츠 영문명/컴포넌트 URL 중복 검사, 중복검사예외 시 커스텀메세지 출력 설정
@3e1704e6239e34626244e824fda8e5c4ee357cdc
--- src/main/java/com/takensoft/cms/bbs/service/Impl/BbsCnServiceImpl.java
+++ src/main/java/com/takensoft/cms/bbs/service/Impl/BbsCnServiceImpl.java
... | ... | @@ -87,7 +87,7 @@ |
87 | 87 |
try { |
88 | 88 |
boolean result = bbsCnDAO.bbsCnIdCheck(bbsCnVO); |
89 | 89 |
if(result) { |
90 |
- throw new CustomDataDuplicationException("이미 존재하는 게시판 아이디입니다."); |
|
90 |
+ throw new CustomDataDuplicationException("이미 존재하는 게시판 아이디입니다.", "Y"); |
|
91 | 91 |
} |
92 | 92 |
|
93 | 93 |
return result; |
--- src/main/java/com/takensoft/cms/bbs/service/Impl/BbsMngServiceImpl.java
+++ src/main/java/com/takensoft/cms/bbs/service/Impl/BbsMngServiceImpl.java
... | ... | @@ -66,7 +66,7 @@ |
66 | 66 |
try { |
67 | 67 |
boolean result = bbsMngDAO.bbsMngIdCheck(bbsMngVO); |
68 | 68 |
if(result) { |
69 |
- throw new CustomDataDuplicationException("이미 존재하는 게시판 아이디입니다."); |
|
69 |
+ throw new CustomDataDuplicationException("이미 존재하는 게시판 아이디입니다.", "Y"); |
|
70 | 70 |
} |
71 | 71 |
|
72 | 72 |
return result; |
--- src/main/java/com/takensoft/cms/contsType/dao/ContsTypeDAO.java
+++ src/main/java/com/takensoft/cms/contsType/dao/ContsTypeDAO.java
... | ... | @@ -18,6 +18,7 @@ |
18 | 18 |
* 2024.04.29 | 박정하 | findAllByExpsr 추가 |
19 | 19 |
* 2024.05.02 | takensoft | findByContsAuthrt 추가 |
20 | 20 |
* 2025.03.13 | 방선주 | 코드 리펙토링 |
21 |
+ * 2025.05.19 | 하석형 | findByCheckContsEngNm, findByCheckCompnCrs 추가 |
|
21 | 22 |
* |
22 | 23 |
* 콘텐츠 유형 관리 관련 DAO |
23 | 24 |
*/ |
... | ... | @@ -25,6 +26,22 @@ |
25 | 26 |
public interface ContsTypeDAO { |
26 | 27 |
|
27 | 28 |
/** |
29 |
+ * @param contsEngNm - 콘텐츠 영문명 |
|
30 |
+ * @return boolean - 콘텐츠 영문명 중복 검사 결과 |
|
31 |
+ * |
|
32 |
+ * 콘텐츠 영문명 중복 확인 |
|
33 |
+ */ |
|
34 |
+ boolean findByCheckContsEngNm(String contsEngNm); |
|
35 |
+ |
|
36 |
+ /** |
|
37 |
+ * @param compnCrs - 컴포넌트 URL |
|
38 |
+ * @return boolean - 컴포넌트 URL 중복 검사 결과 |
|
39 |
+ * |
|
40 |
+ * 컴포넌트 URL 중복 확인 |
|
41 |
+ */ |
|
42 |
+ boolean findByCheckCompnCrs(String compnCrs); |
|
43 |
+ |
|
44 |
+ /** |
|
28 | 45 |
* @param contsTypeVO - 컨텐츠 유형 관리 객체 |
29 | 46 |
* @return int - 등록 성공 여부 |
30 | 47 |
* |
--- src/main/java/com/takensoft/cms/contsType/service/ContsTypeService.java
+++ src/main/java/com/takensoft/cms/contsType/service/ContsTypeService.java
... | ... | @@ -15,12 +15,29 @@ |
15 | 15 |
* 2024.04.29 | 박정하 | findAllByExpsr 추가 |
16 | 16 |
* 2024.05.10 | takensoft | findByContsAuthrt 추가 |
17 | 17 |
* 2025.03.14 | 방선주 | 코드 리펙토링 |
18 |
+ * 2025.05.19 | 하석형 | findByCheckContsEngNm, findByCheckCompnCrs 추가 |
|
18 | 19 |
* |
19 | 20 |
* 콘텐츠 유형 관리 관련 인터페이스 |
20 | 21 |
*/ |
21 | 22 |
public interface ContsTypeService { |
22 | 23 |
|
23 | 24 |
/** |
25 |
+ * @param contsEngNm - 콘텐츠 영문명 |
|
26 |
+ * @return boolean - 콘텐츠 영문명 중복 검사 결과 |
|
27 |
+ * |
|
28 |
+ * 콘텐츠 영문명 중복 검사 |
|
29 |
+ */ |
|
30 |
+ boolean findByCheckContsEngNm(String contsEngNm); |
|
31 |
+ |
|
32 |
+ /** |
|
33 |
+ * @param compnCrs - 컴포넌트 URL |
|
34 |
+ * @return boolean - 컴포넌트 URL 중복 검사 결과 |
|
35 |
+ * |
|
36 |
+ * 컴포넌트 URL 중복 검사 |
|
37 |
+ */ |
|
38 |
+ boolean findByCheckCompnCrs(String compnCrs); |
|
39 |
+ |
|
40 |
+ /** |
|
24 | 41 |
* @param contsTypeVO - 콘텐츠 유형 VO |
25 | 42 |
* @return HashMap<String, Object> - 콘텐츠 유형 등록 결과 |
26 | 43 |
* |
--- src/main/java/com/takensoft/cms/contsType/service/Impl/ContsTypeServiceImpl.java
+++ src/main/java/com/takensoft/cms/contsType/service/Impl/ContsTypeServiceImpl.java
... | ... | @@ -35,6 +35,7 @@ |
35 | 35 |
* 2024.05.08 | takensoft | groupAndShareAuth, findMostComprehensiveAuth 추가 |
36 | 36 |
* 2025.03.14 | 방선주 | 코드 리펙토링 |
37 | 37 |
* 2025.04.04 | 하석형 | 콘텐츠 유형 등록 시 메뉴 필수 등록 |
38 |
+ * 2025.05.19 | 하석형 | findByCheckContsEngNm, findByCheckCompnCrs 추가 |
|
38 | 39 |
* |
39 | 40 |
* EgovAbstractServiceImpl - 전자정부 프레임워크에서 제공하는 추상 서비스 구현 클래스 |
40 | 41 |
* ContsTypeService - 콘텐츠 유형 관리 관련 인터페이스 상속 |
... | ... | @@ -53,6 +54,54 @@ |
53 | 54 |
private final MenuDAO menuDAO; |
54 | 55 |
|
55 | 56 |
/** |
57 |
+ * @param contsEngNm - 콘텐츠 영문명 |
|
58 |
+ * @return boolean - 콘텐츠 영문명 중복 여부 |
|
59 |
+ * @throws CustomDataDuplicationException - 데이터 중복 예외 발생 시 |
|
60 |
+ * @throws DataAccessException - db 관련 예외 발생 시 |
|
61 |
+ * @throws Exception - 그 외 예외 발생 시 |
|
62 |
+ * |
|
63 |
+ * 콘텐츠 영문명 중복 검사 |
|
64 |
+ */ |
|
65 |
+ @Override |
|
66 |
+ public boolean findByCheckContsEngNm(String contsEngNm) { |
|
67 |
+ try { |
|
68 |
+ boolean result = contsTypeDAO.findByCheckContsEngNm(contsEngNm); |
|
69 |
+ if (result) { |
|
70 |
+ throw new CustomDataDuplicationException("이미 사용 중인 콘텐츠 영문명입니다.", "Y"); |
|
71 |
+ } |
|
72 |
+ return result; |
|
73 |
+ } catch (DataAccessException dae) { |
|
74 |
+ throw dae; |
|
75 |
+ } catch (Exception e) { |
|
76 |
+ throw e; |
|
77 |
+ } |
|
78 |
+ } |
|
79 |
+ |
|
80 |
+ /** |
|
81 |
+ * @param compnCrs - 컴포넌트 URL |
|
82 |
+ * @return boolean - 컴포넌트 URL 중복 여부 |
|
83 |
+ * @throws CustomDataDuplicationException - 데이터 중복 예외 발생 시 |
|
84 |
+ * @throws DataAccessException - db 관련 예외 발생 시 |
|
85 |
+ * @throws Exception - 그 외 예외 발생 시 |
|
86 |
+ * |
|
87 |
+ * 컴포넌트 URL 중복 검사 |
|
88 |
+ */ |
|
89 |
+ @Override |
|
90 |
+ public boolean findByCheckCompnCrs(String compnCrs) { |
|
91 |
+ try { |
|
92 |
+ boolean result = contsTypeDAO.findByCheckCompnCrs(compnCrs); |
|
93 |
+ if (result) { |
|
94 |
+ throw new CustomDataDuplicationException("이미 사용 중인 컴포넌트 URL입니다.", "Y"); |
|
95 |
+ } |
|
96 |
+ return result; |
|
97 |
+ } catch (DataAccessException dae) { |
|
98 |
+ throw dae; |
|
99 |
+ } catch (Exception e) { |
|
100 |
+ throw e; |
|
101 |
+ } |
|
102 |
+ } |
|
103 |
+ |
|
104 |
+ /** |
|
56 | 105 |
* @param contsTypeVO - 콘텐츠 유형 객체 |
57 | 106 |
* @return HashMap<String, Object> - 콘텐츠 유형 등록 결과값 |
58 | 107 |
* @throws CustomNotFoundException - 사용자 정보 조회 예외 발생 시 |
--- src/main/java/com/takensoft/cms/contsType/web/ContsTypeController.java
+++ src/main/java/com/takensoft/cms/contsType/web/ContsTypeController.java
... | ... | @@ -3,9 +3,11 @@ |
3 | 3 |
import com.takensoft.cms.contsType.service.ContsTypeService; |
4 | 4 |
import com.takensoft.cms.contsType.vo.ContsAuthrtVO; |
5 | 5 |
import com.takensoft.cms.contsType.vo.ContsTypeVO; |
6 |
+import com.takensoft.common.exception.CustomIdTakenException; |
|
6 | 7 |
import com.takensoft.common.message.MessageCode; |
7 | 8 |
import com.takensoft.common.util.ResponseUtil; |
8 | 9 |
import lombok.RequiredArgsConstructor; |
10 |
+import org.springframework.dao.DataAccessException; |
|
9 | 11 |
import org.springframework.http.ResponseEntity; |
10 | 12 |
import org.springframework.web.bind.annotation.PostMapping; |
11 | 13 |
import org.springframework.web.bind.annotation.RequestBody; |
... | ... | @@ -42,6 +44,11 @@ |
42 | 44 |
|
43 | 45 |
@PostMapping("/saveProc.json") |
44 | 46 |
public ResponseEntity<?> savePorc(@RequestBody ContsTypeVO contsTypeVO){ |
47 |
+ // 콘텐츠 영문명 중복 검사 |
|
48 |
+ boolean isEngNmExist = contsTypeService.findByCheckContsEngNm(contsTypeVO.getContsEngNm()); |
|
49 |
+ // 컴포넌트 URL 중복 검사 |
|
50 |
+ boolean isCompnCrsExist = contsTypeService.findByCheckCompnCrs(contsTypeVO.getCompnCrs()); |
|
51 |
+ |
|
45 | 52 |
// 콘텐츠 유형 등록 |
46 | 53 |
HashMap<String, Object> result = contsTypeService.contsSave(contsTypeVO); |
47 | 54 |
// 응답 처리 |
... | ... | @@ -56,6 +63,11 @@ |
56 | 63 |
*/ |
57 | 64 |
@PostMapping("/updateProc.json") |
58 | 65 |
public ResponseEntity<?> updateProc(@RequestBody ContsTypeVO contsTypeVO) { |
66 |
+ // 콘텐츠 영문명 중복 검사 |
|
67 |
+ boolean isEngNmExist = contsTypeService.findByCheckContsEngNm(contsTypeVO.getContsEngNm()); |
|
68 |
+ // 컴포넌트 URL 중복 검사 |
|
69 |
+ boolean isCompnCrsExist = contsTypeService.findByCheckCompnCrs(contsTypeVO.getCompnCrs()); |
|
70 |
+ |
|
59 | 71 |
// 콘텐츠 유형 수정 처리 |
60 | 72 |
int result = contsTypeService.contsUpdate(contsTypeVO); |
61 | 73 |
// 응답 처리 |
--- src/main/java/com/takensoft/cms/dept/web/DeptController.java
+++ src/main/java/com/takensoft/cms/dept/web/DeptController.java
... | ... | @@ -58,7 +58,7 @@ |
58 | 58 |
} |
59 | 59 |
|
60 | 60 |
/** |
61 |
- * @param mbrList - 부서 사용자 정보 |
|
61 |
+ * @param deptMbrList - 부서 사용자 목록 |
|
62 | 62 |
* @return ResponseEntity - 부서 사용자 등록 결과 |
63 | 63 |
* |
64 | 64 |
* 부서 사용자 등록 |
--- src/main/java/com/takensoft/common/exception/CustomDataDuplicationException.java
+++ src/main/java/com/takensoft/common/exception/CustomDataDuplicationException.java
... | ... | @@ -6,6 +6,7 @@ |
6 | 6 |
* @modification |
7 | 7 |
* since | author | description |
8 | 8 |
* 2025.03.12 | 하석형 | 최초 등록 |
9 |
+ * 2025.05.19 | 하석형 | 커스텀 메세지 출력 여부 추가 |
|
9 | 10 |
* |
10 | 11 |
* RuntimeException - 실행 중 발생하는 예외를 처리하는 기본 클래스 |
11 | 12 |
* |
... | ... | @@ -13,14 +14,21 @@ |
13 | 14 |
*/ |
14 | 15 |
public class CustomDataDuplicationException extends RuntimeException { |
15 | 16 |
|
17 |
+ private String isCustom; // 커스텀 메세지 출력 여부 |
|
18 |
+ |
|
16 | 19 |
public CustomDataDuplicationException() { |
17 | 20 |
} |
18 | 21 |
|
19 |
- public CustomDataDuplicationException(String message) { |
|
22 |
+ public CustomDataDuplicationException(String message, String isCustom) { |
|
20 | 23 |
super(message); |
24 |
+ this.isCustom = isCustom; |
|
21 | 25 |
} |
22 | 26 |
|
23 | 27 |
public CustomDataDuplicationException(String message, Throwable cause) { |
24 | 28 |
super(message, cause); |
25 | 29 |
} |
30 |
+ |
|
31 |
+ public String getCustom() { |
|
32 |
+ return isCustom; |
|
33 |
+ } |
|
26 | 34 |
}(파일 끝에 줄바꿈 문자 없음) |
--- src/main/java/com/takensoft/common/exception/GlobalExceptionHandler.java
+++ src/main/java/com/takensoft/common/exception/GlobalExceptionHandler.java
... | ... | @@ -267,7 +267,12 @@ |
267 | 267 |
@ExceptionHandler(CustomDataDuplicationException.class) |
268 | 268 |
public ResponseEntity<?> handleCustomDataDuplicationException(CustomDataDuplicationException cdde) { |
269 | 269 |
logError(cdde); |
270 |
- return resUtil.errorRes(MessageCode.COMMON_DUPLICATION_DATA); |
|
270 |
+ // CustomDataDuplicationException의 커스텀 메시지가 "Y"인 경우 |
|
271 |
+ if(cdde.getCustom().equals("Y")) { |
|
272 |
+ return resUtil.errorRes(HttpStatus.INTERNAL_SERVER_ERROR, cdde.getMessage()); |
|
273 |
+ } else { |
|
274 |
+ return resUtil.errorRes(MessageCode.COMMON_DUPLICATION_DATA); |
|
275 |
+ } |
|
271 | 276 |
} |
272 | 277 |
|
273 | 278 |
/** |
--- src/main/resources/mybatis/mapper/contsType/contsType-SQL.xml
+++ src/main/resources/mybatis/mapper/contsType/contsType-SQL.xml
... | ... | @@ -28,6 +28,30 @@ |
28 | 28 |
</resultMap> |
29 | 29 |
|
30 | 30 |
<!-- |
31 |
+ 작성자 : 하석형 |
|
32 |
+ 작성일 : 2025.05.19 |
|
33 |
+ 내 용 : 콘텐츠 영문명 중복 확인 |
|
34 |
+ --> |
|
35 |
+ <select id="findByCheckContsEngNm" parameterType="String" resultType="boolean"> |
|
36 |
+ SELECT COUNT(conts_eng_nm) |
|
37 |
+ FROM conts_type_mng |
|
38 |
+ WHERE LOWER(conts_eng_nm) = LOWER(#{contsEngNm}) |
|
39 |
+ AND use_yn = 'Y' |
|
40 |
+ </select> |
|
41 |
+ |
|
42 |
+ <!-- |
|
43 |
+ 작성자 : 하석형 |
|
44 |
+ 작성일 : 2025.05.19 |
|
45 |
+ 내 용 : 컴포넌트 URL 중복 확인 |
|
46 |
+ --> |
|
47 |
+ <select id="findByCheckCompnCrs" parameterType="String" resultType="boolean"> |
|
48 |
+ SELECT COUNT(compn_crs) |
|
49 |
+ FROM conts_type_mng |
|
50 |
+ WHERE LOWER(compn_crs) = LOWER(#{compnCrs}) |
|
51 |
+ AND use_yn = 'Y' |
|
52 |
+ </select> |
|
53 |
+ |
|
54 |
+ <!-- |
|
31 | 55 |
작성자 : takensoft |
32 | 56 |
작성일 : 2024.04.17 |
33 | 57 |
내 용 : 콘텐츠 유형 등록 |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?