Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Client.Wasm/Components/StudentCard.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
</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>
<UnorderedListItem>Номер <Strong>№1 "Кэширование"</Strong></UnorderedListItem>
<UnorderedListItem>Вариант <Strong>№36 "Сотрудник компании"</Strong></UnorderedListItem>
<UnorderedListItem>Выполнена <Strong>Барышниковым Владиславом 6513</Strong> </UnorderedListItem>
<UnorderedListItem><Link To="https://github.com/dedrowe/cloud-development">Ссылка на форк</Link></UnorderedListItem>
</UnorderedList>
</CardBody>
</Card>
2 changes: 1 addition & 1 deletion Client.Wasm/wwwroot/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
}
},
"AllowedHosts": "*",
"BaseAddress": ""
"BaseAddress": "https://localhost:7240/company-employee"
}
18 changes: 18 additions & 0 deletions CloudDevelopment.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ VisualStudioVersion = 17.14.36811.4
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client.Wasm", "Client.Wasm\Client.Wasm.csproj", "{AE7EEA74-2FE0-136F-D797-854FD87E022A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompanyEmployee.Generator", "CompanyEmployee.Generator\CompanyEmployee.Generator.csproj", "{76AE3AB2-7AF9-4BAA-BE4F-1FDEE3D052AA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompanyEmployee.AppHost", "CompanyEmployee.AppHost\CompanyEmployee.AppHost.csproj", "{11A4C40B-7996-4885-88E1-FA478E8AC6B6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CompanyEmployee.ServiceDefaults", "CompanyEmployee.ServiceDefaults\CompanyEmployee.ServiceDefaults.csproj", "{DF70F3CE-6CD9-4334-AB24-0A2BBBD081E8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +21,18 @@ Global
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AE7EEA74-2FE0-136F-D797-854FD87E022A}.Release|Any CPU.Build.0 = Release|Any CPU
{76AE3AB2-7AF9-4BAA-BE4F-1FDEE3D052AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{76AE3AB2-7AF9-4BAA-BE4F-1FDEE3D052AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{76AE3AB2-7AF9-4BAA-BE4F-1FDEE3D052AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{76AE3AB2-7AF9-4BAA-BE4F-1FDEE3D052AA}.Release|Any CPU.Build.0 = Release|Any CPU
{11A4C40B-7996-4885-88E1-FA478E8AC6B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{11A4C40B-7996-4885-88E1-FA478E8AC6B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{11A4C40B-7996-4885-88E1-FA478E8AC6B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{11A4C40B-7996-4885-88E1-FA478E8AC6B6}.Release|Any CPU.Build.0 = Release|Any CPU
{DF70F3CE-6CD9-4334-AB24-0A2BBBD081E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DF70F3CE-6CD9-4334-AB24-0A2BBBD081E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DF70F3CE-6CD9-4334-AB24-0A2BBBD081E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DF70F3CE-6CD9-4334-AB24-0A2BBBD081E8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
14 changes: 14 additions & 0 deletions CompanyEmployee.AppHost/AppHost.cs
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();
23 changes: 23 additions & 0 deletions CompanyEmployee.AppHost/CompanyEmployee.AppHost.csproj
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>
31 changes: 31 additions & 0 deletions CompanyEmployee.AppHost/Properties/launchSettings.json
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"
}
}
}
}
8 changes: 8 additions & 0 deletions CompanyEmployee.AppHost/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions CompanyEmployee.AppHost/appsettings.json
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 CompanyEmployee.Generator/CompanyEmployee.Generator.csproj
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 CompanyEmployee.Generator/Controller/CompanyEmployeeController.cs
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);
}
}
57 changes: 57 additions & 0 deletions CompanyEmployee.Generator/Dto/CompanyEmployeeDto.cs
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; }
}
57 changes: 57 additions & 0 deletions CompanyEmployee.Generator/Program.cs
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 =>
{
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");

app.MapControllers();

app.Run();
41 changes: 41 additions & 0 deletions CompanyEmployee.Generator/Properties/launchSettings.json
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"
}
}
}
}
Loading