-
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 branch 'develop' into feat/issue-763
- Loading branch information
Showing
151 changed files
with
3,823 additions
and
830 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
59 changes: 59 additions & 0 deletions
59
backend/src/main/java/com/funeat/comment/domain/Comment.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,59 @@ | ||
package com.funeat.comment.domain; | ||
|
||
import com.funeat.member.domain.Member; | ||
import com.funeat.recipe.domain.Recipe; | ||
import java.time.LocalDateTime; | ||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.FetchType; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.ManyToOne; | ||
|
||
@Entity | ||
public class Comment { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
private String comment; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "recipe_id") | ||
private Recipe recipe; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "member_id") | ||
private Member member; | ||
|
||
@Column(nullable = false) | ||
private LocalDateTime createdAt = LocalDateTime.now(); | ||
|
||
protected Comment() { | ||
} | ||
|
||
public Comment(final Recipe recipe, final Member member, final String comment) { | ||
this.recipe = recipe; | ||
this.member = member; | ||
this.comment = comment; | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public String getComment() { | ||
return comment; | ||
} | ||
|
||
public Member getMember() { | ||
return member; | ||
} | ||
|
||
public LocalDateTime getCreatedAt() { | ||
return createdAt; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
backend/src/main/java/com/funeat/comment/persistence/CommentRepository.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,8 @@ | ||
package com.funeat.comment.persistence; | ||
|
||
import com.funeat.comment.domain.Comment; | ||
import com.funeat.common.repository.BaseRepository; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface CommentRepository extends JpaRepository<Comment, Long>, BaseRepository<Comment, Long> { | ||
} |
56 changes: 56 additions & 0 deletions
56
backend/src/main/java/com/funeat/comment/specification/CommentSpecification.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,56 @@ | ||
package com.funeat.comment.specification; | ||
|
||
import com.funeat.comment.domain.Comment; | ||
import com.funeat.recipe.domain.Recipe; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import javax.persistence.criteria.JoinType; | ||
import javax.persistence.criteria.Path; | ||
import org.springframework.data.jpa.domain.Specification; | ||
|
||
public class CommentSpecification { | ||
|
||
private CommentSpecification() { | ||
} | ||
|
||
private static final List<Class<Long>> COUNT_RESULT_TYPES = List.of(Long.class, long.class); | ||
|
||
public static Specification<Comment> findAllByRecipe(final Recipe recipe, final Long lastCommentId) { | ||
return (root, query, criteriaBuilder) -> { | ||
if (!COUNT_RESULT_TYPES.contains(query.getResultType())) { | ||
root.fetch("member", JoinType.LEFT); | ||
} | ||
|
||
criteriaBuilder.desc(root.get("id")); | ||
|
||
return Specification | ||
.where(lessThan(lastCommentId)) | ||
.and(equalToRecipe(recipe)) | ||
.toPredicate(root, query, criteriaBuilder); | ||
}; | ||
} | ||
|
||
private static Specification<Comment> lessThan(final Long commentId) { | ||
return (root, query, criteriaBuilder) -> { | ||
if (Objects.isNull(commentId)) { | ||
return null; | ||
} | ||
|
||
final Path<Long> commentIdPath = root.get("id"); | ||
|
||
return criteriaBuilder.lessThan(commentIdPath, commentId); | ||
}; | ||
} | ||
|
||
private static Specification<Comment> equalToRecipe(final Recipe recipe) { | ||
return (root, query, criteriaBuilder) -> { | ||
if (Objects.isNull(recipe)) { | ||
return null; | ||
} | ||
|
||
final Path<Recipe> recipePath = root.get("recipe"); | ||
|
||
return criteriaBuilder.equal(recipePath, recipe); | ||
}; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -5,4 +5,6 @@ | |
public interface ImageUploader { | ||
|
||
String upload(final MultipartFile image); | ||
|
||
void delete(final String fileName); | ||
} |
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
28 changes: 0 additions & 28 deletions
28
backend/src/main/java/com/funeat/member/domain/bookmark/ProductBookmark.java
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
backend/src/main/java/com/funeat/member/domain/bookmark/RecipeBookmark.java
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
backend/src/main/java/com/funeat/member/persistence/ProductBookmarkRepository.java
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
backend/src/main/java/com/funeat/member/persistence/RecipeBookMarkRepository.java
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.