fix(store-service): store Id 잘못된 것 수정
- store Id 잘못된 것 수정
This commit is contained in:
@@ -17,12 +17,12 @@ public class CategoryRepositoryCustom {
|
||||
|
||||
private final JPAQueryFactory jpaQueryFactory;
|
||||
|
||||
public List<Category> getCategoryList(Long storeId){
|
||||
public List<Category> getCategoryList(Long userId){
|
||||
|
||||
List<Category> categoryList = jpaQueryFactory.selectFrom(QCategory.category)
|
||||
.leftJoin(QCategory.category.items, QItem.item).fetchJoin()
|
||||
.join(QCategory.category.store, QStore.store).fetchJoin()
|
||||
.where(QCategory.category.store.id.eq(storeId))
|
||||
.where(QCategory.category.store.userId.eq(userId))
|
||||
.orderBy(QCategory.category.order.asc())
|
||||
.distinct()
|
||||
.fetch();
|
||||
|
||||
@@ -27,9 +27,9 @@ public class CategoryService {
|
||||
private final CategoryRepositoryCustom categoryRepositoryCustom;
|
||||
private final StoreRepository storeRepository;
|
||||
|
||||
public List<CategoryDto> getCategoryList(Long storeId){
|
||||
public List<CategoryDto> getCategoryList(Long userId){
|
||||
|
||||
return categoryRepositoryCustom.getCategoryList(storeId)
|
||||
return categoryRepositoryCustom.getCategoryList(userId)
|
||||
.stream()
|
||||
.map(CategoryDto::new)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -23,8 +23,7 @@ public class CategoryOwnerApiController {
|
||||
|
||||
@GetMapping("/category")
|
||||
public ResponseEntity getCategoryList(@RequestHeader(value = "user-id") String userId ){
|
||||
Long storeId = Long.parseLong(userId);
|
||||
List<CategoryDto> categoryList = categoryService.getCategoryList(storeId);
|
||||
List<CategoryDto> categoryList = categoryService.getCategoryList(Long.parseLong(userId));
|
||||
|
||||
List<CategoryResponse> categoryResponseList = categoryList.stream()
|
||||
.map(CategoryResponse::new)
|
||||
|
||||
@@ -32,14 +32,14 @@ public class ItemRepositoryCustom {
|
||||
return Optional.ofNullable(item);
|
||||
}
|
||||
|
||||
public Page<Item> findItem(Long storeId,String word, Pageable pageable){
|
||||
public Page<Item> findItem(Long userId,String word, Pageable pageable){
|
||||
|
||||
//count 가져오기
|
||||
Long count = queryFactory.select(QItem.item.count())
|
||||
.from(QItem.item)
|
||||
.join(QItem.item.category)
|
||||
.leftJoin(QItem.item.store)
|
||||
.on(QItem.item.store.id.eq(storeId))
|
||||
.on(QItem.item.store.userId.eq(userId))
|
||||
.where(
|
||||
QItem.item.name.contains(word)
|
||||
.or(QItem.item.category.name.contains(word))
|
||||
@@ -52,7 +52,7 @@ public class ItemRepositoryCustom {
|
||||
List<Item> itemList = queryFactory.selectFrom(QItem.item)
|
||||
.join(QItem.item.category).fetchJoin()
|
||||
.leftJoin(QItem.item.store)
|
||||
.on(QItem.item.store.id.eq(storeId))
|
||||
.on(QItem.item.store.id.eq(userId))
|
||||
.where(
|
||||
QItem.item.name.contains(word)
|
||||
.or(QItem.item.category.name.contains(word))
|
||||
|
||||
@@ -14,9 +14,9 @@ public interface ItemService {
|
||||
|
||||
ItemDto findFullItemByItemId(Long itemId);
|
||||
|
||||
Page<ItemDto> findItemList(Long storeId,String word, Pageable pageable);
|
||||
Page<ItemDto> findItemList(Long userId,String word, Pageable pageable);
|
||||
|
||||
void putItem(Long itemId, String itemName, Long itemPrice, Long categoryId, List<ItemOptionDto> itemOptionDtos);
|
||||
|
||||
void createItem( Long storeId, String itemName, Long itemPrice, Long categoryId, List<ItemOptionDto> itemOptionDtos);
|
||||
void createItem( Long userId, String itemName, Long itemPrice, Long categoryId, List<ItemOptionDto> itemOptionDtos);
|
||||
}
|
||||
|
||||
@@ -57,9 +57,9 @@ public class ItemServiceImpl implements ItemService {
|
||||
|
||||
|
||||
@Override
|
||||
public Page<ItemDto> findItemList( Long storeId,String word, Pageable pageable) {
|
||||
public Page<ItemDto> findItemList( Long userId,String word, Pageable pageable) {
|
||||
|
||||
Page<Item> itemList = itemRepositoryCustom.findItem(storeId,word,pageable);
|
||||
Page<Item> itemList = itemRepositoryCustom.findItem(userId,word,pageable);
|
||||
return PageableExecutionUtils.getPage(itemList.stream()
|
||||
.map(ItemDto::createWithCategoryItemDto)
|
||||
.collect(Collectors.toList()),pageable,itemList::getTotalElements);
|
||||
@@ -91,14 +91,14 @@ public class ItemServiceImpl implements ItemService {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void createItem(Long storeId,
|
||||
public void createItem(Long userId,
|
||||
String itemName,
|
||||
Long itemPrice,
|
||||
Long categoryId,
|
||||
List<ItemOptionDto> itemOptionDtos) {
|
||||
|
||||
//find Store
|
||||
Store store = storeRepository.findById(storeId)
|
||||
Store store = storeRepository.findByUserId(userId)
|
||||
.orElseThrow(() -> new NotExistItemException("존재하지 않는 매장 입니다."));
|
||||
|
||||
//find Category
|
||||
|
||||
@@ -32,10 +32,9 @@ public class ItemOwnerApiController {
|
||||
@PageableDefault Pageable pageable,
|
||||
@RequestHeader(value = "user-id") String userId ){
|
||||
|
||||
Long storeId = Long.parseLong(userId);
|
||||
|
||||
Page<ItemDto> itemDtoList =
|
||||
itemService.findItemList(storeId,
|
||||
itemService.findItemList(Long.parseLong(userId),
|
||||
word.orElse(""),
|
||||
pageable);
|
||||
List<GetItemListResponse.Item> itemList = itemDtoList.stream()
|
||||
@@ -200,7 +199,6 @@ public class ItemOwnerApiController {
|
||||
public ResponseEntity createItem( @RequestBody @Valid ItemRequest itemRequest,
|
||||
@RequestHeader(value = "user-id") String userId ){
|
||||
|
||||
Long storeId = Long.parseLong(userId);
|
||||
|
||||
List<ItemOptionDto> itemOption = itemRequest.getRequiredOption().stream()
|
||||
.map(ItemRequest.ItemOptionRequest::createItemOptionDto)
|
||||
@@ -209,7 +207,7 @@ public class ItemOwnerApiController {
|
||||
.map(ItemRequest.ItemOptionRequest::createItemOptionDto)
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
itemService.createItem(storeId
|
||||
itemService.createItem(Long.parseLong(userId)
|
||||
, itemRequest.getItemName()
|
||||
, itemRequest.getItemPrice()
|
||||
, itemRequest.getCategoryId()
|
||||
|
||||
@@ -4,6 +4,10 @@ import com.justpickup.storeservice.domain.store.entity.Store;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface StoreRepository extends JpaRepository<Store,Long> {
|
||||
|
||||
Optional<Store> findByUserId(Long userId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user