package dev.lions.unionflow.server.mapper.gouvernance;

import dev.lions.unionflow.server.api.dto.gouvernance.EchelonOrganigrammeDTO;
import dev.lions.unionflow.server.entity.gouvernance.EchelonOrganigramme;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;

@Mapper(componentModel = "cdi", builder = @org.mapstruct.Builder(disableBuilder = true))
public interface EchelonOrganigrammeMapper {

    @Mapping(target = "organisationId", source = "organisation.id")
    @Mapping(target = "echelonParentId", source = "echelonParent.id")
    EchelonOrganigrammeDTO toDto(EchelonOrganigramme entity);

    @Mapping(target = "id", ignore = true)
    @Mapping(target = "dateCreation", ignore = true)
    @Mapping(target = "dateModification", ignore = true)
    @Mapping(target = "creePar", ignore = true)
    @Mapping(target = "modifiePar", ignore = true)
    @Mapping(target = "version", ignore = true)
    @Mapping(target = "actif", ignore = true)
    @Mapping(target = "organisation", ignore = true)
    @Mapping(target = "echelonParent", ignore = true)
    EchelonOrganigramme toEntity(EchelonOrganigrammeDTO dto);

    @Mapping(target = "id", ignore = true)
    @Mapping(target = "dateCreation", ignore = true)
    @Mapping(target = "dateModification", ignore = true)
    @Mapping(target = "creePar", ignore = true)
    @Mapping(target = "modifiePar", ignore = true)
    @Mapping(target = "version", ignore = true)
    @Mapping(target = "actif", ignore = true)
    @Mapping(target = "organisation", ignore = true)
    @Mapping(target = "echelonParent", ignore = true)
    void updateEntityFromDto(EchelonOrganigrammeDTO dto, @MappingTarget EchelonOrganigramme entity);
}
