package com.cdm.module.trade.convert.cart;

import com.cdm.module.product.api.property.dto.ProductPropertyValueDetailRespDTO;
import com.cdm.module.product.api.sku.dto.ProductSkuRespDTO;
import com.cdm.module.product.api.spu.dto.ProductSpuRespDTO;
import com.cdm.module.trade.controller.app.base.property.AppProductPropertyValueDetailRespVO;
import com.cdm.module.trade.controller.app.base.sku.AppProductSkuBaseRespVO;
import com.cdm.module.trade.controller.app.base.spu.AppProductSpuBaseRespVO;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.processing.Generated;

@Generated(
    value = "org.mapstruct.ap.MappingProcessor",
    date = "2023-12-21T17:56:57+0800",
    comments = "version: 1.5.5.Final, compiler: javac, environment: Java 17.0.3 (JetBrains s.r.o.)"
)
public class TradeCartConvertImpl implements TradeCartConvert {

    @Override
    public AppProductSpuBaseRespVO convert(ProductSpuRespDTO spu) {
        if ( spu == null ) {
            return null;
        }

        AppProductSpuBaseRespVO appProductSpuBaseRespVO = new AppProductSpuBaseRespVO();

        appProductSpuBaseRespVO.setId( spu.getId() );
        appProductSpuBaseRespVO.setName( spu.getName() );
        appProductSpuBaseRespVO.setPicUrl( spu.getPicUrl() );

        return appProductSpuBaseRespVO;
    }

    @Override
    public AppProductSkuBaseRespVO convert(ProductSkuRespDTO sku) {
        if ( sku == null ) {
            return null;
        }

        AppProductSkuBaseRespVO appProductSkuBaseRespVO = new AppProductSkuBaseRespVO();

        appProductSkuBaseRespVO.setId( sku.getId() );
        appProductSkuBaseRespVO.setPicUrl( sku.getPicUrl() );
        appProductSkuBaseRespVO.setPrice( sku.getPrice() );
        appProductSkuBaseRespVO.setStock( sku.getStock() );
        appProductSkuBaseRespVO.setProperties( productPropertyValueDetailRespDTOListToAppProductPropertyValueDetailRespVOList( sku.getProperties() ) );

        return appProductSkuBaseRespVO;
    }

    protected AppProductPropertyValueDetailRespVO productPropertyValueDetailRespDTOToAppProductPropertyValueDetailRespVO(ProductPropertyValueDetailRespDTO productPropertyValueDetailRespDTO) {
        if ( productPropertyValueDetailRespDTO == null ) {
            return null;
        }

        AppProductPropertyValueDetailRespVO appProductPropertyValueDetailRespVO = new AppProductPropertyValueDetailRespVO();

        appProductPropertyValueDetailRespVO.setPropertyId( productPropertyValueDetailRespDTO.getPropertyId() );
        appProductPropertyValueDetailRespVO.setPropertyName( productPropertyValueDetailRespDTO.getPropertyName() );
        appProductPropertyValueDetailRespVO.setValueId( productPropertyValueDetailRespDTO.getValueId() );
        appProductPropertyValueDetailRespVO.setValueName( productPropertyValueDetailRespDTO.getValueName() );

        return appProductPropertyValueDetailRespVO;
    }

    protected List<AppProductPropertyValueDetailRespVO> productPropertyValueDetailRespDTOListToAppProductPropertyValueDetailRespVOList(List<ProductPropertyValueDetailRespDTO> list) {
        if ( list == null ) {
            return null;
        }

        List<AppProductPropertyValueDetailRespVO> list1 = new ArrayList<AppProductPropertyValueDetailRespVO>( list.size() );
        for ( ProductPropertyValueDetailRespDTO productPropertyValueDetailRespDTO : list ) {
            list1.add( productPropertyValueDetailRespDTOToAppProductPropertyValueDetailRespVO( productPropertyValueDetailRespDTO ) );
        }

        return list1;
    }
}
