Update project structure
This commit is contained in:
parent
a1ca6e3b14
commit
c88a7aee5e
@ -28,8 +28,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nocr.TextMatcher.Persistenc
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Contracts", "Contracts", "{0B8E28B3-EECC-4981-A87F-6D74C4F23371}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Contracts", "Contracts", "{0B8E28B3-EECC-4981-A87F-6D74C4F23371}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nocr.TextMatcher.Domain", "src\Nocr.TextMatcher.Domain\Nocr.TextMatcher.Domain.csproj", "{301BBDEA-ACF8-404D-83FA-AA26A8153D35}"
|
|
||||||
EndProject
|
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -68,10 +66,6 @@ Global
|
|||||||
{D578EE54-B55A-4B45-859D-7F343C73EEF5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{D578EE54-B55A-4B45-859D-7F343C73EEF5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{D578EE54-B55A-4B45-859D-7F343C73EEF5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{D578EE54-B55A-4B45-859D-7F343C73EEF5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{D578EE54-B55A-4B45-859D-7F343C73EEF5}.Release|Any CPU.Build.0 = Release|Any CPU
|
{D578EE54-B55A-4B45-859D-7F343C73EEF5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{301BBDEA-ACF8-404D-83FA-AA26A8153D35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{301BBDEA-ACF8-404D-83FA-AA26A8153D35}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{301BBDEA-ACF8-404D-83FA-AA26A8153D35}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{301BBDEA-ACF8-404D-83FA-AA26A8153D35}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(NestedProjects) = preSolution
|
GlobalSection(NestedProjects) = preSolution
|
||||||
{B721E055-84AF-44C6-973D-33241FD2EA7C} = {6E4D9F75-861F-4C00-A5C8-00D1BEE5A659}
|
{B721E055-84AF-44C6-973D-33241FD2EA7C} = {6E4D9F75-861F-4C00-A5C8-00D1BEE5A659}
|
||||||
|
|||||||
@ -15,7 +15,6 @@
|
|||||||
<ProjectReference Include="..\Nocr.TextMatcher.Api.Contracts\Nocr.TextMatcher.Api.Contracts.csproj" />
|
<ProjectReference Include="..\Nocr.TextMatcher.Api.Contracts\Nocr.TextMatcher.Api.Contracts.csproj" />
|
||||||
<ProjectReference Include="..\Nocr.TextMatcher.Async.Api.Contracts\Nocr.TextMatcher.Async.Api.Contracts.csproj" />
|
<ProjectReference Include="..\Nocr.TextMatcher.Async.Api.Contracts\Nocr.TextMatcher.Async.Api.Contracts.csproj" />
|
||||||
<ProjectReference Include="..\Nocr.TextMatcher.Core\Nocr.TextMatcher.Core.csproj" />
|
<ProjectReference Include="..\Nocr.TextMatcher.Core\Nocr.TextMatcher.Core.csproj" />
|
||||||
<ProjectReference Include="..\Nocr.TextMatcher.Persistence\Nocr.TextMatcher.Persistence.csproj" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Nocr.TextMatcher.AppServices.TextMatches.Repositories;
|
using Nocr.TextMatcher.AppServices.TextSubscriptions.EventHandlers;
|
||||||
using Nocr.TextMatcher.AppServices.TextMatches.Services;
|
using Nocr.TextMatcher.AppServices.TextSubscriptions.Services;
|
||||||
using Nocr.TextMatcher.AppServices.TextSubscriptions;
|
|
||||||
using Rebus.Config;
|
using Rebus.Config;
|
||||||
|
|
||||||
namespace Nocr.TextMatcher.AppServices;
|
namespace Nocr.TextMatcher.AppServices;
|
||||||
@ -16,7 +15,6 @@ public static class ServiceCollectionExtensions
|
|||||||
// Add registrations here
|
// Add registrations here
|
||||||
services.AddRebusHandler<MessageReceivedHandler>();
|
services.AddRebusHandler<MessageReceivedHandler>();
|
||||||
services.AddScoped<ITextSubscriptionsService, TextSubscriptionsService>();
|
services.AddScoped<ITextSubscriptionsService, TextSubscriptionsService>();
|
||||||
services.AddScoped<ITextSubscriptionRepository, TextSubscriptionRepository>();
|
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Nocr.TelegramListener.Async.Api.Contracts.Events;
|
using Nocr.TelegramListener.Async.Api.Contracts.Events;
|
||||||
using Nocr.TextMatcher.AppServices.TextMatches.Repositories;
|
using Nocr.TextMatcher.AppServices.TextSubscriptions.Repositories;
|
||||||
using Nocr.TextMatcher.Async.Api.Contracts;
|
using Nocr.TextMatcher.Async.Api.Contracts;
|
||||||
using Nocr.TextMatcher.Core.Dates;
|
using Nocr.TextMatcher.Core.Dates;
|
||||||
using Rebus.Bus;
|
using Rebus.Bus;
|
||||||
using Rebus.Handlers;
|
using Rebus.Handlers;
|
||||||
|
|
||||||
namespace Nocr.TextMatcher.AppServices.TextSubscriptions;
|
namespace Nocr.TextMatcher.AppServices.TextSubscriptions.EventHandlers;
|
||||||
|
|
||||||
public sealed class MessageReceivedHandler : IHandleMessages<MessageReceived>
|
public sealed class MessageReceivedHandler : IHandleMessages<MessageReceived>
|
||||||
{
|
{
|
||||||
@ -42,7 +42,7 @@ public sealed class MessageReceivedHandler : IHandleMessages<MessageReceived>
|
|||||||
SubscriptionId = match.Id,
|
SubscriptionId = match.Id,
|
||||||
SubscriptionUserId = match.UserId,
|
SubscriptionUserId = match.UserId,
|
||||||
ChatUsername = match.ChatUsername,
|
ChatUsername = match.ChatUsername,
|
||||||
Rule = (int)match.Rule,
|
Rule = match.Rule,
|
||||||
Template = match.Template,
|
Template = match.Template,
|
||||||
Text = message.Text,
|
Text = message.Text,
|
||||||
From = message.From,
|
From = message.From,
|
||||||
@ -1,4 +1,4 @@
|
|||||||
namespace Nocr.TextMatcher.AppServices.TextMatches.Repositories;
|
namespace Nocr.TextMatcher.AppServices.TextSubscriptions.Repositories;
|
||||||
|
|
||||||
public interface ITextSubscriptionRepository
|
public interface ITextSubscriptionRepository
|
||||||
{
|
{
|
||||||
@ -1,7 +1,7 @@
|
|||||||
using Nocr.TextMatcher.Api.Contracts.TextMatches.Dto;
|
using Nocr.TextMatcher.Api.Contracts.TextMatches.Dto;
|
||||||
using Nocr.TextMatcher.Contracts;
|
using Nocr.TextMatcher.Contracts;
|
||||||
|
|
||||||
namespace Nocr.TextMatcher.AppServices.TextMatches.Services;
|
namespace Nocr.TextMatcher.AppServices.TextSubscriptions.Services;
|
||||||
|
|
||||||
public interface ITextSubscriptionsService
|
public interface ITextSubscriptionsService
|
||||||
{
|
{
|
||||||
@ -1,11 +1,11 @@
|
|||||||
using Nocr.TextMatcher.Api.Contracts.TextMatches.Dto;
|
using Nocr.TextMatcher.Api.Contracts.TextMatches.Dto;
|
||||||
using Nocr.TextMatcher.AppServices.TextMatches.Repositories;
|
using Nocr.TextMatcher.AppServices.TextSubscriptions.Repositories;
|
||||||
using Nocr.TextMatcher.Async.Api.Contracts;
|
using Nocr.TextMatcher.Async.Api.Contracts;
|
||||||
using Nocr.TextMatcher.Contracts;
|
using Nocr.TextMatcher.Contracts;
|
||||||
using Nocr.TextMatcher.Core.Dates;
|
using Nocr.TextMatcher.Core.Dates;
|
||||||
using Rebus.Bus;
|
using Rebus.Bus;
|
||||||
|
|
||||||
namespace Nocr.TextMatcher.AppServices.TextMatches.Services;
|
namespace Nocr.TextMatcher.AppServices.TextSubscriptions.Services;
|
||||||
|
|
||||||
public sealed class TextSubscriptionsService : ITextSubscriptionsService
|
public sealed class TextSubscriptionsService : ITextSubscriptionsService
|
||||||
{
|
{
|
||||||
@ -1,7 +1,7 @@
|
|||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Nocr.TextMatcher.Contracts;
|
using Nocr.TextMatcher.Contracts;
|
||||||
|
|
||||||
namespace Nocr.TextMatcher.AppServices.TextMatches;
|
namespace Nocr.TextMatcher.AppServices.TextSubscriptions;
|
||||||
|
|
||||||
public sealed class TextSubscription
|
public sealed class TextSubscription
|
||||||
{
|
{
|
||||||
@ -4,4 +4,8 @@
|
|||||||
<IsPackable>true</IsPackable>
|
<IsPackable>true</IsPackable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Nocr.TextMatcher.Contracts\Nocr.TextMatcher.Contracts.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
using Nocr.TextMatcher.Contracts;
|
||||||
|
|
||||||
namespace Nocr.TextMatcher.Async.Api.Contracts;
|
namespace Nocr.TextMatcher.Async.Api.Contracts;
|
||||||
|
|
||||||
public class TextSubscriptionMatched : IEvent
|
public class TextSubscriptionMatched : IEvent
|
||||||
@ -22,7 +24,7 @@ public class TextSubscriptionMatched : IEvent
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Правило совпадения
|
/// Правило совпадения
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Rule { get; set; }
|
public TextSubscriptionRule Rule { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Шаблон совпадения
|
/// Шаблон совпадения
|
||||||
|
|||||||
@ -1,12 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<IsPackable>false</IsPackable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\Nocr.TextMatcher.Contracts\Nocr.TextMatcher.Contracts.csproj" />
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
||||||
@ -2,7 +2,7 @@ using Microsoft.AspNetCore.Mvc;
|
|||||||
using Nocr.TextMatcher.Api.Contracts;
|
using Nocr.TextMatcher.Api.Contracts;
|
||||||
using Nocr.TextMatcher.Api.Contracts.TextMatches.Dto;
|
using Nocr.TextMatcher.Api.Contracts.TextMatches.Dto;
|
||||||
using Nocr.TextMatcher.Api.Contracts.TextMatches.Requests;
|
using Nocr.TextMatcher.Api.Contracts.TextMatches.Requests;
|
||||||
using Nocr.TextMatcher.AppServices.TextMatches.Services;
|
using Nocr.TextMatcher.AppServices.TextSubscriptions.Services;
|
||||||
|
|
||||||
namespace Nocr.TextMatcher.Host.Controllers;
|
namespace Nocr.TextMatcher.Host.Controllers;
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Nocr.TextMatcher.AppServices;
|
using Nocr.TextMatcher.AppServices;
|
||||||
using Nocr.TextMatcher.Core.Dates;
|
using Nocr.TextMatcher.Core.Dates;
|
||||||
@ -30,15 +29,7 @@ public class Startup
|
|||||||
services.AddSwaggerGen();
|
services.AddSwaggerGen();
|
||||||
|
|
||||||
services.AddAppServices();
|
services.AddAppServices();
|
||||||
services.AddDbContext<TextMatcherContext>(
|
services.AddEfPersistence(Configuration.GetConnectionString(nameof(TextMatcherContext))!);
|
||||||
(ctx, context) =>
|
|
||||||
{
|
|
||||||
context.UseMySql(Configuration.GetConnectionString(nameof(TextMatcherContext)),
|
|
||||||
new MariaDbServerVersion(MariaDbServerVersion.LatestSupportedServerVersion),
|
|
||||||
builder => builder.MigrationsAssembly(typeof(TextMatcherContext).Assembly.FullName))
|
|
||||||
.UseLoggerFactory(ctx.GetRequiredService<ILoggerFactory>());
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
services.Configure<RebusRabbitMqOptions>(Configuration.GetSection(nameof(RebusRabbitMqOptions)));
|
services.Configure<RebusRabbitMqOptions>(Configuration.GetSection(nameof(RebusRabbitMqOptions)));
|
||||||
services.AddRebus((builder, ctx) =>
|
services.AddRebus((builder, ctx) =>
|
||||||
|
|||||||
@ -18,7 +18,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Nocr.TextMatcher.Domain\Nocr.TextMatcher.Domain.csproj" />
|
<ProjectReference Include="..\Nocr.TextMatcher.AppServices\Nocr.TextMatcher.AppServices.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -0,0 +1,32 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Nocr.TextMatcher.AppServices.TextSubscriptions.Repositories;
|
||||||
|
using Nocr.TextMatcher.Persistence.TextSubscriptions;
|
||||||
|
|
||||||
|
namespace Nocr.TextMatcher.Persistence;
|
||||||
|
|
||||||
|
public static class ServiceCollectionExtensions
|
||||||
|
{
|
||||||
|
public static IServiceCollection AddEfPersistence(this IServiceCollection services, string connectionString)
|
||||||
|
{
|
||||||
|
if (services == null)
|
||||||
|
throw new ArgumentNullException(nameof(services));
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(connectionString))
|
||||||
|
throw new ArgumentNullException(nameof(connectionString));
|
||||||
|
|
||||||
|
services.AddScoped<ITextSubscriptionRepository, TextSubscriptionRepository>();
|
||||||
|
|
||||||
|
services.AddDbContext<TextMatcherContext>(
|
||||||
|
(ctx, context) =>
|
||||||
|
{
|
||||||
|
context.UseMySql(connectionString, new MariaDbServerVersion(MariaDbServerVersion.LatestSupportedServerVersion),
|
||||||
|
builder => builder.MigrationsAssembly(typeof(TextMatcherContext).Assembly.FullName))
|
||||||
|
.UseLoggerFactory(ctx.GetRequiredService<ILoggerFactory>());
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,5 +1,6 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Nocr.TextMatcher.AppServices.TextMatches;
|
using Nocr.TextMatcher.AppServices.TextSubscriptions;
|
||||||
|
using Nocr.TextMatcher.Persistence.TextSubscriptions;
|
||||||
|
|
||||||
namespace Nocr.TextMatcher.Persistence;
|
namespace Nocr.TextMatcher.Persistence;
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
using Nocr.TextMatcher.AppServices.TextMatches;
|
using Nocr.TextMatcher.AppServices.TextSubscriptions;
|
||||||
|
|
||||||
namespace Nocr.TextMatcher.Persistence;
|
namespace Nocr.TextMatcher.Persistence.TextSubscriptions;
|
||||||
|
|
||||||
public class TextSubscriptionConfiguration : IEntityTypeConfiguration<TextSubscription>
|
public class TextSubscriptionConfiguration : IEntityTypeConfiguration<TextSubscription>
|
||||||
{
|
{
|
||||||
@ -1,7 +1,8 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Nocr.TextMatcher.Persistence;
|
using Nocr.TextMatcher.AppServices.TextSubscriptions;
|
||||||
|
using Nocr.TextMatcher.AppServices.TextSubscriptions.Repositories;
|
||||||
|
|
||||||
namespace Nocr.TextMatcher.AppServices.TextMatches.Repositories;
|
namespace Nocr.TextMatcher.Persistence.TextSubscriptions;
|
||||||
|
|
||||||
public sealed class TextSubscriptionRepository : ITextSubscriptionRepository
|
public sealed class TextSubscriptionRepository : ITextSubscriptionRepository
|
||||||
{
|
{
|
||||||
@ -1,4 +1,4 @@
|
|||||||
using Nocr.TextMatcher.AppServices.TextMatches;
|
using Nocr.TextMatcher.AppServices.TextSubscriptions;
|
||||||
using Nocr.TextMatcher.Contracts;
|
using Nocr.TextMatcher.Contracts;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user