Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions AppHost/AppHost.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<Sdk Name="Aspire.AppHost.Sdk" Version="9.5.2" />

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" Version="9.5.2" />
<PackageReference Include="Aspire.Hosting.Redis" Version="9.5.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Client.Wasm\Client.Wasm.csproj" />
<ProjectReference Include="..\GenerationService\GenerationService.csproj" />
</ItemGroup>

</Project>
13 changes: 13 additions & 0 deletions AppHost/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
var builder = DistributedApplication.CreateBuilder(args);

var cache = builder.AddRedis("cache");

var generationService = builder.AddProject<Projects.GenerationService>("generation-service")
.WithReference(cache)
.WaitFor(cache);

builder.AddProject<Projects.Client_Wasm>("client-wasm")
.WithExternalHttpEndpoints()
.WaitFor(generationService);

builder.Build().Run();
17 changes: 17 additions & 0 deletions AppHost/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:17136;http://localhost:15136",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21197",
"ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:20131"
}
}
}
}
8 changes: 4 additions & 4 deletions Client.Wasm/Components/StudentCard.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
</CardHeader>
<CardBody>
<UnorderedList Unstyled>
<UnorderedListItem>Номер <Strong>№X "Название лабораторной"</Strong></UnorderedListItem>
<UnorderedListItem>Вариант <Strong>№Х "Название варианта"</Strong></UnorderedListItem>
<UnorderedListItem>Выполнена <Strong>Фамилией Именем 65ХХ</Strong> </UnorderedListItem>
<UnorderedListItem><Link To="https://puginarug.com/">Ссылка на форк</Link></UnorderedListItem>
<UnorderedListItem>Номер <Strong>№1 "Кэширование"</Strong></UnorderedListItem>
<UnorderedListItem>Вариант <Strong>№12 "Учебный курс"</Strong></UnorderedListItem>
<UnorderedListItem>Выполнена <Strong>Прибыловым Александром 6511</Strong> </UnorderedListItem>
<UnorderedListItem><Link To="https://github.com/AlexPrib/cloud-development">Ссылка на форк</Link></UnorderedListItem>
</UnorderedList>
</CardBody>
</Card>
6 changes: 3 additions & 3 deletions Client.Wasm/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchBrowser": false,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "http://localhost:5127",
"environmentVariables": {
Expand All @@ -22,7 +22,7 @@
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchBrowser": false,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://localhost:7282;http://localhost:5127",
"environmentVariables": {
Expand All @@ -31,7 +31,7 @@
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchBrowser": false,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
Expand Down
4 changes: 2 additions & 2 deletions Client.Wasm/wwwroot/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
}
},
"AllowedHosts": "*",
"BaseAddress": ""
}
"BaseAddress": "http://localhost:5134/course"
}
54 changes: 54 additions & 0 deletions CloudDevelopment.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,70 @@ VisualStudioVersion = 17.14.36811.4
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client.Wasm", "Client.Wasm\Client.Wasm.csproj", "{AE7EEA74-2FE0-136F-D797-854FD87E022A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceDefaults", "ServiceDefaults\ServiceDefaults.csproj", "{0857E538-DB2E-4DDC-88C1-1FDF48405F7A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GenerationService", "GenerationService\GenerationService.csproj", "{6A40CB16-F88F-47CF-AF4A-95B01FF8054D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppHost", "AppHost\AppHost.csproj", "{916C4526-14E2-484A-AD98-72F31B11CA7B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.Debug|x64.ActiveCfg = Debug|Any CPU
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.Debug|x64.Build.0 = Debug|Any CPU
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.Debug|x86.ActiveCfg = Debug|Any CPU
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.Debug|x86.Build.0 = Debug|Any CPU
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.Release|Any CPU.Build.0 = Release|Any CPU
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.Release|x64.ActiveCfg = Release|Any CPU
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.Release|x64.Build.0 = Release|Any CPU
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.Release|x86.ActiveCfg = Release|Any CPU
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.Release|x86.Build.0 = Release|Any CPU
{0857E538-DB2E-4DDC-88C1-1FDF48405F7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0857E538-DB2E-4DDC-88C1-1FDF48405F7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0857E538-DB2E-4DDC-88C1-1FDF48405F7A}.Debug|x64.ActiveCfg = Debug|Any CPU
{0857E538-DB2E-4DDC-88C1-1FDF48405F7A}.Debug|x64.Build.0 = Debug|Any CPU
{0857E538-DB2E-4DDC-88C1-1FDF48405F7A}.Debug|x86.ActiveCfg = Debug|Any CPU
{0857E538-DB2E-4DDC-88C1-1FDF48405F7A}.Debug|x86.Build.0 = Debug|Any CPU
{0857E538-DB2E-4DDC-88C1-1FDF48405F7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0857E538-DB2E-4DDC-88C1-1FDF48405F7A}.Release|Any CPU.Build.0 = Release|Any CPU
{0857E538-DB2E-4DDC-88C1-1FDF48405F7A}.Release|x64.ActiveCfg = Release|Any CPU
{0857E538-DB2E-4DDC-88C1-1FDF48405F7A}.Release|x64.Build.0 = Release|Any CPU
{0857E538-DB2E-4DDC-88C1-1FDF48405F7A}.Release|x86.ActiveCfg = Release|Any CPU
{0857E538-DB2E-4DDC-88C1-1FDF48405F7A}.Release|x86.Build.0 = Release|Any CPU
{6A40CB16-F88F-47CF-AF4A-95B01FF8054D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6A40CB16-F88F-47CF-AF4A-95B01FF8054D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6A40CB16-F88F-47CF-AF4A-95B01FF8054D}.Debug|x64.ActiveCfg = Debug|Any CPU
{6A40CB16-F88F-47CF-AF4A-95B01FF8054D}.Debug|x64.Build.0 = Debug|Any CPU
{6A40CB16-F88F-47CF-AF4A-95B01FF8054D}.Debug|x86.ActiveCfg = Debug|Any CPU
{6A40CB16-F88F-47CF-AF4A-95B01FF8054D}.Debug|x86.Build.0 = Debug|Any CPU
{6A40CB16-F88F-47CF-AF4A-95B01FF8054D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6A40CB16-F88F-47CF-AF4A-95B01FF8054D}.Release|Any CPU.Build.0 = Release|Any CPU
{6A40CB16-F88F-47CF-AF4A-95B01FF8054D}.Release|x64.ActiveCfg = Release|Any CPU
{6A40CB16-F88F-47CF-AF4A-95B01FF8054D}.Release|x64.Build.0 = Release|Any CPU
{6A40CB16-F88F-47CF-AF4A-95B01FF8054D}.Release|x86.ActiveCfg = Release|Any CPU
{6A40CB16-F88F-47CF-AF4A-95B01FF8054D}.Release|x86.Build.0 = Release|Any CPU
{916C4526-14E2-484A-AD98-72F31B11CA7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{916C4526-14E2-484A-AD98-72F31B11CA7B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{916C4526-14E2-484A-AD98-72F31B11CA7B}.Debug|x64.ActiveCfg = Debug|Any CPU
{916C4526-14E2-484A-AD98-72F31B11CA7B}.Debug|x64.Build.0 = Debug|Any CPU
{916C4526-14E2-484A-AD98-72F31B11CA7B}.Debug|x86.ActiveCfg = Debug|Any CPU
{916C4526-14E2-484A-AD98-72F31B11CA7B}.Debug|x86.Build.0 = Debug|Any CPU
{916C4526-14E2-484A-AD98-72F31B11CA7B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{916C4526-14E2-484A-AD98-72F31B11CA7B}.Release|Any CPU.Build.0 = Release|Any CPU
{916C4526-14E2-484A-AD98-72F31B11CA7B}.Release|x64.ActiveCfg = Release|Any CPU
{916C4526-14E2-484A-AD98-72F31B11CA7B}.Release|x64.Build.0 = Release|Any CPU
{916C4526-14E2-484A-AD98-72F31B11CA7B}.Release|x86.ActiveCfg = Release|Any CPU
{916C4526-14E2-484A-AD98-72F31B11CA7B}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
18 changes: 18 additions & 0 deletions GenerationService/GenerationService.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.StackExchange.Redis.DistributedCaching" Version="9.5.2" />
<PackageReference Include="Bogus" Version="35.6.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ServiceDefaults\ServiceDefaults.csproj" />
</ItemGroup>

</Project>
57 changes: 57 additions & 0 deletions GenerationService/Models/Course.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
namespace GenerationService.Models;

/// <summary>
/// Модель, описывающая учебный курс и его основные метаданные
/// </summary>
public class Course
{
/// <summary>
/// Уникальный идентификатор курса
/// </summary>
public int Id { get; init; }

/// <summary>
/// Название курса
/// </summary>
public string Name { get; init; } = string.Empty;

/// <summary>
/// Полное имя преподавателя курса
/// </summary>
public string TeacherFullName { get; init; } = string.Empty;

/// <summary>
/// Дата начала курса
/// </summary>
public DateOnly StartDate { get; init; }

/// <summary>
/// Дата окончания курса
/// </summary>
public DateOnly EndDate { get; init; }

/// <summary>
/// Максимально допустимое количество студентов, которые могут быть зачислены на курс
/// </summary>
public int MaxStudents { get; init; }

/// <summary>
/// Текущее количество записанных студентов
/// </summary>
public int CurrentStudents { get; init; }

/// <summary>
/// Выдаётся ли по окончании курса сертификат
/// </summary>
public bool HasCertificate { get; init; }

/// <summary>
/// Стоимость курса
/// </summary>
public decimal Cost { get; init; }

/// <summary>
/// Рейтинг курса
/// </summary>
public int Rating { get; init; }
}
58 changes: 58 additions & 0 deletions GenerationService/Program.cs
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

У этого файла нет проекта

Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using ServiceDefaults;
using GenerationService.Models;
using GenerationService.Services;
using Microsoft.Extensions.Caching.Distributed;
using System.Text.Json;

var builder = WebApplication.CreateBuilder(args);

builder.AddServiceDefaults();

builder.AddRedisDistributedCache("cache");

builder.Services.AddCors(options =>
options.AddDefaultPolicy(policy =>
policy.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod()));

var app = builder.Build();

app.UseCors();
app.MapDefaultEndpoints();

app.MapGet("/course", async (int id, IDistributedCache cache, ILogger<Program> logger) =>
{
if (id <= 0)
return Results.BadRequest("Received invalid ID. ID must be a positive number");

var cacheKey = $"course:{id}";

var cached = await cache.GetStringAsync(cacheKey);
if (cached is not null)
{
var cachedCourse = JsonSerializer.Deserialize<Course>(cached);
if (cachedCourse is not null)
{
logger.LogInformation("Cache hit for course with id {CourseId}", id);
return Results.Ok(cachedCourse);
}
}

logger.LogInformation("Cache miss for course with id {CourseId}, generating new data", id);
var course = CourseGenerator.Generate(id);

await cache.SetStringAsync(
cacheKey,
JsonSerializer.Serialize(course),
new DistributedCacheEntryOptions
{
AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(10)
});

logger.LogInformation(
"Generated and cached course {CourseName} with id {CourseId}",
course.Name, id);

return Results.Ok(course);
});

app.Run();
23 changes: 23 additions & 0 deletions GenerationService/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "http://localhost:5134",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:7134;http://localhost:5134",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Loading