package dev.dinauer.maven.app;

import dev.dinauer.maven.maven.core.ArtifactRepo;
import dev.dinauer.maven.user.User;
import dev.dinauer.maven.maven.core.release.ReleaseVersion;
import dev.dinauer.maven.maven.core.ArtifactId;
import dev.dinauer.maven.user.UserClient;
import jakarta.inject.Inject;
import jakarta.transaction.Transactional;
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import org.eclipse.microprofile.rest.client.inject.RestClient;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Path("/artifacts")
public class ArtifactResource
{
    @Inject
    ArtifactRepo artifactRepo;

    @Inject
    ArtifactMapper artifactMapper;

    @GET
    public List<ArtifactDTO> get()
    {
        return artifactMapper.map(artifactRepo.listAll());
    }

    @GET
    @Path("/{id}")
    public ArtifactDTO getById(@PathParam("id") String id)
    {
        return artifactMapper.map(artifactRepo.findById(id));
    }

    @DELETE
    @Path("/{id}")
    @Transactional
    public void deleteById(@PathParam("id") String id)
    {
        artifactRepo.deleteById(id);
    }
}
