Skip to content

Commit

Permalink
add : registerAllItems 메서드 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
oownahcohc committed Nov 18, 2023
1 parent 1752465 commit 96f88ec
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

import backend.wal.admin.application.port.out.RegisterItemManagePort;
import backend.wal.wal.censorWal.application.port.in.RetrieveCensorItemUseCase;
import backend.wal.wal.censorWal.application.port.in.dto.ApprovedCensorItemResponseDto;
import backend.wal.wal.censorWal.application.port.in.dto.ItemToRegisterDto;
import backend.wal.wal.censorWal.application.port.in.dto.RetrieveCensorItemRequestDto;
import backend.wal.wal.common.domain.WalCategoryType;
import backend.wal.wal.item.application.port.in.CountItemUseCase;
import backend.wal.wal.item.application.port.in.RegisterItemUseCase;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

@Component
public class RegisterItemManageAdapter implements RegisterItemManagePort {
Expand All @@ -28,11 +30,22 @@ public RegisterItemManageAdapter(final RetrieveCensorItemUseCase retrieveCensorI

@Override
public void registerItemsBy(WalCategoryType categoryType) {
List<ApprovedCensorItemResponseDto> approvedCensorItemInfo = retrieveCensorItemUseCase
List<ItemToRegisterDto> approvedCensorItemInfo = retrieveCensorItemUseCase
.retrieveApprovedCensorItemInfo(new RetrieveCensorItemRequestDto(categoryType));
Long countOfCategoryType = countItemUseCase.countAllCorrespondItemsByCategoryType(categoryType);
RegisterItemRequestDtoConvertor registerItemRequestDtoConvertor =
new RegisterItemRequestDtoConvertor(approvedCensorItemInfo, countOfCategoryType);
registerItemUseCase.registerNewItems(registerItemRequestDtoConvertor.convert(), categoryType);
}

@Override
public void registerAllItems(Set<String> contents, WalCategoryType categoryType) {
List<ItemToRegisterDto> itemToRegisterInfo = contents.stream()
.map(content -> new ItemToRegisterDto(categoryType, content, ""))
.collect(Collectors.toList());
Long countOfCategoryType = countItemUseCase.countAllCorrespondItemsByCategoryType(categoryType);
RegisterItemRequestDtoConvertor registerItemRequestDtoConvertor =
new RegisterItemRequestDtoConvertor(itemToRegisterInfo, countOfCategoryType);
registerItemUseCase.registerNewItems(registerItemRequestDtoConvertor.convert(), categoryType);
}
}

0 comments on commit 96f88ec

Please sign in to comment.