-
Notifications
You must be signed in to change notification settings - Fork 49
Котлярский Вадим Лаб. 1 Группа 6512 #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 > | ||
|
|
@@ -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> | ||
| } | ||
| } | ||
|
|
@@ -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"/> | ||
|
|
@@ -65,10 +64,72 @@ | |
| 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) | ||
| { | ||
| if (node is null) | ||
| { | ||
| return "нет данных"; | ||
| } | ||
|
|
||
| if (node is JsonValue value) | ||
| { | ||
| if (value.TryGetValue<bool>(out var boolValue)) | ||
| { | ||
| return boolValue ? "Да" : "Нет"; | ||
| } | ||
|
|
||
| if (value.TryGetValue<double>(out var doubleValue)) | ||
| { | ||
| return doubleValue.ToString("0.00"); | ||
| } | ||
|
|
||
| if (value.TryGetValue<int>(out var intValue)) | ||
| { | ||
| return intValue.ToString(); | ||
| } | ||
|
Comment on lines
+117
to
+125
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| if (value.TryGetValue<string>(out var stringValue)) | ||
| { | ||
| return stringValue; | ||
| } | ||
| } | ||
|
|
||
| return node.ToJsonString(); | ||
|
Comment on lines
+105
to
+133
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Можно что то такое: |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,10 +4,13 @@ | |
| </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> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ссылка на форк потерялась |
||
| <UnorderedListItem>Номер <Strong>№1 "Кэширование"</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> | ||
|
|
||
| </UnorderedList> | ||
| </CardBody> | ||
| </Card> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,5 +6,5 @@ | |
| } | ||
| }, | ||
| "AllowedHosts": "*", | ||
| "BaseAddress": "" | ||
| "BaseAddress": "http://localhost:5179/api/patient" | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| 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] | ||
| public async Task<ActionResult<MedicalPatient>> GetById([FromQuery] int id, CancellationToken cancellationToken) | ||
|
Comment on lines
+16
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Добавить атрибут |
||
| { | ||
| logger.LogInformation("Received request to retrieve/generate patient {Id}", id); | ||
|
|
||
| var patient = await generatorService.GetByIdAsync(id, cancellationToken); | ||
|
|
||
| return Ok(patient); | ||
| } | ||
| } | ||
| 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"); | ||
| }); | ||
| }); | ||
|
|
||
| builder.Services.AddScoped<MedicalPatientGenerator>(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| 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(); | ||
| 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> |
| 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); | ||
| } |

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Удалить служебные файлы IDE, добавить
.ideaв.gitignore