package com.red.circle.other.app.inner.service.material.props.impl;

import com.red.circle.other.app.inner.convertor.material.FragmentsBackpackInnerConvertor;
import com.red.circle.other.app.inner.service.material.props.FragmentsBackpackClientService;
import com.red.circle.other.infra.database.rds.service.props.FragmentsBackpackService;
import com.red.circle.other.inner.model.dto.material.FragmentsBackpackDTO;
import java.util.List;
import java.util.Set;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * 碎片背包 实现.
 *
 * @author pengliang on 2023/6/4
 */
@Service
@RequiredArgsConstructor
public class FragmentsBackpackClientServiceImpl implements FragmentsBackpackClientService {

  private final FragmentsBackpackService fragmentsBackpackService;
  private final FragmentsBackpackInnerConvertor fragmentsBackpackInnerConvertor;

  @Override
  public FragmentsBackpackDTO incrFragments(Long userId, Long fragmentsId, Integer quantity,
      String type) {
    return fragmentsBackpackInnerConvertor.toFragmentsBackpackDTO(
        fragmentsBackpackService.incrFragments(userId, fragmentsId, quantity, type));
  }

  @Override
  public boolean decrFragments(Long userId, Set<Long> fragmentsIds, Integer quantity) {
    return fragmentsBackpackService.decrFragments(userId, fragmentsIds, quantity);
  }

  @Override
  public List<FragmentsBackpackDTO> listByUserIdByFragmentsIds(Long userId,
      Set<Long> fragmentsIds) {
    return fragmentsBackpackInnerConvertor.toListFragmentsBackpackDTO(
        fragmentsBackpackService.listByUserIdByFragmentsIds(userId, fragmentsIds)
    );
  }
}
