From 03b29060f7f63194a3092cb584e12f515b2c7cfa Mon Sep 17 00:00:00 2001 From: yeonjy Date: Fri, 12 Jul 2024 10:39:51 +0900 Subject: [PATCH 1/5] =?UTF-8?q?rename:=20INQUIRY=5FNOT=5FADMIN=5FMEMBER=5F?= =?UTF-8?q?ERROR=20=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inquiry/exception/InquiryAnswerNotAdminMemberException.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/pyro/yolog/domain/inquiry/exception/InquiryAnswerNotAdminMemberException.java b/src/main/java/com/pyro/yolog/domain/inquiry/exception/InquiryAnswerNotAdminMemberException.java index bc4e781..4c11301 100644 --- a/src/main/java/com/pyro/yolog/domain/inquiry/exception/InquiryAnswerNotAdminMemberException.java +++ b/src/main/java/com/pyro/yolog/domain/inquiry/exception/InquiryAnswerNotAdminMemberException.java @@ -5,6 +5,6 @@ public class InquiryAnswerNotAdminMemberException extends BusinessException { public InquiryAnswerNotAdminMemberException() { - super(ErrorCode.INQUIRY_NOT_ADMIN_MEMBER); + super(ErrorCode.INQUIRY_NOT_ADMIN_MEMBER_ERROR); } } From 2f520e0a9f011e55c20743d6ee44d924db3a167f Mon Sep 17 00:00:00 2001 From: yeonjy Date: Fri, 12 Jul 2024 10:40:19 +0900 Subject: [PATCH 2/5] =?UTF-8?q?feat:=20Trip=20=EA=B0=9C=EB=B3=84=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pyro/yolog/domain/trip/api/TripApi.java | 20 +++++++++++++++++++ .../yolog/domain/trip/api/TripController.java | 9 ++++++++- .../trip/exception/TripNotFoundException.java | 10 ++++++++++ .../domain/trip/service/TripService.java | 10 +++++++--- 4 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/pyro/yolog/domain/trip/exception/TripNotFoundException.java diff --git a/src/main/java/com/pyro/yolog/domain/trip/api/TripApi.java b/src/main/java/com/pyro/yolog/domain/trip/api/TripApi.java index d6e5176..c04e0c9 100644 --- a/src/main/java/com/pyro/yolog/domain/trip/api/TripApi.java +++ b/src/main/java/com/pyro/yolog/domain/trip/api/TripApi.java @@ -2,6 +2,7 @@ import com.pyro.yolog.domain.trip.dto.TripRequest; import com.pyro.yolog.domain.trip.dto.TripResponse; +import com.pyro.yolog.domain.trip.entity.Trip; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.enums.ParameterIn; @@ -78,4 +79,23 @@ void deleteTrip( ) List getTrips(); + @Operation( + summary = "일기장 상세 조회", + description = "일기장을 상세 조회합니다.", + security = {@SecurityRequirement(name = "access_token")} + ) + @ApiResponses( + value = { + @ApiResponse( + responseCode = "200", + description = "OK" + ) + } + ) + TripResponse getTrip( + @Parameter(in = ParameterIn.QUERY, description = "일기장 ID", required = true) + Long id + ); + + } diff --git a/src/main/java/com/pyro/yolog/domain/trip/api/TripController.java b/src/main/java/com/pyro/yolog/domain/trip/api/TripController.java index b135e4b..63646cc 100644 --- a/src/main/java/com/pyro/yolog/domain/trip/api/TripController.java +++ b/src/main/java/com/pyro/yolog/domain/trip/api/TripController.java @@ -2,7 +2,9 @@ import com.pyro.yolog.domain.trip.dto.TripRequest; import com.pyro.yolog.domain.trip.dto.TripResponse; +import com.pyro.yolog.domain.trip.entity.Trip; import com.pyro.yolog.domain.trip.service.TripService; +import io.swagger.v3.oas.annotations.Parameter; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; @@ -44,5 +46,10 @@ public List getTrips() { return tripService.getTrips(); } - + @ResponseStatus(HttpStatus.OK) + @GetMapping("/{id}") + @Override + public TripResponse getTrip(@Parameter Long id) { + return tripService.getTripDetail(id); + } } diff --git a/src/main/java/com/pyro/yolog/domain/trip/exception/TripNotFoundException.java b/src/main/java/com/pyro/yolog/domain/trip/exception/TripNotFoundException.java new file mode 100644 index 0000000..d99d968 --- /dev/null +++ b/src/main/java/com/pyro/yolog/domain/trip/exception/TripNotFoundException.java @@ -0,0 +1,10 @@ +package com.pyro.yolog.domain.trip.exception; + +import com.pyro.yolog.global.error.ErrorCode; +import com.pyro.yolog.global.error.exception.BusinessException; + +public class TripNotFoundException extends BusinessException { + public TripNotFoundException() { + super(ErrorCode.TRIP_NOT_FOUND_ERROR); + } +} diff --git a/src/main/java/com/pyro/yolog/domain/trip/service/TripService.java b/src/main/java/com/pyro/yolog/domain/trip/service/TripService.java index 36efe1a..43ae5ea 100644 --- a/src/main/java/com/pyro/yolog/domain/trip/service/TripService.java +++ b/src/main/java/com/pyro/yolog/domain/trip/service/TripService.java @@ -8,7 +8,7 @@ import com.pyro.yolog.domain.trip.entity.Trip; import com.pyro.yolog.domain.trip.mapper.TripMapper; import com.pyro.yolog.domain.trip.repository.TripRepository; -import jakarta.persistence.EntityNotFoundException; +import com.pyro.yolog.domain.trip.exception.TripNotFoundException; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -32,7 +32,7 @@ public void saveTrip(final TripRequest request) { @Transactional public void updateTrip(final Long id, final TripRequest request) { - final Trip trip = tripRepository.findById(id).orElseThrow(EntityNotFoundException::new); + final Trip trip = tripRepository.findById(id).orElseThrow(TripNotFoundException::new); trip.update(request); diaryService.deleteOutOfDuration(trip); } @@ -43,7 +43,7 @@ public void deleteTrip(Long id) { } public Trip getTrip(final Long id) { - return tripRepository.findById(id).orElseThrow(EntityNotFoundException::new); + return tripRepository.findById(id).orElseThrow(TripNotFoundException::new); } public List getTrips() { @@ -51,4 +51,8 @@ public List getTrips() { return tripRepository.findAllByMember(login).stream() .map(TripResponse::new).collect(Collectors.toList()); } + + public TripResponse getTripDetail(Long id) { + return new TripResponse(getTrip(id)); + } } From 990407c37100840f1b31d3c2c9061bf36c649606 Mon Sep 17 00:00:00 2001 From: yeonjy Date: Fri, 12 Jul 2024 10:45:41 +0900 Subject: [PATCH 3/5] fix: @Parameter -> @PathParameter --- .../java/com/pyro/yolog/domain/trip/api/TripController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/pyro/yolog/domain/trip/api/TripController.java b/src/main/java/com/pyro/yolog/domain/trip/api/TripController.java index 63646cc..532bf6d 100644 --- a/src/main/java/com/pyro/yolog/domain/trip/api/TripController.java +++ b/src/main/java/com/pyro/yolog/domain/trip/api/TripController.java @@ -49,7 +49,7 @@ public List getTrips() { @ResponseStatus(HttpStatus.OK) @GetMapping("/{id}") @Override - public TripResponse getTrip(@Parameter Long id) { + public TripResponse getTrip(@PathVariable Long id) { return tripService.getTripDetail(id); } } From a3461a69e195415bbf46d7b1237876f0213a7647 Mon Sep 17 00:00:00 2001 From: yeonjy Date: Fri, 12 Jul 2024 10:47:04 +0900 Subject: [PATCH 4/5] =?UTF-8?q?feat:=20TRIP=5FNOT=5FFOUND=5FERROR=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/pyro/yolog/global/error/ErrorCode.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/pyro/yolog/global/error/ErrorCode.java b/src/main/java/com/pyro/yolog/global/error/ErrorCode.java index 8fbb520..9fc83b6 100644 --- a/src/main/java/com/pyro/yolog/global/error/ErrorCode.java +++ b/src/main/java/com/pyro/yolog/global/error/ErrorCode.java @@ -19,9 +19,10 @@ public enum ErrorCode { // INQUIRY INQUIRY_NOT_FOUND_ERROR(HttpStatus.NOT_FOUND, "해당 문의를 찾지 못했습니다."), - INQUIRY_NOT_ADMIN_MEMBER(HttpStatus.BAD_REQUEST, "문의하기 답변은 관리자만 가능합니다."), + INQUIRY_NOT_ADMIN_MEMBER_ERROR(HttpStatus.BAD_REQUEST, "문의하기 답변은 관리자만 가능합니다."), // TRIP + TRIP_NOT_FOUND_ERROR(HttpStatus.NOT_FOUND, "해당 일기장을 찾지 못했습니다."), REQUEST_COLOR_COVER_INVALID_ERROR(HttpStatus.BAD_REQUEST, "올바른 색상 코드를 입력해야 합니다."), //DIARY From 82d979c07e58fc514e40bd9ae4f94c58c1f295c8 Mon Sep 17 00:00:00 2001 From: yeonjy Date: Fri, 12 Jul 2024 10:57:12 +0900 Subject: [PATCH 5/5] fix: parameter query -> path --- src/main/java/com/pyro/yolog/domain/trip/api/TripApi.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/pyro/yolog/domain/trip/api/TripApi.java b/src/main/java/com/pyro/yolog/domain/trip/api/TripApi.java index c04e0c9..d637d41 100644 --- a/src/main/java/com/pyro/yolog/domain/trip/api/TripApi.java +++ b/src/main/java/com/pyro/yolog/domain/trip/api/TripApi.java @@ -42,7 +42,7 @@ public interface TripApi { ) }) void updateTrip( - @Parameter(in = ParameterIn.QUERY, description = "일기장 ID", required = true) + @Parameter(in = ParameterIn.PATH, description = "일기장 ID", required = true) Long id, @RequestBody TripRequest request @@ -60,7 +60,7 @@ void updateTrip( ) }) void deleteTrip( - @Parameter(in = ParameterIn.QUERY, description = "일기장 ID", required = true) + @Parameter(in = ParameterIn.PATH, description = "일기장 ID", required = true) Long id ); @@ -93,7 +93,7 @@ void deleteTrip( } ) TripResponse getTrip( - @Parameter(in = ParameterIn.QUERY, description = "일기장 ID", required = true) + @Parameter(in = ParameterIn.PATH, description = "일기장 ID", required = true) Long id );