From 5d8f203a351d3da0a927adeb8a78c2011f68975a Mon Sep 17 00:00:00 2001 From: glax Date: Tue, 22 Jul 2025 15:56:57 +0200 Subject: [PATCH] Add Queries for MangaConnectorIds --- API/Controllers/MangaController.cs | 32 ++++++++++ API/Controllers/QueryController.cs | 67 +++++++++++---------- API/Schema/MangaContext/Manga.cs | 1 + API/Schema/MangaContext/MangaConnectorId.cs | 2 +- Dockerfile | 3 +- 5 files changed, 71 insertions(+), 34 deletions(-) diff --git a/API/Controllers/MangaController.cs b/API/Controllers/MangaController.cs index 55b2278..7bbcf00 100644 --- a/API/Controllers/MangaController.cs +++ b/API/Controllers/MangaController.cs @@ -456,4 +456,36 @@ public class MangaController(MangaContext context) : Controller return new SearchController(context).SearchManga(MangaConnectorName, manga.Name); } + + /// + /// Returns all which where Authored by with + /// + /// .Key + /// + /// with + [HttpGet("WithAuthorId/{AuthorId}")] + [ProducesResponseType(Status200OK, "application/json")] + public IActionResult GetMangaWithAuthorIds(string AuthorId) + { + if (context.Authors.Find(AuthorId) is not { } author) + return NotFound(); + + return Ok(context.Mangas.Where(m => m.Authors.Contains(author))); + } + + /// + /// Returns all with + /// + /// .Tag + /// + /// not found + [HttpGet("WithTag/{Tag}")] + [ProducesResponseType(Status200OK, "application/json")] + public IActionResult GetMangasWithTag(string Tag) + { + if (context.Tags.Find(Tag) is not { } tag) + return NotFound(); + + return Ok(context.Mangas.Where(m => m.MangaTags.Contains(tag))); + } } \ No newline at end of file diff --git a/API/Controllers/QueryController.cs b/API/Controllers/QueryController.cs index 72ff801..70de774 100644 --- a/API/Controllers/QueryController.cs +++ b/API/Controllers/QueryController.cs @@ -28,38 +28,6 @@ public class QueryController(MangaContext context) : Controller return Ok(author); } - /// - /// Returns all which where Authored by with - /// - /// .Key - /// - /// with - [HttpGet("Mangas/WithAuthorId/{AuthorId}")] - [ProducesResponseType(Status200OK, "application/json")] - public IActionResult GetMangaWithAuthorIds(string AuthorId) - { - if (context.Authors.Find(AuthorId) is not { } author) - return NotFound(); - - return Ok(context.Mangas.Where(m => m.Authors.Contains(author))); - } - - /// - /// Returns all with - /// - /// .Tag - /// - /// not found - [HttpGet("Mangas/WithTag/{Tag}")] - [ProducesResponseType(Status200OK, "application/json")] - public IActionResult GetMangasWithTag(string Tag) - { - if (context.Tags.Find(Tag) is not { } tag) - return NotFound(); - - return Ok(context.Mangas.Where(m => m.MangaTags.Contains(tag))); - } - /// /// Returns with /// @@ -68,6 +36,7 @@ public class QueryController(MangaContext context) : Controller /// with not found [HttpGet("Chapter/{ChapterId}")] [ProducesResponseType(Status200OK, "application/json")] + [ProducesResponseType(Status404NotFound)] public IActionResult GetChapter(string ChapterId) { if (context.Chapters.Find(ChapterId) is not { } chapter) @@ -75,4 +44,38 @@ public class QueryController(MangaContext context) : Controller return Ok(chapter); } + + /// + /// Returns the with .Key + /// + /// Key of + /// + /// with not found + [HttpGet("Manga/MangaConnectorId/{MangaConnectorIdId}")] + [ProducesResponseType>(Status200OK, "application/json")] + [ProducesResponseType(Status404NotFound)] + public IActionResult GetMangaMangaConnectorId(string MangaConnectorIdId) + { + if(context.MangaConnectorToManga.Find(MangaConnectorIdId) is not { } mcIdManga) + return NotFound(); + + return Ok(mcIdManga); + } + + /// + /// Returns the with .Key + /// + /// Key of + /// + /// with not found + [HttpGet("chapter/MangaConnectorId/{MangaConnectorIdId}")] + [ProducesResponseType>(Status200OK, "application/json")] + [ProducesResponseType(Status404NotFound)] + public IActionResult GetChapterMangaConnectorId(string MangaConnectorIdId) + { + if(context.MangaConnectorToChapter.Find(MangaConnectorIdId) is not { } mcIdChapter) + return NotFound(); + + return Ok(mcIdChapter); + } } \ No newline at end of file diff --git a/API/Schema/MangaContext/Manga.cs b/API/Schema/MangaContext/Manga.cs index f474977..99b4b42 100644 --- a/API/Schema/MangaContext/Manga.cs +++ b/API/Schema/MangaContext/Manga.cs @@ -39,6 +39,7 @@ public class Manga : Identifiable [NotMapped] public Dictionary IdsOnMangaConnectors => MangaConnectorIds.ToDictionary(id => id.MangaConnectorName, id => id.IdOnConnectorSite); + [NotMapped] public ICollection MangaConnectorIdsIds => MangaConnectorIds.Select(id => id.Key).ToList(); [JsonIgnore] public ICollection> MangaConnectorIds = null!; public Manga(string name, string description, string coverUrl, MangaReleaseStatus releaseStatus, diff --git a/API/Schema/MangaContext/MangaConnectorId.cs b/API/Schema/MangaContext/MangaConnectorId.cs index 43f09c0..b5de903 100644 --- a/API/Schema/MangaContext/MangaConnectorId.cs +++ b/API/Schema/MangaContext/MangaConnectorId.cs @@ -11,7 +11,7 @@ public class MangaConnectorId : Identifiable where T : Identifiable [StringLength(64)] [Required] public string ObjId { get; private set; } = null!; [JsonIgnore] public T Obj = null!; - [StringLength(32)] [Required] public string MangaConnectorName { get; private set; } = null!; + [StringLength(32)] [Required] public string MangaConnectorName { get; private set; } [StringLength(256)] [Required] public string IdOnConnectorSite { get; init; } [Url] [StringLength(512)] public string? WebsiteUrl { get; internal init; } diff --git a/Dockerfile b/Dockerfile index 0b1c06e..f392a71 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,8 @@ ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium ENV XDG_CONFIG_HOME=/tmp/.chromium ENV XDG_CACHE_HOME=/tmp/.chromium RUN apt-get update \ - && apt-get install -y libx11-6 libx11-xcb1 libatk1.0-0 libgtk-3-0 libcups2 libdrm2 libxkbcommon0 libxcomposite1 libxdamage1 libxrandr2 libgbm1 libpango-1.0-0 libcairo2 libasound2 libxshmfence1 libnss3 chromium \ + && apt-get upgrade -y \ + && apt-get install -y chromium \ && apt-get autopurge -y \ && apt-get autoclean -y