package com.red.circle.wallet.inner.service.freight.impl;

import com.red.circle.wallet.infra.database.rds.service.freight.FreightSellerService;
import com.red.circle.wallet.inner.convertor.FreightSellerInnerConvertor;
import com.red.circle.wallet.inner.model.dto.FreightSellerDTO;
import com.red.circle.wallet.inner.service.freight.FreightSellerClientService;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * 经销商卖家信息.
 *
 * @author pengliang on 2023/12/26
 */
@Service
@RequiredArgsConstructor
public class FreightSellerClientServiceImpl implements FreightSellerClientService {

  private final FreightSellerService freightSellerService;
  private final FreightSellerInnerConvertor freightSellerInnerConvertor;

  @Override
  public boolean existsSeller(Long userId) {
    return freightSellerService.existsSeller(userId);
  }

  @Override
  public Long countByFreightId(Long freightId, String sysOrigin) {
    return freightSellerService.countByFreightId(freightId, sysOrigin);
  }

  @Override
  public List<FreightSellerDTO> listFreightSeller(String sysOrigin, Long freightId) {
    return freightSellerInnerConvertor.toListFreightSellerDTO(
        freightSellerService.listFreightSeller(sysOrigin, freightId)
    );
  }

  @Override
  public FreightSellerDTO getFreightSellerByUserId(Long userId) {
    return freightSellerInnerConvertor.toFreightSellerDTO(
        freightSellerService.getFreightSellerByUserId(userId)
    );
  }

  @Override
  public void updateSelectiveById(FreightSellerDTO dto) {
    freightSellerService.updateSelectiveById(
        freightSellerInnerConvertor.toFreightSeller(dto));
  }

  @Override
  public void save(FreightSellerDTO dto) {
    freightSellerService.save(
        freightSellerInnerConvertor.toFreightSeller(dto));
  }

  @Override
  public FreightSellerDTO getById(Long id) {
    return freightSellerInnerConvertor.toFreightSellerDTO(
        freightSellerService.getById(id)
    );
  }
}
