-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
회원이 착용한 아이템을 조회한다.
- Loading branch information
Showing
5 changed files
with
61 additions
and
0 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
31 changes: 31 additions & 0 deletions
31
api/src/main/java/com/dnd/sbooky/api/item/FindEquippedItemUsecase.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,31 @@ | ||
package com.dnd.sbooky.api.item; | ||
|
||
import com.dnd.sbooky.api.item.response.FindItemsResponse; | ||
import com.dnd.sbooky.core.item.ItemType; | ||
import com.dnd.sbooky.core.item.MemberItemRepository; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class FindEquippedItemUsecase { | ||
|
||
private final MemberItemRepository memberItemRepository; | ||
|
||
@Transactional(readOnly = true) | ||
public FindItemsResponse findEquippedItems(Long memberId) { | ||
Map<ItemType, List<Long>> equippedItems = | ||
memberItemRepository.findEquippedItemsByMemberId(memberId).stream() | ||
.collect( | ||
Collectors.groupingBy( | ||
findItemDTO -> findItemDTO.itemType(), | ||
Collectors.mapping( | ||
findItemDTO -> findItemDTO.itemId(), | ||
Collectors.toList()))); | ||
return FindItemsResponse.from(equippedItems); | ||
} | ||
} |
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