From a2bc14d54adf3844a001b9589f709b8d5ed0df78 Mon Sep 17 00:00:00 2001 From: Glax Date: Thu, 13 Mar 2025 22:47:50 +0100 Subject: [PATCH] Query Endpoints documentation --- API/Controllers/MangaController.cs | 4 +- API/Controllers/QueryController.cs | 60 ++++++++++++++++++++++-------- 2 files changed, 45 insertions(+), 19 deletions(-) diff --git a/API/Controllers/MangaController.cs b/API/Controllers/MangaController.cs index c45e374..100c02e 100644 --- a/API/Controllers/MangaController.cs +++ b/API/Controllers/MangaController.cs @@ -1,9 +1,7 @@ -using API.APIEndpointRecords; -using API.Schema; +using API.Schema; using API.Schema.Jobs; using Asp.Versioning; using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.ModelBinding; using SixLabors.ImageSharp; using SixLabors.ImageSharp.Formats.Jpeg; using SixLabors.ImageSharp.Processing; diff --git a/API/Controllers/QueryController.cs b/API/Controllers/QueryController.cs index b881fa1..3a4fb05 100644 --- a/API/Controllers/QueryController.cs +++ b/API/Controllers/QueryController.cs @@ -10,6 +10,12 @@ namespace API.Controllers; [Route("v{v:apiVersion}/[controller]")] public class QueryController(PgsqlContext context) : Controller { + /// + /// Returns the Author-Information for Author-ID + /// + /// Author-Id + /// + /// Author with ID not found [HttpGet("Author/{AuthorId}")] [ProducesResponseType(Status200OK, "application/json")] [ProducesResponseType(Status404NotFound)] @@ -21,6 +27,11 @@ public class QueryController(PgsqlContext context) : Controller return Ok(ret); } + /// + /// Returns all Mangas which where Authored by Author with AuthorId + /// + /// Author-ID + /// [HttpGet("Mangas/WithAuthorId/{AuthorId}")] [ProducesResponseType(Status200OK, "application/json")] public IActionResult GetMangaWithAuthorIds(string AuthorId) @@ -28,6 +39,12 @@ public class QueryController(PgsqlContext context) : Controller return Ok(context.Manga.Where(m => m.AuthorIds.Contains(AuthorId))); } + /// + /// Returns Link-Information for Link-Id + /// + /// + /// + /// Link with ID not found [HttpGet("Link/{LinkId}")] [ProducesResponseType(Status200OK, "application/json")] [ProducesResponseType(Status404NotFound)] @@ -39,14 +56,12 @@ public class QueryController(PgsqlContext context) : Controller return Ok(ret); } - [HttpGet("Links/WithIds")] - [ProducesResponseType(Status200OK, "application/json")] - public IActionResult GetLink([FromBody]string[] LinkIds) - { - Link[] ret = context.Link.Where(l => LinkIds.Contains(l.LinkId)).ToArray(); - return Ok(ret); - } - + /// + /// Returns AltTitle-Information for AltTitle-Id + /// + /// + /// + /// AltTitle with ID not found [HttpGet("AltTitle/{AltTitleId}")] [ProducesResponseType(Status200OK, "application/json")] [ProducesResponseType(Status404NotFound)] @@ -58,18 +73,31 @@ public class QueryController(PgsqlContext context) : Controller return Ok(ret); } - [HttpGet("AltTitles/WithIds")] - [ProducesResponseType(Status200OK, "application/json")] - public IActionResult GetAltTitle([FromBody]string[] AltTitleIds) - { - MangaAltTitle[] ret = context.AltTitles.Where(a => AltTitleIds.Contains(a.AltTitleId)).ToArray(); - return Ok(ret); - } - + /// + /// Returns all Manga with Tag + /// + /// + /// [HttpGet("Mangas/WithTag/{Tag}")] [ProducesResponseType(Status200OK, "application/json")] public IActionResult GetMangasWithTag(string Tag) { return Ok(context.Manga.Where(m => m.Tags.Contains(Tag))); } + + /// + /// Returns Chapter-Information for Chapter-Id + /// + /// + /// + /// Chapter with ID not found + [HttpGet("Chapter/{ChapterId}")] + [ProducesResponseType(Status200OK, "application/json")] + public IActionResult GetChapter(string ChapterId) + { + Chapter? ret = context.Chapters.Find(ChapterId); + if (ret is null) + return NotFound(); + return Ok(ret); + } } \ No newline at end of file