Перенёс Abstractions в другой namespace и небольшие улучшения

This commit is contained in:
2025-09-22 23:13:38 +03:00
parent f9bf2a46e0
commit 5b961e5b18
12 changed files with 21 additions and 16 deletions

View File

@@ -1,4 +1,4 @@
namespace SfeduSchedule.Plugin.Abstractions;
namespace SfeduSchedule.Abstractions;
// Базовый контракт плагина (общий для хоста и плагинов)
public interface IPlugin

View File

@@ -1,6 +1,6 @@
using System.ComponentModel;
namespace SfeduSchedule.Plugin.Abstractions;
namespace SfeduSchedule.Abstractions;
/// <summary>
/// DTO для запроса расписания в Modeus.

View File

@@ -1,5 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using SfeduSchedule.Plugin.Abstractions;
using SfeduSchedule.Abstractions;
namespace SfeduSchedule.Plugin.Sample;

View File

@@ -12,9 +12,7 @@
</PropertyGroup>
<ItemGroup>
<!-- Даёт доступ к Microsoft.AspNetCore.* (ControllerBase и т.п.) -->
<FrameworkReference Include="Microsoft.AspNetCore.App"/>
<ProjectReference Include="..\SfeduSchedule.Plugin.Abstractions\SfeduSchedule.Plugin.Abstractions.csproj" />
<ProjectReference Include="..\SfeduSchedule.Abstractions\SfeduSchedule.Abstractions.csproj" />
</ItemGroup>

View File

@@ -2,7 +2,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SfeduSchedule", "SfeduSchedule\SfeduSchedule.csproj", "{57B088A7-D7E2-4B5D-82A4-A3070A78A3E4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SfeduSchedule.Plugin.Abstractions", "SfeduSchedule.Plugin.Abstractions\SfeduSchedule.Plugin.Abstractions.csproj", "{B2E8DAD7-7373-4155-B230-4E53DFC04445}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SfeduSchedule.Abstractions", "SfeduSchedule.Abstractions\SfeduSchedule.Abstractions.csproj", "{B2E8DAD7-7373-4155-B230-4E53DFC04445}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SfeduSchedule.Plugin.Sample", "SfeduSchedule.Plugin.Sample\SfeduSchedule.Plugin.Sample.csproj", "{B2B6D730-46AE-40ED-815F-81176FB4E545}"
EndProject

View File

@@ -3,7 +3,7 @@ using System.Text.Json;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.RateLimiting;
using SfeduSchedule.Plugin.Abstractions;
using SfeduSchedule.Abstractions;
using SfeduSchedule.Services;
namespace SfeduSchedule.Controllers
@@ -71,6 +71,7 @@ namespace SfeduSchedule.Controllers
/// <response code="401">Неавторизованный</response>
[HttpGet]
[Authorize(AuthenticationSchemes = "ApiKey")]
[DisableRateLimiting]
[Route("getguid")]
public async Task<IActionResult> GetGuid(string fullname)
{

View File

@@ -65,4 +65,4 @@ public static class MicrosoftLoginHelper
if (Regex.IsMatch(currentHost, "login\\.(microsoftonline|live)\\.com", RegexOptions.IgnoreCase))
throw new Exception("Авторизация не завершена: остались на странице Microsoft Login");
}
}
}

View File

@@ -1,6 +1,6 @@
using System.Reflection;
using System.Runtime.Loader;
using SfeduSchedule.Plugin.Abstractions;
using SfeduSchedule.Abstractions;
namespace SfeduSchedule;
@@ -50,7 +50,7 @@ public sealed class PluginLoadContext : AssemblyLoadContext
}
// Разрешаем управляемые зависимости плагина из его папки.
// Возвращаем null, чтобы отдать решение в Default ALC для общих сборок (например, SfeduSchedule.Plugin.Abstractions).
// Возвращаем null, чтобы отдать решение в Default ALC для общих сборок (например, SfeduSchedule.Abstractions).
protected override Assembly? Load(AssemblyName assemblyName)
{
var path = _resolver.ResolveAssemblyToPath(assemblyName);

View File

@@ -18,6 +18,12 @@ string? tgChatId = configuration["TG_CHAT_ID"];
string? tgToken = configuration["TG_TOKEN"];
string updateJwtCron = configuration["UPDATE_JWT_CRON"] ?? "0 0 4 ? * *";
// Если не указана TZ, ставим Europe/Moscow
if (string.IsNullOrEmpty(configuration["TZ"]))
{
configuration["TZ"] = "Europe/Moscow";
}
int permitLimit = int.TryParse(configuration["PERMIT_LIMIT"], out var parsedPermitLimit) ? parsedPermitLimit : 40;
int timeLimit = int.TryParse(configuration["TIME_LIMIT"], out var parsedTimeLimit) ? parsedTimeLimit : 10;
@@ -96,7 +102,7 @@ builder.Services.AddSwaggerGen(options =>
var mainXmlPath = Path.Combine(AppContext.BaseDirectory, mainXmlFile);
options.IncludeXmlComments(mainXmlPath);
var pluginXmlFile = "SfeduSchedule.Plugin.Abstractions.xml";
var pluginXmlFile = "SfeduSchedule.Abstractions.xml";
var pluginXmlPath = Path.Combine(AppContext.BaseDirectory, pluginXmlFile);
options.IncludeXmlComments(pluginXmlPath);

View File

@@ -1,6 +1,6 @@
using System.Text.Json;
using Microsoft.Net.Http.Headers;
using SfeduSchedule.Plugin.Abstractions;
using SfeduSchedule.Abstractions;
namespace SfeduSchedule.Services
{
@@ -20,9 +20,9 @@ namespace SfeduSchedule.Services
_httpClient.DefaultRequestHeaders.Add(HeaderNames.Authorization, $"Bearer {token}");
}
public async Task<string?> GetScheduleAsync(ModeusScheduleRequest msr, string TZ = "Europe/Moscow")
public async Task<string?> GetScheduleAsync(ModeusScheduleRequest msr)
{
var request = new HttpRequestMessage(HttpMethod.Post, $"schedule-calendar-v2/api/calendar/events/search?tz={TZ}");
var request = new HttpRequestMessage(HttpMethod.Post, $"schedule-calendar-v2/api/calendar/events/search?tz={_configuration["TZ"]!}");
request.Content = new StringContent(JsonSerializer.Serialize(msr, GlobalVariables.jsonSerializerOptions), System.Text.Encoding.UTF8, "application/json");
var response = await _httpClient.SendAsync(request);
_logger.LogInformation("GetScheduleAsync: Ответ получен: {StatusCode}", response.StatusCode);

View File

@@ -18,7 +18,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SfeduSchedule.Plugin.Abstractions\SfeduSchedule.Plugin.Abstractions.csproj" />
<ProjectReference Include="..\SfeduSchedule.Abstractions\SfeduSchedule.Abstractions.csproj" />
</ItemGroup>
</Project>