Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] 중복 id #150 #151

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class CakeRepositoryCustomImpl implements CakeRepositoryCustom {
//가게 메인이미지 조회
@Override
public List<CakeMainImageDto> findMainImageByStoreIds(List<Long> storeIds) {
List<CakeMainImageDto> cakeMainImageDtos = queryFactory.select(Projections.constructor(CakeMainImageDto.class,
List<CakeMainImageDto> cakeMainImageDtos = queryFactory.selectDistinct(Projections.constructor(CakeMainImageDto.class,
cake.storeId,
cake.id,
cake.imageUrl))
Expand Down Expand Up @@ -163,7 +163,7 @@ public List<CakeInfoDto> findPopularCakesByStation(final Long userId,

/// 쿼리 실행
JPQLQuery<CakeInfoDto> query = queryFactory
.select(new QCakeInfoDto(
.selectDistinct(new QCakeInfoDto(
cake.id,
store.id,
store.name,
Expand Down Expand Up @@ -413,7 +413,7 @@ public List<CakeSelectedInfoDto> findCakesByStoreAndConditions(final Long storeI
QCakeTheme cakeTheme = QCakeTheme.cakeTheme;

///첫 번째 케이크: 들어온 cakeId 정보 가져오기
CakeSelectedInfoDto mainCake = queryFactory.select(new QCakeSelectedInfoDto(
CakeSelectedInfoDto mainCake = queryFactory.selectDistinct(new QCakeSelectedInfoDto(
cake.id,
isLikedByUser(cake.id, userId), /// 좋아요 여부 확인
cake.imageUrl
Expand All @@ -437,7 +437,7 @@ public List<CakeSelectedInfoDto> findCakesByStoreAndConditions(final Long storeI
}

/// 나머지 케이크 가져오기
List<CakeSelectedInfoDto> otherCakes = queryFactory.select(new QCakeSelectedInfoDto(
List<CakeSelectedInfoDto> otherCakes = queryFactory.selectDistinct(new QCakeSelectedInfoDto(
cake.id,
isLikedByUser(cake.id, userId), /// 좋아요 여부 확인
cake.imageUrl
Expand Down Expand Up @@ -493,7 +493,7 @@ public List<CakeInfoDto> findCakesByCategoryAndTheme(final DayCategory dayCatego
}

/// QueryDSL 쿼리 작성
List<CakeInfoDto> cakes = queryFactory.select(new QCakeInfoDto(
List<CakeInfoDto> cakes = queryFactory.selectDistinct(new QCakeInfoDto(
cake.id,
cake.storeId,
store.name,
Expand Down Expand Up @@ -826,7 +826,7 @@ public int countCakesByCategoryAndTheme(final DayCategory dayCategory, final The
}

/// 케이크 개수 조회 쿼리
Long count = queryFactory.select(cake.count())
Long count = queryFactory.selectDistinct(cake.count())
.from(cake)
.leftJoin(cakeTheme).on(cake.id.eq(cakeTheme.cakeId))
.where(whereCondition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class StoreRepositoryImpl implements StoreRepositoryCustom {
public List<StoreCoordinatesDto> findStoreCoordinatesByStation(final Station station) {
final List<StoreCoordinatesDto> dtos =
queryFactory
.select(new QStoreCoordinatesDto(
.selectDistinct(new QStoreCoordinatesDto(
store.id,
store.latitude,
store.longitude
Expand Down Expand Up @@ -81,7 +81,7 @@ public List<StoreInfoDto> findPopularitryStoreInfoByStation(final Long userId,

/// 쿼리 실행
JPQLQuery<StoreInfoDto> query =
queryFactory.select(new QStoreInfoDto(
queryFactory.selectDistinct(new QStoreInfoDto(
store.id,
store.name,
store.station,
Expand Down Expand Up @@ -171,7 +171,7 @@ public List<StoreInfoDto> findLatestStoreInfoByStation(final Long userId,

List<StoreInfoDto> storeInfoDtos =
queryFactory
.select(new QStoreInfoDto(
.selectDistinct(new QStoreInfoDto(
store.id,
store.name,
store.station,
Expand Down Expand Up @@ -218,7 +218,7 @@ public List<StoreInfoDto> findLatestStoresLikedByUser(final long userId,

/// 메인 쿼리
List<StoreInfoDto> storeInfoDtos = queryFactory
.select(new QStoreInfoDto(
.selectDistinct(new QStoreInfoDto(
store.id,
store.name,
store.station,
Expand Down Expand Up @@ -278,7 +278,7 @@ public List<StoreInfoDto> findPopularityStoresLikedByUser(

/// 기본 쿼리 생성
final JPQLQuery<StoreInfoDto> query = queryFactory
.select(new QStoreInfoDto(
.selectDistinct(new QStoreInfoDto(
store.id,
store.name,
store.station,
Expand Down Expand Up @@ -360,7 +360,7 @@ public List<StoreInfoDto> findPopularityStoresLikedByUser(
@Override
public List<StoreCoordinatesDto> findLikedStoreCoordinatesByUserId(final Long userId) {
final List<StoreCoordinatesDto> storeCoordinatesDtos = queryFactory
.select(new QStoreCoordinatesDto(
.selectDistinct(new QStoreCoordinatesDto(
store.id,
store.latitude,
store.longitude
Expand All @@ -381,7 +381,7 @@ public List<StoreCoordinatesDto> findLikedStoreCoordinatesByUserId(final Long us
public Optional<StoreBySelectedCakeDto> findStoreBySelectedCakeId(final long cakeId) {
QCake cake = QCake.cake;
QStore store = QStore.store;
return Optional.ofNullable(queryFactory.select(new QStoreBySelectedCakeDto(
return Optional.ofNullable(queryFactory.selectDistinct(new QStoreBySelectedCakeDto(
store.id,
store.name,
store.station
Expand All @@ -407,7 +407,7 @@ public Optional<StoreSelectedDto> findStoreInfoById(final long storeId, final Lo

/// 메인 케이크 이미지 URL 가져오기
String fetchedImageUrl = queryFactory
.select(cake.imageUrl)
.selectDistinct(cake.imageUrl)
.from(cake)
.where(cake.storeId.eq(storeId).and(cake.isMainImage.isTrue()))
.orderBy(cake.id.desc())
Expand All @@ -418,7 +418,7 @@ public Optional<StoreSelectedDto> findStoreInfoById(final long storeId, final Lo
: Expressions.nullExpression(String.class);

/// 메인 쿼리
return Optional.ofNullable(queryFactory.select(new QStoreSelectedDto(
return Optional.ofNullable(queryFactory.selectDistinct(new QStoreSelectedDto(
store.id,
store.name,
store.address,
Expand Down