=== Summary: 675 files | 7 generated | 484 fresh | 4605 untracked | 4268 adopted | 355 marked | 466 validated-ok | 2+0 stale (sig+body) | 0 skipped | 0 failed | elapsed 11:08:11.442 (40091.44s) ===
This commit is contained in:
@@ -16,6 +16,7 @@ namespace adas_core.Infrastructure.Repositories;
|
||||
/// <remarks>
|
||||
/// Inherits core data access functionality from <see cref="MongoRepository{User}"/> and implements the <see cref="IUserRepository"/> contract.
|
||||
/// </remarks>
|
||||
/// <!-- aidoc:v1 sig=7f8031c -->
|
||||
public class UserRepository : MongoRepository<User>, IUserRepository
|
||||
{
|
||||
private readonly ApiSettings _apiSettings;
|
||||
@@ -37,6 +38,7 @@ public class UserRepository : MongoRepository<User>, IUserRepository
|
||||
/// Retrieves the API collection name for users from the configured API settings.
|
||||
/// </summary>
|
||||
/// <returns>The configured name of the users collection.</returns>
|
||||
/// <!-- aidoc:v1 sig=94e22ff body=f29d25a -->
|
||||
public override string GetCollectionName()
|
||||
{
|
||||
return _apiSettings.Users;
|
||||
@@ -49,6 +51,7 @@ public class UserRepository : MongoRepository<User>, IUserRepository
|
||||
/// <param name="username">The username to look up in the collection.</param>
|
||||
/// <param name="password">The password that must match the stored value for the user to be returned.</param>
|
||||
/// <returns>A <see cref="User"/> instance when a matching record is found; otherwise, <c>null</c>.</returns>
|
||||
/// <!-- aidoc:v1 sig=be4ac11 body=ac01c98 -->
|
||||
public async Task<User?> GetUser(string username, string password)
|
||||
{
|
||||
var filter = Builders<User>
|
||||
@@ -63,6 +66,7 @@ public class UserRepository : MongoRepository<User>, IUserRepository
|
||||
/// </summary>
|
||||
/// <param name="id">The <see cref="ObjectId"/> of the user to look up.</param>
|
||||
/// <returns>A <see cref="User"/> instance if a matching document exists; otherwise, <c>null</c>.</returns>
|
||||
/// <!-- aidoc:v1 sig=9cec1a5 body=78ead0f -->
|
||||
public async Task<User?> GetById(ObjectId id)
|
||||
{
|
||||
var filter = Builders<User>
|
||||
@@ -77,6 +81,7 @@ public class UserRepository : MongoRepository<User>, IUserRepository
|
||||
/// </summary>
|
||||
/// <param name="name">The username used to look up the user.</param>
|
||||
/// <returns>A <see cref="User"/> instance if a match is found; otherwise, <c>null</c>.</returns>
|
||||
/// <!-- aidoc:v1 sig=c23232a body=1f6c5cb -->
|
||||
public async Task<User?> GetByUserName(string name)
|
||||
{
|
||||
var filter = Builders<User>
|
||||
@@ -90,6 +95,7 @@ public class UserRepository : MongoRepository<User>, IUserRepository
|
||||
/// </summary>
|
||||
/// <param name="name">The username used to match the user document in the collection.</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> that yields the matching <see cref="User"/> with its authorizations and resolved role, or <c>null</c> if no user is found.</returns>
|
||||
/// <!-- aidoc:v1 sig=31b518d body=72882f6 -->
|
||||
public async Task<User?> GetByUserAndAuthoritesName(string name)
|
||||
{
|
||||
var matchStage = new BsonDocument("$match", new BsonDocument("userName", name));
|
||||
@@ -137,6 +143,7 @@ public class UserRepository : MongoRepository<User>, IUserRepository
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the user to look up.</param>
|
||||
/// <returns>A <see cref="User"/> instance if a match is found; otherwise, null.</returns>
|
||||
/// <!-- aidoc:v1 sig=ccb9033 body=30118c6 -->
|
||||
public async Task<User?> GetByName(string name)
|
||||
{
|
||||
var filter = Builders<User>
|
||||
@@ -152,6 +159,7 @@ public class UserRepository : MongoRepository<User>, IUserRepository
|
||||
/// <param name="user">The user entity whose fields will be applied to the existing record, identified by <see cref="User.Id"/>.</param>
|
||||
/// <param name="updatePass">If <c>true</c>, the password field is included in the update; if <c>false</c>, the password is not modified.</param>
|
||||
/// <returns>The updated <see cref="User"/> retrieved after the update, or <c>null</c> if no matching user was found.</returns>
|
||||
/// <!-- aidoc:v1 sig=3448f77 body=e54a95d -->
|
||||
public async Task<User?> UpdateUser(User user, bool updatePass)
|
||||
{
|
||||
var filter = Builders<User>
|
||||
@@ -176,6 +184,7 @@ public class UserRepository : MongoRepository<User>, IUserRepository
|
||||
/// </summary>
|
||||
/// <param name="filteredRequest">The pagination filter containing paging details and the optional filter payload (text, user status, and user type) used to build the MongoDB query.</param>
|
||||
/// <returns>An <see cref="IFindFluent{TDocument, TProjection}"/> of <see cref="User"/> sorted ascending by user name and shaped by the assembled filter definitions.</returns>
|
||||
/// <!-- aidoc:v1 sig=0f10830 body=0c62e4a -->
|
||||
public IFindFluent<User, User> GetPaginatedUsers(PaginationFilter filteredRequest)
|
||||
{
|
||||
// Crear variable con la clase que construye los filtros que necesitamos
|
||||
@@ -215,6 +224,7 @@ public class UserRepository : MongoRepository<User>, IUserRepository
|
||||
/// Retrieves the system user identified by the username "System", creating and inserting a new one with default credentials if no existing user is found.
|
||||
/// </summary>
|
||||
/// <returns>The existing system user if found; otherwise, the newly created and inserted system user.</returns>
|
||||
/// <!-- aidoc:v1 sig=26219ff body=775a713 -->
|
||||
public async Task<User> GetOrCreateSystemUser()
|
||||
{
|
||||
var user = await GetByUserName("System");
|
||||
@@ -236,6 +246,7 @@ public class UserRepository : MongoRepository<User>, IUserRepository
|
||||
/// <summary>
|
||||
/// Inserts the initial load of data by ensuring that the system user exists, creating one if necessary.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=ccdefcf body=eb41bb0 -->
|
||||
public sealed override async Task InsertInitialLoad()
|
||||
{
|
||||
await GetOrCreateSystemUser();
|
||||
@@ -249,6 +260,7 @@ public class UserRepository : MongoRepository<User>, IUserRepository
|
||||
/// <param name="filters">The list of filter definitions to be combined with logical AND.</param>
|
||||
/// <param name="sort">The sort definition to apply to the query results.</param>
|
||||
/// <returns>A fluent find query for the <see cref="User"/> collection with the combined filter and sort applied.</returns>
|
||||
/// <!-- aidoc:v1 sig=65f1029 body=9a8a34a -->
|
||||
private IFindFluent<User, User> CreateFindFluent(List<FilterDefinition<User>> filters, SortDefinition<User> sort)
|
||||
{
|
||||
var combinedFilter = filters.Any()
|
||||
@@ -264,6 +276,7 @@ public class UserRepository : MongoRepository<User>, IUserRepository
|
||||
/// </summary>
|
||||
/// <param name="type">The user type to filter by. If null or not one of the handled values, no filter is added.</param>
|
||||
/// <returns>A list of FilterDefinition objects matching the specified user type, or an empty list if no specific type was matched.</returns>
|
||||
/// <!-- aidoc:v1 sig=ef9cd45 body=04622cf -->
|
||||
private List<FilterDefinition<User>> GetUserTypeFilter(UserEnum.Type? type)
|
||||
{
|
||||
var filters = new List<FilterDefinition<User>>();
|
||||
@@ -287,6 +300,7 @@ public class UserRepository : MongoRepository<User>, IUserRepository
|
||||
/// </summary>
|
||||
/// <param name="status">The user status used to select which filter combination is applied; a <c>null</c> or unhandled value yields an empty filter list.</param>
|
||||
/// <returns>A list of <see cref="FilterDefinition{TDocument}"/> filters that should be combined to query <see cref="User"/> documents for the specified status.</returns>
|
||||
/// <!-- aidoc:v1 sig=afc76fe body=92c7666 -->
|
||||
private List<FilterDefinition<User>> GetUserStatusFilter(StatusEnum.User? status)
|
||||
{
|
||||
var filters = new List<FilterDefinition<User>>();
|
||||
|
||||
Reference in New Issue
Block a user