Adds user settings management

Adds the UserSettings aggregate with pagination and alpha picker preferences, keyed to a user with a dedicated UserId foreign key. Adds GET and PUT /users/me/settings API endpoints, a localized Tools > Settings page with save confirmation, the EF migration for the UserSettings table, and unit, integration and security tests.
This commit is contained in:
BinaryAlley committed 2026-08-16 08:37:33 -07:00
1 parent c3f8786fe4
commit 2354e21d42
65 files changed
+4711 -21

No files matched your search

@@ -0,0 +1,59 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.Common;
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Application.Common.DataAccess.Entities.UsersManagement;
/// <summary>
/// Repository entity for the settings of a user.
/// </summary>
[DebuggerDisplay("Id: {Id}; UserId: {UserId}")]
public class UserSettingsEntity : IStorageEntity, IAuditableEntity
{
/// <summary>
/// Gets the Id of these user settings.
/// </summary>
public required Guid Id { get; init; }
/// <summary>
/// Gets the Id of the user that owns these settings.
/// </summary>
public required Guid UserId { get; init; }
/// <summary>
/// Gets or sets whether pagination is enabled for the user, or not.
/// </summary>
public bool IsPaginationEnabled { get; set; }
/// <summary>
/// Gets or sets the number of library items displayed per page when pagination is enabled.
/// </summary>
public int ItemsPerPage { get; set; }
/// <summary>
/// Gets or sets whether the "The" prefix of library item titles is ignored by the alpha picker, or not.
/// </summary>
public bool IgnoreThePrefixForAlphaPicker { get; set; }
/// <summary>
/// Gets or sets the time and date when the entity was added.
/// </summary>
public DateTime CreatedOnUtc { get; set; }
/// <summary>
/// Gets or sets the Id of the user that created the entity.
/// </summary>
public Guid CreatedBy { get; set; }
/// <summary>
/// Gets or sets the optional time and date when the entity was updated.
/// </summary>
public DateTime? UpdatedOnUtc { get; set; }
/// <summary>
/// Gets or sets the optional Id of the user that updated the entity.
/// </summary>
public Guid? UpdatedBy { get; set; }
}
@@ -0,0 +1,28 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Common.Primitives;
using Lumina.Application.Common.DataAccess.Entities.UsersManagement;
using Lumina.Application.Common.DataAccess.Repositories.Common.Actions;
using Lumina.Application.Common.DataAccess.Repositories.Common.Base;
using System;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Application.Common.DataAccess.Repositories.Users;
/// <summary>
/// Interface for the repository for user settings.
/// </summary>
public interface IUserSettingsRepository : IRepository<UserSettingsEntity>,
IGetByIdRepositoryAction<UserSettingsEntity, Guid>,
IInsertRepositoryAction<UserSettingsEntity>,
IUpdateRepositoryAction<UserSettingsEntity>
{
/// <summary>
/// Gets the settings of the user identified by <paramref name="userId"/>, if they exist.
/// </summary>
/// <param name="userId">The Id of the user whose settings are retrieved.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> containing either the <see cref="UserSettingsEntity"/> of the user, or an error.</returns>
Task<Result<UserSettingsEntity?>> GetByUserIdAsync(Guid userId, CancellationToken cancellationToken);
}
@@ -80,6 +80,11 @@ public interface IUnitOfWork
/// </summary>
IUserRepository UserRepository { get; }
/// <summary>
/// Gets the user settings repository.
/// </summary>
IUserSettingsRepository UserSettingsRepository { get; }
/// <summary>
/// Saves all changes made to the database.
/// </summary>