package com.xunhong.erp.turbo.biz.infrastructure.convert;

import com.xunhong.erp.turbo.api.biz.dto.cmd.OrderCostCreateCmd;
import com.xunhong.erp.turbo.biz.domain.entity.OrderCost;
import com.xunhong.erp.turbo.biz.domain.entity.PurchaseOrder;
import com.xunhong.erp.turbo.biz.infrastructure.entity.OrderCostDO;
import com.xunhong.erp.turbo.biz.infrastructure.entity.PurchaseOrderDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.NullValueCheckStrategy;

import java.util.List;

/**
 * @author shenyifei
 */
@Mapper(componentModel = "spring", nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
public interface OrderCostConvert {
	@Mapping(target = "orderVehicleDO", ignore = true)
	@Mapping(target = "purchaseOrderDO", ignore = true)
	@Mapping(target = "orderCompanyDO", ignore = true)
	@Mapping(target = "orderCostId", ignore = true)
	@Mapping(target = "version", ignore = true)
	@Mapping(target = "updatedAt", ignore = true)
	@Mapping(target = "isDelete", ignore = true)
	@Mapping(target = "createdAt", ignore = true)
	OrderCostDO toOrderCostDO(OrderCost orderCost);

	@Mapping(target = "orderSupplierList", ignore = true)
	@Mapping(target = "orderShipList", ignore = true)
	@Mapping(target = "orderRebate", ignore = true)
	@Mapping(target = "orderPackageList", ignore = true)
	@Mapping(target = "orderDealer", ignore = true)
	@Mapping(target = "orderCostList", ignore = true)
	@Mapping(target = "orderCostItemList", ignore = true)
	@Mapping(target = "orderCompany", ignore = true)
	@Mapping(target = "orderVehicle", source = "orderVehicleDO")
	PurchaseOrder toPurchaseOrder(PurchaseOrderDO purchaseOrderDO);

	List<OrderCostDO> toOrderCostDOList(List<OrderCost> orderCostList);

	List<OrderCost> toOrderCostList(List<OrderCostDO> orderCostDOList);

	@Mapping(target = "orderCompany", source = "orderCompanyDO")
	@Mapping(target = "purchaseOrder", source = "purchaseOrderDO")
	OrderCost toOrderCost(OrderCostDO orderCostDO);

	@Mapping(target = "version", ignore = true)
	@Mapping(target = "updatedAt", ignore = true)
	@Mapping(target = "purchaseOrderDO", ignore = true)
	@Mapping(target = "poState", ignore = true)
	@Mapping(target = "orderCostId", ignore = true)
	@Mapping(target = "orderCompanyDO", ignore = true)
	@Mapping(target = "isDelete", ignore = true)
	@Mapping(target = "createdAt", ignore = true)
	OrderCostDO toOrderCostDO(OrderCostCreateCmd orderCostCreateCmd);
}
