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


import com.xunhong.erp.turbo.api.infra.dto.cmd.CategoryCreateCmd;
import com.xunhong.erp.turbo.api.infra.dto.cmd.CategoryUpdateCmd;
import com.xunhong.erp.turbo.infra.domain.entity.Category;
import com.xunhong.erp.turbo.infra.infrastructure.entity.CategoryDO;
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 CategoryConvert {

	Category toCategory(CategoryDO categoryDO);

	@Mapping(target = "version", ignore = true)
	@Mapping(target = "updatedAt", ignore = true)
	@Mapping(target = "isDelete", ignore = true)
	@Mapping(target = "createdAt", ignore = true)
	void toCategoryDO(@MappingTarget CategoryDO categoryDO, CategoryUpdateCmd categoryUpdateCmd);

	@Mapping(target = "version", ignore = true)
	@Mapping(target = "updatedAt", ignore = true)
	@Mapping(target = "isDelete", ignore = true)
	@Mapping(target = "createdAt", ignore = true)
	@Mapping(target = "categoryId", ignore = true)
	CategoryDO toCategoryDO(CategoryCreateCmd categoryCreateCmd);
}
