package com.trade.service.trade.salescontract.service.impl;

import com.trade.common.utils.bean.BeanCopyUtils;
import com.trade.service.trade.salescontract.domain.ContractTerms;
import com.trade.service.trade.salescontract.domain.SalesCommodity;
import com.trade.service.trade.salescontract.domain.SalesContract;
import com.trade.service.trade.salescontract.dto.ContractTermsDto;
import com.trade.service.trade.salescontract.dto.SalesCommodityDto;
import com.trade.service.trade.salescontract.dto.SalesContractDto;
import com.trade.service.trade.salescontract.vo.SalesContractVo;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @description: 销售相关数据转换
 * @Author: wanglang
 * @Date: 2024/9/3 14:17
 * @Version: 1.0
 */
@Component
public class SalesDataConverter {

    public SalesCommodity convertCommodityDo(SalesCommodityDto salesCommodityDto) {
        return BeanCopyUtils.copy(salesCommodityDto, SalesCommodity.class);
    }

    public List<SalesCommodity> convertCommodityDo(List<SalesCommodityDto> salesCommodityDtos) {
        List<SalesCommodity> salesCommodities = new ArrayList<>();
        for (SalesCommodityDto salesCommodityDto : salesCommodityDtos) {
            salesCommodities.add(convertCommodityDo(salesCommodityDto));
        }
        return salesCommodities;
    }

    public SalesCommodityDto convertCommodityDto(SalesCommodity salesCommodity) {
        return BeanCopyUtils.copy(salesCommodity, SalesCommodityDto.class);
    }

    public List<SalesCommodityDto> convertCommodityDto(List<SalesCommodity> salesCommodities) {
        List<SalesCommodityDto> salesCommodityDtos = new ArrayList<>();
        for (SalesCommodity salesCommodity : salesCommodities) {
            salesCommodityDtos.add(convertCommodityDto(salesCommodity));
        }
        return salesCommodityDtos;
    }

    public SalesContract convertSalesContractDo(SalesContractDto salesContractDto) {
        return BeanCopyUtils.copy(salesContractDto, SalesContract.class);
    }

    public SalesContractVo convertSalesContractVO(SalesContract salesContract) {
        return BeanCopyUtils.copy(salesContract, SalesContractVo.class);
    }

    public SalesContractDto convertSalesContractDto(SalesContract salesContract) {
        return BeanCopyUtils.copy(salesContract, SalesContractDto.class);
    }

    public ContractTerms convertContractTermsDo(ContractTermsDto contractTermsDto) {
        return BeanCopyUtils.copy(contractTermsDto, ContractTerms.class);
    }

    public ContractTermsDto convertContractTermsDto(ContractTerms contractTerms) {
        return BeanCopyUtils.copy(contractTerms, ContractTermsDto.class);
    }
}
