-
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.
* feat: 꿀조합 북마크 엔티티 및 단위 테스트 추가 * test: 레시피 저장 기능 인수 테스트 추가 * test: 북마크 서비스 테스트 추가 * feat: 레시피 저장 기능 서비스 로직 추가
- Loading branch information
Showing
15 changed files
with
464 additions
and
5 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
65 changes: 65 additions & 0 deletions
65
src/main/java/com/funeat/member/domain/bookmark/RecipeBookmark.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,65 @@ | ||
package com.funeat.member.domain.bookmark; | ||
|
||
import com.funeat.member.domain.Member; | ||
import com.funeat.recipe.domain.Recipe; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.Table; | ||
import jakarta.persistence.UniqueConstraint; | ||
|
||
@Entity | ||
@Table(uniqueConstraints = @UniqueConstraint(columnNames = {"member_id", "recipe_id"})) | ||
public class RecipeBookmark { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "member_id") | ||
private Member member; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "recipe_id") | ||
private Recipe recipe; | ||
|
||
private Boolean bookmark; | ||
|
||
protected RecipeBookmark() { | ||
} | ||
|
||
public RecipeBookmark(final Member member, final Recipe recipe, final Boolean bookmark) { | ||
this.member = member; | ||
this.recipe = recipe; | ||
this.bookmark = bookmark; | ||
} | ||
|
||
public static RecipeBookmark create(final Member member, final Recipe recipe, final Boolean bookmark) { | ||
return new RecipeBookmark(member, recipe, bookmark); | ||
} | ||
|
||
public void updateBookmark(final Boolean bookmark) { | ||
this.bookmark = bookmark; | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public Member getMember() { | ||
return member; | ||
} | ||
|
||
public Recipe getRecipe() { | ||
return recipe; | ||
} | ||
|
||
public Boolean getBookmark() { | ||
return bookmark; | ||
} | ||
} |
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
13 changes: 13 additions & 0 deletions
13
src/main/java/com/funeat/member/persistence/RecipeBookmarkRepository.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,13 @@ | ||
package com.funeat.member.persistence; | ||
|
||
import com.funeat.member.domain.Member; | ||
import com.funeat.member.domain.bookmark.RecipeBookmark; | ||
import com.funeat.recipe.domain.Recipe; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.Optional; | ||
|
||
public interface RecipeBookmarkRepository extends JpaRepository<RecipeBookmark, Long> { | ||
|
||
Optional<RecipeBookmark> findByMemberAndRecipe(final Member member, final Recipe 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
9 changes: 9 additions & 0 deletions
9
src/main/java/com/funeat/recipe/dto/RecipeBookmarkRequest.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,9 @@ | ||
package com.funeat.recipe.dto; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
|
||
public record RecipeBookmarkRequest ( | ||
@NotNull(message = "북마크를 확인해주세요") | ||
Boolean bookmark | ||
) { | ||
} |
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.