package cn.freemud.demo.adapter.manager;

import cn.freemud.demo.entities.bo.goods.ProductBO;
import cn.freemud.demo.entities.bo.goods.ValiadShopProductBO;
import cn.freemud.demo.entities.bo.product.ProductStockBO;
import cn.freemud.entities.dto.GetProductStockResponseDto;
import cn.freemud.entities.dto.product.ValiadShopProductResponse;
import cn.freemud.entities.dto.product.info.ProductBean;
import cn.freemud.utils.BeanUtil;
import ma.glasnost.orika.MapperFacade;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class ProductDTO2BOAdapter {


    @Resource
    private MapperFacade mapperFacade;

    public ProductBO convert2ProductBO(ProductBean productBeanDTO) {

        ProductBO productBO = BeanUtil.convertBean(productBeanDTO, ProductBO::new);
        productBO.setGoodsId(productBeanDTO.getPid());
        productBO.setSpuId(productBeanDTO.getPid());

        return productBO;
    }

    public ProductStockBO convert2ProductStockBO(GetProductStockResponseDto.DataBean ProductStockDTO) {

        ProductStockBO productStockBO = BeanUtil.convertBean(ProductStockDTO, ProductStockBO::new);
        return productStockBO;
    }


    public ValiadShopProductBO convert2ProductStockBO(ValiadShopProductResponse valiadShopProductResponse) {

        ValiadShopProductBO bo = BeanUtil.convertBean(valiadShopProductResponse, ValiadShopProductBO::new);
        return bo;
    }

}
