package dev.lions.unionflow.client.service;

import dev.lions.unionflow.client.dto.AssociationDTO;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import java.util.List;

@RegisterRestClient(configKey = "unionflow-api")
@Path("/api/associations")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public interface AssociationService {
    
    @GET
    List<AssociationDTO> listerToutes();
    
    @GET
    @Path("/{id}")
    AssociationDTO obtenirParId(@PathParam("id") Long id);
    
    @GET
    @Path("/search")
    List<AssociationDTO> rechercher(
        @QueryParam("nom") String nom,
        @QueryParam("type") String type,
        @QueryParam("statut") String statut,
        @QueryParam("region") String region,
        @QueryParam("ville") String ville,
        @QueryParam("page") @DefaultValue("0") int page,
        @QueryParam("size") @DefaultValue("20") int size
    );
    
    @GET
    @Path("/actives")
    List<AssociationDTO> listerActives();
    
    @GET
    @Path("/type/{type}")
    List<AssociationDTO> listerParType(@PathParam("type") String type);
    
    @GET
    @Path("/region/{region}")
    List<AssociationDTO> listerParRegion(@PathParam("region") String region);
    
    @POST
    AssociationDTO creer(AssociationDTO association);
    
    @PUT
    @Path("/{id}")
    AssociationDTO modifier(@PathParam("id") Long id, AssociationDTO association);
    
    @DELETE
    @Path("/{id}")
    void supprimer(@PathParam("id") Long id);
    
    @PUT
    @Path("/{id}/activer")
    AssociationDTO activer(@PathParam("id") Long id);
    
    @PUT
    @Path("/{id}/desactiver")
    AssociationDTO desactiver(@PathParam("id") Long id);
    
    @PUT
    @Path("/{id}/suspendre")
    AssociationDTO suspendre(@PathParam("id") Long id);
    
    @PUT
    @Path("/{id}/dissoudre")
    AssociationDTO dissoudre(@PathParam("id") Long id);
    
    @GET
    @Path("/statistiques")
    StatistiquesAssociationDTO obtenirStatistiques();
    
    @GET
    @Path("/{id}/membres/count")
    Long compterMembres(@PathParam("id") Long id);
    
    @GET
    @Path("/{id}/performance")
    PerformanceAssociationDTO obtenirPerformance(@PathParam("id") Long id);
    
    // Classes DTO internes
    class StatistiquesAssociationDTO {
        public Long totalAssociations;
        public Long associationsActives;
        public Long associationsInactives;
        public Long associationsSuspendues;
        public Long associationsDissoutes;
        public Long nouvellesAssociations30Jours;
        public Double tauxActivite;
        public java.util.Map<String, Long> repartitionParType;
        public java.util.Map<String, Long> repartitionParRegion;
        
        // Constructeurs
        public StatistiquesAssociationDTO() {}
        
        // Getters et setters
        public Long getTotalAssociations() { return totalAssociations; }
        public void setTotalAssociations(Long totalAssociations) { this.totalAssociations = totalAssociations; }
        
        public Long getAssociationsActives() { return associationsActives; }
        public void setAssociationsActives(Long associationsActives) { this.associationsActives = associationsActives; }
        
        public Long getAssociationsInactives() { return associationsInactives; }
        public void setAssociationsInactives(Long associationsInactives) { this.associationsInactives = associationsInactives; }
        
        public Long getAssociationsSuspendues() { return associationsSuspendues; }
        public void setAssociationsSuspendues(Long associationsSuspendues) { this.associationsSuspendues = associationsSuspendues; }
        
        public Long getAssociationsDissoutes() { return associationsDissoutes; }
        public void setAssociationsDissoutes(Long associationsDissoutes) { this.associationsDissoutes = associationsDissoutes; }
        
        public Long getNouvellesAssociations30Jours() { return nouvellesAssociations30Jours; }
        public void setNouvellesAssociations30Jours(Long nouvellesAssociations30Jours) { this.nouvellesAssociations30Jours = nouvellesAssociations30Jours; }
        
        public Double getTauxActivite() { return tauxActivite; }
        public void setTauxActivite(Double tauxActivite) { this.tauxActivite = tauxActivite; }
        
        public java.util.Map<String, Long> getRepartitionParType() { return repartitionParType; }
        public void setRepartitionParType(java.util.Map<String, Long> repartitionParType) { this.repartitionParType = repartitionParType; }
        
        public java.util.Map<String, Long> getRepartitionParRegion() { return repartitionParRegion; }
        public void setRepartitionParRegion(java.util.Map<String, Long> repartitionParRegion) { this.repartitionParRegion = repartitionParRegion; }
    }
    
    class PerformanceAssociationDTO {
        public Long associationId;
        public String nom;
        public Integer scoreGlobal;
        public Integer scoreMembres;
        public Integer scoreActivites;
        public Integer scoreFinances;
        public String tendance;
        public java.time.LocalDateTime derniereMiseAJour;
        
        // Constructeurs
        public PerformanceAssociationDTO() {}
        
        // Getters et setters
        public Long getAssociationId() { return associationId; }
        public void setAssociationId(Long associationId) { this.associationId = associationId; }
        
        public String getNom() { return nom; }
        public void setNom(String nom) { this.nom = nom; }
        
        public Integer getScoreGlobal() { return scoreGlobal; }
        public void setScoreGlobal(Integer scoreGlobal) { this.scoreGlobal = scoreGlobal; }
        
        public Integer getScoreMembres() { return scoreMembres; }
        public void setScoreMembres(Integer scoreMembres) { this.scoreMembres = scoreMembres; }
        
        public Integer getScoreActivites() { return scoreActivites; }
        public void setScoreActivites(Integer scoreActivites) { this.scoreActivites = scoreActivites; }
        
        public Integer getScoreFinances() { return scoreFinances; }
        public void setScoreFinances(Integer scoreFinances) { this.scoreFinances = scoreFinances; }
        
        public String getTendance() { return tendance; }
        public void setTendance(String tendance) { this.tendance = tendance; }
        
        public java.time.LocalDateTime getDerniereMiseAJour() { return derniereMiseAJour; }
        public void setDerniereMiseAJour(java.time.LocalDateTime derniereMiseAJour) { this.derniereMiseAJour = derniereMiseAJour; }
    }
}