diff --git a/src/main/java/com/xit/biz/ctgy/controller/ResidentAndDisabledController.java b/src/main/java/com/xit/biz/ctgy/controller/ResidentAndDisabledController.java index 946f6ed..adf1910 100644 --- a/src/main/java/com/xit/biz/ctgy/controller/ResidentAndDisabledController.java +++ b/src/main/java/com/xit/biz/ctgy/controller/ResidentAndDisabledController.java @@ -25,6 +25,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Nonnull; import javax.validation.Valid; +import javax.validation.constraints.NotNull; /** * 거주자 / 장애인 의견 진술 @@ -45,14 +46,16 @@ public class ResidentAndDisabledController { // TODO :: 파라메터 정의 필요 @Operation(summary = "거주자/장애인 의견지술자료 목록 조회" , description = "거주자/장애인 의견진술자료 목록 조회") @Parameters({ + @Parameter(in = ParameterIn.QUERY, name = "scDatagb", description = "데이타구분", required = true, example = "1"), @Parameter(in = ParameterIn.QUERY, name = "page", description = "페이지", required = true, example = "0"), @Parameter(in = ParameterIn.QUERY, name = "size", description = "페이지당갯수", required = true, example = "10") }) @GetMapping(value="/data", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity findJudgeDatas( + @NotNull final String scDatagb, @Parameter(hidden = true) final Pageable pageable) { - return RestResponse.of(service.findJudgeDatas(pageable)); } + return RestResponse.of(service.findJudgeDatas(scDatagb, pageable)); } @Operation(summary = "거주자/장애인 의견진술 자료 등록", description = "거주자/장애인 의견진술 자료 등록") @PostMapping(value = "/data", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) diff --git a/src/main/java/com/xit/biz/ctgy/repository/IResidentAndDisabledRepositoryCustom.java b/src/main/java/com/xit/biz/ctgy/repository/IResidentAndDisabledRepositoryCustom.java index b067240..636ddf5 100644 --- a/src/main/java/com/xit/biz/ctgy/repository/IResidentAndDisabledRepositoryCustom.java +++ b/src/main/java/com/xit/biz/ctgy/repository/IResidentAndDisabledRepositoryCustom.java @@ -6,6 +6,7 @@ import com.xit.biz.ctgy.dto.JudgeTargetDto; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; +import javax.validation.constraints.NotNull; import java.util.List; /** @@ -20,7 +21,7 @@ public interface IResidentAndDisabledRepositoryCustom { * @param pageable Pageable * @return Page */ - Page findJudgeDatas(Pageable pageable); + Page findJudgeDatas(@NotNull final String scDatagb, Pageable pageable); /** * 거주자 / 장애인 의견진술 자료 정보 조회 diff --git a/src/main/java/com/xit/biz/ctgy/repository/IResidentAndDisabledRepositoryImpl.java b/src/main/java/com/xit/biz/ctgy/repository/IResidentAndDisabledRepositoryImpl.java index 34fc358..b16a3eb 100644 --- a/src/main/java/com/xit/biz/ctgy/repository/IResidentAndDisabledRepositoryImpl.java +++ b/src/main/java/com/xit/biz/ctgy/repository/IResidentAndDisabledRepositoryImpl.java @@ -17,6 +17,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; +import javax.validation.constraints.NotNull; import java.util.ArrayList; import java.util.List; @@ -35,13 +36,13 @@ public class IResidentAndDisabledRepositoryImpl implements IResidentAndDisabledR private final JPAQueryFactory queryFactory; @Override - public Page findJudgeDatas(Pageable pageable) { + public Page findJudgeDatas(@NotNull final String scDatagb, Pageable pageable) { // 커버링 인덱스로 대상 조회 QueryResults scCodeList = queryFactory .select(gnRecallSc.scCode) .from(gnRecallSc) - .where(gnRecallSc.scDatagb.eq(CtgyConstants.Judge.DATAGB_RESIDENT.getCode())) + .where(gnRecallSc.scDatagb.eq(scDatagb)) .orderBy(gnRecallSc.scCode.desc()) .offset(pageable.getOffset()) .limit(pageable.getPageSize()) @@ -89,9 +90,6 @@ public class IResidentAndDisabledRepositoryImpl implements IResidentAndDisabledR @Override public GnRecallScDto findJudgeData(final Long scCode) { - BooleanBuilder builder = new BooleanBuilder(); - builder.and(gnRecallSc.scDatagb.eq(CtgyConstants.Judge.DATAGB_RESIDENT.getCode())); - builder.and(gnRecallSc.scCode.eq(scCode)); return queryFactory .select(Projections.fields( @@ -124,6 +122,7 @@ public class IResidentAndDisabledRepositoryImpl implements IResidentAndDisabledR gnRecallSc.scPicad3, gnRecallSc.scPicad4, gnRecallSc.scTransfer, + gnRecallSc.scDatagb, gnRecallSc.scAnswer, gnRecallSc.scState, gnRecallSc.zipcode1, @@ -160,7 +159,7 @@ public class IResidentAndDisabledRepositoryImpl implements IResidentAndDisabledR "scStateNm") )) .from(gnRecallSc) - .where(builder) + .where(gnRecallSc.scCode.eq(scCode)) .fetchOne(); /* SELECT SC_CODE, SC_SEQ, SC_CARNUM, SC_NAME, SC_DONG, diff --git a/src/main/java/com/xit/biz/ctgy/service/IResidentAndDisabledService.java b/src/main/java/com/xit/biz/ctgy/service/IResidentAndDisabledService.java index 8588339..e7ee6af 100644 --- a/src/main/java/com/xit/biz/ctgy/service/IResidentAndDisabledService.java +++ b/src/main/java/com/xit/biz/ctgy/service/IResidentAndDisabledService.java @@ -6,6 +6,7 @@ import com.xit.biz.ctgy.dto.JudgeTargetDto; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; +import javax.validation.constraints.NotNull; import java.util.List; /** @@ -21,7 +22,7 @@ public interface IResidentAndDisabledService { * @param pageable Pageable * @return Page */ - Page findJudgeDatas(Pageable pageable); + Page findJudgeDatas(@NotNull final String scDatagb, Pageable pageable); /** * 거주자 / 장애인 심의자료 정보 조회 diff --git a/src/main/java/com/xit/biz/ctgy/service/impl/ResidentAndDisabledService.java b/src/main/java/com/xit/biz/ctgy/service/impl/ResidentAndDisabledService.java index 095bd1b..bc47aa1 100644 --- a/src/main/java/com/xit/biz/ctgy/service/impl/ResidentAndDisabledService.java +++ b/src/main/java/com/xit/biz/ctgy/service/impl/ResidentAndDisabledService.java @@ -31,6 +31,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StringUtils; import org.springframework.web.multipart.MultipartFile; +import javax.validation.constraints.NotNull; import java.io.File; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -60,10 +61,11 @@ public class ResidentAndDisabledService implements IResidentAndDisabledService { @Override @Transactional(readOnly = true) - public Page findJudgeDatas(Pageable pageable) { + public Page findJudgeDatas(@NotNull final String scDatagb, Pageable pageable) { // Sort sort = Sort.by(Sort.Direction.DESC, "inCode"); pageable = JpaUtil.getPagingInfo(pageable); return repository.findJudgeDatas( + scDatagb, PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by("scCode").descending())); // List userList = page.getContent(); } diff --git a/src/main/java/com/xit/core/constant/ErrorCode.java b/src/main/java/com/xit/core/constant/ErrorCode.java index 3d5b1bf..1e03213 100644 --- a/src/main/java/com/xit/core/constant/ErrorCode.java +++ b/src/main/java/com/xit/core/constant/ErrorCode.java @@ -70,6 +70,10 @@ public enum ErrorCode { DUPLICATE_RESOURCE(HttpStatus.CONFLICT, "데이터가 이미 존재합니다"), MEMBER_EXISTS(HttpStatus.CONFLICT, "가입되어 있는 회원 입니다"), + // JPA query error + SQL_DATA_RESOURCE_INVALID(HttpStatus.BAD_REQUEST, "JPA(Hibernate) SQL 오류(데이타 / 조건)"), + + FORBIDDEN(HttpStatus.FORBIDDEN, "FORBIDDEN"), INVALID_CODE(HttpStatus.BAD_REQUEST, "유효하지 않은 HttpStatus 상태 코드 입니다"), INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "INTERNAL_SERVER_ERROR"), diff --git a/src/main/java/com/xit/core/exception/handling/CustomRestExceptionHandler.java b/src/main/java/com/xit/core/exception/handling/CustomRestExceptionHandler.java index 62b99af..c6d84d0 100644 --- a/src/main/java/com/xit/core/exception/handling/CustomRestExceptionHandler.java +++ b/src/main/java/com/xit/core/exception/handling/CustomRestExceptionHandler.java @@ -148,10 +148,10 @@ public class CustomRestExceptionHandler extends ResponseEntityExceptionHandler { * @return ErrorResponse */ @ExceptionHandler(value = {NoSuchElementException.class}) - @ResponseStatus(value = HttpStatus.CONFLICT) + @ResponseStatus(value = HttpStatus.BAD_REQUEST) protected ResponseEntity handleNoSuchElementException() { - log.error("==================== handleDataException throw ConstraintViolationException, DataIntegrityViolationException ===================="); - return RestErrorResponse.of(ErrorCode.DUPLICATE_RESOURCE); + log.error("==================== handleNoSuchElementException throw NoSuchElementException ===================="); + return RestErrorResponse.of(ErrorCode.SQL_DATA_RESOURCE_INVALID); } /** @@ -172,10 +172,10 @@ public class CustomRestExceptionHandler extends ResponseEntityExceptionHandler { * @return ErrorResponse */ @ExceptionHandler(value = {ConstraintViolationException.class, DataIntegrityViolationException.class}) - @ResponseStatus(value = HttpStatus.CONFLICT) + @ResponseStatus(value = HttpStatus.BAD_REQUEST) protected ResponseEntity handleDataException() { log.error("==================== handleDataException throw ConstraintViolationException, DataIntegrityViolationException ===================="); - return RestErrorResponse.of(ErrorCode.DUPLICATE_RESOURCE); + return RestErrorResponse.of(ErrorCode.SQL_DATA_RESOURCE_INVALID); } /**