Conversation
| using System; | ||
| namespace AspireApp.ApiService.Properties.Entities; | ||
| using System.Text.Json.Serialization; |
There was a problem hiding this comment.
Папки Entities и Generator вынести из Properties
| public interface IWarehouseCache | ||
| { | ||
| /// <summary>Получить товар из кэша по идентификатору</summary> | ||
| Task<Warehouse?> GetAsync(int id); | ||
|
|
||
| /// <summary>Сохранить товар в кэш с временем</summary> | ||
| Task SetAsync(Warehouse warehouse, TimeSpan expiration); | ||
| } |
| public WarehouseCache(IDistributedCache cache, ILogger<WarehouseCache> logger) | ||
| { | ||
| _cache = cache; | ||
| _logger = logger; | ||
| } |
| /// <summary> | ||
| /// Генерация нескольких случайных товаров | ||
| /// </summary> | ||
| public List<Warehouse> Generate(int count) => _faker.Generate(count); |
| <Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net10.0</TargetFramework> |
There was a problem hiding this comment.
По заданию
Реализация серверной части на .NET 8.
| <ItemGroup> | ||
| <None Remove="Properties\Entities\" /> | ||
| <None Remove="Properties\Generator\" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <Folder Include="Properties\Entities\" /> | ||
| <Folder Include="Properties\Generator\" /> | ||
| </ItemGroup> |
There was a problem hiding this comment.
После переноса папок эти строки не понадобятся
| <ProjectReference Include="..\AspireApp.Web\AspireApp.Web.csproj"> | ||
| <ReferenceSourceTarget></ReferenceSourceTarget> | ||
| </ProjectReference> |
| <ItemGroup> | ||
| <PackageReference Include="Aspire.Hosting.Redis" Version="9.5.0" /> | ||
| </ItemGroup> |
AspireApp.ApiService/Program.cs
Outdated
| builder.AddRedisDistributedCache("RedisCache"); | ||
|
|
||
| builder.Services.AddScoped<IWarehouseCache, WarehouseCache>(); | ||
| builder.Services.AddScoped<WarehouseGenerator>(); |
There was a problem hiding this comment.
WarehouseGenerator можно зарегистрировать как Singleton- он никакого состояния не хранит, его методы не зависят от внешних данных, конструктор выполняет разовые настройки правил генерации
| public Warehouse Generate() | ||
| { | ||
| return _faker.Generate(); | ||
| } |
There was a problem hiding this comment.
public Warehouse Generate() => _faker.Generate();
AspireApp.ApiService/.DS_Store
Outdated
There was a problem hiding this comment.
Если я правильно понял, это файл, создаваемый macos для хранения пользовательских настроек папки. Может добавить его в .gitignore
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Aspire.StackExchange.Redis.DistributedCaching" Version="8.2.2" /> |
AspireApp.ApiService/Program.cs
Outdated
| policy.AllowAnyOrigin() | ||
| .AllowAnyMethod() | ||
| .AllowAnyHeader(); |
| using Microsoft.Extensions.Configuration; | ||
| using Microsoft.Extensions.Logging; |
AspireApp.ApiService/Program.cs
Outdated
| using Microsoft.AspNetCore.Builder; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Microsoft.Extensions.Hosting; |
There was a problem hiding this comment.
Прошлая версия AppHost.cs была верной, вернуть ее
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
There was a problem hiding this comment.
<Project Sdk="Microsoft.NET.Sdk">
<Sdk Name="Aspire.AppHost.Sdk" Version="9.5.2" />
и удалить global.json
There was a problem hiding this comment.
Я выполнила все ваши правки, но на моей macOS 26.3 .NET 8 не может установить компоненты Aspire, хотя сам SDK работает. Все нормально работает и устанавливается только на .NET 10. Можно продолжить на .NET 10?
There was a problem hiding this comment.
правки еще не добавила, потом все вместе залью
There was a problem hiding this comment.
Я посмотрела проекты одноггрупников, у некоторых тоже .NET 10 и им зачли лабораторную
| <PackageReference Include="Aspire.Hosting.AppHost" Version="8.2.2" /> | ||
| <PackageReference Include="Aspire.Hosting.Redis" Version="8.2.2" /> |
AspireApp.sln
Outdated
| {B463AE3B-1390-4073-B15B-77069FFA5C85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| {B463AE3B-1390-4073-B15B-77069FFA5C85}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| {B463AE3B-1390-4073-B15B-77069FFA5C85}.Debug|x64.ActiveCfg = Debug|Any CPU | ||
| {B463AE3B-1390-4073-B15B-77069FFA5C85}.Debug|x64.Build.0 = Debug|Any CPU | ||
| {B463AE3B-1390-4073-B15B-77069FFA5C85}.Debug|x86.ActiveCfg = Debug|Any CPU | ||
| {B463AE3B-1390-4073-B15B-77069FFA5C85}.Debug|x86.Build.0 = Debug|Any CPU | ||
| {B463AE3B-1390-4073-B15B-77069FFA5C85}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
| {B463AE3B-1390-4073-B15B-77069FFA5C85}.Release|Any CPU.Build.0 = Release|Any CPU | ||
| {B463AE3B-1390-4073-B15B-77069FFA5C85}.Release|x64.ActiveCfg = Release|Any CPU | ||
| {B463AE3B-1390-4073-B15B-77069FFA5C85}.Release|x64.Build.0 = Release|Any CPU | ||
| {B463AE3B-1390-4073-B15B-77069FFA5C85}.Release|x86.ActiveCfg = Release|Any CPU | ||
| {B463AE3B-1390-4073-B15B-77069FFA5C85}.Release|x86.Build.0 = Release|Any CPU | ||
| {AE8D1D1E-7160-4C73-B0DB-5AC93C8D7094}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| {AE8D1D1E-7160-4C73-B0DB-5AC93C8D7094}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| {AE8D1D1E-7160-4C73-B0DB-5AC93C8D7094}.Debug|x64.ActiveCfg = Debug|Any CPU | ||
| {AE8D1D1E-7160-4C73-B0DB-5AC93C8D7094}.Debug|x64.Build.0 = Debug|Any CPU | ||
| {AE8D1D1E-7160-4C73-B0DB-5AC93C8D7094}.Debug|x86.ActiveCfg = Debug|Any CPU | ||
| {AE8D1D1E-7160-4C73-B0DB-5AC93C8D7094}.Debug|x86.Build.0 = Debug|Any CPU | ||
| {AE8D1D1E-7160-4C73-B0DB-5AC93C8D7094}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
| {AE8D1D1E-7160-4C73-B0DB-5AC93C8D7094}.Release|Any CPU.Build.0 = Release|Any CPU | ||
| {AE8D1D1E-7160-4C73-B0DB-5AC93C8D7094}.Release|x64.ActiveCfg = Release|Any CPU | ||
| {AE8D1D1E-7160-4C73-B0DB-5AC93C8D7094}.Release|x64.Build.0 = Release|Any CPU | ||
| {AE8D1D1E-7160-4C73-B0DB-5AC93C8D7094}.Release|x86.ActiveCfg = Release|Any CPU | ||
| {AE8D1D1E-7160-4C73-B0DB-5AC93C8D7094}.Release|x86.Build.0 = Release|Any CPU |
AspireApp.ApiService/Program.cs
Outdated
| policy.WithOrigins("http://localhost:5127") | ||
| .AllowAnyMethod() | ||
| .AllowAnyHeader(); |
There was a problem hiding this comment.
Еще можно указать разрешенные методы и заголовки
AspireApp.ServiceDefaults/.DS_Store
Outdated
Client.Wasm/Client.Wasm.csproj
Outdated
| <PropertyGroup Condition=" '$(RunConfiguration)' == 'https' " /> | ||
| <PropertyGroup Condition=" '$(RunConfiguration)' == 'http' " /> | ||
| <ItemGroup> | ||
| <None Remove="Components\StudentCard.razor~RF1bb17a4.TMP" /> | ||
| </ItemGroup> |
There was a problem hiding this comment.
PropertyGroup и ItemGroup - пустые, можно удалить




ФИО: Карпачева Полина
Номер группы: 6512
Номер лабораторной: 1
Номер варианта: 22
Краткое описание предметной области: Товар на складе
Краткое описание добавленных фич: Добавлен сервис генерации и кэширование