feat: add Shikimori metadata service endpoint
Co-authored-by: aider (openrouter/deepseek/deepseek-chat) <aider@aider.chat>
This commit is contained in:
8
pom.xml
8
pom.xml
@ -39,6 +39,14 @@
|
|||||||
<groupId>io.quarkus</groupId>
|
<groupId>io.quarkus</groupId>
|
||||||
<artifactId>quarkus-rest</artifactId>
|
<artifactId>quarkus-rest</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.microprofile.rest.client</groupId>
|
||||||
|
<artifactId>microprofile-rest-client-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.quarkus</groupId>
|
||||||
|
<artifactId>quarkus-rest-client</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.quarkus</groupId>
|
<groupId>io.quarkus</groupId>
|
||||||
<artifactId>quarkus-junit</artifactId>
|
<artifactId>quarkus-junit</artifactId>
|
||||||
|
|||||||
@ -0,0 +1,13 @@
|
|||||||
|
package com.backend.metadata.shikimori.model;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class AnimeMetadata {
|
||||||
|
public int shikimori_id;
|
||||||
|
public String title;
|
||||||
|
public String poster;
|
||||||
|
public String description;
|
||||||
|
public List<Character> characters;
|
||||||
|
public List<RelatedAnime> related;
|
||||||
|
public List<VoiceActor> voice_actors;
|
||||||
|
}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
package com.backend.metadata.shikimori.model;
|
||||||
|
|
||||||
|
public class Character {
|
||||||
|
public String name;
|
||||||
|
public String role;
|
||||||
|
public String poster;
|
||||||
|
public String seiyuu;
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
package com.backend.metadata.shikimori.model;
|
||||||
|
|
||||||
|
public class RelatedAnime {
|
||||||
|
public int shikimori_id;
|
||||||
|
public String relation;
|
||||||
|
public String title;
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
package com.backend.metadata.shikimori.model;
|
||||||
|
|
||||||
|
public class VoiceActor {
|
||||||
|
public String name;
|
||||||
|
public String language;
|
||||||
|
public String character;
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
package com.backend.metadata.shikimori.service;
|
||||||
|
|
||||||
|
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 org.eclipse.microprofile.rest.client.inject.RestClient;
|
||||||
|
|
||||||
|
@Path("/metadata")
|
||||||
|
public class MetadataResource {
|
||||||
|
|
||||||
|
@RestClient
|
||||||
|
ShikimoriService shikimoriService;
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/{shikimori_id}")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
public AnimeMetadata getMetadata(@PathParam("shikimori_id") int shikimoriId) {
|
||||||
|
return shikimoriService.getMetadata(shikimoriId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
package com.backend.metadata.shikimori.service;
|
||||||
|
|
||||||
|
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 org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
|
||||||
|
|
||||||
|
@RegisterRestClient(configKey = "shikimori-api")
|
||||||
|
public interface ShikimoriService {
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/api/graphql")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
AnimeMetadata getMetadata(@PathParam("id") int shikimoriId);
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
# Shikimori API configuration
|
||||||
|
shikimori-api/mp-rest/url=https://shikimori.one
|
||||||
|
shikimori-api/mp-rest/scope=jakarta.inject.Singleton
|
||||||
|
|||||||
Reference in New Issue
Block a user