-
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.
Merge pull request #102 from D-VIDE/feature/review-like
리뷰 좋아요 api 구현
- Loading branch information
Showing
8 changed files
with
158 additions
and
0 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
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,38 @@ | ||
package com.divide.review; | ||
|
||
import com.divide.user.User; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import javax.persistence.*; | ||
import javax.validation.constraints.NotNull; | ||
|
||
import static javax.persistence.FetchType.LAZY; | ||
|
||
@Getter | ||
@Entity | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class ReviewLike { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long reviewLikeId; | ||
|
||
@ManyToOne(fetch = LAZY) | ||
@JoinColumn(name = "review_id") | ||
@NotNull | ||
private Review review; | ||
|
||
@ManyToOne(fetch = LAZY) | ||
@JoinColumn(name = "user_id") | ||
@NotNull | ||
private User user; | ||
|
||
@Builder | ||
public ReviewLike(Long reviewLikeId, Review review, User user) { | ||
this.reviewLikeId = reviewLikeId; | ||
this.review = review; | ||
this.user = user; | ||
} | ||
} |
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,25 @@ | ||
package com.divide.review; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import javax.persistence.EntityManager; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class ReviewLikeRepository { | ||
private final EntityManager em; | ||
|
||
public void save(ReviewLike reviewLike) { | ||
em.persist(reviewLike);} | ||
|
||
public void delete(ReviewLike reviewLike){ | ||
em.remove(reviewLike); | ||
} | ||
|
||
public ReviewLike findById(Long reviewLikeId){ | ||
ReviewLike reviewLike = em.find(ReviewLike.class, reviewLikeId); | ||
return reviewLike; | ||
} | ||
|
||
} |
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
12 changes: 12 additions & 0 deletions
12
src/main/java/com/divide/review/dto/response/DeleteReviewLikeResponse.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,12 @@ | ||
package com.divide.review.dto.response; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@AllArgsConstructor | ||
public class DeleteReviewLikeResponse { | ||
private Long ReviewId; | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/divide/review/dto/response/PostReviewLikeResponse.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,12 @@ | ||
package com.divide.review.dto.response; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@AllArgsConstructor | ||
public class PostReviewLikeResponse { | ||
private Long reviewLikeId; | ||
} |