-
Notifications
You must be signed in to change notification settings - Fork 52
Казаков Андрей Лаб. 3 Группа 6513 #85
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 23 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
3eb0932
Начало?
Gironape 27f7867
тест
Gironape c36dd20
еще тест
Gironape 68dcf77
Облажался....
Gironape f7c703c
Испарвления
Gironape 58725bb
Delete WeatherForecastController.cs
Gironape 06de5f2
Продолжаю не спать
Gironape 361302a
Я уже близко к разгадке
Gironape e55fc94
Что-то получилось
Gironape adec247
Delete README.md
Gironape 7a0df48
Наворотил исправления
Gironape 839842f
Update Employee.cs
Gironape 3640a4b
начало 2 лабы
Gironape 1a05646
Работа
Gironape fcd95ac
Вроде, сделал
Gironape 1a7ce23
Fix
Gironape 08662e9
Начало 3-й лабы
Gironape ad91d6a
В процессе
Gironape 3b7d3ba
Немного ошибся
Gironape bc47690
Работает
Gironape 4f8812a
Я дурак...
Gironape 4c9a32e
Исправил
Gironape 43b081d
мини исправление
Gironape faabc52
Исправления
Gironape 54ce072
Финал
Gironape 83c0407
Исправления
Gironape b91579b
Очередняра
Gironape 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
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": "https://localhost:7000/api/employee" | ||
| } | ||
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,24 @@ | ||
| <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.0" /> | ||
| <PackageReference Include="Bogus" Version="35.6.5" /> | ||
| <PackageReference Include="MassTransit.AmazonSQS" Version="8.3.0" /> | ||
| <PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\Client.Wasm\Client.Wasm.csproj" /> | ||
| <ProjectReference Include="..\CompanyEmployee.Domain\CompanyEmployee.Domain.csproj" /> | ||
| <ProjectReference Include="..\CompanyEmployee.ServiceDefaults\CompanyEmployee.ServiceDefaults.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| <ProjectExtensions><VisualStudio><UserProperties properties_4launchsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions> | ||
|
|
||
| </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,55 @@ | ||
| using CompanyEmployee.Api.Services; | ||
| using CompanyEmployee.Domain.Entity; | ||
| using Microsoft.AspNetCore.Mvc; | ||
|
|
||
| namespace CompanyEmployee.Api.Controllers; | ||
|
|
||
| /// <summary> | ||
| /// Контроллер для работы с сотрудниками. | ||
| /// </summary> | ||
| /// <param name="employeeService">Сервис для получения сотрудников с кэшированием.</param> | ||
| /// <param name="logger">Логгер для записи информации о запросах.</param> | ||
| [ApiController] | ||
| [Route("api/[controller]")] | ||
| public class EmployeeController( | ||
| IEmployeeService employeeService, | ||
| ILogger<EmployeeController> logger) : ControllerBase | ||
| { | ||
| /// <summary> | ||
| /// Получить сотрудника по идентификатору. | ||
| /// </summary> | ||
| /// <param name="id">Идентификатор сотрудника.</param> | ||
| /// <param name="cancellationToken">Токен отмены операции.</param> | ||
| /// <returns>Объект сотрудника.</returns> | ||
| [HttpGet] | ||
| [ProducesResponseType(typeof(Employee), StatusCodes.Status200OK)] | ||
| [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||
| [ProducesResponseType(StatusCodes.Status404NotFound)] | ||
| [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||
| public async Task<ActionResult<Employee>> GetEmployee([FromQuery] int id, CancellationToken cancellationToken) | ||
| { | ||
| try | ||
| { | ||
| logger.LogInformation("Запрос на получение сотрудника с id: {Id}", id); | ||
|
|
||
| if (id <= 0) | ||
| { | ||
| return BadRequest("ID должен быть положительным числом"); | ||
| } | ||
|
|
||
| var employee = await employeeService.GetEmployeeAsync(id, cancellationToken); | ||
|
|
||
| if (employee == null) | ||
| { | ||
| return NotFound($"Сотрудник с ID {id} не найден"); | ||
| } | ||
|
|
||
| return Ok(employee); | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| logger.LogError(ex, "Ошибка при получении сотрудника с id: {Id}", id); | ||
| return StatusCode(500, "Внутренняя ошибка сервера"); | ||
| } | ||
| } | ||
| } |
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,54 @@ | ||
| using Amazon.SimpleNotificationService; | ||
| using Amazon.SQS; | ||
| using CompanyEmployee.Api.Services; | ||
| using CompanyEmployee.ServiceDefaults; | ||
| using MassTransit; | ||
|
|
||
| var builder = WebApplication.CreateBuilder(args); | ||
|
|
||
| builder.AddServiceDefaults(); | ||
| builder.AddRedisDistributedCache("redis"); | ||
|
|
||
| builder.Services.AddSingleton<IEmployeeGenerator, EmployeeGenerator>(); | ||
| builder.Services.AddSingleton<ICacheService, RedisCacheService>(); | ||
| builder.Services.AddScoped<IEmployeeService, EmployeeService>(); | ||
|
|
||
| var awsServiceUrl = builder.Configuration["AWS:ServiceURL"] ?? "http://localhost:4566"; | ||
| var awsRegion = builder.Configuration["AWS:Region"] ?? "us-east-1"; | ||
| var awsAccessKey = builder.Configuration["AWS:AccessKeyId"] ?? "test"; | ||
| var awsSecretKey = builder.Configuration["AWS:SecretAccessKey"] ?? "test"; | ||
|
|
||
| builder.Services.AddMassTransit(x => | ||
| { | ||
| x.UsingAmazonSqs((context, cfg) => | ||
| { | ||
| cfg.Host(awsRegion, h => | ||
| { | ||
| h.Config(new AmazonSQSConfig { ServiceURL = awsServiceUrl }); | ||
| h.Config(new AmazonSimpleNotificationServiceConfig { ServiceURL = awsServiceUrl }); | ||
| h.AccessKey(awsAccessKey); | ||
| h.SecretKey(awsSecretKey); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| builder.Services.AddSingleton<IPublishEndpoint>(sp => sp.GetRequiredService<IBusControl>()); | ||
|
|
||
| builder.Services.AddControllers(); | ||
| builder.Services.AddEndpointsApiExplorer(); | ||
| builder.Services.AddSwaggerGen(); | ||
|
|
||
| var app = builder.Build(); | ||
|
|
||
| if (app.Environment.IsDevelopment()) | ||
| { | ||
| app.UseSwagger(); | ||
| app.UseSwaggerUI(); | ||
| } | ||
|
|
||
| app.MapDefaultEndpoints(); | ||
| app.UseHttpsRedirection(); | ||
| app.UseAuthorization(); | ||
| app.MapControllers(); | ||
|
|
||
| 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,41 @@ | ||
| { | ||
| "$schema": "http://json.schemastore.org/launchsettings.json", | ||
| "iisSettings": { | ||
| "windowsAuthentication": false, | ||
| "anonymousAuthentication": true, | ||
| "iisExpress": { | ||
| "applicationUrl": "http://localhost:56739", | ||
| "sslPort": 44378 | ||
| } | ||
| }, | ||
| "profiles": { | ||
| "http": { | ||
| "commandName": "Project", | ||
| "dotnetRunMessages": true, | ||
| "launchBrowser": false, | ||
| "launchUrl": "swagger", | ||
| "applicationUrl": "http://localhost:6001", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development" | ||
| } | ||
| }, | ||
| "https": { | ||
| "commandName": "Project", | ||
| "dotnetRunMessages": true, | ||
| "launchBrowser": false, | ||
| "launchUrl": "swagger", | ||
| "applicationUrl": "https://localhost:6001", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development" | ||
| } | ||
| }, | ||
| "IIS Express": { | ||
| "commandName": "IISExpress", | ||
| "launchBrowser": true, | ||
| "launchUrl": "swagger", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development" | ||
| } | ||
| } | ||
| } | ||
| } |
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.