-
Notifications
You must be signed in to change notification settings - Fork 5
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
19 changed files
with
508 additions
and
165 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
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
11 changes: 11 additions & 0 deletions
11
src/main/java/jeje/work/aeatbe/dto/review/ReviewRequestDTO.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,11 @@ | ||
package jeje.work.aeatbe.dto.review; | ||
|
||
import lombok.Builder; | ||
|
||
@Builder | ||
public record ReviewRequestDTO( | ||
Long rate, | ||
String content, | ||
Long productId | ||
) { | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/jeje/work/aeatbe/dto/review/ReviewResponseDTO.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,15 @@ | ||
package jeje.work.aeatbe.dto.review; | ||
|
||
import jeje.work.aeatbe.dto.user.UserInfoResponseDTO; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public record ReviewResponseDTO( | ||
Long id, | ||
Long rate, | ||
String content, | ||
UserInfoResponseDTO user, | ||
Long productId, | ||
String productImgUrl | ||
) { | ||
} |
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
7 changes: 7 additions & 0 deletions
7
src/main/java/jeje/work/aeatbe/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,7 @@ | ||
package jeje.work.aeatbe.exception; | ||
|
||
public class ReviewNotFoundException extends RuntimeException { | ||
public ReviewNotFoundException(String message) { | ||
super(message); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/jeje/work/aeatbe/mapper/Review/ReviewMapper.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,35 @@ | ||
package jeje.work.aeatbe.mapper.Review; | ||
|
||
import jeje.work.aeatbe.dto.review.ReviewDTO; | ||
import jeje.work.aeatbe.entity.Product; | ||
import jeje.work.aeatbe.entity.Review; | ||
import jeje.work.aeatbe.entity.User; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class ReviewMapper { | ||
public ReviewDTO toDTO(Review review) { | ||
return ReviewDTO.builder() | ||
.id(review.getId()) | ||
.rate(review.getRate()) | ||
.content(review.getContent()) | ||
.userId(review.getUser().getId()) | ||
.productId(review.getProduct().getId()) | ||
.productImgUrl(review.getProduct().getProductImageUrl()) | ||
.build(); | ||
} | ||
|
||
public Review toEntity(ReviewDTO reviewDTO, User user, Product product, boolean idRequired) { | ||
return Review.builder() | ||
.id(idRequired ? reviewDTO.id() : null) | ||
.rate(reviewDTO.rate()) | ||
.content(reviewDTO.content()) | ||
.user(user) | ||
.product(product) | ||
.build(); | ||
} | ||
|
||
public Review toEntity(ReviewDTO reviewDTO, User user, Product product) { | ||
return toEntity(reviewDTO, user, product, false); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/jeje/work/aeatbe/mapper/Review/ReviewRequestMapper.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 jeje.work.aeatbe.mapper.Review; | ||
|
||
import jeje.work.aeatbe.dto.review.ReviewDTO; | ||
import jeje.work.aeatbe.dto.review.ReviewRequestDTO; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class ReviewRequestMapper { | ||
public ReviewDTO toDTO(ReviewRequestDTO reviewRequestDTO) { | ||
return ReviewDTO.builder() | ||
.rate(reviewRequestDTO.rate()) | ||
.content(reviewRequestDTO.content()) | ||
.productId(reviewRequestDTO.productId()) | ||
.build(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/jeje/work/aeatbe/mapper/Review/ReviewResponseMapper.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,20 @@ | ||
package jeje.work.aeatbe.mapper.Review; | ||
|
||
import jeje.work.aeatbe.dto.review.ReviewDTO; | ||
import jeje.work.aeatbe.dto.review.ReviewResponseDTO; | ||
import jeje.work.aeatbe.dto.user.UserInfoResponseDTO; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class ReviewResponseMapper { | ||
public ReviewResponseDTO toDTO(ReviewDTO reviewDTO, UserInfoResponseDTO userInfoResponseDTO) { | ||
return ReviewResponseDTO.builder() | ||
.id(reviewDTO.id()) | ||
.rate(reviewDTO.rate()) | ||
.content(reviewDTO.content()) | ||
.user(userInfoResponseDTO) | ||
.productId(reviewDTO.productId()) | ||
.productImgUrl(reviewDTO.productImgUrl()) | ||
.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
Oops, something went wrong.