-
Notifications
You must be signed in to change notification settings - Fork 49
Гусарова Маргарита Лаб. 1 Группа 6512 #60
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
MaargoGysarova
wants to merge
3
commits into
itsecd:main
Choose a base branch
from
MaargoGysarova: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
3 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
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,108 @@ | ||
| @inject IConfiguration Configuration | ||
| @inject HttpClient Client | ||
|
|
||
| <CardDeck> | ||
| <Card> | ||
| <CardHeader> | ||
| <Heading Size="HeadingSize.Is5"><Icon Name="IconName.User" /> Кредитная заявка</Heading> | ||
| </CardHeader> | ||
| <CardBody> | ||
| <Row> | ||
| <Column ColumnSize="ColumnSize.Is4"> | ||
| <Text>Идентификатор заявки:</Text> | ||
| </Column> | ||
| <Column ColumnSize="ColumnSize.Is4"> | ||
| <NumericEdit TValue="int" @bind-Value="@Id"/> | ||
| </Column> | ||
| <Column ColumnSize="ColumnSize.Is4"> | ||
| <Button Clicked="Request" Color="Color.Primary">Запросить <Icon Name="IconName.ArrowRight" /></Button> | ||
| </Column> | ||
| </Row> | ||
| </CardBody> | ||
| </Card> | ||
|
|
||
| <Card Margin="Margin.Is3.OnY"> | ||
| <CardHeader> | ||
| <Heading Size="HeadingSize.Is5"><Icon Name="IconName.Table" /> Характеристики</Heading> | ||
| </CardHeader> | ||
| <CardBody> | ||
| @if (Application is null) | ||
| { | ||
| <Alert Color="Color.Light">Нет данных. Укажите идентификатор и запросите заявку.</Alert> | ||
| } | ||
| else | ||
| { | ||
| <Table Bordered> | ||
| <TableHeader ThemeContrast="ThemeContrast.Light"> | ||
| <TableRow> | ||
| <TableHeaderCell>#</TableHeaderCell> | ||
| <TableHeaderCell>Характеристика</TableHeaderCell> | ||
| <TableHeaderCell>Значение</TableHeaderCell> | ||
| </TableRow> | ||
| </TableHeader> | ||
| <TableBody> | ||
| @Row(1, "Идентификатор в системе", Get("id")) | ||
| @Row(2, "Тип кредита", Get("creditType")) | ||
| @Row(3, "Запрашиваемая сумма", GetAmount("requestedAmount")) | ||
| @Row(4, "Срок в месяцах", Get("termMonths")) | ||
| @Row(5, "Процентная ставка (%)", GetRate("interestRate")) | ||
| @Row(6, "Дата подачи", Get("applicationDate")) | ||
| @Row(7, "Необходимость страховки", GetBool("requiresInsurance")) | ||
| @Row(8, "Статус заявки", Get("status")) | ||
| @Row(9, "Дата решения", Get("decisionDate")) | ||
| @Row(10, "Одобренная сумма", GetAmount("approvedAmount")) | ||
| </TableBody> | ||
| </Table> | ||
| } | ||
| </CardBody> | ||
| </Card> | ||
| </CardDeck> | ||
|
|
||
| @code { | ||
| private JsonObject? Application { get; set; } | ||
| private int Id { get; set; } | ||
|
|
||
| private async Task Request() | ||
| { | ||
| var baseAddress = Configuration["BaseAddress"] ?? throw new KeyNotFoundException("Конфигурация клиента не содержит параметра BaseAddress"); | ||
| Application = await Client.GetFromJsonAsync<JsonObject>($"{baseAddress}?id={Id}", new JsonSerializerOptions { }); | ||
| StateHasChanged(); | ||
| } | ||
|
|
||
| private RenderFragment Row(int idx, string name, string? value) => builder => | ||
| { | ||
| builder.OpenComponent<TableRow>(0); | ||
| builder.AddAttribute(1, "ChildContent", (RenderFragment)(rowBuilder => | ||
| { | ||
| rowBuilder.OpenComponent<TableRowCell>(0); | ||
| rowBuilder.AddAttribute(1, "ChildContent", (RenderFragment)(c => c.AddContent(0, idx))); | ||
| rowBuilder.CloseComponent(); | ||
|
|
||
| rowBuilder.OpenComponent<TableRowCell>(2); | ||
| rowBuilder.AddAttribute(3, "ChildContent", (RenderFragment)(c => c.AddContent(0, name))); | ||
| rowBuilder.CloseComponent(); | ||
|
|
||
| rowBuilder.OpenComponent<TableRowCell>(4); | ||
| rowBuilder.AddAttribute(5, "ChildContent", (RenderFragment)(c => c.AddContent(0, value ?? "—"))); | ||
| rowBuilder.CloseComponent(); | ||
| })); | ||
| builder.CloseComponent(); | ||
| }; | ||
|
|
||
| private string? Get(string key) => Application?[key]?.ToString(); | ||
| private string? GetBool(string key) | ||
| { | ||
| var s = Application?[key]?.ToString(); | ||
| return s is null ? null : (bool.TryParse(s, out var b) ? (b ? "Да" : "Нет") : s); | ||
| } | ||
| private string? GetAmount(string key) | ||
| { | ||
| var s = Application?[key]?.ToString(); | ||
| return s is null ? null : (decimal.TryParse(s, out var d) ? d.ToString("F2") : s); | ||
| } | ||
| private string? GetRate(string key) | ||
| { | ||
| var s = Application?[key]?.ToString(); | ||
| return s is null ? null : (double.TryParse(s, out var d) ? d.ToString("F2") : s); | ||
| } | ||
| } |
This file was deleted.
Oops, something went wrong.
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,13 +1,12 @@ | ||
| <Card> | ||
| <Card> | ||
| <CardHeader> | ||
| <Heading Size="HeadingSize.Is5"><Icon Name="IconName.User" /> Лабораторная работа</Heading> | ||
| </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>№21 "Кредитная заявка"</Strong></UnorderedListItem> | ||
| <UnorderedListItem>Выполнена <Strong>Гусаровой Маргаритой 6512</Strong> </UnorderedListItem> | ||
| </UnorderedList> | ||
| </CardBody> | ||
| </Card> | ||
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,3 +1,3 @@ | ||
| @page "/" | ||
| @page "/" | ||
|
|
||
| <DataCard/> | ||
| <CreditApplicationCard/> |
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:5179/api/creditapplication" | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Добавить проект с тестами |
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,21 @@ | ||
| using Microsoft.AspNetCore.Mvc; | ||
| using ProjectApp.Api.Services.CreditApplicationGeneratorService; | ||
| using ProjectApp.Domain.Entities; | ||
|
|
||
| namespace ProjectApp.Api.Controllers; | ||
|
|
||
| [Route("api/[controller]")] | ||
| [ApiController] | ||
| public class CreditApplicationController(ICreditApplicationGeneratorService generatorService, ILogger<CreditApplicationController> logger) : ControllerBase | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Добавить атрибут |
||
| { | ||
| /// <summary> | ||
| /// Получить кредитную заявку по ID, если не найдена в кэше — сгенерировать новую | ||
| /// </summary> | ||
| [HttpGet] | ||
| public async Task<ActionResult<CreditApplication>> GetById([FromQuery] int id, CancellationToken cancellationToken) | ||
| { | ||
| logger.LogInformation("Received request to retrieve/generate credit application {Id}", id); | ||
| var application = await generatorService.GetByIdAsync(id, cancellationToken); | ||
| return Ok(application); | ||
| } | ||
| } | ||
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,59 @@ | ||
| using ProjectApp.Api.Services.CreditApplicationGeneratorService; | ||
| using ProjectApp.ServiceDefaults; | ||
|
|
||
| var builder = WebApplication.CreateBuilder(args); | ||
|
|
||
| builder.AddServiceDefaults(); | ||
|
|
||
| builder.AddRedisDistributedCache("cache"); | ||
|
|
||
| builder.Services.AddCors(options => | ||
| { | ||
| options.AddDefaultPolicy(policy => | ||
| { | ||
| policy.WithOrigins("http://localhost:5127") | ||
| .WithMethods("GET") | ||
| .WithHeaders("Content-Type"); | ||
| }); | ||
| }); | ||
|
|
||
| builder.Services.AddSingleton<CreditApplicationGenerator>(); | ||
| builder.Services.AddScoped<ICreditApplicationGeneratorService, CreditApplicationGeneratorService>(); | ||
|
|
||
| builder.Services.AddControllers(); | ||
| builder.Services.AddEndpointsApiExplorer(); | ||
| builder.Services.AddSwaggerGen(options => | ||
| { | ||
| options.SwaggerDoc("v1", new Microsoft.OpenApi.OpenApiInfo | ||
| { | ||
| Title = "Credit Application 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.UseCors(); | ||
| 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> |
Oops, something went wrong.
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.
Потерялась ссылка на форк