fix: 거주자 / 장애인 의견진술 저장 진행

dev
Lim Jonguk 3 years ago
parent 09dae5f85e
commit 837abfb985

@ -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<? extends IRestResponse> 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)

@ -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<GnRecallScDto>
*/
Page<GnRecallScDto> findJudgeDatas(Pageable pageable);
Page<GnRecallScDto> findJudgeDatas(@NotNull final String scDatagb, Pageable pageable);
/**
* /

@ -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<GnRecallScDto> findJudgeDatas(Pageable pageable) {
public Page<GnRecallScDto> findJudgeDatas(@NotNull final String scDatagb, Pageable pageable) {
// 커버링 인덱스로 대상 조회
QueryResults<Long> 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,

@ -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<GnRecallScDto>
*/
Page<GnRecallScDto> findJudgeDatas(Pageable pageable);
Page<GnRecallScDto> findJudgeDatas(@NotNull final String scDatagb, Pageable pageable);
/**
* /

@ -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<GnRecallScDto> findJudgeDatas(Pageable pageable) {
public Page<GnRecallScDto> 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<CmmUser> userList = page.getContent();
}

@ -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"),

@ -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<RestErrorResponse> 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<RestErrorResponse> handleDataException() {
log.error("==================== handleDataException throw ConstraintViolationException, DataIntegrityViolationException ====================");
return RestErrorResponse.of(ErrorCode.DUPLICATE_RESOURCE);
return RestErrorResponse.of(ErrorCode.SQL_DATA_RESOURCE_INVALID);
}
/**

Loading…
Cancel
Save