feat (scalarUi) , fix (search)
-Add scalar ui instead of swagger -Fix search product returnsrelease
parent
b7dbe67e7f
commit
9f6af37e7f
|
@ -13,11 +13,8 @@
|
|||
"Microsoft.AspNetCore.Http.Connections": "Debug"
|
||||
}
|
||||
},
|
||||
"ShopSettings": {
|
||||
"TaxesFee": 9
|
||||
},
|
||||
"SiteSettings": {
|
||||
"BaseUrl": "http://localhost:32770",
|
||||
"BaseUrl": "https://api.hamyanedalat.com",
|
||||
"WebSiteUrl": "https://hamyanedalat.com",
|
||||
"AdminPanelBaseUrl": "https://admin.hamyanedalat.com",
|
||||
"StorageBaseUrl": "https://storage.hamyanedalat.com",
|
||||
|
@ -28,18 +25,14 @@
|
|||
"Email": "avvampier@gmail.com",
|
||||
"Password": "2Tsr87RWRn5T",
|
||||
"Phone": "09214802813",
|
||||
"RoleName": "RootAdmin",
|
||||
"FirstName": "همه کاره",
|
||||
"LastName": "سیستم"
|
||||
"RoleName": "RootAdmin"
|
||||
},
|
||||
"Manager": {
|
||||
"Username": "09122171024",
|
||||
"Email": "kamran_mirzayi@gmail.com",
|
||||
"Password": "YAWEheKEi7gh",
|
||||
"Phone": "09128387004",
|
||||
"RoleName": "Manager",
|
||||
"FirstName": "کامران",
|
||||
"LastName": "میرزایی"
|
||||
"RoleName": "Manager"
|
||||
},
|
||||
"StorageSetting": {
|
||||
"AccessKey": "de129835-b43a-4552-8ed4-865e2635ab3d",
|
||||
|
|
|
@ -17,6 +17,8 @@ public class SeedController : ICarterModule
|
|||
var group = app.NewVersionedApi("Seed")
|
||||
.MapGroup("api/seed");
|
||||
|
||||
group.MapPost("sitemap", CreateSiteMapAsync)
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapPost("product/categories", SeedCategoriesAsync)
|
||||
.WithDisplayName("SeedCategoriesAsync")
|
||||
|
@ -43,6 +45,16 @@ public class SeedController : ICarterModule
|
|||
|
||||
}
|
||||
|
||||
public async Task<IResult> CreateSiteMapAsync([FromQuery] string key, ISiteMapService siteMapService, CancellationToken cancellationToken)
|
||||
{
|
||||
if (key != "kKAYskyG8xPxKnJrHkuYxub4Ao2bnz7AOmNtwDT0RaqzaG7ZvbvaP29tCrC8wJ823RczJFXOIQT2bDOec4F38A==")
|
||||
throw new AppException("Key is not valid", ApiResultStatusCode.UnAuthorized);
|
||||
|
||||
await siteMapService.CreateSiteMapAsync();
|
||||
|
||||
return TypedResults.Ok();
|
||||
}
|
||||
|
||||
public async Task<IResult> SeedProductsAsync([FromBody] List<CreateProductCommand> request, [FromQuery] string key, IMediator mediator, CancellationToken cancellationToken)
|
||||
{
|
||||
if (key != "kKAYskyG8xPxKnJrHkuYxub4Ao2bnz7AOmNtwDT0RaqzaG7ZvbvaP29tCrC8wJ823RczJFXOIQT2bDOec4F38A==")
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using Netina.Api.WebFramework.ScalarUi;
|
||||
using Netina.Repository.Behaviors;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
@ -97,12 +98,13 @@ var app = builder.Build();
|
|||
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
//app.UseSwagger();
|
||||
|
||||
//app.UseCustomSwagger(siteSetting.BaseUrl);
|
||||
app.UseSwagger();
|
||||
app.MapScalarUi();
|
||||
//app.UseSwaggerUI();
|
||||
}
|
||||
else
|
||||
|
||||
if (app.Environment.IsProduction())
|
||||
{
|
||||
app.UseHsts();
|
||||
}
|
||||
|
@ -113,7 +115,6 @@ app.UseCors(x => x
|
|||
.AllowCredentials());
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseCustomSwagger(siteSetting.BaseUrl);
|
||||
|
||||
app.UseAuthorization();
|
||||
app.UseAuthentication();
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
"Docker": {
|
||||
"commandName": "Docker",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
|
||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/scalar/v1",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_URLS": "http://+:80"
|
||||
},
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
namespace Netina.Api.WebFramework.ScalarUi;
|
||||
|
||||
public static class ScalarUiConfiguration
|
||||
{
|
||||
public static void MapScalarUi(this IEndpointRouteBuilder app)
|
||||
{
|
||||
app.MapGet("/scalar/{documentName}", (string documentName) =>
|
||||
{
|
||||
|
||||
var scalarScript = $$"""
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Scalar API Reference</title>
|
||||
<meta charset="utf-8" />
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1" />
|
||||
</head>
|
||||
<body>
|
||||
<!-- Add your own OpenAPI/Swagger specification URL here: -->
|
||||
<!-- Note: The example is our public proxy (to avoid CORS issues). You can remove the `data-proxy-url` attribute if you don’t need it. -->
|
||||
<script
|
||||
id="api-reference"
|
||||
data-url="/swagger/{{documentName}}/swagger.json"></script>
|
||||
|
||||
<!-- Optional: You can set a full configuration object like this: -->
|
||||
<script>
|
||||
var configuration = {
|
||||
theme: 'bluePlanet',
|
||||
}
|
||||
|
||||
document.getElementById('api-reference').dataset.configuration =
|
||||
JSON.stringify(configuration)
|
||||
</script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>
|
||||
</body>
|
||||
</html>
|
||||
""";
|
||||
|
||||
return Results.Content(scalarScript, "text/html");
|
||||
}).ExcludeFromDescription();
|
||||
}
|
||||
}
|
|
@ -1,6 +1,4 @@
|
|||
using MediatR;
|
||||
using Netina.Domain.Dtos.ResponseDtos.Torob;
|
||||
using Netina.Domain.Dtos.ResponseDtos.Zarehbin;
|
||||
using Netina.Domain.Dtos.ResponseDtos.Zarehbin;
|
||||
using Netina.Domain.Entities.ProductCategories;
|
||||
|
||||
namespace Netina.Core.CoreServices;
|
||||
|
@ -15,17 +13,16 @@ public class SearchService : ISearchService
|
|||
}
|
||||
public async Task<SearchResponseDto> SearchAsync(string name, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var searchQuery = name.ToLower().Trim();
|
||||
int minSimilarityThreshold = 20;
|
||||
var searchQuery = name;
|
||||
var products = await _repositoryWrapper.SetRepository<Product>()
|
||||
.TableNoTracking
|
||||
.Where(p => FuzzySharp.Fuzz.PartialRatio(p.PersianName.ToLower().Trim(), searchQuery) >= minSimilarityThreshold)
|
||||
.OrderByDescending(p => EF.Functions.TrigramsSimilarity(p.PersianName, searchQuery))
|
||||
.Select(ProductMapper.ProjectToSDto)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
var categories = await _repositoryWrapper.SetRepository<ProductCategory>()
|
||||
.TableNoTracking
|
||||
.Where(p => FuzzySharp.Fuzz.PartialRatio(p.Name.ToLower().Trim(), searchQuery) >= minSimilarityThreshold)
|
||||
.OrderByDescending(p => EF.Functions.TrigramsSimilarity(p.Name, searchQuery))
|
||||
.Select(ProductCategoryMapper.ProjectToSDto)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using Netina.Common.Models.Api;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.Processing;
|
||||
|
||||
namespace Netina.Core.Utilities;
|
||||
|
|
Loading…
Reference in New Issue