-
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.
v2.0.2
- Loading branch information
Showing
58 changed files
with
1,611 additions
and
268 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
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; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/com/funeat/member/dto/MemberBookmarkRecipeDto.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,41 @@ | ||
package com.funeat.member.dto; | ||
|
||
import com.funeat.product.domain.Product; | ||
import com.funeat.recipe.domain.Recipe; | ||
import com.funeat.recipe.domain.RecipeImage; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
public record MemberBookmarkRecipeDto( | ||
Long id, | ||
String title, | ||
String image, | ||
String content, | ||
Boolean favorite, | ||
MemberResponse author, | ||
MemberBookmarkRecipeProductsDto products, | ||
LocalDateTime createdAt | ||
) { | ||
|
||
private MemberBookmarkRecipeDto(final Long id, final String title, final String content, final Boolean favorite, | ||
final MemberResponse author, final MemberBookmarkRecipeProductsDto products, | ||
final LocalDateTime createdAt) { | ||
this(id, title, null, content, favorite, author, products, createdAt); | ||
} | ||
|
||
public static MemberBookmarkRecipeDto toDto(final Recipe recipe, final List<RecipeImage> findRecipeImages, | ||
final List<Product> recipeInProducts, final Boolean isFavorite) { | ||
final MemberResponse author = MemberResponse.toResponse(recipe.getMember()); | ||
final MemberBookmarkRecipeProductsDto products = MemberBookmarkRecipeProductsDto.toDto(recipeInProducts); | ||
|
||
if (findRecipeImages.isEmpty()) { | ||
return new MemberBookmarkRecipeDto(recipe.getId(), recipe.getTitle(), recipe.getContent(), isFavorite, | ||
author, products, recipe.getCreatedAt() | ||
); | ||
} | ||
return new MemberBookmarkRecipeDto(recipe.getId(), recipe.getTitle(), findRecipeImages.get(0).getImage(), | ||
recipe.getContent(), isFavorite, author, products, recipe.getCreatedAt() | ||
); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/funeat/member/dto/MemberBookmarkRecipeProductDto.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,17 @@ | ||
package com.funeat.member.dto; | ||
|
||
import com.funeat.product.domain.Product; | ||
|
||
public record MemberBookmarkRecipeProductDto( | ||
Long id, | ||
String name, | ||
Long price, | ||
String image, | ||
Double averageRating | ||
) { | ||
|
||
public static MemberBookmarkRecipeProductDto toDto(final Product product) { | ||
return new MemberBookmarkRecipeProductDto(product.getId(), product.getName(), product.getPrice(), | ||
product.getImage(), product.getAverageRating()); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/funeat/member/dto/MemberBookmarkRecipeProductsDto.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.funeat.member.dto; | ||
|
||
import com.funeat.product.domain.Product; | ||
|
||
import java.util.List; | ||
|
||
public record MemberBookmarkRecipeProductsDto( | ||
List<MemberBookmarkRecipeProductDto> products | ||
) { | ||
|
||
public static MemberBookmarkRecipeProductsDto toDto(final List<Product> recipeInProducts) { | ||
final List<MemberBookmarkRecipeProductDto> products = recipeInProducts.stream() | ||
.map(MemberBookmarkRecipeProductDto::toDto) | ||
.toList(); | ||
|
||
return new MemberBookmarkRecipeProductsDto(products); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/funeat/member/dto/MemberBookmarkRecipesResponse.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 com.funeat.member.dto; | ||
|
||
import com.funeat.common.dto.PageDto; | ||
|
||
import java.util.List; | ||
|
||
public record MemberBookmarkRecipesResponse( | ||
PageDto page, | ||
List<MemberBookmarkRecipeDto> recipes | ||
) { | ||
|
||
public static MemberBookmarkRecipesResponse toResponse(final PageDto page, | ||
final List<MemberBookmarkRecipeDto> recipes) { | ||
return new MemberBookmarkRecipesResponse(page, recipes); | ||
} | ||
} |
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.