mirror of
https://github.com/C9Glax/tranga.git
synced 2025-04-15 12:53:17 +02:00
XML-Documentation
This commit is contained in:
parent
3305519307
commit
3ecbc1a805
@ -214,7 +214,7 @@ public class JobController(PgsqlContext context) : Controller
|
|||||||
/// <response code="202">Job modified</response>
|
/// <response code="202">Job modified</response>
|
||||||
/// <response code="400">Malformed request</response>
|
/// <response code="400">Malformed request</response>
|
||||||
/// <response code="404">Job with ID not found</response>
|
/// <response code="404">Job with ID not found</response>
|
||||||
/// <response code="500">Internal Error</response>
|
/// <response code="500">Error during Database Operation</response>
|
||||||
[HttpPatch("{id}/")]
|
[HttpPatch("{id}/")]
|
||||||
[ProducesResponseType<Job>(Status202Accepted)]
|
[ProducesResponseType<Job>(Status202Accepted)]
|
||||||
[ProducesResponseType(Status400BadRequest)]
|
[ProducesResponseType(Status400BadRequest)]
|
||||||
@ -247,7 +247,7 @@ public class JobController(PgsqlContext context) : Controller
|
|||||||
/// <response code="202">Job started</response>
|
/// <response code="202">Job started</response>
|
||||||
/// <response code="404">Job with ID not found</response>
|
/// <response code="404">Job with ID not found</response>
|
||||||
/// <response code="409">Job was already running</response>
|
/// <response code="409">Job was already running</response>
|
||||||
/// <response code="500">Internal Error</response>
|
/// <response code="500">Error during Database Operation</response>
|
||||||
[HttpPost("{id}/Start")]
|
[HttpPost("{id}/Start")]
|
||||||
[ProducesResponseType(Status202Accepted)]
|
[ProducesResponseType(Status202Accepted)]
|
||||||
[ProducesResponseType(Status404NotFound)]
|
[ProducesResponseType(Status404NotFound)]
|
||||||
@ -276,19 +276,10 @@ public class JobController(PgsqlContext context) : Controller
|
|||||||
/// Stops the Job with the requested ID
|
/// Stops the Job with the requested ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">Job-ID</param>
|
/// <param name="id">Job-ID</param>
|
||||||
/// <response code="202">Job started</response>
|
|
||||||
/// <response code="404">Job with ID not found</response>
|
|
||||||
/// <response code="409">Job was not running</response>
|
|
||||||
/// <response code="500">Internal Error</response>
|
|
||||||
/// <remarks>NOT IMPLEMENTED</remarks>
|
/// <remarks>NOT IMPLEMENTED</remarks>
|
||||||
[ProducesResponseType(Status202Accepted)]
|
|
||||||
[ProducesResponseType(Status404NotFound)]
|
|
||||||
[ProducesResponseType(Status409Conflict)]
|
|
||||||
[ProducesResponseType(Status500InternalServerError)]
|
|
||||||
[HttpPost("{id}/Stop")]
|
[HttpPost("{id}/Stop")]
|
||||||
public IActionResult StopJob(string id)
|
public IActionResult StopJob(string id)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
return NotFound(new ProblemResponse("Not implemented"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,7 +15,7 @@ public class LibraryConnectorController(PgsqlContext context) : Controller
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets all configured Library-Connectors
|
/// Gets all configured Library-Connectors
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Array of configured Library-Connectors</returns>
|
/// <response code="200"></response>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[ProducesResponseType<LibraryConnector[]>(Status200OK)]
|
[ProducesResponseType<LibraryConnector[]>(Status200OK)]
|
||||||
public IActionResult GetAllConnectors()
|
public IActionResult GetAllConnectors()
|
||||||
@ -28,7 +28,8 @@ public class LibraryConnectorController(PgsqlContext context) : Controller
|
|||||||
/// Returns Library-Connector with requested ID
|
/// Returns Library-Connector with requested ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">Library-Connector-ID</param>
|
/// <param name="id">Library-Connector-ID</param>
|
||||||
/// <returns>Library-Connector</returns>
|
/// <response code="200"></response>
|
||||||
|
/// <response code="404">Connector with ID not found.</response>
|
||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
[ProducesResponseType<LibraryConnector>(Status200OK)]
|
[ProducesResponseType<LibraryConnector>(Status200OK)]
|
||||||
[ProducesResponseType(Status404NotFound)]
|
[ProducesResponseType(Status404NotFound)]
|
||||||
@ -46,7 +47,8 @@ public class LibraryConnectorController(PgsqlContext context) : Controller
|
|||||||
/// Creates a new Library-Connector
|
/// Creates a new Library-Connector
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="libraryConnector">Library-Connector</param>
|
/// <param name="libraryConnector">Library-Connector</param>
|
||||||
/// <returns>Nothing</returns>
|
/// <response code="200"></response>
|
||||||
|
/// <response code="500">Error during Database Operation</response>
|
||||||
[HttpPut]
|
[HttpPut]
|
||||||
[ProducesResponseType(Status200OK)]
|
[ProducesResponseType(Status200OK)]
|
||||||
[ProducesResponseType<string>(Status500InternalServerError)]
|
[ProducesResponseType<string>(Status500InternalServerError)]
|
||||||
@ -68,7 +70,9 @@ public class LibraryConnectorController(PgsqlContext context) : Controller
|
|||||||
/// Deletes the Library-Connector with the requested ID
|
/// Deletes the Library-Connector with the requested ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">Library-Connector-ID</param>
|
/// <param name="id">Library-Connector-ID</param>
|
||||||
/// <returns>Nothing</returns>
|
/// <response code="200"></response>
|
||||||
|
/// <response code="404">Connector with ID not found.</response>
|
||||||
|
/// <response code="500">Error during Database Operation</response>
|
||||||
[HttpDelete("{id}")]
|
[HttpDelete("{id}")]
|
||||||
[ProducesResponseType(Status200OK)]
|
[ProducesResponseType(Status200OK)]
|
||||||
[ProducesResponseType(Status404NotFound)]
|
[ProducesResponseType(Status404NotFound)]
|
||||||
|
@ -15,7 +15,7 @@ public class MangaConnectorController(PgsqlContext context) : Controller
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get all available Connectors (Scanlation-Sites)
|
/// Get all available Connectors (Scanlation-Sites)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <response code="200">List of all Connectors</response>
|
/// <response code="200"></response>
|
||||||
[HttpGet("GetConnectors")]
|
[HttpGet("GetConnectors")]
|
||||||
[ProducesResponseType<MangaConnector[]>(Status200OK)]
|
[ProducesResponseType<MangaConnector[]>(Status200OK)]
|
||||||
public IActionResult GetConnectors()
|
public IActionResult GetConnectors()
|
||||||
@ -27,7 +27,7 @@ public class MangaConnectorController(PgsqlContext context) : Controller
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get all enabled Connectors (Scanlation-Sites)
|
/// Get all enabled Connectors (Scanlation-Sites)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <response code="200">List of all enabled Connectors</response>
|
/// <response code="200"></response>
|
||||||
[HttpGet("GetConnectors/enabled")]
|
[HttpGet("GetConnectors/enabled")]
|
||||||
[ProducesResponseType<MangaConnector[]>(Status200OK)]
|
[ProducesResponseType<MangaConnector[]>(Status200OK)]
|
||||||
public IActionResult GetEnabledConnectors()
|
public IActionResult GetEnabledConnectors()
|
||||||
@ -39,7 +39,7 @@ public class MangaConnectorController(PgsqlContext context) : Controller
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get all disabled Connectors (Scanlation-Sites)
|
/// Get all disabled Connectors (Scanlation-Sites)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <response code="200">List of all enabled Connectors</response>
|
/// <response code="200"></response>
|
||||||
[HttpGet("GetConnectors/disabled")]
|
[HttpGet("GetConnectors/disabled")]
|
||||||
[ProducesResponseType<MangaConnector[]>(Status200OK)]
|
[ProducesResponseType<MangaConnector[]>(Status200OK)]
|
||||||
public IActionResult GetDisabledConnectors()
|
public IActionResult GetDisabledConnectors()
|
||||||
|
@ -14,7 +14,7 @@ public class MangaController(PgsqlContext context) : Controller
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns all cached Manga
|
/// Returns all cached Manga
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Array of Manga</returns>
|
/// <response code="200"></response>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[ProducesResponseType<Manga[]>(Status200OK)]
|
[ProducesResponseType<Manga[]>(Status200OK)]
|
||||||
public IActionResult GetAllManga()
|
public IActionResult GetAllManga()
|
||||||
@ -27,7 +27,7 @@ public class MangaController(PgsqlContext context) : Controller
|
|||||||
/// Returns all cached Manga with IDs
|
/// Returns all cached Manga with IDs
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ids">Array of Manga-IDs</param>
|
/// <param name="ids">Array of Manga-IDs</param>
|
||||||
/// <returns>Array of Manga</returns>
|
/// <response code="200"></response>
|
||||||
[HttpPost("WithIDs")]
|
[HttpPost("WithIDs")]
|
||||||
[ProducesResponseType<Manga[]>(Status200OK)]
|
[ProducesResponseType<Manga[]>(Status200OK)]
|
||||||
public IActionResult GetManga([FromBody]string[] ids)
|
public IActionResult GetManga([FromBody]string[] ids)
|
||||||
@ -40,42 +40,41 @@ public class MangaController(PgsqlContext context) : Controller
|
|||||||
/// Return Manga with ID
|
/// Return Manga with ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">Manga-ID</param>
|
/// <param name="id">Manga-ID</param>
|
||||||
/// <returns>Manga</returns>
|
/// <response code="200"></response>
|
||||||
|
/// <response code="404">Manga with ID not found</response>
|
||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
[ProducesResponseType<Manga>(Status200OK)]
|
[ProducesResponseType<Manga>(Status200OK)]
|
||||||
[ProducesResponseType(Status404NotFound)]
|
[ProducesResponseType(Status404NotFound)]
|
||||||
public IActionResult GetManga(string id)
|
public IActionResult GetManga(string id)
|
||||||
{
|
{
|
||||||
Manga? ret = context.Manga.Find(id);
|
Manga? ret = context.Manga.Find(id);
|
||||||
return (ret is not null) switch
|
if (ret is null)
|
||||||
{
|
return NotFound();
|
||||||
true => Ok(ret),
|
return Ok(ret);
|
||||||
false => NotFound()
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delete Manga with ID
|
/// Delete Manga with ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">Manga-ID</param>
|
/// <param name="id">Manga-ID</param>
|
||||||
/// <returns>Nothing</returns>
|
/// <response code="200"></response>
|
||||||
|
/// <response code="404">Manga with ID not found</response>
|
||||||
|
/// <response code="500">Error during Database Operation</response>
|
||||||
[HttpDelete("{id}")]
|
[HttpDelete("{id}")]
|
||||||
[ProducesResponseType(Status200OK)]
|
[ProducesResponseType(Status200OK)]
|
||||||
[ProducesResponseType(Status404NotFound)]
|
[ProducesResponseType(Status404NotFound)]
|
||||||
[ProducesResponseType(Status500InternalServerError)]
|
[ProducesResponseType<string>(Status500InternalServerError)]
|
||||||
public IActionResult DeleteManga(string id)
|
public IActionResult DeleteManga(string id)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Manga? ret = context.Manga.Find(id);
|
Manga? ret = context.Manga.Find(id);
|
||||||
switch (ret is not null)
|
if (ret is null)
|
||||||
{
|
return NotFound();
|
||||||
case true:
|
|
||||||
context.Remove(ret);
|
context.Remove(ret);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return Ok();
|
return Ok();
|
||||||
case false: return NotFound();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -87,28 +86,29 @@ public class MangaController(PgsqlContext context) : Controller
|
|||||||
/// Returns URL of Cover of Manga
|
/// Returns URL of Cover of Manga
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">Manga-ID</param>
|
/// <param name="id">Manga-ID</param>
|
||||||
/// <returns>URL of Cover</returns>
|
/// <remarks>NOT IMPLEMENTED</remarks>
|
||||||
[HttpGet("{id}/Cover")]
|
[HttpGet("{id}/Cover")]
|
||||||
[ProducesResponseType<string>(Status500InternalServerError)]
|
|
||||||
public IActionResult GetCover(string id)
|
public IActionResult GetCover(string id)
|
||||||
{
|
{
|
||||||
return StatusCode(500, "Not implemented"); //TODO
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns all Chapters of Manga
|
/// Returns all Chapters of Manga
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">Manga-ID</param>
|
/// <param name="id">Manga-ID</param>
|
||||||
/// <returns>Array of Chapters</returns>
|
/// <response code="200"></response>
|
||||||
|
/// <response code="404">Manga with ID not found</response>
|
||||||
[HttpGet("{id}/Chapters")]
|
[HttpGet("{id}/Chapters")]
|
||||||
[ProducesResponseType<Chapter[]>(Status200OK)]
|
[ProducesResponseType<Chapter[]>(Status200OK)]
|
||||||
[ProducesResponseType<string>(Status404NotFound)]
|
[ProducesResponseType(Status404NotFound)]
|
||||||
public IActionResult GetChapters(string id)
|
public IActionResult GetChapters(string id)
|
||||||
{
|
{
|
||||||
Manga? m = context.Manga.Find(id);
|
Manga? m = context.Manga.Find(id);
|
||||||
if (m is null)
|
if (m is null)
|
||||||
return NotFound("Manga could not be found");
|
return NotFound();
|
||||||
Chapter[] ret = context.Chapters.Where(c => c.ParentManga.MangaId == m.MangaId).ToArray();
|
|
||||||
|
Chapter[] ret = context.Chapters.Where(c => c.ParentMangaId == m.MangaId).ToArray();
|
||||||
return Ok(ret);
|
return Ok(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,35 +116,46 @@ public class MangaController(PgsqlContext context) : Controller
|
|||||||
/// Returns the latest Chapter of requested Manga
|
/// Returns the latest Chapter of requested Manga
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">Manga-ID</param>
|
/// <param name="id">Manga-ID</param>
|
||||||
/// <returns>Latest Chapter</returns>
|
/// <response code="200"></response>
|
||||||
|
/// <response code="204">No available chapters</response>
|
||||||
|
/// <response code="404">Manga with ID not found.</response>
|
||||||
|
/// <response code="500">Could not retrieve the maximum chapter-number</response>
|
||||||
[HttpGet("{id}/Chapter/Latest")]
|
[HttpGet("{id}/Chapter/Latest")]
|
||||||
[ProducesResponseType<Chapter>(Status200OK)]
|
[ProducesResponseType<Chapter>(Status200OK)]
|
||||||
[ProducesResponseType<string>(Status404NotFound)]
|
[ProducesResponseType(Status204NoContent)]
|
||||||
|
[ProducesResponseType(Status404NotFound)]
|
||||||
|
[ProducesResponseType<string>(Status500InternalServerError)]
|
||||||
public IActionResult GetLatestChapter(string id)
|
public IActionResult GetLatestChapter(string id)
|
||||||
{
|
{
|
||||||
Manga? m = context.Manga.Find(id);
|
Manga? m = context.Manga.Find(id);
|
||||||
if (m is null)
|
if (m is null)
|
||||||
return NotFound("Manga could not be found");
|
return NotFound();
|
||||||
List<Chapter> chapters = context.Chapters.Where(c => c.ParentManga.MangaId == m.MangaId).ToList();
|
|
||||||
|
List<Chapter> chapters = context.Chapters.Where(c => c.ParentMangaId == m.MangaId).ToList();
|
||||||
|
if (chapters.Count == 0)
|
||||||
|
return NoContent();
|
||||||
|
|
||||||
Chapter? max = chapters.Max();
|
Chapter? max = chapters.Max();
|
||||||
if (max is null)
|
if (max is null)
|
||||||
return NotFound("Chapter could not be found");
|
return StatusCode(500, "Max chapter could not be found");
|
||||||
|
|
||||||
return Ok(max);
|
return Ok(max);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Configure the cut-off for Manga
|
/// Configure the cut-off for Manga
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>This is important for the DownloadNewChapters-Job</remarks>
|
|
||||||
/// <param name="id">Manga-ID</param>
|
/// <param name="id">Manga-ID</param>
|
||||||
/// <returns>Nothing</returns>
|
/// <response code="200"></response>
|
||||||
|
/// <response code="404">Manga with ID not found.</response>
|
||||||
[HttpPatch("{id}/IgnoreChaptersBefore")]
|
[HttpPatch("{id}/IgnoreChaptersBefore")]
|
||||||
[ProducesResponseType<float>(Status200OK)]
|
[ProducesResponseType<float>(Status200OK)]
|
||||||
|
[ProducesResponseType(Status404NotFound)]
|
||||||
public IActionResult IgnoreChaptersBefore(string id)
|
public IActionResult IgnoreChaptersBefore(string id)
|
||||||
{
|
{
|
||||||
Manga? m = context.Manga.Find(id);
|
Manga? m = context.Manga.Find(id);
|
||||||
if (m is null)
|
if (m is null)
|
||||||
return NotFound("Manga could not be found");
|
return NotFound();
|
||||||
return Ok(m.IgnoreChapterBefore);
|
return Ok(m.IgnoreChapterBefore);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,11 +164,10 @@ public class MangaController(PgsqlContext context) : Controller
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">Manga-ID</param>
|
/// <param name="id">Manga-ID</param>
|
||||||
/// <param name="folder">New Directory-Path</param>
|
/// <param name="folder">New Directory-Path</param>
|
||||||
/// <returns>Nothing</returns>
|
/// <remarks>NOT IMPLEMENTED</remarks>
|
||||||
[HttpPost("{id}/MoveFolder")]
|
[HttpPost("{id}/MoveFolder")]
|
||||||
[ProducesResponseType<string>(Status500InternalServerError)]
|
|
||||||
public IActionResult MoveFolder(string id, [FromBody]string folder)
|
public IActionResult MoveFolder(string id, [FromBody]string folder)
|
||||||
{
|
{
|
||||||
return StatusCode(500, "Not implemented"); //TODO
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,7 +15,7 @@ public class NotificationConnectorController(PgsqlContext context) : Controller
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets all configured Notification-Connectors
|
/// Gets all configured Notification-Connectors
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Array of configured Notification-Connectors</returns>
|
/// <response code="200"></response>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[ProducesResponseType<NotificationConnector[]>(Status200OK)]
|
[ProducesResponseType<NotificationConnector[]>(Status200OK)]
|
||||||
public IActionResult GetAllConnectors()
|
public IActionResult GetAllConnectors()
|
||||||
@ -28,7 +28,8 @@ public class NotificationConnectorController(PgsqlContext context) : Controller
|
|||||||
/// Returns Notification-Connector with requested ID
|
/// Returns Notification-Connector with requested ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">Notification-Connector-ID</param>
|
/// <param name="id">Notification-Connector-ID</param>
|
||||||
/// <returns>Notification-Connector</returns>
|
/// <response code="200"></response>
|
||||||
|
/// <response code="404">NotificationConnector with ID not found</response>
|
||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
[ProducesResponseType<NotificationConnector>(Status200OK)]
|
[ProducesResponseType<NotificationConnector>(Status200OK)]
|
||||||
[ProducesResponseType(Status404NotFound)]
|
[ProducesResponseType(Status404NotFound)]
|
||||||
@ -46,7 +47,8 @@ public class NotificationConnectorController(PgsqlContext context) : Controller
|
|||||||
/// Creates a new Notification-Connector
|
/// Creates a new Notification-Connector
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="notificationConnector">Notification-Connector</param>
|
/// <param name="notificationConnector">Notification-Connector</param>
|
||||||
/// <returns>Nothing</returns>
|
/// <response code="201"></response>
|
||||||
|
/// <response code="500">Error during Database Operation</response>
|
||||||
[HttpPut]
|
[HttpPut]
|
||||||
[ProducesResponseType<NotificationConnector[]>(Status200OK)]
|
[ProducesResponseType<NotificationConnector[]>(Status200OK)]
|
||||||
[ProducesResponseType<string>(Status500InternalServerError)]
|
[ProducesResponseType<string>(Status500InternalServerError)]
|
||||||
@ -68,7 +70,9 @@ public class NotificationConnectorController(PgsqlContext context) : Controller
|
|||||||
/// Deletes the Notification-Connector with the requested ID
|
/// Deletes the Notification-Connector with the requested ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">Notification-Connector-ID</param>
|
/// <param name="id">Notification-Connector-ID</param>
|
||||||
/// <returns>Nothing</returns>
|
/// <response code="200"></response>
|
||||||
|
/// <response code="404">NotificationConnector with ID not found</response>
|
||||||
|
/// <response code="500">Error during Database Operation</response>
|
||||||
[HttpDelete("{id}")]
|
[HttpDelete("{id}")]
|
||||||
[ProducesResponseType(Status200OK)]
|
[ProducesResponseType(Status200OK)]
|
||||||
[ProducesResponseType(Status404NotFound)]
|
[ProducesResponseType(Status404NotFound)]
|
||||||
@ -78,14 +82,12 @@ public class NotificationConnectorController(PgsqlContext context) : Controller
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
NotificationConnector? ret = context.NotificationConnectors.Find(id);
|
NotificationConnector? ret = context.NotificationConnectors.Find(id);
|
||||||
switch (ret is not null)
|
if(ret is null)
|
||||||
{
|
return NotFound();
|
||||||
case true:
|
|
||||||
context.Remove(ret);
|
context.Remove(ret);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return Ok();
|
return Ok();
|
||||||
case false: return NotFound();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -18,14 +18,17 @@ public class SearchController(PgsqlContext context) : Controller
|
|||||||
/// Initiate a search for a Manga on all Connectors
|
/// Initiate a search for a Manga on all Connectors
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">Name/Title of the Manga</param>
|
/// <param name="name">Name/Title of the Manga</param>
|
||||||
/// <returns>Array of Manga</returns>
|
/// <response code="200"></response>
|
||||||
|
/// <response code="500">Error during Database Operation</response>
|
||||||
[HttpPost("{name}")]
|
[HttpPost("{name}")]
|
||||||
[ProducesResponseType<Manga[]>(Status500InternalServerError)]
|
[ProducesResponseType<Manga[]>(Status200OK)]
|
||||||
|
[ProducesResponseType<string>(Status500InternalServerError)]
|
||||||
public IActionResult SearchMangaGlobal(string name)
|
public IActionResult SearchMangaGlobal(string name)
|
||||||
{
|
{
|
||||||
List<(Manga, List<Author>?, List<MangaTag>?, List<Link>?, List<MangaAltTitle>?)> allManga = new();
|
List<(Manga, List<Author>?, List<MangaTag>?, List<Link>?, List<MangaAltTitle>?)> allManga = new();
|
||||||
foreach (MangaConnector contextMangaConnector in context.MangaConnectors)
|
foreach (MangaConnector contextMangaConnector in context.MangaConnectors)
|
||||||
allManga.AddRange(contextMangaConnector.GetManga(name));
|
allManga.AddRange(contextMangaConnector.GetManga(name));
|
||||||
|
|
||||||
List<Manga> retMangas = new();
|
List<Manga> retMangas = new();
|
||||||
foreach ((Manga? manga, List<Author>? authors, List<MangaTag>? tags, List<Link>? links, List<MangaAltTitle>? altTitles) in allManga)
|
foreach ((Manga? manga, List<Author>? authors, List<MangaTag>? tags, List<Link>? links, List<MangaAltTitle>? altTitles) in allManga)
|
||||||
{
|
{
|
||||||
@ -35,9 +38,9 @@ public class SearchController(PgsqlContext context) : Controller
|
|||||||
if(add is not null)
|
if(add is not null)
|
||||||
retMangas.Add(add);
|
retMangas.Add(add);
|
||||||
}
|
}
|
||||||
catch (DbUpdateException)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
return StatusCode(500, new ProblemResponse("An error occurred while processing your request."));
|
return StatusCode(500, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Ok(retMangas.ToArray());
|
return Ok(retMangas.ToArray());
|
||||||
@ -48,16 +51,23 @@ public class SearchController(PgsqlContext context) : Controller
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">Manga-Connector-ID</param>
|
/// <param name="id">Manga-Connector-ID</param>
|
||||||
/// <param name="name">Name/Title of the Manga</param>
|
/// <param name="name">Name/Title of the Manga</param>
|
||||||
/// <returns>Manga</returns>
|
/// <response code="200"></response>
|
||||||
|
/// <response code="404">MangaConnector with ID not found</response>
|
||||||
|
/// <response code="406">MangaConnector with ID is disabled</response>
|
||||||
|
/// <response code="500">Error during Database Operation</response>
|
||||||
[HttpPost("{id}/{name}")]
|
[HttpPost("{id}/{name}")]
|
||||||
[ProducesResponseType<Manga[]>(Status200OK)]
|
[ProducesResponseType<Manga[]>(Status200OK)]
|
||||||
[ProducesResponseType<ProblemResponse>(Status404NotFound)]
|
[ProducesResponseType(Status404NotFound)]
|
||||||
[ProducesResponseType<ProblemResponse>(Status500InternalServerError)]
|
[ProducesResponseType(Status406NotAcceptable)]
|
||||||
|
[ProducesResponseType<string>(Status500InternalServerError)]
|
||||||
public IActionResult SearchManga(string id, string name)
|
public IActionResult SearchManga(string id, string name)
|
||||||
{
|
{
|
||||||
MangaConnector? connector = context.MangaConnectors.Find(id);
|
MangaConnector? connector = context.MangaConnectors.Find(id);
|
||||||
if (connector is null)
|
if (connector is null)
|
||||||
return NotFound(new ProblemResponse("Connector not found."));
|
return NotFound();
|
||||||
|
else if (connector.Enabled is false)
|
||||||
|
return StatusCode(406);
|
||||||
|
|
||||||
(Manga, List<Author>?, List<MangaTag>?, List<Link>?, List<MangaAltTitle>?)[] mangas = connector.GetManga(name);
|
(Manga, List<Author>?, List<MangaTag>?, List<Link>?, List<MangaAltTitle>?)[] mangas = connector.GetManga(name);
|
||||||
List<Manga> retMangas = new();
|
List<Manga> retMangas = new();
|
||||||
foreach ((Manga? manga, List<Author>? authors, List<MangaTag>? tags, List<Link>? links, List<MangaAltTitle>? altTitles) in mangas)
|
foreach ((Manga? manga, List<Author>? authors, List<MangaTag>? tags, List<Link>? links, List<MangaAltTitle>? altTitles) in mangas)
|
||||||
@ -68,15 +78,15 @@ public class SearchController(PgsqlContext context) : Controller
|
|||||||
if(add is not null)
|
if(add is not null)
|
||||||
retMangas.Add(add);
|
retMangas.Add(add);
|
||||||
}
|
}
|
||||||
catch (DbUpdateException e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
return StatusCode(500, new ProblemResponse("An error occurred while processing your request.", e.Message));
|
return StatusCode(500, e.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(retMangas.ToArray());
|
return Ok(retMangas.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Manga? AddMangaToContext(Manga? manga, List<Author>? authors, List<MangaTag>? tags, List<Link>? links,
|
private Manga? AddMangaToContext(Manga? manga, List<Author>? authors, List<MangaTag>? tags, List<Link>? links,
|
||||||
List<MangaAltTitle>? altTitles)
|
List<MangaAltTitle>? altTitles)
|
||||||
{
|
{
|
||||||
@ -144,7 +154,7 @@ public class SearchController(PgsqlContext context) : Controller
|
|||||||
context.Manga.Update(existing);
|
context.Manga.Update(existing);
|
||||||
else
|
else
|
||||||
context.Manga.Add(manga);
|
context.Manga.Add(manga);
|
||||||
|
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return existing ?? manga;
|
return existing ?? manga;
|
||||||
}
|
}
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
namespace API;
|
|
||||||
|
|
||||||
public record ProblemResponse(string title, string? message = null);
|
|
@ -118,7 +118,7 @@ public static class TrangaSettings
|
|||||||
ExportSettings();
|
ExportSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ResetRateLimits()
|
public static void ResetRequestLimits()
|
||||||
{
|
{
|
||||||
requestLimits = DefaultRequestLimits;
|
requestLimits = DefaultRequestLimits;
|
||||||
ExportSettings();
|
ExportSettings();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user