Skip to content

Commit

Permalink
hotfix: item inventory 쿼리 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Shin-Jae-Yoon committed Nov 28, 2023
1 parent ecd65d2 commit eeda751
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.util.Optional;
import java.util.Set;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import com.moabam.api.domain.coupon.Coupon;
Expand Down Expand Up @@ -33,7 +32,7 @@ public class CouponManageService {
private final CouponManageRepository couponManageRepository;
private final CouponWalletRepository couponWalletRepository;

@Scheduled(fixedDelay = 1000)
// @Scheduled(fixedDelay = 1000)
public void issue() {
LocalDate now = clockHolder.date();
Optional<Coupon> isCoupon = couponRepository.findByStartAt(now);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.moabam.api.domain.item.repository;

import static com.moabam.api.domain.item.QInventory.*;
import static com.moabam.api.domain.item.QItem.*;
import static com.moabam.api.domain.item.QInventory.inventory;
import static com.moabam.api.domain.item.QItem.item;

import java.util.List;

Expand All @@ -10,7 +10,6 @@
import com.moabam.api.domain.item.Item;
import com.moabam.api.domain.item.ItemType;
import com.moabam.global.common.util.DynamicQuery;
import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.jpa.impl.JPAQueryFactory;

import lombok.RequiredArgsConstructor;
Expand All @@ -24,20 +23,17 @@ public class ItemSearchRepository {
public List<Item> findNotPurchasedItems(Long memberId, ItemType type) {
return jpaQueryFactory.selectFrom(item)
.leftJoin(inventory)
.on(inventory.item.id.eq(item.id))
.on(inventory.item.id.eq(item.id)
.and(inventory.memberId.eq(memberId)))
.where(
DynamicQuery.generateEq(type, item.type::eq),
DynamicQuery.generateEq(memberId, this::filterByMemberId))
inventory.memberId.isNull()
)
.orderBy(
item.unlockLevel.asc(),
item.bugPrice.asc(),
item.goldenBugPrice.asc(),
item.name.asc())
.fetch();
}

private BooleanExpression filterByMemberId(Long memberId) {
return inventory.memberId.isNull()
.or(inventory.memberId.ne(memberId));
}
}
8 changes: 4 additions & 4 deletions src/main/resources/sql/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,29 @@ values ('MORNING', 'SKIN', '오목눈이', 'https://image.moabam.com/moabam/skin
'https://image.moabam.com/moabam/skins/omok/default/eyes-closed.png', 1, current_time());

insert into item (type, category, name, awake_image, sleep_image, unlock_level, created_at)
values ('MORNING', 'SKIN', '부엉이', 'https://image.moabam.com/moabam/skins/owl/default/eyes-opened.png',
values ('NIGHT', 'SKIN', '부엉이', 'https://image.moabam.com/moabam/skins/owl/default/eyes-opened.png',
'https://image.moabam.com/moabam/skins/owl/default/eyes-closed.png', 1, current_time());

insert into item (type, category, name, awake_image, sleep_image, bug_price, golden_bug_price, unlock_level, created_at)
values ('MORNING', 'SKIN', '안경 오목눈이', 'https://image.moabam.com/moabam/skins/omok/glasses/eyes-opened.png',
'https://image.moabam.com/moabam/skins/omok/glasses/eyes-closed', 10, 5, 5, current_time());

insert into item (type, category, name, awake_image, sleep_image, bug_price, golden_bug_price, unlock_level, created_at)
values ('MORNING', 'SKIN', '안경 부엉이', 'https://image.moabam.com/moabam/skins/owl/glasses/eyes-opened.png',
values ('NIGHT', 'SKIN', '안경 부엉이', 'https://image.moabam.com/moabam/skins/owl/glasses/eyes-opened.png',
'https://image.moabam.com/moabam/skins/owl/glasses/eyes-closed', 10, 5, 5, current_time());

insert into item (type, category, name, awake_image, sleep_image, bug_price, golden_bug_price, unlock_level, created_at)
values ('MORNING', 'SKIN', '목도리 오목눈이', 'https://image.moabam.com/moabam/skins/omok/scarf/eyes-opened.png',
'https://image.moabam.com/moabam/skins/omok/scarf/eyes-closed', 20, 10, 10, current_time());

insert into item (type, category, name, awake_image, sleep_image, bug_price, golden_bug_price, unlock_level, created_at)
values ('MORNING', 'SKIN', '목도리 부엉이', 'https://image.moabam.com/moabam/skins/owl/scarf/eyes-opened.png',
values ('NIGHT', 'SKIN', '목도리 부엉이', 'https://image.moabam.com/moabam/skins/owl/scarf/eyes-opened.png',
'https://image.moabam.com/moabam/skins/owl/scarf/eyes-closed', 20, 10, 10, current_time());

insert into item (type, category, name, awake_image, sleep_image, bug_price, golden_bug_price, unlock_level, created_at)
values ('MORNING', 'SKIN', '산타 오목눈이', 'https://image.moabam.com/moabam/skins/omok/scarf/eyes-opened.png',
'https://image.moabam.com/moabam/skins/omok/scarf/eyes-closed', 30, 15, 15, current_time());

insert into item (type, category, name, awake_image, sleep_image, bug_price, golden_bug_price, unlock_level, created_at)
values ('MORNING', 'SKIN', '산타 부엉이', 'https://image.moabam.com/moabam/skins/owl/santa/eyes-opened.png',
values ('NIGHT', 'SKIN', '산타 부엉이', 'https://image.moabam.com/moabam/skins/owl/santa/eyes-opened.png',
'https://image.moabam.com/moabam/skins/owl/santa/eyes-closed', 30, 15, 15, current_time());

0 comments on commit eeda751

Please sign in to comment.