Skip to content

Commit

Permalink
REFACTOR: 관리자 계정에서 아이템, 코인 지급 컨트롤러 통합
Browse files Browse the repository at this point in the history
  • Loading branch information
saewoo1 committed Oct 25, 2024
1 parent 43ba574 commit 800a8a5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.util.Map;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.ftclub.cabinet.admin.dto.AdminCoinAssignRequestDto;
import org.ftclub.cabinet.admin.dto.AdminItemHistoryPaginationDto;
import org.ftclub.cabinet.admin.item.service.AdminItemFacadeService;
import org.ftclub.cabinet.auth.domain.AuthGuard;
Expand Down Expand Up @@ -69,14 +68,7 @@ public ItemStoreResponseDto getAllItems() {
@AuthGuard(level = AuthLevel.ADMIN_ONLY)
public void assignItem(@RequestBody ItemAssignRequestDto itemAssignRequestDto) {
adminItemFacadeService.assignItem(itemAssignRequestDto.getUserIds(),
itemAssignRequestDto.getItemSku());
}

@PostMapping("/assign/coin")
@AuthGuard(level = AuthLevel.ADMIN_ONLY)
public void assignCoin(@RequestBody AdminCoinAssignRequestDto coinAssignRequestDto) {
adminItemFacadeService.assignCoin(coinAssignRequestDto.getUserIds(),
coinAssignRequestDto.getItemSku(), coinAssignRequestDto.getAmount());
itemAssignRequestDto.getItemSku(), itemAssignRequestDto.getAmount());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,7 @@ public void createItem(Integer Price, Sku sku, ItemType type) {
}

@Transactional
public void assignItem(List<Long> userIds, Sku sku) {
Item item = itemQueryService.getBySku(sku);
Long price = item.getPrice();
LocalDateTime now = null;
if (price > 0) {
now = LocalDateTime.now();
userCommandService.addBulkCoin(userIds, price);
}
itemHistoryCommandService.createItemHistories(userIds, item.getId(), now, price);
}

@Transactional
public void assignCoin(List<Long> userIds, Sku sku, Long amount) {
public void assignItem(List<Long> userIds, Sku sku, Long amount) {
Item item = itemQueryService.getBySku(sku);
LocalDateTime now = null;
Long coinAmount = item.getPrice();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ public class ItemAssignRequestDto {

private Sku itemSku;
private List<Long> userIds;
private Long amount;
}

0 comments on commit 800a8a5

Please sign in to comment.