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

import com.xunhong.erp.turbo.api.biz.dto.cmd.SupplierCreateCmd;
import com.xunhong.erp.turbo.api.biz.dto.cmd.SupplierUpdateCmd;
import com.xunhong.erp.turbo.api.biz.dto.common.OrderSupplier;
import com.xunhong.erp.turbo.biz.domain.entity.Supplier;
import com.xunhong.erp.turbo.biz.infrastructure.entity.SupplierDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.NullValueCheckStrategy;

/**
 * @author shenyifei
 */
@Mapper(componentModel = "spring", nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
public interface SupplierConvert {

	@Mapping(target = "dealer", source = "dealerDO")
	Supplier toSupplier(SupplierDO supplierDO);

	@Mapping(target = "dealerDO", ignore = true)
	@Mapping(target = "version", ignore = true)
	@Mapping(target = "updatedAt", ignore = true)
	@Mapping(target = "isDelete", ignore = true)
	@Mapping(target = "createdAt", ignore = true)
	SupplierDO toSupplierDO(SupplierCreateCmd supplierCreateCmd);

	@Mapping(target = "dealerDO", ignore = true)
	@Mapping(target = "version", ignore = true)
	@Mapping(target = "updatedAt", ignore = true)
	@Mapping(target = "isDelete", ignore = true)
	@Mapping(target = "createdAt", ignore = true)
	void toSupplierDO(@MappingTarget SupplierDO supplierDO, SupplierUpdateCmd supplierUpdateCmd);

	@Mapping(target = "dealerId", ignore = true)
	@Mapping(target = "dealerDO", ignore = true)
	@Mapping(target = "version", ignore = true)
	@Mapping(target = "updatedAt", ignore = true)
	@Mapping(target = "status", ignore = true)
	@Mapping(target = "remark", ignore = true)
	@Mapping(target = "isDelete", ignore = true)
	@Mapping(target = "createdAt", ignore = true)
	SupplierDO toSupplierDO(OrderSupplier updatedSupplier);
}

