-
Notifications
You must be signed in to change notification settings - Fork 24
Барышников Влад 6513 Лаб. 1 #11
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
dedrowe
wants to merge
6
commits into
itsecd:main
Choose a base branch
from
dedrowe:feature/lab1
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
6 commits
Select commit
Hold shift + click to select a range
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
Some comments aren't visible on the classic Files Changed page.
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:7240/company-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,14 @@ | ||
| var builder = DistributedApplication.CreateBuilder(args); | ||
|
|
||
| var cache = builder.AddRedis("cache") | ||
| .WithRedisInsight(containerName: "redis-insight"); | ||
|
|
||
| var generator = builder.AddProject<Projects.CompanyEmployee_Generator>("generator") | ||
| .WithReference(cache) | ||
| .WaitFor(cache); | ||
|
|
||
| var client = builder.AddProject<Projects.Client_Wasm>("client") | ||
| .WithReference(generator) | ||
| .WaitFor(generator); | ||
|
|
||
| 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,23 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <Sdk Name="Aspire.AppHost.Sdk" Version="9.5.0" /> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
| <UserSecretsId>9511602b-1df2-46c9-8aeb-4a3bacf565a2</UserSecretsId> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Aspire.Hosting.AppHost" Version="9.5.0" /> | ||
| <PackageReference Include="Aspire.Hosting.Redis" Version="9.5.0" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\Client.Wasm\Client.Wasm.csproj" /> | ||
| <ProjectReference Include="..\CompanyEmployee.Generator\CompanyEmployee.Generator.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,31 @@ | ||
| { | ||
| "$schema": "https://json.schemastore.org/launchsettings.json", | ||
| "profiles": { | ||
| "https": { | ||
| "commandName": "Project", | ||
| "dotnetRunMessages": true, | ||
| "launchBrowser": true, | ||
| "applicationUrl": "https://localhost:17150;http://localhost:15212", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development", | ||
| "DOTNET_ENVIRONMENT": "Development", | ||
| "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21292", | ||
| "ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "https://localhost:23155", | ||
| "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22112" | ||
| } | ||
| }, | ||
| "http": { | ||
| "commandName": "Project", | ||
| "dotnetRunMessages": true, | ||
| "launchBrowser": true, | ||
| "applicationUrl": "http://localhost:15212", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development", | ||
| "DOTNET_ENVIRONMENT": "Development", | ||
| "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19225", | ||
| "ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "http://localhost:18266", | ||
| "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20084" | ||
| } | ||
| } | ||
| } | ||
| } |
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,8 @@ | ||
| { | ||
| "Logging": { | ||
| "LogLevel": { | ||
| "Default": "Information", | ||
| "Microsoft.AspNetCore": "Warning" | ||
| } | ||
| } | ||
| } |
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,9 @@ | ||
| { | ||
| "Logging": { | ||
| "LogLevel": { | ||
| "Default": "Information", | ||
| "Microsoft.AspNetCore": "Warning", | ||
| "Aspire.Hosting.Dcp": "Warning" | ||
| } | ||
| } | ||
| } |
19 changes: 19 additions & 0 deletions
19
CompanyEmployee.Generator/CompanyEmployee.Generator.csproj
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,19 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Aspire.StackExchange.Redis.DistributedCaching" Version="9.5.2" /> | ||
| <PackageReference Include="Bogus" Version="35.6.5" /> | ||
| <PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\CompanyEmployee.ServiceDefaults\CompanyEmployee.ServiceDefaults.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
41 changes: 41 additions & 0 deletions
41
CompanyEmployee.Generator/Controller/CompanyEmployeeController.cs
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 @@ | ||
| using CompanyEmployee.Generator.Dto; | ||
| using CompanyEmployee.Generator.Service; | ||
| using Microsoft.AspNetCore.Mvc; | ||
|
|
||
| namespace CompanyEmployee.Generator.Controller; | ||
|
|
||
| /// <summary> | ||
| /// Контроллер для получения сотрудника компании по id | ||
| /// </summary> | ||
| /// <param name="service">Сервис получения сотрудника компании</param> | ||
| /// <param name="logger">Логгер</param> | ||
| [ApiController] | ||
| [Route("company-employee")] | ||
| public class CompanyEmployeeController( | ||
| ICompanyEmployeeService service, | ||
| ILogger<CompanyEmployeeController> logger | ||
| ) : ControllerBase | ||
| { | ||
| /// <summary> | ||
| /// Метод для получения сотрудника компании по id | ||
| /// </summary> | ||
| /// <param name="id">Идентификатор сотрудника</param> | ||
| /// <param name="cancellationToken">Токен отмены запроса</param> | ||
| /// <returns>DTO сотрудника компании</returns> | ||
| /// <response code="200">Успешное получение сотрудника</response> | ||
| /// <response code="400">Некорректный id</response> | ||
| [HttpGet] | ||
| [ProducesResponseType(typeof(CompanyEmployeeDto), StatusCodes.Status200OK)] | ||
| [ProducesResponseType(typeof(string), StatusCodes.Status400BadRequest)] | ||
| public async Task<ActionResult<CompanyEmployeeDto>> GetById([FromQuery] int id, CancellationToken cancellationToken) | ||
| { | ||
| if (id < 0) | ||
| { | ||
| return BadRequest("Id must be greater or equal than 0"); | ||
| } | ||
| logger.LogInformation("HTTP GET /company-employee, id: {employeeId}", id); | ||
|
|
||
| var employee = await service.GetByIdAsync(id, cancellationToken); | ||
| return Ok(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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| namespace CompanyEmployee.Generator.Dto; | ||
|
|
||
| /// <summary> | ||
| /// Информация о сотруднике компании | ||
| /// </summary> | ||
| public class CompanyEmployeeDto | ||
| { | ||
| /// <summary> | ||
| /// Идентификатор сотрудника в системе | ||
| /// </summary> | ||
| public required int Id { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// ФИО | ||
| /// </summary> | ||
| public required string FullName { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// Должность | ||
| /// </summary> | ||
| public required string Position { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// Отдел | ||
| /// </summary> | ||
| public required string Department { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// Дата приема | ||
| /// </summary> | ||
| public required DateOnly EmploymentDate { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// Оклад | ||
| /// </summary> | ||
| public required decimal Salary { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// Электронная почта | ||
| /// </summary> | ||
| public required string Email { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// Номер телефона | ||
| /// </summary> | ||
| public required string PhoneNumber { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// Индикатор увольнения | ||
| /// </summary> | ||
| public required bool DismissalFlag { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// Дата увольнения | ||
| /// </summary> | ||
| public DateOnly? DismissalDate { get; init; } | ||
| } |
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,57 @@ | ||
| using CompanyEmployee.ServiceDefaults; | ||
| using CompanyEmployee.Generator.Service; | ||
|
|
||
|
|
||
| var builder = WebApplication.CreateBuilder(args); | ||
|
|
||
| builder.AddServiceDefaults(); | ||
|
|
||
| builder.Services.AddControllers(); | ||
| builder.Services.AddEndpointsApiExplorer(); | ||
| builder.Services.AddSwaggerGen(); | ||
|
|
||
| builder.Services.AddCors(options => | ||
alxmcs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| options.AddPolicy("wasm", policy => | ||
| policy.SetIsOriginAllowed(origin => | ||
| { | ||
| try | ||
| { | ||
| var uri = new Uri(origin); | ||
| return uri.Host == "localhost"; | ||
| } | ||
| catch | ||
| { | ||
| return false; | ||
| } | ||
| }) | ||
| .WithMethods("GET") | ||
| .AllowAnyHeader()); | ||
| }); | ||
|
|
||
| builder.AddRedisDistributedCache(connectionName: "cache"); | ||
|
|
||
| builder.Services.AddSingleton<ICompanyEmployeeGenerator, CompanyEmployeeGenerator>(); | ||
| builder.Services.AddSingleton<ICompanyEmployeeService, CompanyEmployeeService>(); | ||
|
|
||
| var app = builder.Build(); | ||
|
|
||
| app.UseCors(); | ||
|
|
||
| app.MapDefaultEndpoints(); | ||
|
|
||
| if (app.Environment.IsDevelopment()) | ||
| { | ||
| app.UseSwagger(); | ||
| app.UseSwaggerUI(); | ||
| } | ||
|
|
||
| app.UseHttpsRedirection(); | ||
|
|
||
| app.UseAuthorization(); | ||
|
|
||
| app.UseCors("wasm"); | ||
alxmcs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| 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:6127", | ||
| "sslPort": 44325 | ||
| } | ||
| }, | ||
| "profiles": { | ||
| "http": { | ||
| "commandName": "Project", | ||
| "dotnetRunMessages": true, | ||
| "launchBrowser": true, | ||
| "launchUrl": "swagger", | ||
| "applicationUrl": "http://localhost:5291", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development" | ||
| } | ||
| }, | ||
| "https": { | ||
| "commandName": "Project", | ||
| "dotnetRunMessages": true, | ||
| "launchBrowser": true, | ||
| "launchUrl": "swagger", | ||
| "applicationUrl": "https://localhost:7240;http://localhost:5291", | ||
| "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.