-
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.
- Loading branch information
Showing
7 changed files
with
123 additions
and
3 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
19 changes: 19 additions & 0 deletions
19
src/main/java/com/mookive/mookive_backend/keyword/domain/service/KeywordQueryService.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,19 @@ | ||
package com.mookive.mookive_backend.keyword.domain.service; | ||
|
||
import com.mookive.mookive_backend.keyword.domain.entity.Keyword; | ||
import com.mookive.mookive_backend.keyword.domain.repository.KeywordRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class KeywordQueryService { | ||
|
||
private final KeywordRepository keywordRepository; | ||
|
||
public List<Keyword> findByReviewId(Long reviewId) { | ||
return keywordRepository.findByReviewId(reviewId); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...main/java/com/mookive/mookive_backend/review/application/dto/response/ReviewResponse.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,29 @@ | ||
package com.mookive.mookive_backend.review.application.dto.response; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
public class ReviewResponse { | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
public static class ReviewDetailResponse { | ||
private String rating; | ||
private String text; | ||
private LocalDate date; | ||
private List<String> keywords; | ||
|
||
@Builder | ||
public ReviewDetailResponse(String rating, String text, LocalDate date, List<String> keywords) { | ||
this.rating = rating; | ||
this.text = text; | ||
this.date = date; | ||
this.keywords = keywords; | ||
} | ||
} | ||
|
||
} |
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
31 changes: 31 additions & 0 deletions
31
src/main/java/com/mookive/mookive_backend/review/application/service/ReviewGetService.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,31 @@ | ||
package com.mookive.mookive_backend.review.application.service; | ||
|
||
import com.mookive.mookive_backend.keyword.domain.entity.Keyword; | ||
import com.mookive.mookive_backend.keyword.domain.service.KeywordQueryService; | ||
import com.mookive.mookive_backend.review.application.dto.response.ReviewResponse; | ||
import com.mookive.mookive_backend.review.application.mapper.ReviewMapper; | ||
import com.mookive.mookive_backend.review.domain.entity.Review; | ||
import com.mookive.mookive_backend.review.domain.service.ReviewQueryService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class ReviewGetService { | ||
|
||
private final ReviewQueryService reviewQueryService; | ||
private final KeywordQueryService keywordQueryService; | ||
|
||
public ReviewResponse.ReviewDetailResponse getReview(Long reviewId) { | ||
Review review = reviewQueryService.findById(reviewId); | ||
List<Keyword> keywordList = keywordQueryService.findByReviewId(reviewId); | ||
List<String> keywords= new ArrayList<>(); | ||
for(Keyword keyword : keywordList){ | ||
keywords.add(keyword.getWord()); | ||
} | ||
return ReviewMapper.mapToReviewDetailResponse(review, keywords); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/mookive/mookive_backend/review/domain/service/ReviewQueryService.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,18 @@ | ||
package com.mookive.mookive_backend.review.domain.service; | ||
|
||
import com.mookive.mookive_backend.review.domain.entity.Review; | ||
import com.mookive.mookive_backend.review.domain.repository.ReviewRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class ReviewQueryService { | ||
|
||
private final ReviewRepository reviewRepository; | ||
|
||
public Review findById(Long reviewId) { | ||
return reviewRepository.findById(reviewId) | ||
.orElseThrow(() -> new IllegalArgumentException("Review not found")); | ||
} | ||
} |
13 changes: 10 additions & 3 deletions
13
src/main/java/com/mookive/mookive_backend/review/presentation/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,20 +1,27 @@ | ||
package com.mookive.mookive_backend.review.presentation; | ||
|
||
import com.mookive.mookive_backend.review.application.dto.request.ReviewRequest; | ||
import com.mookive.mookive_backend.review.application.dto.response.ReviewResponse; | ||
import com.mookive.mookive_backend.review.application.service.ReviewCreateService; | ||
import com.mookive.mookive_backend.review.application.service.ReviewGetService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
public class ReviewController { | ||
|
||
private final ReviewCreateService reviewCreateService; | ||
private final ReviewGetService reviewGetService; | ||
|
||
@PostMapping("/review") | ||
public void createReview(@RequestBody ReviewRequest.ReviewCreateRequest reviewCreateRequest) { | ||
reviewCreateService.createReview(reviewCreateRequest); | ||
} | ||
|
||
@GetMapping("/review/{reviewId}") | ||
public ReviewResponse.ReviewDetailResponse getReview(@PathVariable Long reviewId) { | ||
return reviewGetService.getReview(reviewId); | ||
} | ||
|
||
} |