-
Notifications
You must be signed in to change notification settings - Fork 52
Земель Алексей Лаб. 2 Группа 6511 #103
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
Open
AlexeyZemel
wants to merge
13
commits into
itsecd:main
Choose a base branch
from
AlexeyZemel:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c013e52
сделана доменная модель данных, добавлен сервис генерации, кешировани…
AlexeyZemel 335b2d0
переписан ридми под проект
AlexeyZemel b19e17f
добавлены саммари, исправлен корс
AlexeyZemel 6b5317c
исправлено: запуск лишнего браузера, кодировка
AlexeyZemel 91cc10e
попытка 2 - исправление кодировки
AlexeyZemel 5e223aa
пожалуйста
AlexeyZemel a657c29
ааааа
AlexeyZemel 3ed9555
попытка
AlexeyZemel 678006e
исправлено: кодировка
AlexeyZemel 3c7bfa8
всё исправлено
AlexeyZemel 8b1e76d
добавлен запуск реплик реализован апи гейтвей и алгоритм балансировки…
AlexeyZemel 90f66d4
кодировка
AlexeyZemel a42e918
исправления
AlexeyZemel 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 |
|---|---|---|
|
|
@@ -415,4 +415,4 @@ FodyWeavers.xsd | |
| *.msi | ||
| *.msix | ||
| *.msm | ||
| *.msp | ||
| *.msp | ||
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
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 |
|---|---|---|
|
|
@@ -6,5 +6,5 @@ | |
| } | ||
| }, | ||
| "AllowedHosts": "*", | ||
| "BaseAddress": "" | ||
| "BaseAddress": "http://localhost:5043/api/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
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,34 @@ | ||
| using ProjectApp.Domain.Entities; | ||
| using Microsoft.AspNetCore.Mvc; | ||
| using ProjectApp.Api.Services; | ||
|
|
||
| namespace ProjectApp.Api.Controllers; | ||
|
|
||
| [Route("api/[controller]")] | ||
| [ApiController] | ||
| public class ProjectController(ProgramProjectGeneratorService generatorService, ILogger<ProjectController> logger) : ControllerBase | ||
| { | ||
| /// <summary> | ||
| /// Возвращает проект по идентификатору или генерирует новый, если он не найден в кэше | ||
| /// </summary> | ||
| /// <param name="id">Идентификатор проекта</param> | ||
| /// <param name="cancellationToken">Токен отмены</param> | ||
| /// <returns>Программный проект</returns> | ||
| [HttpGet] | ||
| [ProducesResponseType(StatusCodes.Status200OK)] | ||
| [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||
| public async Task<ActionResult<ProgramProject>> GetById([FromQuery] int id, CancellationToken cancellationToken) | ||
| { | ||
| if (id < 0) | ||
| { | ||
| return BadRequest("id must be a positive integer."); | ||
| } | ||
|
|
||
| logger.LogInformation("Instance: {InstanceId}", Environment.MachineName); | ||
| logger.LogInformation("Received request to retrieve/generate project {Id}", id); | ||
|
|
||
| var project = await generatorService.GetByIdAsync(id, cancellationToken); | ||
|
|
||
| return Ok(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,6 @@ | ||
| namespace ProjectApp.Api.Options; | ||
|
|
||
| public class CacheSettings | ||
| { | ||
| public int ExpirationMinutes { get; set; } = 10; | ||
| } |
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,53 @@ | ||
| using ProjectApp.Api.Services; | ||
| using ProjectApp.ServiceDefaults; | ||
| using ProjectApp.Api.Options; | ||
| using System.Text.Json; | ||
|
|
||
| var builder = WebApplication.CreateBuilder(args); | ||
|
|
||
|
|
||
| builder.AddServiceDefaults(); | ||
|
|
||
| builder.AddRedisDistributedCache("cache"); | ||
|
|
||
| builder.Services.Configure<CacheSettings>(builder.Configuration.GetSection("CacheSettings")); | ||
| builder.Services.AddSingleton(new JsonSerializerOptions(JsonSerializerDefaults.Web)); | ||
|
|
||
| builder.Services.AddScoped<ProgramProjectGeneratorService>(); | ||
|
|
||
| builder.Services.AddControllers(); | ||
| builder.Services.AddEndpointsApiExplorer(); | ||
| builder.Services.AddSwaggerGen(options => | ||
| { | ||
| options.SwaggerDoc("v1", new Microsoft.OpenApi.OpenApiInfo | ||
| { | ||
| Title = "Project 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.MapControllers(); | ||
| app.MapDefaultEndpoints(); | ||
|
|
||
| app.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,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> |
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,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:0", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development" | ||
| } | ||
| }, | ||
| "https": { | ||
| "commandName": "Project", | ||
| "dotnetRunMessages": true, | ||
| "launchBrowser": true, | ||
| "launchUrl": "swagger", | ||
| "applicationUrl": "https://localhost:0;http://localhost:0", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development" | ||
| } | ||
| }, | ||
| "IIS Express": { | ||
| "commandName": "IISExpress", | ||
| "launchBrowser": true, | ||
| "launchUrl": "swagger", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development" | ||
| } | ||
| } | ||
| } | ||
| } |
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,56 @@ | ||
| using Bogus; | ||
| using ProjectApp.Domain.Entities; | ||
|
|
||
| namespace ProjectApp.Api.Services; | ||
|
|
||
| /// <summary> | ||
| /// Генерирует случайный программный проект | ||
| /// </summary> | ||
| public static class ProgramProjectGenerator | ||
| { | ||
| private static readonly Faker<ProgramProject> _faker = new Faker<ProgramProject>("ru") | ||
| .RuleFor(p => p.ProjectName, f => | ||
| $"{f.Commerce.ProductName()} {f.Hacker.Noun()} {f.Finance.AccountName()} {f.Lorem.Word()}") | ||
| .RuleFor(p => p.Customer, f => | ||
| f.Company.CompanyName()) | ||
| .RuleFor(p => p.ProjectManager, f => f.Name.FullName()) | ||
| .RuleFor(p => p.StartDate, | ||
| f => f.Date.PastDateOnly(3)) | ||
| .RuleFor(p => p.PlannedEndDate, | ||
| (f, p) => p.StartDate.AddDays(f.Random.Int(30, 730))) | ||
| .RuleFor(p => p.Budget, | ||
| f => Math.Round(f.Finance.Amount(500000, 50000000), 2)) | ||
| .RuleFor(p => p.ActualEndDate, (f, p) => | ||
| { | ||
| var completed = f.Random.Bool(0.4f); | ||
|
|
||
| if (!completed) | ||
| return null; | ||
|
|
||
| var start = p.StartDate.ToDateTime(TimeOnly.MinValue); | ||
| var end = f.Date.Between(start.AddDays(1), DateTime.Now); | ||
|
|
||
| return DateOnly.FromDateTime(end); | ||
| }) | ||
| .RuleFor(p => p.CompletionPercentage, (f, p) => | ||
| { | ||
| if (p.ActualEndDate != null) | ||
| return 100; | ||
|
|
||
| return f.Random.Int(0, 99); | ||
| }) | ||
| .RuleFor(p => p.ActualCost, (f, p) => | ||
| { | ||
| var minFactor = Math.Max(0.1m, p.CompletionPercentage / 100m * 0.8m); | ||
| var maxFactor = Math.Min(1.2m, p.CompletionPercentage / 100m * 1.2m); | ||
|
|
||
| var factor = f.Random.Decimal(minFactor, maxFactor); | ||
|
|
||
| return Math.Round(p.Budget * factor, 2); | ||
| }); | ||
|
|
||
| public static ProgramProject Generate() | ||
| { | ||
| return _faker.Generate(); | ||
| } | ||
| } |
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.
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.
Либо
Выполнил, либо поменять склонение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.
у меня фамилия не склоняется(