Collection Rework (#2830)
This commit is contained in:
parent
0dacc061f1
commit
deaaccb96a
93 changed files with 5413 additions and 1120 deletions
|
|
@ -3,6 +3,7 @@ using System.Linq;
|
|||
using API.Data.Migrations;
|
||||
using API.DTOs;
|
||||
using API.DTOs.Account;
|
||||
using API.DTOs.Collection;
|
||||
using API.DTOs.CollectionTags;
|
||||
using API.DTOs.Dashboard;
|
||||
using API.DTOs.Device;
|
||||
|
|
@ -53,6 +54,8 @@ public class AutoMapperProfiles : Profile
|
|||
CreateMap<Chapter, ChapterDto>();
|
||||
CreateMap<Series, SeriesDto>();
|
||||
CreateMap<CollectionTag, CollectionTagDto>();
|
||||
CreateMap<AppUserCollection, AppUserCollectionDto>()
|
||||
.ForMember(dest => dest.Owner, opt => opt.MapFrom(src => src.AppUser.UserName));
|
||||
CreateMap<Person, PersonDto>();
|
||||
CreateMap<Genre, GenreTagDto>();
|
||||
CreateMap<Tag, TagDto>();
|
||||
|
|
@ -141,10 +144,6 @@ public class AutoMapperProfiles : Profile
|
|||
opt =>
|
||||
opt.MapFrom(
|
||||
src => src.Genres.OrderBy(p => p.NormalizedTitle)))
|
||||
.ForMember(dest => dest.CollectionTags,
|
||||
opt =>
|
||||
opt.MapFrom(
|
||||
src => src.CollectionTags.OrderBy(p => p.NormalizedTitle)))
|
||||
.ForMember(dest => dest.Tags,
|
||||
opt =>
|
||||
opt.MapFrom(
|
||||
|
|
|
|||
72
API/Helpers/Builders/AppUserCollectionBuilder.cs
Normal file
72
API/Helpers/Builders/AppUserCollectionBuilder.cs
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
using System.Collections.Generic;
|
||||
using API.Entities;
|
||||
using API.Entities.Enums;
|
||||
using API.Extensions;
|
||||
using API.Services.Plus;
|
||||
|
||||
namespace API.Helpers.Builders;
|
||||
|
||||
public class AppUserCollectionBuilder : IEntityBuilder<AppUserCollection>
|
||||
{
|
||||
private readonly AppUserCollection _collection;
|
||||
public AppUserCollection Build() => _collection;
|
||||
|
||||
public AppUserCollectionBuilder(string title, bool promoted = false)
|
||||
{
|
||||
title = title.Trim();
|
||||
_collection = new AppUserCollection()
|
||||
{
|
||||
Id = 0,
|
||||
NormalizedTitle = title.ToNormalized(),
|
||||
Title = title,
|
||||
Promoted = promoted,
|
||||
Summary = string.Empty,
|
||||
AgeRating = AgeRating.Unknown,
|
||||
Source = ScrobbleProvider.Kavita,
|
||||
Items = new List<Series>()
|
||||
};
|
||||
}
|
||||
|
||||
public AppUserCollectionBuilder WithSource(ScrobbleProvider provider)
|
||||
{
|
||||
_collection.Source = provider;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public AppUserCollectionBuilder WithSummary(string summary)
|
||||
{
|
||||
_collection.Summary = summary;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AppUserCollectionBuilder WithIsPromoted(bool promoted)
|
||||
{
|
||||
_collection.Promoted = promoted;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AppUserCollectionBuilder WithItem(Series series)
|
||||
{
|
||||
_collection.Items ??= new List<Series>();
|
||||
_collection.Items.Add(series);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AppUserCollectionBuilder WithItems(IEnumerable<Series> series)
|
||||
{
|
||||
_collection.Items ??= new List<Series>();
|
||||
foreach (var s in series)
|
||||
{
|
||||
_collection.Items.Add(s);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public AppUserCollectionBuilder WithCoverImage(string cover)
|
||||
{
|
||||
_collection.CoverImage = cover;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
using API.Entities;
|
||||
using API.Entities.Metadata;
|
||||
using API.Extensions;
|
||||
|
||||
namespace API.Helpers.Builders;
|
||||
|
||||
public class CollectionTagBuilder : IEntityBuilder<CollectionTag>
|
||||
{
|
||||
private readonly CollectionTag _collectionTag;
|
||||
public CollectionTag Build() => _collectionTag;
|
||||
|
||||
public CollectionTagBuilder(string title, bool promoted = false)
|
||||
{
|
||||
title = title.Trim();
|
||||
_collectionTag = new CollectionTag()
|
||||
{
|
||||
Id = 0,
|
||||
NormalizedTitle = title.ToNormalized(),
|
||||
Title = title,
|
||||
Promoted = promoted,
|
||||
Summary = string.Empty,
|
||||
SeriesMetadatas = new List<SeriesMetadata>()
|
||||
};
|
||||
}
|
||||
|
||||
public CollectionTagBuilder WithId(int id)
|
||||
{
|
||||
_collectionTag.Id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CollectionTagBuilder WithSummary(string summary)
|
||||
{
|
||||
_collectionTag.Summary = summary;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CollectionTagBuilder WithIsPromoted(bool promoted)
|
||||
{
|
||||
_collectionTag.Promoted = promoted;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CollectionTagBuilder WithSeriesMetadata(SeriesMetadata seriesMetadata)
|
||||
{
|
||||
_collectionTag.SeriesMetadatas ??= new List<SeriesMetadata>();
|
||||
_collectionTag.SeriesMetadatas.Add(seriesMetadata);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CollectionTagBuilder WithCoverImage(string cover)
|
||||
{
|
||||
_collectionTag.CoverImage = cover;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue