package cn.lihongjie.coal.tzDeviceCategory.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.tzDeviceCategory.dto.CreateTzDeviceCategoryDto;
import cn.lihongjie.coal.tzDeviceCategory.dto.TzDeviceCategoryDto;
import cn.lihongjie.coal.tzDeviceCategory.dto.TzDeviceCategoryTreeDto;
import cn.lihongjie.coal.tzDeviceCategory.dto.UpdateTzDeviceCategoryDto;
import cn.lihongjie.coal.tzDeviceCategory.entity.TzDeviceCategoryEntity;

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 TzDeviceCategoryMapper
        extends BaseMapper<
                TzDeviceCategoryEntity,
                TzDeviceCategoryDto,
                CreateTzDeviceCategoryDto,
                UpdateTzDeviceCategoryDto> {
    @Mappings({@Mapping(target = "children", qualifiedByName = "toTreeDto")})
    @Named("toTreeDto")
    TzDeviceCategoryTreeDto toTreeDto(TzDeviceCategoryEntity entity);

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