-
Notifications
You must be signed in to change notification settings - Fork 2
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 #98 from cvs-go/feature#97
상품 좋아요 태그 조회 추가
- Loading branch information
Showing
11 changed files
with
310 additions
and
41 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
19 changes: 19 additions & 0 deletions
19
src/main/java/com/cvsgo/dto/product/ReadProductLikeTagResponseDto.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,19 @@ | ||
package com.cvsgo.dto.product; | ||
|
||
import com.querydsl.core.annotations.QueryProjection; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class ReadProductLikeTagResponseDto { | ||
|
||
private final Long id; | ||
private final String name; | ||
private final Long tagCount; | ||
|
||
@QueryProjection | ||
public ReadProductLikeTagResponseDto(Long id, String name, Long tagCount) { | ||
this.id = id; | ||
this.name = name; | ||
this.tagCount = tagCount; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/cvsgo/repository/TagCustomRepository.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,11 @@ | ||
package com.cvsgo.repository; | ||
|
||
import com.cvsgo.dto.product.ReadProductLikeTagResponseDto; | ||
import com.cvsgo.entity.Product; | ||
import java.util.List; | ||
|
||
public interface TagCustomRepository { | ||
|
||
List<ReadProductLikeTagResponseDto> findTop3ByProduct(Product product); | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/com/cvsgo/repository/TagCustomRepositoryImpl.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,37 @@ | ||
package com.cvsgo.repository; | ||
|
||
import static com.cvsgo.entity.QProductLike.productLike; | ||
import static com.cvsgo.entity.QTag.tag; | ||
import static com.cvsgo.entity.QUserTag.userTag; | ||
|
||
import com.cvsgo.dto.product.QReadProductLikeTagResponseDto; | ||
import com.cvsgo.dto.product.ReadProductLikeTagResponseDto; | ||
import com.cvsgo.entity.Product; | ||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@RequiredArgsConstructor | ||
@Repository | ||
public class TagCustomRepositoryImpl implements TagCustomRepository { | ||
|
||
private final JPAQueryFactory queryFactory; | ||
|
||
public List<ReadProductLikeTagResponseDto> findTop3ByProduct(Product product) { | ||
return queryFactory.select(new QReadProductLikeTagResponseDto( | ||
userTag.tag.id, | ||
userTag.tag.name, | ||
userTag.tag.count() | ||
)) | ||
.from(userTag) | ||
.join(userTag.tag, tag) | ||
.join(productLike).on(productLike.user.eq(userTag.user)) | ||
.where(productLike.product.eq(product)) | ||
.groupBy(userTag.tag.id, userTag.tag.name) | ||
.orderBy(userTag.tag.count().desc()) | ||
.limit(3) | ||
.fetch(); | ||
} | ||
|
||
} |
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
Oops, something went wrong.