Сборка

This commit is contained in:
Халимов Рустам
2026-03-31 00:16:18 +03:00
parent f1f8f6e012
commit b09e197626
16 changed files with 68 additions and 102 deletions
@@ -10,15 +10,15 @@ public static class DependencyInjection
{
public static IServiceCollection AddProfilesModule(this IServiceCollection services, IConfiguration configuration)
{
services.AddScoped<IProfileRepository, ProfileRepository>();
services.AddScoped<IProfilesUnitOfWork, ProfilesUnitOfWork>();
services.AddScoped<IAvatarStorageService, AvatarStorageService>();
services.AddScoped<Knot.Contracts.Profiles.Domain.IProfileRepository, ProfileRepository>();
services.AddScoped<Knot.Contracts.Profiles.Domain.IProfilesUnitOfWork, ProfilesUnitOfWork>();
services.AddScoped<Knot.Contracts.Profiles.Domain.IAvatarStorageService, AvatarStorageService>();
// MongoDB Registration
var mongoConnection = configuration.GetConnectionString("MongoConnection")
?? configuration["MONGO_URL"]
var mongoConnection = configuration.GetConnectionString("MongoConnection")
?? configuration["MONGO_URL"]
?? "mongodb://mongo:27017";
var mongoClient = new MongoClient(mongoConnection);
var databaseName = new MongoUrl(mongoConnection).DatabaseName ?? "knot_messager";
var database = mongoClient.GetDatabase(databaseName);
@@ -1,11 +0,0 @@
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace Knot.Modules.Profiles.Domain;
public interface IAvatarStorageService
{
Task<string> UploadAsync(Stream content, string fileName, string contentType, CancellationToken ct = default);
Task DeleteAsync(string fileId, CancellationToken ct = default);
}
@@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace Knot.Modules.Profiles.Domain;
public interface IProfileRepository
{
Task<ProfileDocument?> GetByIdAsync(Guid id, CancellationToken ct = default);
Task<ProfileDocument?> GetByUsernameAsync(string username, CancellationToken ct = default);
Task AddAsync(ProfileDocument profile, CancellationToken ct = default);
Task UpdateAsync(ProfileDocument profile, CancellationToken ct = default);
Task<List<ProfileDocument>> SearchAsync(string query, CancellationToken ct = default);
}
@@ -1,9 +0,0 @@
using System.Threading;
using System.Threading.Tasks;
namespace Knot.Modules.Profiles.Domain;
public interface IProfilesUnitOfWork
{
Task SaveChangesAsync(CancellationToken ct = default);
}
@@ -1,10 +0,0 @@
namespace Knot.Modules.Profiles.Domain;
using Knot.Shared.Kernel;
public static class ProfilesErrors
{
public static readonly Error ProfileNotFound = new("Profile.NotFound", "Profile not found");
}
public static class IdentityErrors
{
public static readonly Error UserNotFound = new("Profile.NotFound", "Profile not found");
}
+26 -12
View File
@@ -1,18 +1,32 @@
global using System;
global using System;
global using System.Collections.Generic;
global using System.Collections.Generic;
global using System.IO;
global using System.IO;
global using System.Linq;
global using System.Linq;
global using System.Threading;
global using System.Threading;
global using System.Threading.Tasks;
global using System.Threading.Tasks;
global using Knot.Modules.Profiles.Domain;
global using Knot.Modules.Profiles.Domain;
global using Knot.Modules.Profiles.Domain.Events;
global using Knot.Modules.Profiles.Domain.Events;
global using Knot.Modules.Profiles.Infrastructure.Database;
global using Knot.Modules.Profiles.Infrastructure.Database;
global using Knot.Shared.Kernel;
global using Knot.Shared.Kernel.Events;
global using Knot.Shared.Kernel.Storage;
global using Knot.Modules.Profiles.Domain;
global using Knot.Modules.Profiles.Domain.Events;
global using Knot.Modules.Profiles.Infrastructure.Database;
global using MediatR;
global using Microsoft.Extensions.Configuration;
global using Microsoft.Extensions.DependencyInjection;
global using MongoDB.Bson;
global using MongoDB.Bson.Serialization.Attributes;
global using MongoDB.Driver;
global using MediatR;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Configuration;
global using System;
global using System.Collections.Generic;
global using System.Threading;
global using System.Threading.Tasks;
global using System.IO;
global using System.Linq;
global using IAvatarStorageService = Knot.Contracts.Profiles.Domain.IAvatarStorageService;
// Алиасы для использования контрактов вместо дублирующихся интерфейсов модуля
global using IProfileRepository = Knot.Contracts.Profiles.Domain.IProfileRepository;
global using IProfilesUnitOfWork = Knot.Contracts.Profiles.Domain.IProfilesUnitOfWork;
global using ProfilesErrors = Knot.Contracts.Profiles.Application.DTOs.ProfilesErrors;
@@ -3,12 +3,11 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Knot.Contracts.Profiles.Domain;
using Knot.Contracts.Profiles.Application.DTOs;
using Knot.Contracts.Profiles.Domain;
using Knot.Modules.Profiles.Domain;
using Knot.Modules.Profiles.Infrastructure.Mappings;
using Knot.Shared.Kernel;
using ProfilesErrors = Knot.Contracts.Profiles.Application.DTOs.ProfilesErrors;
using MongoDB.Bson;
using MongoDB.Driver;