mirror of
https://github.com/C9Glax/tranga.git
synced 2025-06-12 22:47:52 +02:00
Fix annotations
This commit is contained in:
@ -6,7 +6,10 @@ namespace API.Schema;
|
||||
[PrimaryKey("AuthorId")]
|
||||
public class Author(string authorName)
|
||||
{
|
||||
[MaxLength(64)]
|
||||
[StringLength(64)]
|
||||
[Required]
|
||||
public string AuthorId { get; init; } = TokenGen.CreateToken(typeof(Author), authorName);
|
||||
[StringLength(128)]
|
||||
[Required]
|
||||
public string AuthorName { get; init; } = authorName;
|
||||
}
|
@ -27,19 +27,30 @@ public class Chapter : IComparable<Chapter>
|
||||
Title = title;
|
||||
}
|
||||
|
||||
[MaxLength(64)] public string ChapterId { get; init; }
|
||||
|
||||
[StringLength(64)]
|
||||
[Required]
|
||||
public string ChapterId { get; init; }
|
||||
public int? VolumeNumber { get; private set; }
|
||||
[StringLength(10)]
|
||||
[Required]
|
||||
public string ChapterNumber { get; private set; }
|
||||
|
||||
[MaxLength(10)] public string ChapterNumber { get; private set; }
|
||||
|
||||
[StringLength(256)]
|
||||
[Required]
|
||||
[Url]
|
||||
public string Url { get; internal set; }
|
||||
[StringLength(256)]
|
||||
public string? Title { get; private set; }
|
||||
[StringLength(256)]
|
||||
[Required]
|
||||
public string ArchiveFileName { get; private set; }
|
||||
[Required]
|
||||
public bool Downloaded { get; internal set; } = false;
|
||||
|
||||
[Required]
|
||||
[StringLength(64)]
|
||||
public string ParentMangaId { get; internal set; }
|
||||
[JsonIgnore] public Manga? ParentManga { get; init; }
|
||||
[JsonIgnore]
|
||||
public Manga? ParentManga { get; init; }
|
||||
|
||||
public int CompareTo(Chapter? other)
|
||||
{
|
||||
|
@ -8,26 +8,31 @@ namespace API.Schema.Jobs;
|
||||
[PrimaryKey("JobId")]
|
||||
public abstract class Job
|
||||
{
|
||||
[MaxLength(64)]
|
||||
[StringLength(64)]
|
||||
[Required]
|
||||
public string JobId { get; init; }
|
||||
|
||||
[MaxLength(64)]
|
||||
[StringLength(64)]
|
||||
public string? ParentJobId { get; init; }
|
||||
[JsonIgnore]
|
||||
public Job? ParentJob { get; init; }
|
||||
|
||||
[MaxLength(64)]
|
||||
[StringLength(64)]
|
||||
public ICollection<string>? DependsOnJobsIds { get; init; }
|
||||
[JsonIgnore]
|
||||
public ICollection<Job>? DependsOnJobs { get; init; }
|
||||
|
||||
[Required]
|
||||
public JobType JobType { get; init; }
|
||||
[Required]
|
||||
public ulong RecurrenceMs { get; set; }
|
||||
[Required]
|
||||
public DateTime LastExecution { get; internal set; } = DateTime.UnixEpoch;
|
||||
|
||||
[NotMapped]
|
||||
[Required]
|
||||
public DateTime NextExecution => LastExecution.AddMilliseconds(RecurrenceMs);
|
||||
[Required]
|
||||
public JobState state { get; internal set; } = JobState.Waiting;
|
||||
[Required]
|
||||
public bool Enabled { get; internal set; } = true;
|
||||
|
||||
public Job(string jobId, JobType jobType, ulong recurrenceMs, Job? parentJob = null, ICollection<Job>? dependsOnJobs = null)
|
||||
|
@ -6,11 +6,18 @@ namespace API.Schema.LibraryConnectors;
|
||||
[PrimaryKey("LibraryConnectorId")]
|
||||
public abstract class LibraryConnector(string libraryConnectorId, LibraryType libraryType, string baseUrl, string auth)
|
||||
{
|
||||
[MaxLength(64)]
|
||||
[StringLength(64)]
|
||||
[Required]
|
||||
public string LibraryConnectorId { get; } = libraryConnectorId;
|
||||
|
||||
[Required]
|
||||
public LibraryType LibraryType { get; init; } = libraryType;
|
||||
[StringLength(256)]
|
||||
[Required]
|
||||
[Url]
|
||||
public string BaseUrl { get; init; } = baseUrl;
|
||||
[StringLength(256)]
|
||||
[Required]
|
||||
public string Auth { get; init; } = auth;
|
||||
|
||||
protected abstract void UpdateLibraryInternal();
|
||||
|
@ -6,9 +6,15 @@ namespace API.Schema;
|
||||
[PrimaryKey("LinkId")]
|
||||
public class Link(string linkProvider, string linkUrl)
|
||||
{
|
||||
[MaxLength(64)]
|
||||
[StringLength(64)]
|
||||
[Required]
|
||||
public string LinkId { get; init; } = TokenGen.CreateToken(typeof(Link), linkProvider, linkUrl);
|
||||
[StringLength(128)]
|
||||
[Required]
|
||||
public string LinkProvider { get; init; } = linkProvider;
|
||||
[StringLength(128)]
|
||||
[Required]
|
||||
[Url]
|
||||
public string LinkUrl { get; init; } = linkUrl;
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
|
@ -1,6 +1,8 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using API.MangaDownloadClients;
|
||||
@ -15,39 +17,66 @@ namespace API.Schema;
|
||||
[PrimaryKey("MangaId")]
|
||||
public class Manga
|
||||
{
|
||||
[MaxLength(64)]
|
||||
[StringLength(64)]
|
||||
[Required]
|
||||
public string MangaId { get; init; }
|
||||
[MaxLength(64)]
|
||||
[StringLength(128)]
|
||||
[Required]
|
||||
public string IdOnConnectorSite { get; init; }
|
||||
|
||||
[StringLength(256)]
|
||||
[Required]
|
||||
public string Name { get; internal set; }
|
||||
[Required]
|
||||
public string Description { get; internal set; }
|
||||
[Url]
|
||||
[StringLength(256)]
|
||||
[Required]
|
||||
public string WebsiteUrl { get; internal set; }
|
||||
[JsonIgnore]
|
||||
[Url]
|
||||
public string CoverUrl { get; internal set; }
|
||||
[JsonIgnore]
|
||||
public string? CoverFileNameInCache { get; internal set; }
|
||||
[Required]
|
||||
public uint Year { get; internal set; }
|
||||
[StringLength(8)]
|
||||
[Required]
|
||||
public string? OriginalLanguage { get; internal set; }
|
||||
[Required]
|
||||
public MangaReleaseStatus ReleaseStatus { get; internal set; }
|
||||
[Required]
|
||||
public string FolderName { get; private set; }
|
||||
[Required]
|
||||
public float IgnoreChapterBefore { get; internal set; }
|
||||
|
||||
[StringLength(64)]
|
||||
[Required]
|
||||
public string MangaConnectorId { get; private set; }
|
||||
[JsonIgnore] public MangaConnector? MangaConnector { get; private set; }
|
||||
|
||||
[JsonIgnore] public ICollection<Author>? Authors { get; internal set; }
|
||||
[NotMapped] public IEnumerable<string> AuthorIds => Authors?.Select(a => a.AuthorId) ?? [];
|
||||
[NotMapped]
|
||||
[StringLength(64)]
|
||||
[Required]
|
||||
public IEnumerable<string> AuthorIds => Authors?.Select(a => a.AuthorId) ?? [];
|
||||
|
||||
[JsonIgnore] public ICollection<MangaTag>? MangaTags { get; internal set; }
|
||||
[NotMapped] public IEnumerable<string> Tags => MangaTags.Select(t => t.Tag);
|
||||
[NotMapped]
|
||||
[StringLength(64)]
|
||||
[Required]
|
||||
public IEnumerable<string> Tags => MangaTags?.Select(t => t.Tag) ?? [];
|
||||
|
||||
|
||||
[JsonIgnore] public ICollection<Link>? Links { get; internal set; }
|
||||
[NotMapped] public IEnumerable<string> LinkIds => Links?.Select(l => l.LinkId) ?? [];
|
||||
[NotMapped]
|
||||
[StringLength(64)]
|
||||
[Required]
|
||||
public IEnumerable<string> LinkIds => Links?.Select(l => l.LinkId) ?? [];
|
||||
|
||||
[JsonIgnore] public ICollection<MangaAltTitle>? AltTitles { get; internal set; }
|
||||
[NotMapped] public IEnumerable<string> AltTitleIds => AltTitles?.Select(a => a.AltTitleId) ?? [];
|
||||
[NotMapped]
|
||||
[StringLength(64)]
|
||||
[Required]
|
||||
public IEnumerable<string> AltTitleIds => AltTitles?.Select(a => a.AltTitleId) ?? [];
|
||||
|
||||
public Manga(string idOnConnectorSite, string name, string description, string websiteUrl, string coverUrl,
|
||||
string? coverFileNameInCache, uint year, string? originalLanguage, MangaReleaseStatus releaseStatus,
|
||||
|
@ -7,9 +7,13 @@ namespace API.Schema;
|
||||
[PrimaryKey("AltTitleId")]
|
||||
public class MangaAltTitle(string language, string title)
|
||||
{
|
||||
[MaxLength(64)]
|
||||
[StringLength(64)]
|
||||
[Required]
|
||||
public string AltTitleId { get; init; } = TokenGen.CreateToken("AltTitle", language, title);
|
||||
[MaxLength(8)]
|
||||
[StringLength(8)]
|
||||
[Required]
|
||||
public string Language { get; init; } = language;
|
||||
[StringLength(256)]
|
||||
[Required]
|
||||
public string Title { get; set; } = title;
|
||||
}
|
@ -10,12 +10,19 @@ namespace API.Schema.MangaConnectors;
|
||||
[PrimaryKey("Name")]
|
||||
public abstract class MangaConnector(string name, string[] supportedLanguages, string[] baseUris, string iconUrl)
|
||||
{
|
||||
[MaxLength(32)]
|
||||
[StringLength(32)]
|
||||
[Required]
|
||||
public string Name { get; init; } = name;
|
||||
[StringLength(8)]
|
||||
[Required]
|
||||
public string[] SupportedLanguages { get; init; } = supportedLanguages;
|
||||
[StringLength(256)]
|
||||
[Required]
|
||||
public string IconUrl { get; init; } = iconUrl;
|
||||
[StringLength(256)]
|
||||
[Required]
|
||||
public string[] BaseUris { get; init; } = baseUris;
|
||||
|
||||
[Required]
|
||||
public bool Enabled { get; internal set; } = true;
|
||||
|
||||
public abstract (Manga, List<Author>?, List<MangaTag>?, List<Link>?, List<MangaAltTitle>?)[] GetManga(string publicationTitle = "");
|
||||
|
@ -1,9 +1,12 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace API.Schema;
|
||||
|
||||
[PrimaryKey("Tag")]
|
||||
public class MangaTag(string tag)
|
||||
{
|
||||
[StringLength(64)]
|
||||
[Required]
|
||||
public string Tag { get; init; } = tag;
|
||||
}
|
@ -6,15 +6,22 @@ namespace API.Schema;
|
||||
[PrimaryKey("NotificationId")]
|
||||
public class Notification(string title, string message = "", NotificationUrgency urgency = NotificationUrgency.Normal, DateTime? date = null)
|
||||
{
|
||||
[MaxLength(64)]
|
||||
[StringLength(64)]
|
||||
[Required]
|
||||
public string NotificationId { get; init; } = TokenGen.CreateToken("Notification");
|
||||
|
||||
[Required]
|
||||
public NotificationUrgency Urgency { get; init; } = urgency;
|
||||
|
||||
[StringLength(128)]
|
||||
[Required]
|
||||
public string Title { get; init; } = title;
|
||||
|
||||
[StringLength(512)]
|
||||
[Required]
|
||||
public string Message { get; init; } = message;
|
||||
|
||||
[Required]
|
||||
public DateTime Date { get; init; } = date ?? DateTime.UtcNow;
|
||||
|
||||
public Notification() : this("") { }
|
||||
|
@ -9,15 +9,24 @@ namespace API.Schema.NotificationConnectors;
|
||||
[PrimaryKey("Name")]
|
||||
public class NotificationConnector(string name, string url, Dictionary<string, string> headers, string httpMethod, string body)
|
||||
{
|
||||
[MaxLength(64)]
|
||||
[StringLength(64)]
|
||||
[Required]
|
||||
public string Name { get; init; } = name;
|
||||
|
||||
[StringLength(256)]
|
||||
[Required]
|
||||
[Url]
|
||||
public string Url { get; internal set; } = url;
|
||||
|
||||
[Required]
|
||||
public Dictionary<string, string> Headers { get; internal set; } = headers;
|
||||
|
||||
[StringLength(8)]
|
||||
[Required]
|
||||
public string HttpMethod { get; internal set; } = httpMethod;
|
||||
|
||||
[StringLength(512)]
|
||||
[Required]
|
||||
public string Body { get; internal set; } = body;
|
||||
|
||||
[JsonIgnore]
|
||||
|
Reference in New Issue
Block a user