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

import com.xunhong.erp.turbo.api.biz.dto.cmd.CostCreateCmd;
import com.xunhong.erp.turbo.api.biz.dto.cmd.CostUpdateCmd;
import com.xunhong.erp.turbo.biz.domain.entity.Cost;
import com.xunhong.erp.turbo.biz.infrastructure.entity.CostDO;
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 CostConvert {

	@Mapping(target = "costItemList", source = "costItemDOList")
	Cost toCost(CostDO costDO);

	@Mapping(target = "costItemDOList", ignore = true)
	@Mapping(target = "version", ignore = true)
	@Mapping(target = "updatedAt", ignore = true)
	@Mapping(target = "isDelete", ignore = true)
	@Mapping(target = "createdAt", ignore = true)
	CostDO toCostDO(CostCreateCmd costCreateCmd);

	@Mapping(target = "costItemDOList", ignore = true)
	@Mapping(target = "version", ignore = true)
	@Mapping(target = "updatedAt", ignore = true)
	@Mapping(target = "isDelete", ignore = true)
	@Mapping(target = "createdAt", ignore = true)
	void toCostDO(@MappingTarget CostDO costDO, CostUpdateCmd costUpdateCmd);
}

