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

import dev.lions.unionflow.server.api.dto.tontine.TourTontineDTO;
import dev.lions.unionflow.server.entity.tontine.TourTontine;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;

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

    @Mapping(target = "tontineId", source = "tontine.id")
    @Mapping(target = "membreBeneficiaireId", source = "membreBeneficiaire.id")
    TourTontineDTO toDto(TourTontine 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 = "tontine", ignore = true)
    @Mapping(target = "membreBeneficiaire", ignore = true)
    TourTontine toEntity(TourTontineDTO 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 = "tontine", ignore = true)
    @Mapping(target = "membreBeneficiaire", ignore = true)
    void updateEntityFromDto(TourTontineDTO dto, @MappingTarget TourTontine entity);
}
