Refactoring, database structure changed

This commit is contained in:
2025-03-03 00:56:32 +01:00
Unverified
parent d3805ef3db
commit c603c41c0b
913 changed files with 21764 additions and 32775 deletions

View File

@@ -0,0 +1,19 @@
using System.Text.RegularExpressions;
using WatchIt.Database.Model.Roles;
using WatchIt.DTO.Query;
namespace WatchIt.DTO.Models.Controllers.Roles.Role.Filters;
public record RoleActorNameFilter : Filter<RoleActor>
{
public RoleActorNameFilter(string? regexQuery) : base(x =>
(
string.IsNullOrWhiteSpace(regexQuery)
||
(
!string.IsNullOrWhiteSpace(x.Name)
&&
Regex.IsMatch(x.Name, regexQuery, RegexOptions.IgnoreCase)
)
)) { }
}

View File

@@ -0,0 +1,14 @@
using WatchIt.Database.Model.Roles;
using WatchIt.DTO.Query;
namespace WatchIt.DTO.Models.Controllers.Roles.Role.Filters;
public record RoleActorTypeIdFilter : Filter<RoleActor>
{
public RoleActorTypeIdFilter(short? query) : base(x =>
(
query == null
||
x.ActorTypeId == query
)) { }
}

View File

@@ -0,0 +1,14 @@
using WatchIt.Database.Model.Roles;
using WatchIt.DTO.Query;
namespace WatchIt.DTO.Models.Controllers.Roles.Role.Filters;
public record RoleCreatorTypeIdFilter : Filter<RoleCreator>
{
public RoleCreatorTypeIdFilter(short? query) : base(x =>
(
query == null
||
x.CreatorTypeId == query
)) { }
}

View File

@@ -0,0 +1,13 @@
using WatchIt.DTO.Query;
namespace WatchIt.DTO.Models.Controllers.Roles.Role.Filters;
public record RoleMediumIdFilter<T> : Filter<T> where T : Database.Model.Roles.Role
{
public RoleMediumIdFilter(long? query) : base(x =>
(
query == null
||
x.MediumId == query
)) { }
}

View File

@@ -0,0 +1,13 @@
using WatchIt.DTO.Query;
namespace WatchIt.DTO.Models.Controllers.Roles.Role.Filters;
public record RolePersonIdFilter<T> : Filter<T> where T : Database.Model.Roles.Role
{
public RolePersonIdFilter(long? query) : base(x =>
(
query == null
||
x.PersonId == query
)) { }
}

View File

@@ -0,0 +1,33 @@
using Microsoft.AspNetCore.Mvc;
using Refit;
using WatchIt.DTO.Models.Controllers.Roles.Role.Filters;
using WatchIt.DTO.Query;
namespace WatchIt.DTO.Models.Controllers.Roles.Role.Query;
public abstract class BaseRoleFilterQuery<T> : IFilterQuery<T> where T : Database.Model.Roles.Role
{
#region PROPERTIES
[FromQuery(Name = "person_id")]
[AliasAs("person_id")]
public long? PersonId { get; set; }
[FromQuery(Name = "medium_id")]
[AliasAs("medium_id")]
public long? MediumId { get; set; }
#endregion
#region PUBLIC METHODS
public virtual IEnumerable<Filter<T>> GetFilters() =>
[
new RolePersonIdFilter<T>(PersonId),
new RoleMediumIdFilter<T>(MediumId),
];
#endregion
}

View File

@@ -0,0 +1,8 @@
namespace WatchIt.DTO.Models.Controllers.Roles.Role.Query;
public interface IRoleFilterQuery
{
short? TypeId { get; set; }
long? PersonId { get; set; }
long? MediumId { get; set; }
}

View File

@@ -0,0 +1,32 @@
using Microsoft.AspNetCore.Mvc;
using Refit;
using WatchIt.Database.Model.Roles;
using WatchIt.DTO.Models.Controllers.Roles.Role.Filters;
using WatchIt.DTO.Query;
namespace WatchIt.DTO.Models.Controllers.Roles.Role.Query;
public class RoleActorFilterQuery : BaseRoleFilterQuery<RoleActor>, IRoleFilterQuery
{
#region PROPERTIES
[FromQuery(Name = "type_id")]
[AliasAs("type_id")]
public short? TypeId { get; set; }
[FromQuery(Name = "name")]
[AliasAs("name")]
public string? Name { get; set; }
#endregion
#region PUBLIC METHODS
public override IEnumerable<Filter<RoleActor>> GetFilters() => base.GetFilters()
.Append(new RoleActorTypeIdFilter(TypeId))
.Append(new RoleActorNameFilter(Name));
#endregion
}

View File

@@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Mvc;
using Refit;
using WatchIt.Database.Model.Roles;
using WatchIt.DTO.Models.Controllers.Roles.Role.Filters;
using WatchIt.DTO.Query;
namespace WatchIt.DTO.Models.Controllers.Roles.Role.Query;
public class RoleCreatorFilterQuery : BaseRoleFilterQuery<RoleCreator>, IRoleFilterQuery
{
#region PROPERTIES
[FromQuery(Name = "type_id")]
[AliasAs("type_id")]
public short? TypeId { get; set; }
#endregion
#region PUBLIC METHODS
public override IEnumerable<Filter<RoleCreator>> GetFilters() => base.GetFilters()
.Append(new RoleCreatorTypeIdFilter(TypeId));
#endregion
}

View File

@@ -0,0 +1,11 @@
namespace WatchIt.DTO.Models.Controllers.Roles.Role.Request;
public class RoleActorRequest : RoleRequest
{
#region PROPERTIES
public short TypeId { get; set; }
public string Name { get; set; } = null!;
#endregion
}

View File

@@ -0,0 +1,10 @@
namespace WatchIt.DTO.Models.Controllers.Roles.Role.Request;
public class RoleCreatorRequest : RoleRequest
{
#region PROPERTIES
public short TypeId { get; set; }
#endregion
}

View File

@@ -0,0 +1,11 @@
namespace WatchIt.DTO.Models.Controllers.Roles.Role.Request;
public abstract class RoleRequest
{
#region PROPERTIES
public long MediumId { get; set; }
public long PersonId { get; set; }
#endregion
}

View File

@@ -0,0 +1,10 @@
namespace WatchIt.DTO.Models.Controllers.Roles.Role.Response;
public class RoleActorResponse : RoleResponse
{
#region PROPERTIES
public string Name { get; set; } = null!;
#endregion
}

View File

@@ -0,0 +1,3 @@
namespace WatchIt.DTO.Models.Controllers.Roles.Role.Response;
public class RoleCreatorResponse : RoleResponse;

View File

@@ -0,0 +1,13 @@
namespace WatchIt.DTO.Models.Controllers.Roles.Role.Response;
public abstract class RoleResponse
{
#region PROPERTIES
public Guid Id { get; set; }
public long MediumId { get; set; }
public long PersonId { get; set; }
public short TypeId { get; set; }
#endregion
}

View File

@@ -0,0 +1,25 @@
using System.Linq.Expressions;
using WatchIt.Database.Model.Roles;
namespace WatchIt.DTO.Models.Controllers.Roles.Role;
public class RoleOrderKeys
{
public static Dictionary<string, Expression<Func<T, object?>>> Base<T>() where T : Database.Model.Roles.Role => new Dictionary<string, Expression<Func<T, object?>>>
{
{ "person", item => item.PersonId },
{ "medium", item => item.MediumId },
{ "medium.release_date", item => item.Medium.ReleaseDate }
};
public static readonly Dictionary<string, Expression<Func<RoleActor, object?>>> RoleActor = new Dictionary<string, Expression<Func<RoleActor, object?>>>
{
{ "type_id", x => x.ActorTypeId },
{ "name", x => x.Name },
};
public static readonly Dictionary<string, Expression<Func<RoleCreator, object?>>> RoleCreator = new Dictionary<string, Expression<Func<RoleCreator, object?>>>
{
{ "type_id", x => x.CreatorTypeId },
};
}