mirror of
https://github.com/C9Glax/tranga.git
synced 2025-06-12 22:47:52 +02:00
Remove APISerializable and APIJsonSerializer
This commit is contained in:
@ -1,3 +0,0 @@
|
||||
namespace API.Schema;
|
||||
|
||||
public interface APISerializable;
|
@ -1,5 +1,4 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace API.Schema;
|
||||
|
@ -6,7 +6,7 @@ using Newtonsoft.Json;
|
||||
namespace API.Schema.Jobs;
|
||||
|
||||
[PrimaryKey("JobId")]
|
||||
public abstract class Job : APISerializable
|
||||
public abstract class Job
|
||||
{
|
||||
[MaxLength(64)]
|
||||
public string JobId { get; init; }
|
||||
|
@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore;
|
||||
namespace API.Schema.LibraryConnectors;
|
||||
|
||||
[PrimaryKey("LibraryConnectorId")]
|
||||
public abstract class LibraryConnector(string libraryConnectorId, LibraryType libraryType, string baseUrl, string auth) : APISerializable
|
||||
public abstract class LibraryConnector(string libraryConnectorId, LibraryType libraryType, string baseUrl, string auth)
|
||||
{
|
||||
[MaxLength(64)]
|
||||
public string LibraryConnectorId { get; } = libraryConnectorId;
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace API.Schema;
|
||||
@ -11,7 +10,4 @@ public class Link(string linkProvider, string linkUrl)
|
||||
public string LinkId { get; init; } = TokenGen.CreateToken(typeof(Link), 64);
|
||||
public string LinkProvider { get; init; } = linkProvider;
|
||||
public string LinkUrl { get; init; } = linkUrl;
|
||||
|
||||
[ForeignKey("MangaId")]
|
||||
public virtual Manga Manga { get; init; }
|
||||
}
|
@ -70,9 +70,6 @@ public class Manga(
|
||||
public string[] AltTitleIds { get; internal set; } = altTitleIds;
|
||||
[ForeignKey("AltTitleIds")]
|
||||
public virtual MangaAltTitle[] AltTitles { get; }
|
||||
|
||||
[ForeignKey("ChapterIds")]
|
||||
public virtual Chapter[] Chapters { get; internal set; }
|
||||
|
||||
public MoveFileOrFolderJob UpdateFolderName(string downloadLocation, string newName)
|
||||
{
|
||||
|
@ -12,7 +12,4 @@ public class MangaAltTitle(string language, string title)
|
||||
[MaxLength(8)]
|
||||
public string Language { get; init; } = language;
|
||||
public string Title { get; set; } = title;
|
||||
|
||||
[ForeignKey("MangaId")]
|
||||
public virtual Manga Manga { get; init; }
|
||||
}
|
@ -13,11 +13,6 @@ public abstract class MangaConnector(string name, string[] supportedLanguages, s
|
||||
public string Name { get; init; } = name;
|
||||
public string[] SupportedLanguages { get; init; } = supportedLanguages;
|
||||
public string[] BaseUris { get; init; } = baseUris;
|
||||
|
||||
[JsonIgnore]
|
||||
[ForeignKey("MangaIds")]
|
||||
public virtual Manga[] Mangas { get; internal set; } = [];
|
||||
|
||||
|
||||
public abstract (Manga, Author[], MangaTag[], Link[], MangaAltTitle[])[] GetManga(string publicationTitle = "");
|
||||
|
||||
|
@ -7,7 +7,4 @@ namespace API.Schema;
|
||||
public class MangaTag(string tag)
|
||||
{
|
||||
public string Tag { get; init; } = tag;
|
||||
|
||||
[ForeignKey("MangaIds")]
|
||||
public virtual Manga[] Mangas { get; internal set; } = [];
|
||||
}
|
@ -6,7 +6,7 @@ using Newtonsoft.Json;
|
||||
namespace API.Schema.NotificationConnectors;
|
||||
|
||||
[PrimaryKey("NotificationConnectorId")]
|
||||
public abstract class NotificationConnector(string notificationConnectorId, NotificationConnectorType notificationConnectorType) : APISerializable
|
||||
public abstract class NotificationConnector(string notificationConnectorId, NotificationConnectorType notificationConnectorType)
|
||||
{
|
||||
[MaxLength(64)]
|
||||
public string NotificationConnectorId { get; } = notificationConnectorId;
|
||||
|
@ -52,9 +52,7 @@ public class PgsqlContext(DbContextOptions<PgsqlContext> options) : DbContext(op
|
||||
.HasValue<UpdateMetadataJob>(JobType.UpdateMetaDataJob);
|
||||
|
||||
modelBuilder.Entity<Chapter>()
|
||||
.HasOne<Manga>(c => c.ParentManga)
|
||||
.WithMany(m => m.Chapters)
|
||||
.HasForeignKey(c => c.ParentMangaId);
|
||||
.HasOne<Manga>(c => c.ParentManga);
|
||||
|
||||
modelBuilder.Entity<Manga>()
|
||||
.HasOne<Chapter>(m => m.LatestChapterAvailable)
|
||||
@ -63,30 +61,14 @@ public class PgsqlContext(DbContextOptions<PgsqlContext> options) : DbContext(op
|
||||
.HasOne<Chapter>(m => m.LatestChapterDownloaded)
|
||||
.WithOne();
|
||||
modelBuilder.Entity<Manga>()
|
||||
.HasOne<MangaConnector>(m => m.MangaConnector)
|
||||
.WithMany(c => c.Mangas)
|
||||
.HasForeignKey(m => m.MangaConnectorName);
|
||||
.HasOne<MangaConnector>(m => m.MangaConnector);
|
||||
modelBuilder.Entity<Manga>()
|
||||
.HasMany<Author>(m => m.Authors)
|
||||
.WithMany(a => a.Mangas)
|
||||
.UsingEntity(
|
||||
"MangaAuthor",
|
||||
l => l.HasOne(typeof(Manga)).WithMany().HasForeignKey("MangaId").HasPrincipalKey("MangaId"),
|
||||
r => r.HasOne(typeof(Author)).WithMany().HasForeignKey("AuthorId").HasPrincipalKey("AuthorId"),
|
||||
j => j.HasKey("MangaId", "AuthorId"));
|
||||
.HasMany<Author>(m => m.Authors);
|
||||
modelBuilder.Entity<Manga>()
|
||||
.HasMany<MangaTag>(m => m.Tags)
|
||||
.WithMany(t => t.Mangas)
|
||||
.UsingEntity(
|
||||
"MangaTag",
|
||||
l => l.HasOne(typeof(Manga)).WithMany().HasForeignKey("MangaId").HasPrincipalKey("MangaId"),
|
||||
r => r.HasOne(typeof(MangaTag)).WithMany().HasForeignKey("Tag").HasPrincipalKey("Tag"),
|
||||
j => j.HasKey("MangaId", "Tag"));
|
||||
.HasMany<MangaTag>(m => m.Tags);
|
||||
modelBuilder.Entity<Manga>()
|
||||
.HasMany<Link>(m => m.Links)
|
||||
.WithOne(c => c.Manga);
|
||||
.HasMany<Link>(m => m.Links);
|
||||
modelBuilder.Entity<Manga>()
|
||||
.HasMany<MangaAltTitle>(m => m.AltTitles)
|
||||
.WithOne(c => c.Manga);
|
||||
.HasMany<MangaAltTitle>(m => m.AltTitles);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user