-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stock 객체 생성, secret.yml 파일 생성 및 스웨거를 위한 @operation 추가
- Loading branch information
Showing
17 changed files
with
257 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,6 @@ out/ | |
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### etc ### | ||
secret.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/main/java/kea/dpang/item/controller/ReviewController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,63 @@ | ||
package kea.dpang.item.controller; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import kea.dpang.item.dto.*; | ||
import kea.dpang.item.service.ReviewServiceImpl; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
import org.springframework.web.servlet.support.ServletUriComponentsBuilder; | ||
|
||
import java.net.URI; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/reviews") | ||
@Slf4j | ||
public class ReviewController { | ||
|
||
private final ReviewServiceImpl reviewService; | ||
|
||
@PostMapping | ||
@Operation(summary = "리뷰 등록", description = "리뷰 정보를 시스템에 추가합니다.") | ||
public ResponseEntity<ReviewResponseDto> createReview(@RequestBody ReviewCreateDto reviewCreateDto) { | ||
ReviewResponseDto review = reviewService.createReview(reviewCreateDto); | ||
log.info("새로운 리뷰 등록 완료. 리뷰 ID: {}", review.getReviewId()); | ||
|
||
URI location = ServletUriComponentsBuilder.fromCurrentRequest() | ||
.path("/{reviewId}") | ||
.buildAndExpand(review.getReviewId()) | ||
.toUri(); | ||
|
||
return ResponseEntity.created(location).body(review); | ||
} | ||
|
||
@GetMapping("/{reviewId}") | ||
@Operation(summary = "리뷰 조회", description = "리뷰를 조회합니다.") | ||
public ResponseEntity<ReviewResponseDto> getReview(@PathVariable Long reviewId) { | ||
ReviewResponseDto review = reviewService.getReview(reviewId); | ||
log.info("리뷰 정보 조회 완료. 리뷰 ID: {}", review.getReviewId()); | ||
|
||
return ResponseEntity.ok(review); | ||
} | ||
|
||
@PutMapping("/{reviewId}") | ||
@Operation(summary = "리뷰 수정", description = "기존 리뷰 정보를 업데이트합니다.") | ||
public ResponseEntity<ReviewResponseDto> updateReview(@PathVariable Long reviewId, @RequestBody ReviewUpdateDto reviewUpdateDto) { | ||
ReviewResponseDto review = reviewService.updateReview(reviewId, reviewUpdateDto); | ||
log.info("리뷰 정보 업데이트 완료. 리뷰 ID: {}", review.getReviewId()); | ||
|
||
return ResponseEntity.ok(review); | ||
} | ||
|
||
@DeleteMapping("/{reviewId}") | ||
@Operation(summary = "리뷰 삭제", description = "리뷰 정보를 시스템에서 제거합니다.") | ||
public ResponseEntity<Void> deleteReview(@PathVariable Long reviewId) { | ||
reviewService.deleteReview(reviewId); | ||
log.info("리뷰 삭제 완료. 리뷰 ID: {}", reviewId); | ||
|
||
return ResponseEntity.noContent().build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/main/java/kea/dpang/item/exception/ReviewNotFoundException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package kea.dpang.item.exception; | ||
|
||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
|
||
@Getter | ||
@ResponseStatus(value = HttpStatus.NOT_FOUND) | ||
public class ReviewNotFoundException extends RuntimeException { | ||
private final Long reviewId; | ||
|
||
public ReviewNotFoundException(Long reviewId) { | ||
super(String.format("상품을 찾을 수 없음: 상품 ID - '%s'", reviewId)); | ||
this.reviewId = reviewId; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,40 @@ | ||
package kea.dpang.item.service; | ||
|
||
import kea.dpang.item.dto.ReviewCreateDto; | ||
import kea.dpang.item.dto.ReviewResponseDto; | ||
import kea.dpang.item.dto.ReviewUpdateDto; | ||
import kea.dpang.item.entity.Review; | ||
|
||
public interface ReviewService { | ||
/** | ||
* 주어진 ID에 해당하는 리뷰의 정보를 조회합니다. | ||
* | ||
* @param reviewId 조회할 리뷰의 ID | ||
* @return 조회된 리뷰의 정보가 담긴 Detail DTO | ||
*/ | ||
ReviewResponseDto getReview(Long reviewId); | ||
|
||
/** | ||
* 새로운 리뷰을 등록합니다. | ||
* | ||
* @param reviewCreateDto 등록할 리뷰의 정보가 담긴 DTO | ||
* @return 등록된 리뷰의 정보가 담긴 Detail DTO | ||
*/ | ||
ReviewResponseDto createReview(ReviewCreateDto reviewCreateDto); | ||
|
||
/** | ||
* 리뷰의 정보를 업데이트합니다. | ||
* | ||
* @param reviewId 업데이트할 리뷰의 ID | ||
* @param reviewUpdateDto 업데이트할 리뷰의 정보가 담긴 DTO | ||
* @return 업데이트된 리뷰의 정보가 담긴 Detail DTO | ||
*/ | ||
ReviewResponseDto updateReview(Long reviewId, ReviewUpdateDto reviewUpdateDto); | ||
|
||
/** | ||
* 주어진 ID에 해당하는 리뷰을 삭제합니다. | ||
* | ||
* @param reviewId 삭제할 리뷰의 ID | ||
*/ | ||
void deleteReview(Long reviewId); | ||
} |
Oops, something went wrong.