package fr.titionfire.ffsaf.rest;

import fr.titionfire.ffsaf.domain.service.ResultService;
import fr.titionfire.ffsaf.rest.data.ResultCategoryData;
import fr.titionfire.ffsaf.utils.SecurityCtx;
import io.quarkus.security.Authenticated;
import io.smallrye.mutiny.Uni;
import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;

import java.util.HashMap;
import java.util.List;

@Authenticated
@Path("api/result")
public class ResultEndpoints {

    @Inject
    ResultService resultService;

    @Inject
    SecurityCtx securityCtx;

    @GET
    @Path("list")
    public Uni<List<Object[]>> getList() {
        return resultService.getList(securityCtx);
    }

    @GET
    @Path("{uuid}/category/list")
    public Uni<HashMap<String, Long>> getCategoryList(@PathParam("uuid") String uuid) {
        return resultService.getCategoryList(uuid, securityCtx);
    }

    @GET
    @Path("{uuid}/category/{id}")
    public Uni<ResultCategoryData> getCategory(@PathParam("uuid") String uuid, @PathParam("id") long id) {
        return resultService.getCategory(uuid, id, securityCtx);
    }

    @GET
    @Path("{uuid}/club/list")
    public Uni<HashMap<String, Long>> getClubList(@PathParam("uuid") String uuid) {
        return resultService.getClubList(uuid, securityCtx);
    }

    @GET
    @Path("{uuid}/club/classement")
    public Uni<List<ResultService.ClubClassement>> getClubClassement(@PathParam("uuid") String uuid) {
        return resultService.getAllClubArray(uuid, securityCtx);
    }

    @GET
    @Path("{uuid}/club/{id}")
    public Uni<ResultService.ClubArrayData> getClub(@PathParam("uuid") String uuid, @PathParam("id") long id) {
        return resultService.getClubArray(uuid, id, securityCtx);
    }

    @GET
    @Path("{uuid}/comb/list")
    public Uni<HashMap<String, String>> getCombList(@PathParam("uuid") String uuid) {
        return resultService.getCombList(uuid, securityCtx);
    }

    @GET
    @Path("{uuid}/comb/{id}")
    public Uni<?> getCombList(@PathParam("uuid") String uuid, @PathParam("id") String id) {
        return resultService.getCombArrayPublic(uuid, id, securityCtx);
    }

    @GET
    @Path("{uuid}/comb")
    public Uni<ResultService.CombsArrayData> getComb(@PathParam("uuid") String uuid) {
        return resultService.getAllCombArray(uuid, securityCtx);
    }
}
