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

import dev.lions.unionflow.server.api.dto.tontine.TontineRequest;
import dev.lions.unionflow.server.api.dto.tontine.TontineResponse;
import dev.lions.unionflow.server.entity.tontine.Tontine;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;

@Mapper(componentModel = "jakarta-cdi", uses = {
        TourTontineMapper.class }, builder = @org.mapstruct.Builder(disableBuilder = true))
public interface TontineMapper {

    @Mapping(target = "organisationId", source = "organisation.id")
    @Mapping(target = "nombreParticipantsActuels", ignore = true)
    @Mapping(target = "fondTotalCollecte", ignore = true)
    TontineResponse toDto(Tontine 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 = "calendrierTours", ignore = true)
    @Mapping(target = "statut", ignore = true)
    @Mapping(target = "dateDebutEffective", ignore = true)
    @Mapping(target = "dateFinPrevue", ignore = true)
    Tontine toEntity(TontineRequest request);

    @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 = "calendrierTours", ignore = true)
    @Mapping(target = "statut", ignore = true)
    @Mapping(target = "dateDebutEffective", ignore = true)
    @Mapping(target = "dateFinPrevue", ignore = true)
    void updateEntityFromDto(TontineRequest request, @MappingTarget Tontine entity);
}
