package com.qqchen.deploy.backend.system.converter;

import com.qqchen.deploy.backend.system.entity.Department;
import com.qqchen.deploy.backend.framework.converter.BaseConverter;
import com.qqchen.deploy.backend.system.model.DepartmentDTO;
import com.qqchen.deploy.backend.system.model.response.DepartmentResponse;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.ReportingPolicy;

import java.util.List;

@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface DepartmentConverter extends BaseConverter<Department, DepartmentDTO> {
    // 继承了 BaseConverter 的方法，不需要再声明

    @Mapping(target = "children", expression = "java(toResponseList(dto.getChildren()))")
    DepartmentResponse toResponse(DepartmentDTO dto);

    List<DepartmentResponse> toResponseList(List<DepartmentDTO> dtoList);

} 