-
Notifications
You must be signed in to change notification settings - Fork 52
Чумаков Иван. Лаб. 1. Группа 6511 #53
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
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3e47d82
Релизован сервис генерации
mestromezer e3392b6
hotfix:
mestromezer 756ff79
upda readme
mestromezer 97d9950
Переерзд на aspire
mestromezer f440860
фикс readme
mestromezer 37f5fac
фиксы по ревью
mestromezer 96ae604
Правки по review
mestromezer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <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> | ||
| <IsAspireHost>true</IsAspireHost> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Aspire.Hosting.AppHost" Version="9.5.2" /> | ||
| <PackageReference Include="Aspire.Hosting.Redis" Version="9.5.2" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\GeneratorService\GeneratorService.csproj" /> | ||
| <ProjectReference Include="..\Client.Wasm\Client.Wasm.csproj" /> | ||
| <ProjectReference Include="..\ServiceDefaults\ServiceDefaults.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| var builder = DistributedApplication.CreateBuilder(args); | ||
|
|
||
| var redis = builder.AddRedis("redis") | ||
| .WithRedisInsight(); | ||
|
|
||
| var client = builder.AddProject<Projects.Client_Wasm>("client"); | ||
|
|
||
| builder.AddProject<Projects.GeneratorService>("generator-service") | ||
| .WithReference(redis) | ||
| .WaitFor(redis) | ||
| .WithEnvironment("Cors__AllowedOrigin", client.GetEndpoint("http")) | ||
| .WaitFor(client) | ||
| .WithUrlForEndpoint("http", url => url.Url += "/swagger") | ||
| .WithUrlForEndpoint("https", url => url.Url += "/swagger"); | ||
|
|
||
| builder.Build().Run(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "profiles": { | ||
| "AppHost": { | ||
| "commandName": "Project", | ||
| "dotnetRunMessages": true, | ||
| "launchBrowser": true, | ||
| "applicationUrl": "https://localhost:17193;http://localhost:15237", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development", | ||
| "DOTNET_ENVIRONMENT": "Development", | ||
| "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21193", | ||
| "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22057" | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,3 @@ | ||
| { | ||
| "Logging": { | ||
| "LogLevel": { | ||
| "Default": "Information", | ||
| "Microsoft.AspNetCore": "Warning" | ||
| } | ||
| }, | ||
| "AllowedHosts": "*", | ||
| "BaseAddress": "" | ||
| "BaseAddress": "http://localhost:3343/patient" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <Nullable>enable</Nullable> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <IsPackable>false</IsPackable> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" /> | ||
| <PackageReference Include="xunit" Version="2.9.3" /> | ||
| <PackageReference Include="xunit.runner.visualstudio" Version="2.8.2"> | ||
| <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
| <PrivateAssets>all</PrivateAssets> | ||
| </PackageReference> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\GeneratorService\GeneratorService.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| using GeneratorService.Generators; | ||
| using Xunit; | ||
|
|
||
| namespace GeneratorService.Tests; | ||
|
|
||
| public sealed class MedicalPatientGeneratorTests | ||
| { | ||
| public static readonly DateOnly Today = DateOnly.FromDateTime(DateTime.Today); | ||
|
|
||
| public static IEnumerable<object[]> Patients() => | ||
| Enumerable.Range(1, 300).Select(i => new object[] { MedicalPatientGenerator.Generate(i) }); | ||
|
|
||
| [Theory] | ||
| [MemberData(nameof(Patients))] | ||
| public void Id_MatchesRequested(GeneratorService.Models.MedicalPatient p) | ||
| => Assert.True(p.Id > 0); | ||
|
|
||
| [Theory] | ||
| [MemberData(nameof(Patients))] | ||
| public void FullName_HasThreeParts(GeneratorService.Models.MedicalPatient p) | ||
| => Assert.Equal(3, p.FullName.Split(' ', StringSplitOptions.RemoveEmptyEntries).Length); | ||
|
|
||
| [Theory] | ||
| [MemberData(nameof(Patients))] | ||
| public void BirthDate_NotInFuture(GeneratorService.Models.MedicalPatient p) | ||
| => Assert.True(p.BirthDate <= Today); | ||
|
|
||
| [Theory] | ||
| [MemberData(nameof(Patients))] | ||
| public void Height_InReasonableBounds(GeneratorService.Models.MedicalPatient p) | ||
| => Assert.InRange(p.Height, 50.0, 220.0); | ||
|
|
||
| [Theory] | ||
| [MemberData(nameof(Patients))] | ||
| public void Height_RoundedToTwoDecimals(GeneratorService.Models.MedicalPatient p) | ||
| => Assert.Equal(p.Height, Math.Round(p.Height, 2)); | ||
|
|
||
| [Theory] | ||
| [MemberData(nameof(Patients))] | ||
| public void Weight_InReasonableBounds(GeneratorService.Models.MedicalPatient p) | ||
| => Assert.InRange(p.Weight, 2.5, 200.0); | ||
|
|
||
| [Theory] | ||
| [MemberData(nameof(Patients))] | ||
| public void Weight_RoundedToTwoDecimals(GeneratorService.Models.MedicalPatient p) | ||
| => Assert.Equal(p.Weight, Math.Round(p.Weight, 2)); | ||
|
|
||
| [Theory] | ||
| [MemberData(nameof(Patients))] | ||
| public void BloodGroup_Between1And4(GeneratorService.Models.MedicalPatient p) | ||
| => Assert.InRange(p.BloodGroup, 1, 4); | ||
|
|
||
| [Theory] | ||
| [MemberData(nameof(Patients))] | ||
| public void LastExamination_NotBeforeBirthDate(GeneratorService.Models.MedicalPatient p) | ||
| => Assert.True(p.LastExaminationDate >= p.BirthDate); | ||
|
|
||
| [Theory] | ||
| [MemberData(nameof(Patients))] | ||
| public void LastExamination_NotInFuture(GeneratorService.Models.MedicalPatient p) | ||
| => Assert.True(p.LastExaminationDate <= Today); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <Nullable>enable</Nullable> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <GenerateDocumentationFile>true</GenerateDocumentationFile> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Aspire.StackExchange.Redis.DistributedCaching" Version="8.2.2" /> | ||
| <PackageReference Include="Bogus" Version="35.6.1" /> | ||
| <PackageReference Include="Serilog.AspNetCore" Version="8.0.3" /> | ||
| <PackageReference Include="Serilog.Enrichers.Environment" Version="3.0.1" /> | ||
| <PackageReference Include="Serilog.Enrichers.Thread" Version="4.0.0" /> | ||
| <PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" /> | ||
| <PackageReference Include="Swashbuckle.AspNetCore" Version="6.9.0" /> | ||
| <PackageReference Include="Serilog.Sinks.OpenTelemetry" Version="4.0.0" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\ServiceDefaults\ServiceDefaults.csproj" /> | ||
| </ItemGroup> | ||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| using Bogus; | ||
| using GeneratorService.Models; | ||
|
|
||
| namespace GeneratorService.Generators; | ||
|
|
||
| public static class MedicalPatientGenerator | ||
| { | ||
| private static readonly Faker<MedicalPatient> _faker = new Faker<MedicalPatient>("ru") | ||
| .RuleFor(p => p.Id, _ => 0) | ||
| .RuleFor(p => p.FullName, f => | ||
| $"{f.Name.LastName()} {f.Name.FirstName()} {f.Name.LastName()}ович") | ||
| .RuleFor(p => p.Address, f => f.Address.FullAddress()) | ||
| .RuleFor(p => p.BirthDate, f => f.Date.PastDateOnly(100)) | ||
| .RuleFor(p => p.Height, f => Math.Round(f.Random.Double(50.0, 220.0), 2)) | ||
| .RuleFor(p => p.Weight, f => Math.Round(f.Random.Double(2.5, 200.0), 2)) | ||
| .RuleFor(p => p.BloodGroup, f => f.Random.Int(1, 4)) | ||
| .RuleFor(p => p.RhFactor, f => f.Random.Bool()) | ||
| .RuleFor(p => p.LastExaminationDate, (f, p) => | ||
| f.Date.BetweenDateOnly(p.BirthDate, DateOnly.FromDateTime(DateTime.Today))) | ||
| .RuleFor(p => p.IsVaccinated, f => f.Random.Bool()); | ||
|
|
||
| public static MedicalPatient Generate(int id) | ||
| { | ||
| var generated = _faker.Generate(); | ||
| return new MedicalPatient | ||
| { | ||
| Id = id, | ||
| FullName = generated.FullName, | ||
| Address = generated.Address, | ||
| BirthDate = generated.BirthDate, | ||
| Height = generated.Height, | ||
| Weight = generated.Weight, | ||
| BloodGroup = generated.BloodGroup, | ||
| RhFactor = generated.RhFactor, | ||
| LastExaminationDate = generated.LastExaminationDate, | ||
| IsVaccinated = generated.IsVaccinated | ||
| }; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| namespace GeneratorService.Models; | ||
|
|
||
| /// <summary> | ||
| /// Медицинская карта пациента. | ||
| /// </summary> | ||
| public sealed class MedicalPatient | ||
| { | ||
| /// <summary>Уникальный идентификатор пациента.</summary> | ||
| public int Id { get; init; } | ||
|
|
||
| /// <summary>Полное имя пациента (фамилия, имя, отчество).</summary> | ||
| public required string FullName { get; init; } | ||
|
|
||
| /// <summary>Адрес проживания пациента.</summary> | ||
| public required string Address { get; init; } | ||
|
|
||
| /// <summary>Дата рождения пациента.</summary> | ||
| public DateOnly BirthDate { get; init; } | ||
|
|
||
| /// <summary>Рост пациента в сантиметрах.</summary> | ||
| public double Height { get; init; } | ||
|
|
||
| /// <summary>Вес пациента в килограммах.</summary> | ||
| public double Weight { get; init; } | ||
|
|
||
| /// <summary>Группа крови (1–4).</summary> | ||
| public int BloodGroup { get; init; } | ||
|
|
||
| /// <summary>Резус-фактор: <c>true</c> — положительный, <c>false</c> — отрицательный.</summary> | ||
| public bool RhFactor { get; init; } | ||
|
|
||
| /// <summary>Дата последнего медицинского осмотра.</summary> | ||
| public DateOnly LastExaminationDate { get; init; } | ||
|
|
||
| /// <summary>Наличие прививок.</summary> | ||
| public bool IsVaccinated { get; init; } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.