Skip to content
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 @@ -11,15 +11,17 @@ public class StoreRankingDto {
private final Integer totalSales;
private final Long currentRank;
private final Integer delta;
private final String profileUrl;

public StoreRankingDto(Long storeId, String storeName, Long departmentId, String departmentName, Integer totalSales,
Long currentRank, Integer delta) {
Long currentRank, Integer delta, String profileUrl) {
this.storeId = storeId;
this.storeName = storeName;
this.departmentId = departmentId;
this.departmentName = departmentName;
this.totalSales = totalSales;
this.currentRank = currentRank;
this.delta = delta;
this.profileUrl = profileUrl;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public List<StoreRankingDto> getStatisticsRankings(MemberDetails memberDetails)
// 1) Redis에서 Top4+내주점: storeId, totalSales, currentRank, delta
List<RankingEntry> entries = rankingQuery.getRankings(userStoreId, 5);

// 2) DB에서 store 정보 가져오기
// 2) redis 에서 storeId 정보 가져오기
List<Long> storeIds = entries.stream()
.map(RankingEntry::getStoreId)
.toList();
Expand All @@ -67,7 +67,8 @@ public List<StoreRankingDto> getStatisticsRankings(MemberDetails memberDetails)
info.getDepartmentName(),
e.getTotalSales(),
e.getCurrentRank(),
e.getDelta()
e.getDelta(),
info.getProfileUrl()
);
})
.collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ public class StoreInfo {
private final String storeName;
private final Long departmentId;
private final String departmentName;
private final String profileUrl;

public StoreInfo(Long storeId, String storeName, Long departmentId, String departmentName) {
public StoreInfo(Long storeId, String storeName, Long departmentId, String departmentName, String profileUrl) {
this.storeId = storeId;
this.storeName = storeName;
this.departmentId = departmentId;
this.departmentName = departmentName;
this.profileUrl = profileUrl;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@
import com.nowait.domainadminrdb.statistic.dto.TopSalesStoresDetail;
import com.nowait.domaincorerdb.department.entity.QDepartment;
import com.nowait.domaincorerdb.order.entity.QUserOrder;
import com.nowait.domaincorerdb.store.entity.ImageType;
import com.nowait.domaincorerdb.store.entity.QStore;
import com.nowait.domaincorerdb.store.entity.QStoreImage;
import com.querydsl.core.Tuple;
import com.querydsl.jpa.impl.JPAQueryFactory;

import lombok.extern.slf4j.Slf4j;

@Repository
@Slf4j
public class StatisticCustomRepositoryImpl implements StatisticCustomRepository {

private final JPAQueryFactory queryFactory;
Expand All @@ -35,8 +40,9 @@ public StatisticCustomRepositoryImpl(JPAQueryFactory queryFactory) {
}

private static final QUserOrder u = QUserOrder.userOrder;
private static final QStore s = store;
private static final QStore s = QStore.store;
private static final QDepartment d = QDepartment.department;
private static final QStoreImage si = QStoreImage.storeImage;

@Override
public OrderSalesSumDetail findSalesSumByStoreId(Long storeId) {
Expand Down Expand Up @@ -262,8 +268,6 @@ private Map<Long, String> getDepartmentNames(Set<Long> departmentIds) {
return departmentNameMap;
}



// redis 사용하는 부분
@Override
public List<StoreSales> findTotalSales() {
Expand Down Expand Up @@ -294,18 +298,20 @@ public List<StoreSales> findTotalSales() {
@Override
public List<StoreInfo> findStoreInfoByIds(List<Long> storeIds) {
List<Tuple> tuples = queryFactory
.select(s.storeId, s.name, store.departmentId, d.name)
.from(store)
.join(d).on(store.departmentId.eq(d.id))
.where(store.storeId.in(storeIds))
.select(s.storeId, s.name, s.departmentId, d.name, si.imageUrl.coalesce(""))
.from(s)
.join(d).on(s.departmentId.eq(d.id))
.leftJoin(si).on(s.storeId.eq(si.store.storeId).and(si.imageType.eq(ImageType.PROFILE)))
.where(s.storeId.in(storeIds))
.fetch();

return tuples.stream()
.map(t -> new StoreInfo(
t.get(store.storeId),
t.get(store.name),
t.get(store.departmentId),
t.get(d.name)
t.get(s.storeId),
t.get(s.name),
t.get(s.departmentId),
t.get(d.name),
t.get(si.imageUrl.coalesce(""))
))
.collect(Collectors.toList());
}
Expand Down