mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Remove old People references
This commit is contained in:
parent
9493531eaa
commit
3e44d38a90
@ -68,11 +68,6 @@ namespace Kyoo.Abstractions.Controllers
|
||||
/// </summary>
|
||||
IRepository<Episode> Episodes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The repository that handle people.
|
||||
/// </summary>
|
||||
IRepository<People> People { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The repository that handle studios.
|
||||
/// </summary>
|
||||
|
@ -1,81 +0,0 @@
|
||||
// Kyoo - A portable and vast media library solution.
|
||||
// Copyright (c) Kyoo.
|
||||
//
|
||||
// See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
//
|
||||
// Kyoo is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// any later version.
|
||||
//
|
||||
// Kyoo is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Kyoo.Abstractions.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// A role a person played for a show. It can be an actor, musician, voice actor, director, writer...
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This class is not serialized like other classes.
|
||||
/// Based on the <see cref="ForPeople"/> field, it is serialized like
|
||||
/// a show with two extra fields (<see cref="Role"/> and <see cref="Type"/>).
|
||||
/// </remarks>
|
||||
public class PeopleRole : IResource
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public Guid Id { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Slug => ForPeople ? Show!.Slug : People.Slug;
|
||||
|
||||
/// <summary>
|
||||
/// Should this role be used as a Show substitute (the value is <c>true</c>) or
|
||||
/// as a People substitute (the value is <c>false</c>).
|
||||
/// </summary>
|
||||
public bool ForPeople { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The ID of the People playing the role.
|
||||
/// </summary>
|
||||
public Guid PeopleID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The people that played this role.
|
||||
/// </summary>
|
||||
public People People { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The ID of the Show where the People playing in.
|
||||
/// </summary>
|
||||
public Guid? ShowID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The show where the People played in.
|
||||
/// </summary>
|
||||
public Show? Show { get; set; }
|
||||
|
||||
public Guid? MovieID { get; set; }
|
||||
|
||||
public Movie? Movie { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The type of work the person has done for the show.
|
||||
/// That can be something like "Actor", "Writer", "Music", "Voice Actor"...
|
||||
/// </summary>
|
||||
public string Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The role the People played.
|
||||
/// This is mostly used to inform witch character was played for actor and voice actors.
|
||||
/// </summary>
|
||||
public string Role { get; set; }
|
||||
}
|
||||
}
|
@ -36,7 +36,6 @@ namespace Kyoo.Abstractions.Models
|
||||
: IQuery,
|
||||
IResource,
|
||||
IMetadata,
|
||||
IOnMerge,
|
||||
IThumbnails,
|
||||
IAddedDate,
|
||||
ILibraryItem,
|
||||
@ -147,11 +146,6 @@ namespace Kyoo.Abstractions.Models
|
||||
[LoadableRelation(nameof(StudioId))]
|
||||
public Studio? Studio { get; set; }
|
||||
|
||||
// /// <summary>
|
||||
// /// The list of people that made this show.
|
||||
// /// </summary>
|
||||
// [SerializeIgnore] public ICollection<PeopleRole>? People { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The list of collections that contains this show.
|
||||
/// </summary>
|
||||
@ -180,16 +174,6 @@ namespace Kyoo.Abstractions.Models
|
||||
// There is a global query filter to filter by user so we just need to do single.
|
||||
private MovieWatchStatus? _WatchStatus => Watched!.FirstOrDefault();
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnMerge(object merged)
|
||||
{
|
||||
// if (People != null)
|
||||
// {
|
||||
// foreach (PeopleRole link in People)
|
||||
// link.Movie = this;
|
||||
// }
|
||||
}
|
||||
|
||||
public Movie() { }
|
||||
|
||||
[JsonConstructor]
|
||||
|
@ -1,79 +0,0 @@
|
||||
// Kyoo - A portable and vast media library solution.
|
||||
// Copyright (c) Kyoo.
|
||||
//
|
||||
// See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
//
|
||||
// Kyoo is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// any later version.
|
||||
//
|
||||
// Kyoo is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json.Serialization;
|
||||
using Kyoo.Abstractions.Controllers;
|
||||
using Kyoo.Utils;
|
||||
|
||||
namespace Kyoo.Abstractions.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// An actor, voice actor, writer, animator, somebody who worked on a <see cref="Show"/>.
|
||||
/// </summary>
|
||||
[Table("people")]
|
||||
public class People : IQuery, IResource, IMetadata, IThumbnails
|
||||
{
|
||||
public static Sort DefaultSort => new Sort<People>.By(x => x.Name);
|
||||
|
||||
/// <inheritdoc />
|
||||
public Guid Id { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[MaxLength(256)]
|
||||
public string Slug { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of this person.
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public Image? Poster { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public Image? Thumbnail { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public Image? Logo { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public Dictionary<string, MetadataId> ExternalId { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// The list of roles this person has played in. See <see cref="PeopleRole"/> for more information.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public ICollection<PeopleRole>? Roles { get; set; }
|
||||
|
||||
public People() { }
|
||||
|
||||
[JsonConstructor]
|
||||
public People(string name)
|
||||
{
|
||||
if (name != null)
|
||||
{
|
||||
Slug = Utility.ToSlug(name);
|
||||
Name = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -138,11 +138,6 @@ namespace Kyoo.Abstractions.Models
|
||||
[LoadableRelation(nameof(StudioId))]
|
||||
public Studio? Studio { get; set; }
|
||||
|
||||
// /// <summary>
|
||||
// /// The list of people that made this show.
|
||||
// /// </summary>
|
||||
// [SerializeIgnore] public ICollection<PeopleRole>? People { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The different seasons in this show. If this is a movie, this list is always null or empty.
|
||||
/// </summary>
|
||||
@ -232,11 +227,6 @@ namespace Kyoo.Abstractions.Models
|
||||
/// <inheritdoc />
|
||||
public void OnMerge(object merged)
|
||||
{
|
||||
// if (People != null)
|
||||
// {
|
||||
// foreach (PeopleRole link in People)
|
||||
// link.Show = this;
|
||||
// }
|
||||
if (Seasons != null)
|
||||
{
|
||||
foreach (Season season in Seasons)
|
||||
|
@ -38,7 +38,6 @@ namespace Kyoo.Core.Controllers
|
||||
IRepository<Show> showRepository,
|
||||
IRepository<Season> seasonRepository,
|
||||
IRepository<Episode> episodeRepository,
|
||||
IRepository<People> peopleRepository,
|
||||
IRepository<Studio> studioRepository,
|
||||
IRepository<User> userRepository
|
||||
)
|
||||
@ -51,7 +50,6 @@ namespace Kyoo.Core.Controllers
|
||||
Shows = showRepository;
|
||||
Seasons = seasonRepository;
|
||||
Episodes = episodeRepository;
|
||||
People = peopleRepository;
|
||||
Studios = studioRepository;
|
||||
Users = userRepository;
|
||||
|
||||
@ -64,7 +62,6 @@ namespace Kyoo.Core.Controllers
|
||||
Shows,
|
||||
Seasons,
|
||||
Episodes,
|
||||
People,
|
||||
Studios,
|
||||
Users
|
||||
};
|
||||
@ -94,9 +91,6 @@ namespace Kyoo.Core.Controllers
|
||||
/// <inheritdoc />
|
||||
public IRepository<Episode> Episodes { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IRepository<People> People { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public IRepository<Studio> Studios { get; }
|
||||
|
||||
|
@ -42,29 +42,15 @@ namespace Kyoo.Core.Controllers
|
||||
/// </summary>
|
||||
private readonly IRepository<Studio> _studios;
|
||||
|
||||
/// <summary>
|
||||
/// A people repository to handle creation/validation of related people.
|
||||
/// </summary>
|
||||
private readonly IRepository<People> _people;
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="MovieRepository"/>.
|
||||
/// </summary>
|
||||
/// <param name="database">The database handle to use</param>
|
||||
/// <param name="studios">A studio repository</param>
|
||||
/// <param name="people">A people repository</param>
|
||||
/// <param name="thumbs">The thumbnail manager used to store images.</param>
|
||||
public MovieRepository(
|
||||
DatabaseContext database,
|
||||
IRepository<Studio> studios,
|
||||
IRepository<People> people,
|
||||
IThumbnailsManager thumbs
|
||||
)
|
||||
: base(database, thumbs)
|
||||
{
|
||||
_database = database;
|
||||
_studios = studios;
|
||||
_people = people;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@ -98,17 +84,6 @@ namespace Kyoo.Core.Controllers
|
||||
resource.Studio = await _studios.CreateIfNotExists(resource.Studio);
|
||||
resource.StudioId = resource.Studio.Id;
|
||||
}
|
||||
|
||||
// if (resource.People != null)
|
||||
// {
|
||||
// foreach (PeopleRole role in resource.People)
|
||||
// {
|
||||
// role.People = _database.LocalEntity<People>(role.People.Slug)
|
||||
// ?? await _people.CreateIfNotExists(role.People);
|
||||
// role.PeopleID = role.People.Id;
|
||||
// _database.Entry(role).State = EntityState.Added;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@ -121,12 +96,6 @@ namespace Kyoo.Core.Controllers
|
||||
await Database.Entry(resource).Reference(x => x.Studio).LoadAsync();
|
||||
resource.Studio = changed.Studio;
|
||||
}
|
||||
|
||||
// if (changed.People != null)
|
||||
// {
|
||||
// await Database.Entry(resource).Collection(x => x.People!).LoadAsync();
|
||||
// resource.People = changed.People;
|
||||
// }
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@ -1,206 +0,0 @@
|
||||
// Kyoo - A portable and vast media library solution.
|
||||
// Copyright (c) Kyoo.
|
||||
//
|
||||
// See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
//
|
||||
// Kyoo is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// any later version.
|
||||
//
|
||||
// Kyoo is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Kyoo.Abstractions.Controllers;
|
||||
using Kyoo.Abstractions.Models;
|
||||
using Kyoo.Abstractions.Models.Utils;
|
||||
using Kyoo.Postgresql;
|
||||
using Kyoo.Utils;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Kyoo.Core.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// A local repository to handle people.
|
||||
/// </summary>
|
||||
public class PeopleRepository : LocalRepository<People>
|
||||
{
|
||||
/// <summary>
|
||||
/// The database handle
|
||||
/// </summary>
|
||||
private readonly DatabaseContext _database;
|
||||
|
||||
/// <summary>
|
||||
/// A lazy loaded show repository to validate requests from shows.
|
||||
/// </summary>
|
||||
private readonly Lazy<IRepository<Show>> _shows;
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="PeopleRepository"/>
|
||||
/// </summary>
|
||||
/// <param name="database">The database handle</param>
|
||||
/// <param name="shows">A lazy loaded show repository</param>
|
||||
/// <param name="thumbs">The thumbnail manager used to store images.</param>
|
||||
public PeopleRepository(
|
||||
DatabaseContext database,
|
||||
Lazy<IRepository<Show>> shows,
|
||||
IThumbnailsManager thumbs
|
||||
)
|
||||
: base(database, thumbs)
|
||||
{
|
||||
_database = database;
|
||||
_shows = shows;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Task<ICollection<People>> Search(
|
||||
string query,
|
||||
Include<People>? include = default
|
||||
)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
// return await AddIncludes(_database.People, include)
|
||||
// .Where(x => EF.Functions.ILike(x.Name, $"%{query}%"))
|
||||
// .Take(20)
|
||||
// .ToListAsync();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async Task<People> Create(People obj)
|
||||
{
|
||||
await base.Create(obj);
|
||||
_database.Entry(obj).State = EntityState.Added;
|
||||
await _database.SaveChangesAsync(() => Get(obj.Slug));
|
||||
await IRepository<People>.OnResourceCreated(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task Validate(People resource)
|
||||
{
|
||||
await base.Validate(resource);
|
||||
|
||||
if (resource.Roles != null)
|
||||
{
|
||||
foreach (PeopleRole role in resource.Roles)
|
||||
{
|
||||
role.Show =
|
||||
_database.LocalEntity<Show>(role.Show!.Slug)
|
||||
?? await _shows.Value.CreateIfNotExists(role.Show);
|
||||
role.ShowID = role.Show.Id;
|
||||
_database.Entry(role).State = EntityState.Added;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task EditRelations(People resource, People changed)
|
||||
{
|
||||
await Validate(changed);
|
||||
|
||||
if (changed.Roles != null)
|
||||
{
|
||||
await Database.Entry(resource).Collection(x => x.Roles!).LoadAsync();
|
||||
resource.Roles = changed.Roles;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async Task Delete(People obj)
|
||||
{
|
||||
_database.Entry(obj).State = EntityState.Deleted;
|
||||
obj.Roles.ForEach(x => _database.Entry(x).State = EntityState.Deleted);
|
||||
await _database.SaveChangesAsync();
|
||||
await base.Delete(obj);
|
||||
}
|
||||
|
||||
// /// <inheritdoc />
|
||||
// public Task<ICollection<PeopleRole>> GetFromShow(int showID,
|
||||
// Expression<Func<PeopleRole, bool>>? where = null,
|
||||
// Sort<PeopleRole>? sort = default,
|
||||
// Pagination? limit = default)
|
||||
// {
|
||||
// ICollection<PeopleRole> people = await ApplyFilters(_database.PeopleRoles
|
||||
// .Where(x => x.ShowID == showID)
|
||||
// .Include(x => x.People),
|
||||
// x => x.People.Name,
|
||||
// where,
|
||||
// sort,
|
||||
// limit);
|
||||
// if (!people.Any() && await _shows.Value.GetOrDefault(showID) == null)
|
||||
// throw new ItemNotFoundException();
|
||||
// foreach (PeopleRole role in people)
|
||||
// role.ForPeople = true;
|
||||
// return people;
|
||||
// }
|
||||
|
||||
// /// <inheritdoc />
|
||||
// public Task<ICollection<PeopleRole>> GetFromShow(string showSlug,
|
||||
// Expression<Func<PeopleRole, bool>>? where = null,
|
||||
// Sort<PeopleRole>? sort = default,
|
||||
// Pagination? limit = default)
|
||||
// {
|
||||
// ICollection<PeopleRole> people = await ApplyFilters(_database.PeopleRoles
|
||||
// .Where(x => x.Show.Slug == showSlug)
|
||||
// .Include(x => x.People)
|
||||
// .Include(x => x.Show),
|
||||
// id => _database.PeopleRoles.FirstOrDefaultAsync(x => x.ID == id),
|
||||
// x => x.People.Name,
|
||||
// where,
|
||||
// sort,
|
||||
// limit);
|
||||
// if (!people.Any() && await _shows.Value.GetOrDefault(showSlug) == null)
|
||||
// throw new ItemNotFoundException();
|
||||
// foreach (PeopleRole role in people)
|
||||
// role.ForPeople = true;
|
||||
// return people;
|
||||
// }
|
||||
|
||||
// /// <inheritdoc />
|
||||
// public Task<ICollection<PeopleRole>> GetFromPeople(int id,
|
||||
// Expression<Func<PeopleRole, bool>>? where = null,
|
||||
// Sort<PeopleRole>? sort = default,
|
||||
// Pagination? limit = default)
|
||||
// {
|
||||
// ICollection<PeopleRole> roles = await ApplyFilters(_database.PeopleRoles
|
||||
// .Where(x => x.PeopleID == id)
|
||||
// .Include(x => x.Show),
|
||||
// y => _database.PeopleRoles.FirstOrDefaultAsync(x => x.ID == y),
|
||||
// x => x.Show.Title,
|
||||
// where,
|
||||
// sort,
|
||||
// limit);
|
||||
// if (!roles.Any() && await GetOrDefault(id) == null)
|
||||
// throw new ItemNotFoundException();
|
||||
// return roles;
|
||||
// }
|
||||
|
||||
// /// <inheritdoc />
|
||||
// public Task<ICollection<PeopleRole>> GetFromPeople(string slug,
|
||||
// Expression<Func<PeopleRole, bool>>? where = null,
|
||||
// Sort<PeopleRole>? sort = default,
|
||||
// Pagination? limit = default)
|
||||
// {
|
||||
// ICollection<PeopleRole> roles = await ApplyFilters(_database.PeopleRoles
|
||||
// .Where(x => x.People.Slug == slug)
|
||||
// .Include(x => x.Show),
|
||||
// id => _database.PeopleRoles.FirstOrDefaultAsync(x => x.ID == id),
|
||||
// x => x.Show.Title,
|
||||
// where,
|
||||
// sort,
|
||||
// limit);
|
||||
// if (!roles.Any() && await GetOrDefault(slug) == null)
|
||||
// throw new ItemNotFoundException();
|
||||
// return roles;
|
||||
// }
|
||||
}
|
||||
}
|
@ -43,29 +43,15 @@ namespace Kyoo.Core.Controllers
|
||||
/// </summary>
|
||||
private readonly IRepository<Studio> _studios;
|
||||
|
||||
/// <summary>
|
||||
/// A people repository to handle creation/validation of related people.
|
||||
/// </summary>
|
||||
private readonly IRepository<People> _people;
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="ShowRepository"/>.
|
||||
/// </summary>
|
||||
/// <param name="database">The database handle to use</param>
|
||||
/// <param name="studios">A studio repository</param>
|
||||
/// <param name="people">A people repository</param>
|
||||
/// <param name="thumbs">The thumbnail manager used to store images.</param>
|
||||
public ShowRepository(
|
||||
DatabaseContext database,
|
||||
IRepository<Studio> studios,
|
||||
IRepository<People> people,
|
||||
IThumbnailsManager thumbs
|
||||
)
|
||||
: base(database, thumbs)
|
||||
{
|
||||
_database = database;
|
||||
_studios = studios;
|
||||
_people = people;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@ -99,17 +85,6 @@ namespace Kyoo.Core.Controllers
|
||||
resource.Studio = await _studios.CreateIfNotExists(resource.Studio);
|
||||
resource.StudioId = resource.Studio.Id;
|
||||
}
|
||||
|
||||
// if (resource.People != null)
|
||||
// {
|
||||
// foreach (PeopleRole role in resource.People)
|
||||
// {
|
||||
// role.People = _database.LocalEntity<People>(role.People.Slug)
|
||||
// ?? await _people.CreateIfNotExists(role.People);
|
||||
// role.PeopleID = role.People.Id;
|
||||
// _database.Entry(role).State = EntityState.Added;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@ -122,12 +97,6 @@ namespace Kyoo.Core.Controllers
|
||||
await Database.Entry(resource).Reference(x => x.Studio).LoadAsync();
|
||||
resource.Studio = changed.Studio;
|
||||
}
|
||||
|
||||
// if (changed.People != null)
|
||||
// {
|
||||
// await Database.Entry(resource).Collection(x => x.People!).LoadAsync();
|
||||
// resource.People = changed.People;
|
||||
// }
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@ -66,7 +66,6 @@ namespace Kyoo.Core
|
||||
builder.RegisterRepository<ShowRepository>();
|
||||
builder.RegisterRepository<SeasonRepository>();
|
||||
builder.RegisterRepository<EpisodeRepository>();
|
||||
builder.RegisterRepository<PeopleRepository>();
|
||||
builder.RegisterRepository<StudioRepository>();
|
||||
builder.RegisterRepository<UserRepository>().As<IUserRepository>();
|
||||
builder.RegisterRepository<NewsRepository>();
|
||||
|
@ -1,90 +0,0 @@
|
||||
// Kyoo - A portable and vast media library solution.
|
||||
// Copyright (c) Kyoo.
|
||||
//
|
||||
// See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
//
|
||||
// Kyoo is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// any later version.
|
||||
//
|
||||
// Kyoo is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
using Kyoo.Abstractions.Controllers;
|
||||
using Kyoo.Abstractions.Models;
|
||||
using Kyoo.Abstractions.Models.Attributes;
|
||||
using Kyoo.Abstractions.Models.Permissions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using static Kyoo.Abstractions.Models.Utils.Constants;
|
||||
|
||||
namespace Kyoo.Core.Api
|
||||
{
|
||||
/// <summary>
|
||||
/// Information about one or multiple staff member.
|
||||
/// </summary>
|
||||
[Route("staff")]
|
||||
[Route("people", Order = AlternativeRoute)]
|
||||
[ApiController]
|
||||
[PartialPermission(nameof(People))]
|
||||
[ApiDefinition("Staff", Group = MetadataGroup)]
|
||||
public class StaffApi : CrudThumbsApi<People>
|
||||
{
|
||||
/// <summary>
|
||||
/// The library manager used to modify or retrieve information in the data store.
|
||||
/// </summary>
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="StaffApi"/>.
|
||||
/// </summary>
|
||||
/// <param name="libraryManager">
|
||||
/// The library manager used to modify or retrieve information about the data store.
|
||||
/// </param>
|
||||
/// <param name="thumbs">The thumbnail manager used to retrieve images paths.</param>
|
||||
public StaffApi(ILibraryManager libraryManager, IThumbnailsManager thumbs)
|
||||
: base(libraryManager.People, thumbs)
|
||||
{
|
||||
_libraryManager = libraryManager;
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// Get roles
|
||||
// /// </summary>
|
||||
// /// <remarks>
|
||||
// /// List the roles in witch this person has played, written or worked in a way.
|
||||
// /// </remarks>
|
||||
// /// <param name="identifier">The ID or slug of the person.</param>
|
||||
// /// <param name="sortBy">A key to sort roles by.</param>
|
||||
// /// <param name="where">An optional list of filters.</param>
|
||||
// /// <param name="pagination">The number of roles to return.</param>
|
||||
// /// <returns>A page of roles.</returns>
|
||||
// /// <response code="400">The filters or the sort parameters are invalid.</response>
|
||||
// /// <response code="404">No person with the given ID or slug could be found.</response>
|
||||
// [HttpGet("{identifier:id}/roles")]
|
||||
// [HttpGet("{identifier:id}/role", Order = AlternativeRoute)]
|
||||
// [PartialPermission(Kind.Read)]
|
||||
// [ProducesResponseType(StatusCodes.Status200OK)]
|
||||
// [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(RequestError))]
|
||||
// [ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
// public async Task<ActionResult<Page<PeopleRole>>> GetRoles(Identifier identifier,
|
||||
// [FromQuery] Sort<PeopleRole> sortBy,
|
||||
// [FromQuery] Dictionary<string, string> where,
|
||||
// [FromQuery] Pagination pagination)
|
||||
// {
|
||||
// Expression<Func<PeopleRole, bool>>? whereQuery = ApiHelper.ParseWhere<PeopleRole>(where);
|
||||
//
|
||||
// ICollection<PeopleRole> resources = await identifier.Match(
|
||||
// id => _libraryManager.GetRolesFromPeople(id, whereQuery, sortBy, pagination),
|
||||
// slug => _libraryManager.GetRolesFromPeople(slug, whereQuery, sortBy, pagination)
|
||||
// );
|
||||
//
|
||||
// return Page(resources, pagination.Limit);
|
||||
// }
|
||||
}
|
||||
}
|
@ -43,40 +43,6 @@ namespace Kyoo.Core.Api
|
||||
public class MovieApi(ILibraryManager libraryManager, IThumbnailsManager thumbs)
|
||||
: TranscoderApi<Movie>(libraryManager.Movies, thumbs)
|
||||
{
|
||||
// /// <summary>
|
||||
// /// Get staff
|
||||
// /// </summary>
|
||||
// /// <remarks>
|
||||
// /// List staff members that made this show.
|
||||
// /// </remarks>
|
||||
// /// <param name="identifier">The ID or slug of the <see cref="Show"/>.</param>
|
||||
// /// <param name="sortBy">A key to sort staff members by.</param>
|
||||
// /// <param name="where">An optional list of filters.</param>
|
||||
// /// <param name="pagination">The number of people to return.</param>
|
||||
// /// <returns>A page of people.</returns>
|
||||
// /// <response code="400">The filters or the sort parameters are invalid.</response>
|
||||
// /// <response code="404">No show with the given ID or slug could be found.</response>
|
||||
// [HttpGet("{identifier:id}/staff")]
|
||||
// [HttpGet("{identifier:id}/people", Order = AlternativeRoute)]
|
||||
// [PartialPermission(Kind.Read)]
|
||||
// [ProducesResponseType(StatusCodes.Status200OK)]
|
||||
// [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(RequestError))]
|
||||
// [ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
// public async Task<ActionResult<Page<PeopleRole>>> GetPeople(Identifier identifier,
|
||||
// [FromQuery] string sortBy,
|
||||
// [FromQuery] Dictionary<string, string> where,
|
||||
// [FromQuery] Pagination pagination)
|
||||
// {
|
||||
// Expression<Func<PeopleRole, bool>> whereQuery = ApiHelper.ParseWhere<PeopleRole>(where);
|
||||
// Sort<PeopleRole> sort = Sort<PeopleRole>.From(sortBy);
|
||||
//
|
||||
// ICollection<PeopleRole> resources = await identifier.Match(
|
||||
// id => _libraryManager.GetPeopleFromShow(id, whereQuery, sort, pagination),
|
||||
// slug => _libraryManager.GetPeopleFromShow(slug, whereQuery, sort, pagination)
|
||||
// );
|
||||
// return Page(resources, pagination.Limit);
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// Get studio that made the show
|
||||
/// </summary>
|
||||
|
@ -146,41 +146,6 @@ namespace Kyoo.Core.Api
|
||||
return Page(resources, pagination.Limit);
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// Get staff
|
||||
// /// </summary>
|
||||
// /// <remarks>
|
||||
// /// List staff members that made this show.
|
||||
// /// </remarks>
|
||||
// /// <param name="identifier">The ID or slug of the <see cref="Show"/>.</param>
|
||||
// /// <param name="sortBy">A key to sort staff members by.</param>
|
||||
// /// <param name="where">An optional list of filters.</param>
|
||||
// /// <param name="pagination">The number of people to return.</param>
|
||||
// /// <param name="fields">The aditional fields to include in the result.</param>
|
||||
// /// <returns>A page of people.</returns>
|
||||
// /// <response code="400">The filters or the sort parameters are invalid.</response>
|
||||
// /// <response code="404">No show with the given ID or slug could be found.</response>
|
||||
// [HttpGet("{identifier:id}/staff")]
|
||||
// [HttpGet("{identifier:id}/people", Order = AlternativeRoute)]
|
||||
// [PartialPermission(Kind.Read)]
|
||||
// [ProducesResponseType(StatusCodes.Status200OK)]
|
||||
// [ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(RequestError))]
|
||||
// [ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
// public async Task<ActionResult<Page<PeopleRole>>> GetPeople(Identifier identifier,
|
||||
// [FromQuery] Sort<PeopleRole> sortBy,
|
||||
// [FromQuery] Dictionary<string, string> where,
|
||||
// [FromQuery] Pagination pagination,
|
||||
// [FromQuery] Include<PeopleRole> fields)
|
||||
// {
|
||||
// Expression<Func<PeopleRole, bool>>? whereQuery = ApiHelper.ParseWhere<PeopleRole>(where);
|
||||
//
|
||||
// ICollection<PeopleRole> resources = await identifier.Match(
|
||||
// id => _libraryManager.GetPeopleFromShow(id, whereQuery, sortBy, pagination),
|
||||
// slug => _libraryManager.GetPeopleFromShow(slug, whereQuery, sortBy, pagination)
|
||||
// );
|
||||
// return Page(resources, pagination.Limit);
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// Get studio that made the show
|
||||
/// </summary>
|
||||
|
@ -78,11 +78,6 @@ namespace Kyoo.Postgresql
|
||||
/// </summary>
|
||||
public DbSet<Episode> Episodes { get; set; }
|
||||
|
||||
// /// <summary>
|
||||
// /// All people of Kyoo. See <see cref="People"/>.
|
||||
// /// </summary>
|
||||
// public DbSet<People> People { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// All studios of Kyoo. See <see cref="Studio"/>.
|
||||
/// </summary>
|
||||
@ -93,11 +88,6 @@ namespace Kyoo.Postgresql
|
||||
/// </summary>
|
||||
public DbSet<User> Users { get; set; }
|
||||
|
||||
// /// <summary>
|
||||
// /// All people's role. See <see cref="PeopleRole"/>.
|
||||
// /// </summary>
|
||||
// public DbSet<PeopleRole> PeopleRoles { get; set; }
|
||||
|
||||
public DbSet<MovieWatchStatus> MovieWatchStatus { get; set; }
|
||||
|
||||
public DbSet<ShowWatchStatus> ShowWatchStatus { get; set; }
|
||||
@ -275,8 +265,6 @@ namespace Kyoo.Postgresql
|
||||
.Ignore(x => x.PreviousEpisode)
|
||||
.Ignore(x => x.NextEpisode);
|
||||
|
||||
// modelBuilder.Entity<PeopleRole>()
|
||||
// .Ignore(x => x.ForPeople);
|
||||
modelBuilder
|
||||
.Entity<Show>()
|
||||
.HasMany(x => x.Seasons)
|
||||
@ -312,14 +300,12 @@ namespace Kyoo.Postgresql
|
||||
_HasMetadata<Show>(modelBuilder);
|
||||
_HasMetadata<Season>(modelBuilder);
|
||||
_HasMetadata<Episode>(modelBuilder);
|
||||
// _HasMetadata<People>(modelBuilder);
|
||||
_HasMetadata<Studio>(modelBuilder);
|
||||
|
||||
_HasImages<Collection>(modelBuilder);
|
||||
_HasImages<Movie>(modelBuilder);
|
||||
_HasImages<Show>(modelBuilder);
|
||||
_HasImages<Season>(modelBuilder);
|
||||
// _HasImages<People>(modelBuilder);
|
||||
_HasImages<Episode>(modelBuilder);
|
||||
|
||||
_HasAddedDate<Collection>(modelBuilder);
|
||||
@ -382,9 +368,6 @@ namespace Kyoo.Postgresql
|
||||
modelBuilder.Entity<Episode>().Ignore(x => x.WatchStatus);
|
||||
|
||||
modelBuilder.Entity<Collection>().HasIndex(x => x.Slug).IsUnique();
|
||||
// modelBuilder.Entity<People>()
|
||||
// .HasIndex(x => x.Slug)
|
||||
// .IsUnique();
|
||||
modelBuilder.Entity<Movie>().HasIndex(x => x.Slug).IsUnique();
|
||||
modelBuilder.Entity<Show>().HasIndex(x => x.Slug).IsUnique();
|
||||
modelBuilder.Entity<Studio>().HasIndex(x => x.Slug).IsUnique();
|
||||
|
Loading…
x
Reference in New Issue
Block a user