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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*.userosscache
*.sln.docstates
*.env
.DS_Store

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
Expand Down Expand Up @@ -42,6 +43,7 @@ bld/

# Visual Studio 2015/2017 cache/options directory
.vs/
.idea/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/

Expand Down
57 changes: 49 additions & 8 deletions Client.Wasm/Components/DataCard.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<CardDeck>
<Card>
<CardHeader>
<Heading Size="HeadingSize.Is5"><Icon Name="IconName.Table" /> Характеристики текущего объекта</Heading>
<Heading Size="HeadingSize.Is5"><Icon Name="IconName.Table" /> Характеристики медицинского пациента</Heading>
</CardHeader>
<CardBody>
<Table Bordered >
Expand All @@ -26,13 +26,12 @@
}
else
{
var array = Value.ToArray();
foreach (var property in array)
foreach (var property in GetDisplayRows())
{
<TableRow>
<TableRowCell>@(Array.IndexOf(array, property)+1)</TableRowCell>
<TableRowCell>@property.Key</TableRowCell>
<TableRowCell>@property.Value?.ToString()</TableRowCell>
<TableRowCell>@property.Number</TableRowCell>
<TableRowCell>@property.Title</TableRowCell>
<TableRowCell>@property.Value</TableRowCell>
</TableRow>
}
}
Expand All @@ -43,12 +42,12 @@

<Card Margin="Margin.Is3.OnY">
<CardHeader>
<Heading Size="HeadingSize.Is5"><Icon Name="IconName.Send" /> Запросить новый объект</Heading>
<Heading Size="HeadingSize.Is5"><Icon Name="IconName.Send" /> Запросить нового пациента</Heading>
</CardHeader>
<CardBody>
<Row>
<Column ColumnSize="ColumnSize.Is4">
<Text>Идентификатор нового объекта:</Text>
<Text>Идентификатор пациента:</Text>
</Column>
<Column ColumnSize="ColumnSize.Is4">
<NumericEdit TValue="int" @bind-Value="@Id"/>
Expand All @@ -65,10 +64,52 @@
private JsonObject? Value { get; set; }
private int Id { get; set; }

private static readonly (string Key, string Title)[] PropertyOrder =
[
("id", "Идентификатор в системе"),
("fullName", "ФИО пациента"),
("address", "Адрес проживания"),
("birthDate", "Дата рождения"),
("height", "Рост"),
("weight", "Вес"),
("bloodGroup", "Группа крови"),
("rhFactor", "Резус-фактор"),
("lastExaminationDate", "Дата последнего осмотра"),
("isVaccinated", "Отметка о вакцинации")
];

private async Task RequestNewData()
{
var baseAddress = Configuration["BaseAddress"] ?? throw new KeyNotFoundException("Конфигурация клиента не содержит параметра BaseAddress");
Value = await Client.GetFromJsonAsync<JsonObject>($"{baseAddress}?id={Id}", new JsonSerializerOptions { });
StateHasChanged();
}

private IEnumerable<(int Number, string Title, string Value)> GetDisplayRows()
{
if (Value is null)
{
yield break;
}

for (var i = 0; i < PropertyOrder.Length; i++)
{
var (key, title) = PropertyOrder[i];
var rawValue = Value[key];
yield return (i + 1, title, FormatValue(rawValue));
}
}

private static string FormatValue(JsonNode? node)
{
return node switch
{
null => "нет данных",
JsonValue value when value.TryGetValue<bool>(out var boolValue) => boolValue ? "Да" : "Нет",
JsonValue value when value.TryGetValue<int>(out var intValue) => intValue.ToString(),
JsonValue value when value.TryGetValue<double>(out var doubleValue) => doubleValue.ToString("0.00"),
JsonValue value when value.TryGetValue<string>(out var stringValue) => stringValue,
_ => node.ToJsonString()
};
}
}
12 changes: 8 additions & 4 deletions Client.Wasm/Components/StudentCard.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
</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>№2 "Балансировка нагрузки"</Strong></UnorderedListItem>
<UnorderedListItem>Вариант <Strong>"Медицинский пациент"</Strong></UnorderedListItem>
<UnorderedListItem>Балансировка <Strong>Weighted Random</Strong></UnorderedListItem>
<UnorderedListItem>Брокер <Strong>SNS</Strong></UnorderedListItem>
<UnorderedListItem>Хранилище <Strong>Minio</Strong></UnorderedListItem>
<UnorderedListItem>Выполнена <Strong>Котлярским Вадимом 6512</Strong> </UnorderedListItem>
<UnorderedListItem><a href="https://github.com/K0tlyarski/cloud-development" target="_blank" rel="noopener noreferrer">Ссылка на форк</a></UnorderedListItem>

</UnorderedList>
</CardBody>
</Card>
2 changes: 1 addition & 1 deletion Client.Wasm/wwwroot/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
}
},
"AllowedHosts": "*",
"BaseAddress": ""
"BaseAddress": "https://localhost:7139/api/patient"
}
33 changes: 31 additions & 2 deletions CloudDevelopment.sln
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36811.4
VisualStudioVersion = 17.13.35931.197
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}") = "ProjectApp.Api", "ProjectApp.Api\ProjectApp.Api.csproj", "{E7D4CA8B-53EA-9676-D96D-BE2F0CB11054}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectApp.Domain", "ProjectApp.Domain\ProjectApp.Domain.csproj", "{CC5A9873-4CC3-4B71-83AF-E4FD09F7B1AD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectApp.ServiceDefaults", "ProjectApp.ServiceDefaults\ProjectApp.ServiceDefaults.csproj", "{B2C3D4E5-F6A7-8901-BCDE-F12345678901}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectApp.AppHost", "ProjectApp.AppHost\ProjectApp.AppHost.csproj", "{2A5FB573-9376-4FEB-9289-A8387F435C13}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectApp.ApiGateway", "ProjectApp.ApiGateway\ProjectApp.ApiGateway.csproj", "{C7D4CA8B-53EA-9676-D96D-BE2F0CB11055}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +24,26 @@ Global
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.Debug|Any CPU.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
{E7D4CA8B-53EA-9676-D96D-BE2F0CB11054}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E7D4CA8B-53EA-9676-D96D-BE2F0CB11054}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E7D4CA8B-53EA-9676-D96D-BE2F0CB11054}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E7D4CA8B-53EA-9676-D96D-BE2F0CB11054}.Release|Any CPU.Build.0 = Release|Any CPU
{CC5A9873-4CC3-4B71-83AF-E4FD09F7B1AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CC5A9873-4CC3-4B71-83AF-E4FD09F7B1AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CC5A9873-4CC3-4B71-83AF-E4FD09F7B1AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CC5A9873-4CC3-4B71-83AF-E4FD09F7B1AD}.Release|Any CPU.Build.0 = Release|Any CPU
{B2C3D4E5-F6A7-8901-BCDE-F12345678901}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B2C3D4E5-F6A7-8901-BCDE-F12345678901}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B2C3D4E5-F6A7-8901-BCDE-F12345678901}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B2C3D4E5-F6A7-8901-BCDE-F12345678901}.Release|Any CPU.Build.0 = Release|Any CPU
{2A5FB573-9376-4FEB-9289-A8387F435C13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2A5FB573-9376-4FEB-9289-A8387F435C13}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2A5FB573-9376-4FEB-9289-A8387F435C13}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2A5FB573-9376-4FEB-9289-A8387F435C13}.Release|Any CPU.Build.0 = Release|Any CPU
{C7D4CA8B-53EA-9676-D96D-BE2F0CB11055}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C7D4CA8B-53EA-9676-D96D-BE2F0CB11055}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C7D4CA8B-53EA-9676-D96D-BE2F0CB11055}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C7D4CA8B-53EA-9676-D96D-BE2F0CB11055}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
26 changes: 26 additions & 0 deletions ProjectApp.Api/Controllers/PatientController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Microsoft.AspNetCore.Mvc;
using ProjectApp.Api.Services.ProjectGeneratorService;
using ProjectApp.Domain.Entities;

namespace ProjectApp.Api.Controllers;

[Route("api/[controller]")]
[ApiController]
public class PatientController(
IMedicalPatientGeneratorService generatorService,
ILogger<PatientController> logger) : ControllerBase
{
/// <summary>
/// Получить медицинского пациента по ID, если не найден в кэше, сгенерировать нового
/// </summary>
[HttpGet]
[ProducesResponseType(typeof(MedicalPatient), StatusCodes.Status200OK)]
public async Task<ActionResult<MedicalPatient>> GetById([FromQuery] int id, CancellationToken cancellationToken)
{
logger.LogInformation("Received request to retrieve/generate patient {Id}", id);

var patient = await generatorService.GetByIdAsync(id, cancellationToken);

return Ok(patient);
}
}
59 changes: 59 additions & 0 deletions ProjectApp.Api/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using ProjectApp.Api.Services.ProjectGeneratorService;
using ProjectApp.ServiceDefaults;

var builder = WebApplication.CreateBuilder(args);

builder.AddServiceDefaults();

builder.AddRedisDistributedCache("cache");

builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(policy =>
{
policy.WithOrigins("http://localhost:5127")
.WithMethods("GET")
.WithHeaders("Content-Type");
});
});
Comment on lines +10 to +18
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Теперь тут cors не нужны


builder.Services.AddSingleton<MedicalPatientGenerator>();
builder.Services.AddScoped<IMedicalPatientGeneratorService, MedicalPatientGeneratorService>();

builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new Microsoft.OpenApi.OpenApiInfo
{
Title = "Medical Patient Generator API"
});

var xmlFilename = $"{System.Reflection.Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFilename);
if (File.Exists(xmlPath))
{
options.IncludeXmlComments(xmlPath);
}

var domainXmlPath = Path.Combine(AppContext.BaseDirectory, "ProjectApp.Domain.xml");
if (File.Exists(domainXmlPath))
{
options.IncludeXmlComments(domainXmlPath);
}
});

var app = builder.Build();

if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}

app.UseHttpsRedirection();
app.UseCors();
app.MapControllers();
app.MapDefaultEndpoints();

app.Run();
23 changes: 23 additions & 0 deletions ProjectApp.Api/ProjectApp.Api.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.StackExchange.Redis.DistributedCaching" Version="9.5.2" />
<PackageReference Include="Bogus" Version="35.6.5" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.24" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.4" />
</ItemGroup>

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

</Project>
41 changes: 41 additions & 0 deletions ProjectApp.Api/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:46825",
"sslPort": 44333
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5179",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7170;http://localhost:5179",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using ProjectApp.Domain.Entities;

namespace ProjectApp.Api.Services.ProjectGeneratorService;

/// <summary>
/// Сервис получения медицинского пациента
/// </summary>
public interface IMedicalPatientGeneratorService
{
public Task<MedicalPatient> GetByIdAsync(int id, CancellationToken cancellationToken = default);
}
Loading
Loading