Skip to content

Commit

Permalink
[refac] change response type and query
Browse files Browse the repository at this point in the history
  • Loading branch information
PicturePark1101 committed Jul 15, 2024
1 parent e826e26 commit 68b64bd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@
import java.util.List;
import org.hankki.hankkiserver.api.favorite.service.response.util.FavoriteResponseUtil;
import org.hankki.hankkiserver.domain.favorite.model.Favorite;
import org.hankki.hankkiserver.domain.favorite.model.FavoriteImage;

public record FavoriteWithStatusResponse(
Long id,
String title,
String imageUrl,
FavoriteImage imageType,
List<String> details,
boolean isReported
boolean isAdded
) {
public static FavoriteWithStatusResponse of(Favorite favorite, boolean isReported) {
return new FavoriteWithStatusResponse(
favorite.getId(),
favorite.getName(),
favorite.getImageUrl(),
favorite.getImageType(),
FavoriteResponseUtil.getDetail(favorite.getDetail()),
isReported);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ public interface FavoriteRepository extends JpaRepository<Favorite, Long> {

List<Favorite> findByUserIdOrderByCreatedAtDesc(Long userId);

@Query("select f from Favorite f join fetch f.user where f.id = :favoriteId")
@Query("select f from Favorite f where f.id = :favoriteId")
Optional<Favorite> findByIdWithUser(@Param("favoriteId") Long favoriteId);
}

0 comments on commit 68b64bd

Please sign in to comment.