feat : add thumb search , add version 0.25.28.49
parent
0e2b99d85e
commit
108230cc15
|
@ -12,11 +12,19 @@ public class SearchController : ICarterModule
|
|||
.WithDisplayName("Search Async")
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapGet("/thumb", SearchThumbAsync)
|
||||
.WithDisplayName("Thumb Search Async")
|
||||
.HasApiVersion(1.0);
|
||||
|
||||
group.MapGet("zarehbin", ZarehbinAsync)
|
||||
.WithDisplayName("Search Async")
|
||||
.HasApiVersion(1.0);
|
||||
}
|
||||
|
||||
private async Task<IResult> SearchThumbAsync([FromQuery] string name, [FromServices] ISearchService searchService, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await searchService.ThumbSearchAsync(name, cancellationToken));
|
||||
|
||||
|
||||
private async Task<IResult> SearchAsync([FromQuery] string name, [FromServices] ISearchService searchService, CancellationToken cancellationToken)
|
||||
=> TypedResults.Ok(await searchService.SearchAsync(name, cancellationToken));
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<AssemblyVersion>0.25.27.48</AssemblyVersion>
|
||||
<FileVersion>0.25.27.48</FileVersion>
|
||||
<AssemblyVersion>0.25.28.49</AssemblyVersion>
|
||||
<FileVersion>0.25.28.49</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Netina.Core.CoreServices.Abstracts;
|
|||
public interface ISearchService : IScopedDependency
|
||||
{
|
||||
public Task<SearchResponseDto> SearchAsync(string name,CancellationToken cancellationToken = default);
|
||||
public Task<SearchResponseDto> ThumbSearchAsync(string name,CancellationToken cancellationToken = default);
|
||||
public Task<ZarehbinPagedResponseDto> ZarehbinAsync(int page,CancellationToken cancellationToken = default);
|
||||
public Task<ZarehbinProductResponseDto> ZarehbinAsync(Guid productId,CancellationToken cancellationToken = default);
|
||||
}
|
|
@ -32,6 +32,28 @@ public class SearchService : ISearchService
|
|||
};
|
||||
}
|
||||
|
||||
public async Task<SearchResponseDto> ThumbSearchAsync(string name, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var products = await _repositoryWrapper.SetRepository<Product>()
|
||||
.TableNoTracking
|
||||
.Where(p => p.PersianName.Trim().ToLower().Contains(name.Trim().ToLower()))
|
||||
.Take(8)
|
||||
.Select(ProductMapper.ProjectToSDto)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
var categories = await _repositoryWrapper.SetRepository<ProductCategory>()
|
||||
.TableNoTracking
|
||||
.Where(p => p.Name.Trim().ToLower().Contains(name.Trim().ToLower()))
|
||||
.Select(ProductCategoryMapper.ProjectToSDto)
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
return new SearchResponseDto
|
||||
{
|
||||
Products = products.Select(p => p.Adapt<SearchedProductResponseDto>()).ToList(),
|
||||
Categories = categories.Select(c => c.Adapt<SearchedProductCategoryResponseDto>()).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
public Task<ZarehbinPagedResponseDto> ZarehbinAsync(int page, CancellationToken cancellationToken = default)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
|
Loading…
Reference in New Issue