mirror of
https://github.com/C9Glax/tranga.git
synced 2025-04-15 12:53:17 +02:00
Types return only Ids of related Entities
This commit is contained in:
parent
4cb48dd1b4
commit
6909c367e5
@ -2,6 +2,7 @@
|
|||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using API.Schema.Jobs;
|
using API.Schema.Jobs;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace API.Schema;
|
namespace API.Schema;
|
||||||
|
|
||||||
@ -38,6 +39,7 @@ public class Chapter : IComparable<Chapter>
|
|||||||
public bool Downloaded { get; internal set; } = false;
|
public bool Downloaded { get; internal set; } = false;
|
||||||
|
|
||||||
public string ParentMangaId { get; internal set; }
|
public string ParentMangaId { get; internal set; }
|
||||||
|
[JsonIgnore]
|
||||||
public Manga? ParentManga { get; init; }
|
public Manga? ParentManga { get; init; }
|
||||||
|
|
||||||
public int CompareTo(Chapter? other)
|
public int CompareTo(Chapter? other)
|
||||||
|
@ -3,6 +3,7 @@ using System.IO.Compression;
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using API.MangaDownloadClients;
|
using API.MangaDownloadClients;
|
||||||
using API.Schema.MangaConnectors;
|
using API.Schema.MangaConnectors;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using SixLabors.ImageSharp;
|
using SixLabors.ImageSharp;
|
||||||
using SixLabors.ImageSharp.Formats.Jpeg;
|
using SixLabors.ImageSharp.Formats.Jpeg;
|
||||||
using SixLabors.ImageSharp.Processing;
|
using SixLabors.ImageSharp.Processing;
|
||||||
@ -16,6 +17,7 @@ public class DownloadMangaCoverJob(string mangaId, string? parentJobId = null, I
|
|||||||
{
|
{
|
||||||
[MaxLength(64)]
|
[MaxLength(64)]
|
||||||
public string MangaId { get; init; } = mangaId;
|
public string MangaId { get; init; } = mangaId;
|
||||||
|
[JsonIgnore]
|
||||||
public Manga? Manga { get; init; }
|
public Manga? Manga { get; init; }
|
||||||
|
|
||||||
protected override IEnumerable<Job> RunInternal(PgsqlContext context)
|
protected override IEnumerable<Job> RunInternal(PgsqlContext context)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using API.Schema.MangaConnectors;
|
using API.Schema.MangaConnectors;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace API.Schema.Jobs;
|
namespace API.Schema.Jobs;
|
||||||
|
|
||||||
@ -8,6 +9,8 @@ public class DownloadNewChaptersJob(ulong recurrenceMs, string mangaId, string?
|
|||||||
{
|
{
|
||||||
[MaxLength(64)]
|
[MaxLength(64)]
|
||||||
public string MangaId { get; init; } = mangaId;
|
public string MangaId { get; init; } = mangaId;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public Manga? Manga { get; init; }
|
public Manga? Manga { get; init; }
|
||||||
|
|
||||||
protected override IEnumerable<Job> RunInternal(PgsqlContext context)
|
protected override IEnumerable<Job> RunInternal(PgsqlContext context)
|
||||||
|
@ -3,6 +3,7 @@ using System.IO.Compression;
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using API.MangaDownloadClients;
|
using API.MangaDownloadClients;
|
||||||
using API.Schema.MangaConnectors;
|
using API.Schema.MangaConnectors;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using SixLabors.ImageSharp;
|
using SixLabors.ImageSharp;
|
||||||
using SixLabors.ImageSharp.Formats.Jpeg;
|
using SixLabors.ImageSharp.Formats.Jpeg;
|
||||||
using SixLabors.ImageSharp.Processing;
|
using SixLabors.ImageSharp.Processing;
|
||||||
@ -16,6 +17,8 @@ public class DownloadSingleChapterJob(string chapterId, string? parentJobId = nu
|
|||||||
{
|
{
|
||||||
[MaxLength(64)]
|
[MaxLength(64)]
|
||||||
public string ChapterId { get; init; } = chapterId;
|
public string ChapterId { get; init; } = chapterId;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public Chapter? Chapter { get; init; }
|
public Chapter? Chapter { get; init; }
|
||||||
|
|
||||||
protected override IEnumerable<Job> RunInternal(PgsqlContext context)
|
protected override IEnumerable<Job> RunInternal(PgsqlContext context)
|
||||||
|
@ -13,10 +13,12 @@ public abstract class Job
|
|||||||
|
|
||||||
[MaxLength(64)]
|
[MaxLength(64)]
|
||||||
public string? ParentJobId { get; init; }
|
public string? ParentJobId { get; init; }
|
||||||
|
[JsonIgnore]
|
||||||
public Job? ParentJob { get; init; }
|
public Job? ParentJob { get; init; }
|
||||||
|
|
||||||
[MaxLength(64)]
|
[MaxLength(64)]
|
||||||
public ICollection<string>? DependsOnJobsIds { get; init; }
|
public ICollection<string>? DependsOnJobsIds { get; init; }
|
||||||
|
[JsonIgnore]
|
||||||
public ICollection<Job>? DependsOnJobs { get; init; }
|
public ICollection<Job>? DependsOnJobs { get; init; }
|
||||||
|
|
||||||
public JobType JobType { get; init; }
|
public JobType JobType { get; init; }
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using JsonSerializer = Newtonsoft.Json.JsonSerializer;
|
|
||||||
|
|
||||||
namespace API.Schema.Jobs;
|
|
||||||
|
|
||||||
public class JobJsonDeserializer : JsonConverter<Job>
|
|
||||||
{
|
|
||||||
public override bool CanWrite { get; } = false;
|
|
||||||
|
|
||||||
public override void WriteJson(JsonWriter writer, Job? value, JsonSerializer serializer)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Job? ReadJson(JsonReader reader, Type objectType, Job? existingValue, bool hasExistingValue, JsonSerializer serializer)
|
|
||||||
{
|
|
||||||
JObject j = JObject.Load(reader);
|
|
||||||
JobType? type = Enum.Parse<JobType>(j.GetValue("jobType")!.Value<string>()!);
|
|
||||||
return type switch
|
|
||||||
{
|
|
||||||
JobType.DownloadSingleChapterJob => j.ToObject<DownloadSingleChapterJob>(),
|
|
||||||
JobType.DownloadNewChaptersJob => j.ToObject<DownloadNewChaptersJob>(),
|
|
||||||
JobType.UpdateMetaDataJob => j.ToObject<UpdateMetadataJob>(),
|
|
||||||
JobType.MoveFileOrFolderJob => j.ToObject<MoveFileOrFolderJob>(),
|
|
||||||
_ => null
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +1,6 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using API.Schema.MangaConnectors;
|
using API.Schema.MangaConnectors;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace API.Schema.Jobs;
|
namespace API.Schema.Jobs;
|
||||||
|
|
||||||
@ -8,6 +9,8 @@ public class UpdateMetadataJob(ulong recurrenceMs, string mangaId, string? paren
|
|||||||
{
|
{
|
||||||
[MaxLength(64)]
|
[MaxLength(64)]
|
||||||
public string MangaId { get; init; } = mangaId;
|
public string MangaId { get; init; } = mangaId;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public virtual Manga? Manga { get; init; }
|
public virtual Manga? Manga { get; init; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using System.Collections;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
@ -6,6 +7,7 @@ using API.MangaDownloadClients;
|
|||||||
using API.Schema.Jobs;
|
using API.Schema.Jobs;
|
||||||
using API.Schema.MangaConnectors;
|
using API.Schema.MangaConnectors;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using static System.IO.UnixFileMode;
|
using static System.IO.UnixFileMode;
|
||||||
|
|
||||||
namespace API.Schema;
|
namespace API.Schema;
|
||||||
@ -30,15 +32,23 @@ public class Manga
|
|||||||
public float IgnoreChapterBefore { get; internal set; }
|
public float IgnoreChapterBefore { get; internal set; }
|
||||||
|
|
||||||
public string MangaConnectorId { get; private set; }
|
public string MangaConnectorId { get; private set; }
|
||||||
|
[JsonIgnore]
|
||||||
public MangaConnector? MangaConnector { get; private set; }
|
public MangaConnector? MangaConnector { get; private set; }
|
||||||
|
|
||||||
|
public ICollection<string> AuthorIds { get; internal set; }
|
||||||
|
[JsonIgnore]
|
||||||
public ICollection<Author>? Authors { get; internal set; }
|
public ICollection<Author>? Authors { get; internal set; }
|
||||||
|
|
||||||
|
public ICollection<string> TagIds { get; internal set; }
|
||||||
|
[JsonIgnore]
|
||||||
public ICollection<MangaTag>? Tags { get; internal set; }
|
public ICollection<MangaTag>? Tags { get; internal set; }
|
||||||
|
|
||||||
|
public ICollection<string> LinkIds { get; internal set; }
|
||||||
|
[JsonIgnore]
|
||||||
public ICollection<Link>? Links { get; internal set; }
|
public ICollection<Link>? Links { get; internal set; }
|
||||||
|
|
||||||
|
public ICollection<string> AltTitleIds { get; internal set; }
|
||||||
|
[JsonIgnore]
|
||||||
public ICollection<MangaAltTitle>? AltTitles { get; internal set; }
|
public ICollection<MangaAltTitle>? AltTitles { get; internal set; }
|
||||||
|
|
||||||
public Manga(string connectorId, string name, string description, string websiteUrl, string coverUrl,
|
public Manga(string connectorId, string name, string description, string websiteUrl, string coverUrl,
|
||||||
@ -48,9 +58,13 @@ public class Manga
|
|||||||
: this(connectorId, name, description, websiteUrl, coverUrl, coverFileNameInCache, year, originalLanguage,
|
: this(connectorId, name, description, websiteUrl, coverUrl, coverFileNameInCache, year, originalLanguage,
|
||||||
releaseStatus, ignoreChapterBefore, mangaConnector.Name)
|
releaseStatus, ignoreChapterBefore, mangaConnector.Name)
|
||||||
{
|
{
|
||||||
|
this.AuthorIds = authors.Select(a => a.AuthorId) as ICollection<string>;
|
||||||
this.Authors = authors;
|
this.Authors = authors;
|
||||||
|
this.TagIds = tags.Select(t => t.Tag) as ICollection<string>;
|
||||||
this.Tags = tags;
|
this.Tags = tags;
|
||||||
|
this.LinkIds = links.Select(l => l.LinkId) as ICollection<string>;
|
||||||
this.Links = links;
|
this.Links = links;
|
||||||
|
this.AltTitleIds = altTitles.Select(t => t.AltTitleId) as ICollection<string>;
|
||||||
this.AltTitles = altTitles;
|
this.AltTitles = altTitles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user