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


import com.xunhong.erp.turbo.api.infra.dto.cmd.MaterialCreateCmd;
import com.xunhong.erp.turbo.api.infra.dto.cmd.MaterialUpdateCmd;
import com.xunhong.erp.turbo.infra.domain.entity.Material;
import com.xunhong.erp.turbo.infra.infrastructure.entity.MaterialDO;
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 MaterialConvert {

	@Mapping(target = "categoryDO", ignore = true)
	@Mapping(target = "materialId", ignore = true)
	@Mapping(target = "version", ignore = true)
	@Mapping(target = "updatedAt", ignore = true)
	@Mapping(target = "isDelete", ignore = true)
	@Mapping(target = "createdAt", ignore = true)
	MaterialDO toMaterialDO(MaterialCreateCmd materialCreateCmd);

	@Mapping(target = "category", source = "categoryDO")
	Material toMaterial(MaterialDO materialDO);

	@Mapping(target = "categoryDO", ignore = true)
	@Mapping(target = "version", ignore = true)
	@Mapping(target = "updatedAt", ignore = true)
	@Mapping(target = "isDelete", ignore = true)
	@Mapping(target = "createdAt", ignore = true)
	void toMaterialDO(@MappingTarget MaterialDO materialDO, MaterialUpdateCmd materialUpdateCmd);
}
