|
|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package go.kr.project.system.code.service.impl;
|
|
|
|
|
|
|
|
|
|
import egovframework.exception.MessageException;
|
|
|
|
|
import egovframework.util.SessionUtil;
|
|
|
|
|
import go.kr.project.system.code.mapper.CodeMapper;
|
|
|
|
|
import go.kr.project.system.code.model.*;
|
|
|
|
|
@ -7,6 +8,8 @@ import go.kr.project.system.code.service.CodeService;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.egovframe.rte.fdl.cmmn.EgovAbstractServiceImpl;
|
|
|
|
|
import org.springframework.dao.DataIntegrityViolationException;
|
|
|
|
|
import org.springframework.dao.DuplicateKeyException;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
@ -79,6 +82,7 @@ public class CodeServiceImpl extends EgovAbstractServiceImpl implements CodeServ
|
|
|
|
|
*
|
|
|
|
|
* @param modifyData 저장할 코드 상세 정보 목록
|
|
|
|
|
* @return 등록, 수정, 삭제 된 행의 수
|
|
|
|
|
* @throws MessageException 중복 에러 발생 시 발생
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public int saveCodeDetails(CodeDetailModifiedDataVO modifyData) {
|
|
|
|
|
@ -102,7 +106,15 @@ public class CodeServiceImpl extends EgovAbstractServiceImpl implements CodeServ
|
|
|
|
|
if (codeDetailVO.getUseYn() == null || codeDetailVO.getUseYn().isEmpty()) {
|
|
|
|
|
codeDetailVO.setUseYn("Y");
|
|
|
|
|
}
|
|
|
|
|
result += codeMapper.insertCodeDetail(codeDetailVO);
|
|
|
|
|
try {
|
|
|
|
|
// 코드 상세 등록 시도
|
|
|
|
|
result += codeMapper.insertCodeDetail(codeDetailVO);
|
|
|
|
|
} catch (DuplicateKeyException e) {
|
|
|
|
|
// 중복 에러 처리
|
|
|
|
|
// 동일한 그룹코드ID와 코드ID 조합이 이미 존재하는 경우 중복 에러 발생
|
|
|
|
|
log.error("중복 에러 발생: {}", e.getMessage());
|
|
|
|
|
throw new MessageException("상세코드ID가 중복되었습니다");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -115,7 +127,15 @@ public class CodeServiceImpl extends EgovAbstractServiceImpl implements CodeServ
|
|
|
|
|
if (codeDetailVO.getUseYn() == null || codeDetailVO.getUseYn().isEmpty()) {
|
|
|
|
|
codeDetailVO.setUseYn("Y");
|
|
|
|
|
}
|
|
|
|
|
result += codeMapper.updateCodeDetail(codeDetailVO);
|
|
|
|
|
try {
|
|
|
|
|
// 코드 상세 수정 시도
|
|
|
|
|
result += codeMapper.updateCodeDetail(codeDetailVO);
|
|
|
|
|
} catch (DuplicateKeyException e) {
|
|
|
|
|
// 중복 에러 처리
|
|
|
|
|
// 수정 시 다른 코드와 ID가 중복되는 경우 에러 발생
|
|
|
|
|
log.error("중복 에러 발생: {}", e.getMessage());
|
|
|
|
|
throw new MessageException("상세코드ID가 중복되었습니다");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -127,6 +147,7 @@ public class CodeServiceImpl extends EgovAbstractServiceImpl implements CodeServ
|
|
|
|
|
*
|
|
|
|
|
* @param modifyData 저장할 코드 그룹 정보 목록
|
|
|
|
|
* @return 등록, 수정, 삭제 된 행의 수
|
|
|
|
|
* @throws MessageException 중복 에러 또는 외래키 제약조건 위반 시 발생
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public int saveCodeGroups(CodeGroupModifiedDataVO modifyData) {
|
|
|
|
|
@ -136,7 +157,15 @@ public class CodeServiceImpl extends EgovAbstractServiceImpl implements CodeServ
|
|
|
|
|
List<CodeGroupVO> deletedRows = modifyData.getDeletedRows();
|
|
|
|
|
if (deletedRows != null && !deletedRows.isEmpty()) {
|
|
|
|
|
for (CodeGroupVO codeGroupVO : deletedRows) {
|
|
|
|
|
result += codeMapper.deleteCodeGroup(codeGroupVO);
|
|
|
|
|
try {
|
|
|
|
|
// 코드 그룹 삭제 시도
|
|
|
|
|
result += codeMapper.deleteCodeGroup(codeGroupVO);
|
|
|
|
|
} catch (DataIntegrityViolationException e) {
|
|
|
|
|
// 외래키 제약조건 위반 예외 처리
|
|
|
|
|
// 코드 그룹에 연결된 코드 상세가 있을 경우 삭제할 수 없음
|
|
|
|
|
log.error("외래키 제약조건 위반 에러 발생: {}", e.getMessage());
|
|
|
|
|
throw new MessageException("상세코드 데이터 삭제 후 그룹코드를 삭제하시기 바랍니다");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -149,7 +178,15 @@ public class CodeServiceImpl extends EgovAbstractServiceImpl implements CodeServ
|
|
|
|
|
if (codeGroupVO.getUseYn() == null || codeGroupVO.getUseYn().isEmpty()) {
|
|
|
|
|
codeGroupVO.setUseYn("Y");
|
|
|
|
|
}
|
|
|
|
|
result += codeMapper.insertCodeGroup(codeGroupVO);
|
|
|
|
|
try {
|
|
|
|
|
// 코드 그룹 등록 시도
|
|
|
|
|
result += codeMapper.insertCodeGroup(codeGroupVO);
|
|
|
|
|
} catch (DuplicateKeyException e) {
|
|
|
|
|
// 중복 에러 처리
|
|
|
|
|
// 동일한 그룹코드ID가 이미 존재하는 경우 중복 에러 발생
|
|
|
|
|
log.error("중복 에러 발생: {}", e.getMessage());
|
|
|
|
|
throw new MessageException("그룹코드ID가 중복되었습니다");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -165,7 +202,15 @@ public class CodeServiceImpl extends EgovAbstractServiceImpl implements CodeServ
|
|
|
|
|
if (codeGroupVO.getUseYn() == null || codeGroupVO.getUseYn().isEmpty()) {
|
|
|
|
|
codeGroupVO.setUseYn("Y");
|
|
|
|
|
}
|
|
|
|
|
result += codeMapper.updateCodeGroup(codeGroupVO);
|
|
|
|
|
try {
|
|
|
|
|
// 코드 그룹 수정 시도
|
|
|
|
|
result += codeMapper.updateCodeGroup(codeGroupVO);
|
|
|
|
|
} catch (DuplicateKeyException e) {
|
|
|
|
|
// 중복 에러 처리
|
|
|
|
|
// 수정 시 다른 그룹코드와 ID가 중복되는 경우 에러 발생
|
|
|
|
|
log.error("중복 에러 발생: {}", e.getMessage());
|
|
|
|
|
throw new MessageException("그룹코드ID가 중복되었습니다");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|