diff --git a/Directory.Build.props b/Directory.Build.props index 899da35..bedb16d 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,14 +1,14 @@  - net8.0 + net10.0 disable enable true Winsomnia - 1.1.0 - 1.1.3.0 - 1.1.3.0 + 1.2.0 + 1.2.0.0 + 1.2.0.0 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 0661923..ca0f610 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base LABEL company="Winsomnia" LABEL maintainer.name="Wesser" maintainer.email="support@winsomnia.net" WORKDIR /app @@ -7,7 +7,7 @@ RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD curl --fail http://localhost:8080/health || exit 1 -FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build WORKDIR /src COPY . . @@ -15,15 +15,19 @@ ARG NUGET_USERNAME ARG NUGET_PASSWORD ARG NUGET_ADDRESS -ENV NUGET_USERNAME=$NUGET_USERNAME -ENV NUGET_PASSWORD=$NUGET_PASSWORD -ENV NUGET_ADDRESS=$NUGET_ADDRESS +RUN dotnet nuget add source ${NUGET_ADDRESS} \ + --name Winsomnia \ + --username ${NUGET_USERNAME} \ + --password ${NUGET_PASSWORD} \ + --store-password-in-clear-text -RUN dotnet nuget add source --name="Winsomnia" --username ${NUGET_USERNAME} --store-password-in-clear-text --password ${NUGET_PASSWORD} ${NUGET_ADDRESS} RUN dotnet restore ./Backend.sln -WORKDIR /app -WORKDIR /src -RUN dotnet publish ./Endpoint/Endpoint.csproj -c Release --self-contained false -p:PublishSingleFile=false -o /app + +RUN dotnet publish Endpoint/Endpoint.csproj \ + -c Release \ + --self-contained false \ + -p:PublishSingleFile=false \ + -o /app FROM base AS final WORKDIR /app diff --git a/Endpoint/Configuration/Core/Startup/LoggerConfiguration.cs b/Endpoint/Configuration/Core/Startup/LoggerConfiguration.cs index aadb912..e56b95c 100644 Binary files a/Endpoint/Configuration/Core/Startup/LoggerConfiguration.cs and b/Endpoint/Configuration/Core/Startup/LoggerConfiguration.cs differ diff --git a/Endpoint/Configuration/Core/Startup/SwaggerConfiguration.cs b/Endpoint/Configuration/Core/Startup/SwaggerConfiguration.cs index ae6f3f9..7cb2f14 100644 Binary files a/Endpoint/Configuration/Core/Startup/SwaggerConfiguration.cs and b/Endpoint/Configuration/Core/Startup/SwaggerConfiguration.cs differ diff --git a/Endpoint/Configuration/SwaggerOptions/ActionResultSchemaFilter.cs b/Endpoint/Configuration/SwaggerOptions/ActionResultSchemaFilter.cs deleted file mode 100644 index f1584e2..0000000 --- a/Endpoint/Configuration/SwaggerOptions/ActionResultSchemaFilter.cs +++ /dev/null @@ -1,81 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.OpenApi.Models; -using Swashbuckle.AspNetCore.SwaggerGen; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Mirea.Api.Endpoint.Configuration.SwaggerOptions; - -public class ActionResultSchemaFilter : IOperationFilter -{ - public void Apply(OpenApiOperation operation, OperationFilterContext context) - { - var returnType = context.MethodInfo.ReturnType; - if (!returnType.IsEquivalentTo(typeof(ActionResult)) && - !returnType.IsEquivalentTo(typeof(ContentResult)) && - !returnType.IsEquivalentTo(typeof(FileStreamResult)) && - !returnType.IsGenericType) - return; - - if (returnType.IsGenericType && - !returnType.GetGenericTypeDefinition().IsEquivalentTo(typeof(ActionResult<>)) && - !returnType.GetGenericTypeDefinition().IsEquivalentTo(typeof(Task<>))) - return; - - var genericType = returnType.IsGenericType ? returnType.GetGenericArguments().FirstOrDefault() : returnType; - if (genericType == null) - return; - - var responseTypeAttributes = context.MethodInfo.GetCustomAttributes(typeof(ProducesResponseTypeAttribute), false) - .Cast() - .Where(attr => attr.StatusCode == 200) - .ToList(); - - var contentType = "application/json"; - - if (context.MethodInfo.GetCustomAttributes(typeof(ProducesAttribute), false) - .FirstOrDefault() is ProducesAttribute producesAttribute) - contentType = producesAttribute.ContentTypes.FirstOrDefault() ?? "application/json"; - - if (responseTypeAttributes.Count != 0) - { - var responseType = responseTypeAttributes.First().Type; - genericType = responseType; - } - - if (genericType.IsEquivalentTo(typeof(ContentResult)) || genericType.IsEquivalentTo(typeof(FileStreamResult))) - { - operation.Responses["200"] = new OpenApiResponse - { - Description = "OK", - Content = new Dictionary - { - [contentType] = new() - } - }; - } - else if (genericType == typeof(ActionResult)) - { - operation.Responses["200"] = new OpenApiResponse { Description = "OK" }; - } - else - { - OpenApiSchema schema; - if (genericType.IsGenericType && genericType.GetGenericTypeDefinition() == typeof(ActionResult<>)) - schema = context.SchemaGenerator.GenerateSchema(genericType.GetGenericArguments().FirstOrDefault(), - context.SchemaRepository); - else - schema = context.SchemaGenerator.GenerateSchema(genericType, context.SchemaRepository); - - operation.Responses["200"] = new OpenApiResponse - { - Description = "OK", - Content = new Dictionary - { - [contentType] = new() { Schema = schema } - } - }; - } - } -} \ No newline at end of file diff --git a/Endpoint/Configuration/SwaggerOptions/ConfigureSwaggerOptions.cs b/Endpoint/Configuration/SwaggerOptions/ConfigureSwaggerOptions.cs index 8b40ca0..55d5e9c 100644 Binary files a/Endpoint/Configuration/SwaggerOptions/ConfigureSwaggerOptions.cs and b/Endpoint/Configuration/SwaggerOptions/ConfigureSwaggerOptions.cs differ diff --git a/Endpoint/Configuration/SwaggerOptions/DefaultValues.cs b/Endpoint/Configuration/SwaggerOptions/DefaultValues.cs deleted file mode 100644 index 7ad61a9..0000000 --- a/Endpoint/Configuration/SwaggerOptions/DefaultValues.cs +++ /dev/null @@ -1,51 +0,0 @@ -using Microsoft.AspNetCore.Mvc.ApiExplorer; -using Microsoft.AspNetCore.Mvc.ModelBinding; -using Microsoft.OpenApi.Models; -using Swashbuckle.AspNetCore.SwaggerGen; -using System; -using System.Linq; -using System.Text.Json; - -namespace Mirea.Api.Endpoint.Configuration.SwaggerOptions; - -public class DefaultValues : IOperationFilter -{ - public void Apply(OpenApiOperation operation, OperationFilterContext context) - { - var apiDescription = context.ApiDescription; - operation.Deprecated |= apiDescription.IsDeprecated(); - - foreach (var responseType in context.ApiDescription.SupportedResponseTypes) - { - var responseKey = responseType.IsDefaultResponse ? "default" : responseType.StatusCode.ToString(); - var response = operation.Responses[responseKey]; - - foreach (var contentType in response.Content.Keys) - { - if (responseType.ApiResponseFormats.All(x => x.MediaType != contentType)) - response.Content.Remove(contentType); - } - } - - if (operation.Parameters == null) - return; - - foreach (var parameter in operation.Parameters) - { - var description = apiDescription.ParameterDescriptions.First(p => p.Name == parameter.Name); - - parameter.Description ??= description.ModelMetadata.Description; - - if (parameter.Schema.Default == null && - description.DefaultValue != null && - description.DefaultValue is not DBNull && - description.ModelMetadata is ModelMetadata modelMetadata) - { - var json = JsonSerializer.Serialize(description.DefaultValue, modelMetadata.ModelType); - parameter.Schema.Default = OpenApiAnyFactory.CreateFromJson(json); - } - - parameter.Required |= description.IsRequired; - } - } -} \ No newline at end of file diff --git a/Endpoint/Configuration/SwaggerOptions/EnumSchemaFilter.cs b/Endpoint/Configuration/SwaggerOptions/EnumSchemaFilter.cs deleted file mode 100644 index f64fc87..0000000 --- a/Endpoint/Configuration/SwaggerOptions/EnumSchemaFilter.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Microsoft.OpenApi.Any; -using Microsoft.OpenApi.Models; -using Swashbuckle.AspNetCore.SwaggerGen; -using System; -using System.Linq; - -namespace Mirea.Api.Endpoint.Configuration.SwaggerOptions; - -public class EnumSchemaFilter : ISchemaFilter -{ - public void Apply(OpenApiSchema schema, SchemaFilterContext context) - { - if (!context.Type.IsEnum) - return; - - schema.Enum.Clear(); - - var enumValues = Enum.GetNames(context.Type) - .Select(name => new OpenApiString(name)) - .ToList(); - - foreach (var value in enumValues) - schema.Enum.Add(value); - - schema.Type = "string"; - schema.Format = null; - } -} \ No newline at end of file diff --git a/Endpoint/Configuration/SwaggerOptions/ExampleFilter.cs b/Endpoint/Configuration/SwaggerOptions/ExampleFilter.cs deleted file mode 100644 index 060aa52..0000000 --- a/Endpoint/Configuration/SwaggerOptions/ExampleFilter.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Microsoft.OpenApi.Models; -using Mirea.Api.Endpoint.Common.Attributes; -using Swashbuckle.AspNetCore.SwaggerGen; -using System.Reflection; - -namespace Mirea.Api.Endpoint.Configuration.SwaggerOptions; - -public class ExampleFilter : ISchemaFilter -{ - public void Apply(OpenApiSchema schema, SchemaFilterContext context) - { - var att = context.ParameterInfo?.GetCustomAttribute(); - if (att != null) - schema.Example = new Microsoft.OpenApi.Any.OpenApiString(att.Value); - } -} \ No newline at end of file diff --git a/Endpoint/Configuration/SwaggerOptions/TagSchemeFilter.cs b/Endpoint/Configuration/SwaggerOptions/TagSchemeFilter.cs deleted file mode 100644 index 4c2be6f..0000000 --- a/Endpoint/Configuration/SwaggerOptions/TagSchemeFilter.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc.Controllers; -using Microsoft.OpenApi.Models; -using Swashbuckle.AspNetCore.SwaggerGen; -using System.Linq; -using System.Reflection; - -namespace Mirea.Api.Endpoint.Configuration.SwaggerOptions; - -public class TagSchemeFilter : IOperationFilter -{ - public void Apply(OpenApiOperation operation, OperationFilterContext context) - { - if (context.ApiDescription.ActionDescriptor is not ControllerActionDescriptor controllerActionDescriptor) - return; - - var controllerType = controllerActionDescriptor.ControllerTypeInfo; - - var tagsAttribute = controllerType.GetCustomAttributes(inherit: true).FirstOrDefault(); - - if (tagsAttribute == null) - { - var baseType = controllerType.BaseType; - while (baseType != null) - { - tagsAttribute = baseType.GetCustomAttributes(inherit: true).FirstOrDefault(); - if (tagsAttribute != null) - break; - - baseType = baseType.BaseType; - } - } - - if (tagsAttribute == null) - return; - - operation.Tags ??= []; - operation.Tags.Add(new OpenApiTag { Name = tagsAttribute.Tags[0] }); - } -} \ No newline at end of file diff --git a/Endpoint/Endpoint.csproj b/Endpoint/Endpoint.csproj index 1215604..2e64ba9 100644 --- a/Endpoint/Endpoint.csproj +++ b/Endpoint/Endpoint.csproj @@ -9,7 +9,7 @@ docs.xml $(NoWarn);1591 false - + @@ -20,63 +20,50 @@ - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - + + - - - - - + + + + + - + - + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + @@ -86,7 +73,6 @@ - \ No newline at end of file diff --git a/Endpoint/Program.cs b/Endpoint/Program.cs index 7edc3b9..4b6af60 100644 Binary files a/Endpoint/Program.cs and b/Endpoint/Program.cs differ diff --git a/Endpoint/Properties/launchSettings.json b/Endpoint/Properties/launchSettings.json index 7bd9647..c47a070 100644 Binary files a/Endpoint/Properties/launchSettings.json and b/Endpoint/Properties/launchSettings.json differ diff --git a/Endpoint/Resources/SharedResources.Designer.cs b/Endpoint/Resources/SharedResources.Designer.cs new file mode 100644 index 0000000..5c5f3e3 --- /dev/null +++ b/Endpoint/Resources/SharedResources.Designer.cs @@ -0,0 +1,90 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace Mirea.Api.Endpoint.Resources { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом StronglyTypedResourceBuilder + // с помощью такого средства, как ResGen или Visual Studio. + // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen + // с параметром /str или перестройте свой проект VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class SharedResources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal SharedResources() { + } + + /// + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Mirea.Api.Endpoint.Resources.SharedResources", typeof(SharedResources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Ищет локализованную строку, похожую на Please provide this traceId to the administrator for further investigation.. + /// + public static string ProvideTraceId { + get { + return ResourceManager.GetString("ProvideTraceId", resourceCulture); + } + } + + /// + /// Ищет локализованную строку, похожую на Resource not found.. + /// + public static string ResourceNotFound { + get { + return ResourceManager.GetString("ResourceNotFound", resourceCulture); + } + } + + /// + /// Ищет локализованную строку, похожую на An unexpected error occurred.. + /// + public static string UnexpectedErrorOccurred { + get { + return ResourceManager.GetString("UnexpectedErrorOccurred", resourceCulture); + } + } + } +} diff --git a/Endpoint/Resources/SharedResources.resx b/Endpoint/Resources/SharedResources.resx new file mode 100644 index 0000000..9fd9950 --- /dev/null +++ b/Endpoint/Resources/SharedResources.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Please provide this traceId to the administrator for further investigation. + + + Resource not found. + + + An unexpected error occurred. + + \ No newline at end of file diff --git a/Endpoint/Resources/SharedResources.ru-RU.resx b/Endpoint/Resources/SharedResources.ru-RU.resx new file mode 100644 index 0000000..baed993 --- /dev/null +++ b/Endpoint/Resources/SharedResources.ru-RU.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + + + + + Неизвестная ошибка + + \ No newline at end of file diff --git a/Security/Security.csproj b/Security/Security.csproj index dd9d12a..dee6605 100644 --- a/Security/Security.csproj +++ b/Security/Security.csproj @@ -8,8 +8,6 @@ - - diff --git a/SqlData/Application/Application.csproj b/SqlData/Application/Application.csproj index 46dda66..7bee919 100644 --- a/SqlData/Application/Application.csproj +++ b/SqlData/Application/Application.csproj @@ -6,13 +6,13 @@ - - - - - - - + + + + + + + diff --git a/SqlData/Persistence/DependencyInjection.cs b/SqlData/Persistence/DependencyInjection.cs index b9376a9..fba6271 100644 Binary files a/SqlData/Persistence/DependencyInjection.cs and b/SqlData/Persistence/DependencyInjection.cs differ diff --git a/SqlData/Persistence/Persistence.csproj b/SqlData/Persistence/Persistence.csproj index a939260..90011ec 100644 --- a/SqlData/Persistence/Persistence.csproj +++ b/SqlData/Persistence/Persistence.csproj @@ -9,9 +9,8 @@ - - - + +