package fr.titionfire.ffsaf.rest;

import fr.titionfire.ffsaf.domain.service.CompetitionService;
import fr.titionfire.ffsaf.rest.data.CompetitionData;
import fr.titionfire.ffsaf.utils.CompetitionSystem;
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 jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;

import java.util.List;

@Path("api/competition/admin")
public class CompetitionAdminEndpoints {

    @Inject
    CompetitionService service;

    @Inject
    SecurityCtx securityCtx;

    @GET
    @Path("{id}")
    @Authenticated
    @Produces(MediaType.APPLICATION_JSON)
    public Uni<CompetitionData> getByIdAdmin(@PathParam("id") Long id) {
        return service.getByIdAdmin(securityCtx, id);
    }

    @GET
    @Path("all")
    @Authenticated
    @Produces(MediaType.APPLICATION_JSON)
    public Uni<List<CompetitionData>> getAllAdmin() {
        return service.getAllAdmin(securityCtx);
    }

    @GET
    @Path("all/{system}")
    @Authenticated
    @Produces(MediaType.APPLICATION_JSON)
    public Uni<List<CompetitionData>> getAllSystemAdmin(@PathParam("system") CompetitionSystem system) {
        return service.getAllSystemAdmin(securityCtx, system);
    }

    @GET
    @Path("all/{system}/table")
    @Authenticated
    @Produces(MediaType.APPLICATION_JSON)
    public Uni<List<CompetitionData>> getAllSystemTable(@PathParam("system") CompetitionSystem system) {
        return service.getAllSystemTable(securityCtx, system);
    }
}
