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

import dev.lions.unionflow.server.api.dto.vote.CandidatDTO;
import dev.lions.unionflow.server.entity.vote.Candidat;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;

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

    @Mapping(target = "campagneVoteId", source = "campagneVote.id")
    CandidatDTO toDto(Candidat 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 = "campagneVote", ignore = true)
    @Mapping(target = "nombreDeVoix", ignore = true)
    @Mapping(target = "pourcentageObtenu", ignore = true)
    Candidat toEntity(CandidatDTO 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 = "campagneVote", ignore = true)
    @Mapping(target = "nombreDeVoix", ignore = true)
    @Mapping(target = "pourcentageObtenu", ignore = true)
    void updateEntityFromDto(CandidatDTO dto, @MappingTarget Candidat entity);
}
