package cn.lihongjie.coal.deviceCategory.mapper;

import cn.lihongjie.coal.base.mapper.BaseMapper;
import cn.lihongjie.coal.base.mapper.CommonEntityMapper;
import cn.lihongjie.coal.base.mapper.CommonMapper;
import cn.lihongjie.coal.deviceCategory.dto.CreateDeviceCategoryDto;
import cn.lihongjie.coal.deviceCategory.dto.DeviceCategoryDto;
import cn.lihongjie.coal.deviceCategory.dto.DeviceCategoryTreeDto;
import cn.lihongjie.coal.deviceCategory.dto.UpdateDeviceCategoryDto;
import cn.lihongjie.coal.deviceCategory.entity.DeviceCategoryEntity;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.Named;
import org.mapstruct.control.DeepClone;

@Mapper(
        componentModel = org.mapstruct.MappingConstants.ComponentModel.SPRING,
        uses = {CommonMapper.class, CommonEntityMapper.class},
        mappingControl = DeepClone.class)
public interface DeviceCategoryMapper
        extends BaseMapper<
                DeviceCategoryEntity,
                DeviceCategoryDto,
                CreateDeviceCategoryDto,
                UpdateDeviceCategoryDto> {
    @Mappings({@Mapping(target = "children", qualifiedByName = "toTreeDto")})
    @Named("toTreeDto")
    DeviceCategoryTreeDto toTreeDto(DeviceCategoryEntity entity);

    @Mappings({@Mapping(target = "children", ignore = true)})
    DeviceCategoryTreeDto toTreeDtoExcludeChildren(DeviceCategoryEntity entity);
}
