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

import dev.lions.unionflow.server.api.dto.vote.CampagneVoteRequest;
import dev.lions.unionflow.server.api.dto.vote.CampagneVoteResponse;
import dev.lions.unionflow.server.entity.vote.CampagneVote;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;

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

    @Mapping(target = "organisationId", source = "organisation.id")
    @Mapping(target = "candidatsExposes", source = "candidats")
    @Mapping(target = "tauxDeParticipation", ignore = true)
    CampagneVoteResponse toDto(CampagneVote 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 = "candidats", ignore = true)
    @Mapping(target = "statut", ignore = true)
    @Mapping(target = "totalElecteursInscrits", ignore = true)
    @Mapping(target = "totalVotantsEffectifs", ignore = true)
    @Mapping(target = "totalVotesBlancsOuNuls", ignore = true)
    CampagneVote toEntity(CampagneVoteRequest 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 = "candidats", ignore = true)
    @Mapping(target = "statut", ignore = true)
    @Mapping(target = "totalElecteursInscrits", ignore = true)
    @Mapping(target = "totalVotantsEffectifs", ignore = true)
    @Mapping(target = "totalVotesBlancsOuNuls", ignore = true)
    void updateEntityFromDto(CampagneVoteRequest request, @MappingTarget CampagneVote entity);
}
