Сборка бэк
This commit is contained in:
@@ -3,7 +3,6 @@ using Microsoft.EntityFrameworkCore;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Knot.Modules.Relations.Application.Abstractions;
|
||||
namespace Knot.Modules.Relations.Application.Abstractions;
|
||||
|
||||
public interface IContactsDbContext
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
|
||||
namespace Knot.Modules.Relations.Application.Contacts;
|
||||
|
||||
public class ContactDto
|
||||
{
|
||||
public Guid Id { get; init; }
|
||||
public string Username { get; init; } = string.Empty;
|
||||
public string DisplayName { get; init; } = string.Empty;
|
||||
public string Avatar { get; init; } = string.Empty;
|
||||
public bool IsOnline { get; init; }
|
||||
public DateTime? LastSeen { get; init; }
|
||||
public Guid RelationId { get; init; }
|
||||
public bool IsBlocked { get; init; }
|
||||
public bool IsExternal { get; init; }
|
||||
public string? Domain { get; init; }
|
||||
|
||||
public ContactDto(
|
||||
Guid id,
|
||||
string username,
|
||||
string displayName,
|
||||
string avatar,
|
||||
bool isOnline,
|
||||
DateTime? lastSeen,
|
||||
Guid relationId,
|
||||
bool isBlocked = false,
|
||||
bool isExternal = false,
|
||||
string? domain = null)
|
||||
{
|
||||
Id = id;
|
||||
Username = username;
|
||||
DisplayName = displayName;
|
||||
Avatar = avatar;
|
||||
IsOnline = isOnline;
|
||||
LastSeen = lastSeen;
|
||||
RelationId = relationId;
|
||||
IsBlocked = isBlocked;
|
||||
IsExternal = isExternal;
|
||||
Domain = domain;
|
||||
}
|
||||
}
|
||||
@@ -10,18 +10,6 @@ using Knot.Modules.Relations.Application.Abstractions;
|
||||
|
||||
namespace Knot.Modules.Relations.Application.Contacts;
|
||||
|
||||
public record ContactDto(
|
||||
Guid Id,
|
||||
string Username,
|
||||
string DisplayName,
|
||||
string Avatar,
|
||||
bool IsOnline,
|
||||
DateTime? LastSeen,
|
||||
Guid RelationId,
|
||||
bool IsBlocked = false,
|
||||
bool IsExternal = false,
|
||||
string? Domain = null);
|
||||
|
||||
public record GetContactsQuery(Guid UserId) : IQuery<List<ContactDto>>;
|
||||
|
||||
internal sealed class GetContactsQueryHandler : IQueryHandler<GetContactsQuery, List<ContactDto>>
|
||||
@@ -56,7 +44,7 @@ internal sealed class GetContactsQueryHandler : IQueryHandler<GetContactsQuery,
|
||||
replica.Username,
|
||||
replica.DisplayName,
|
||||
replica.Avatar,
|
||||
false, // Presence handled by another service or real-time
|
||||
false,
|
||||
null,
|
||||
rel.Id,
|
||||
rel.Status == ContactStatus.Blocked,
|
||||
|
||||
@@ -14,9 +14,6 @@ internal sealed class RemoveContactCommandHandler : ICommandHandler<RemoveContac
|
||||
{
|
||||
private readonly IContactsDbContext _context;
|
||||
|
||||
public ContactRelationNotFound() : base("Contacts.NotFound", "Contact relation not found.") { }
|
||||
public ContactRelationUnauthorized() : base("Contacts.Unauthorized", "You are not authorized to remove this contact.") { }
|
||||
|
||||
public RemoveContactCommandHandler(IContactsDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
|
||||
21
backend/src/Modules/Relations/DependencyInjection.cs
Normal file
21
backend/src/Modules/Relations/DependencyInjection.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Knot.Modules.Relations.Infrastructure.Persistence;
|
||||
|
||||
namespace Knot.Modules.Relations;
|
||||
|
||||
public static class DependencyInjection
|
||||
{
|
||||
public static IServiceCollection AddRelationsModule(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
var connectionString = configuration.GetConnectionString("DefaultConnection");
|
||||
services.AddDbContext<RelationsDbContext>(options =>
|
||||
options.UseNpgsql(connectionString));
|
||||
|
||||
services.AddMediatR(config =>
|
||||
config.RegisterServicesFromAssembly(typeof(DependencyInjection).Assembly));
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Shared\Knot.Shared.Kernel\Knot.Shared.Kernel.csproj" />
|
||||
<ProjectReference Include="..\..\Shared\Knot.Shared.Infrastructure\Knot.Shared.Infrastructure.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -15,11 +16,15 @@
|
||||
<PackageReference Include="MediatR" Version="12.0.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="10.0.4" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.0" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
<ProjectReference Include="..\Settings\Knot.Modules.Settings.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
using Carter;
|
||||
using Knot.Shared.Kernel;
|
||||
using Knot.Modules.Relations.Application.Friends;
|
||||
using Knot.Modules.Relations.Application.Friends.DTOs;
|
||||
using Knot.Shared.Infrastructure;
|
||||
using Knot.Modules.Relations.Application.Contacts;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Knot.Modules.Relations.Application.Contacts;
|
||||
|
||||
namespace Knot.Modules.Relations.Presentation.Endpoints;
|
||||
|
||||
69
backend/src/Modules/Relations/rel_err.json
Normal file
69
backend/src/Modules/Relations/rel_err.json
Normal file
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/sarif-1.0.0",
|
||||
"version": "1.0.0",
|
||||
"runs": [
|
||||
{
|
||||
"tool": {
|
||||
"name": "Компилятор Microsoft (R) Visual C#",
|
||||
"version": "5.0.0.0",
|
||||
"fileVersion": "5.0.0-1.25358.103 (75972a5b)",
|
||||
"semanticVersion": "5.0.0",
|
||||
"language": "ru-RU"
|
||||
},
|
||||
"results": [
|
||||
{
|
||||
"ruleId": "CS1520",
|
||||
"level": "error",
|
||||
"message": "Метод должен иметь тип возвращаемого значения",
|
||||
"locations": [
|
||||
{
|
||||
"resultFile": {
|
||||
"uri": "file:///E:/GIT/forkmessager/backend/src/Modules/Relations/Application/Contacts/RemoveContact.cs",
|
||||
"region": {
|
||||
"startLine": 17,
|
||||
"startColumn": 12,
|
||||
"endLine": 17,
|
||||
"endColumn": 35
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"ruleId": "CS1520",
|
||||
"level": "error",
|
||||
"message": "Метод должен иметь тип возвращаемого значения",
|
||||
"locations": [
|
||||
{
|
||||
"resultFile": {
|
||||
"uri": "file:///E:/GIT/forkmessager/backend/src/Modules/Relations/Application/Contacts/RemoveContact.cs",
|
||||
"region": {
|
||||
"startLine": 18,
|
||||
"startColumn": 12,
|
||||
"endLine": 18,
|
||||
"endColumn": 39
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"rules": {
|
||||
"CS1520": {
|
||||
"id": "CS1520",
|
||||
"defaultLevel": "error",
|
||||
"helpUri": "https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS1520)",
|
||||
"properties": {
|
||||
"category": "Compiler",
|
||||
"isEnabledByDefault": true,
|
||||
"tags": [
|
||||
"Compiler",
|
||||
"Telemetry",
|
||||
"NotConfigurable"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user