-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
151 additions
and
5 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/EoaServer.Application.Contracts/Search/Dto/ChainsInfoDto.cs
This file contains 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,26 @@ | ||
using System; | ||
|
||
namespace EoaServer.Search.Dto; | ||
|
||
public class ChainsInfoDto | ||
{ | ||
public string ChainId { get; set; } | ||
public string ChainName { get; set; } | ||
public string EndPoint { get; set; } | ||
public string ExplorerUrl { get; set; } | ||
public string CaContractAddress { get; set; } | ||
public string DisplayChainName { get; set; } | ||
public string ChainImageUrl { get; set; } | ||
public DefaultTokenInfoDto DefaultToken { get; set; } | ||
public DateTime LastModifyTime { get; set; } | ||
} | ||
|
||
public class DefaultTokenInfoDto | ||
{ | ||
public string Name { get; set; } | ||
public string Address { get; set; } | ||
public string ImageUrl { get; set; } | ||
public string Symbol { get; set; } | ||
public string Decimals { get; set; } | ||
public long IssueChainId { get; set; } | ||
} |
10 changes: 10 additions & 0 deletions
10
src/EoaServer.Application.Contracts/Search/ISearchAppService.cs
This file contains 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,10 @@ | ||
using System.Threading.Tasks; | ||
using EoaServer.Search.Dto; | ||
using Volo.Abp.Application.Dtos; | ||
|
||
namespace EoaServer.Search; | ||
|
||
public interface ISearchAppService | ||
{ | ||
Task<PagedResultDto<ChainsInfoDto>> GetChainsInfoAsync(); | ||
} |
This file contains 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 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 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 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,49 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using AElf.Indexing.Elasticsearch; | ||
using EoaServer.Entities.Es; | ||
using EoaServer.Search.Dto; | ||
using Nest; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Serialization; | ||
using Volo.Abp; | ||
using Volo.Abp.Application.Dtos; | ||
using Volo.Abp.Auditing; | ||
using Volo.Abp.ObjectMapping; | ||
|
||
namespace EoaServer.Search; | ||
|
||
[RemoteService(false)] | ||
[DisableAuditing] | ||
public class SearchAppService : EoaServerBaseService, ISearchAppService | ||
{ | ||
private readonly INESTRepository<ChainsInfoIndex, string> _chainsInfoRepository; | ||
private readonly IObjectMapper _objectMapper; | ||
|
||
public SearchAppService( | ||
INESTRepository<ChainsInfoIndex, string> chainsInfoRepository, | ||
IObjectMapper objectMapper) | ||
{ | ||
_chainsInfoRepository = chainsInfoRepository; | ||
_objectMapper = objectMapper; | ||
} | ||
|
||
public async Task<PagedResultDto<ChainsInfoDto>> GetChainsInfoAsync() | ||
{ | ||
var mustQuery = new List<Func<QueryContainerDescriptor<ChainsInfoIndex>, QueryContainer>>(); | ||
QueryContainer Filter(QueryContainerDescriptor<ChainsInfoIndex> f) => f.Bool(b => b.Must(mustQuery)); | ||
|
||
var (totalCount, list) = await _chainsInfoRepository.GetListAsync(Filter); | ||
|
||
var serializeSetting = new JsonSerializerSettings | ||
{ | ||
ContractResolver = new CamelCasePropertyNamesContractResolver() | ||
}; | ||
return new PagedResultDto<ChainsInfoDto> | ||
{ | ||
TotalCount = totalCount, | ||
Items = _objectMapper.Map<List<ChainsInfoIndex>, List<ChainsInfoDto>>(list) | ||
}; | ||
} | ||
} |
This file contains 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 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,28 @@ | ||
using System; | ||
using AElf.Indexing.Elasticsearch; | ||
using Nest; | ||
|
||
namespace EoaServer.Entities.Es; | ||
|
||
public class ChainsInfoIndex : EoaBaseEsEntity<string>, IIndexBuild | ||
{ | ||
[Keyword] public string ChainId { get; set; } | ||
[Keyword] public string ChainName { get; set; } | ||
[Keyword] public string EndPoint { get; set; } | ||
[Keyword] public string ExplorerUrl { get; set; } | ||
[Keyword] public string CaContractAddress { get; set; } | ||
[Keyword] public string DisplayChainName { get; set; } | ||
[Keyword] public string ChainImageUrl { get; set; } | ||
public DefaultTokenInfo DefaultToken { get; set; } | ||
public DateTime LastModifyTime { get; set; } | ||
} | ||
|
||
public class DefaultTokenInfo | ||
{ | ||
[Keyword] public string Name { get; set; } | ||
[Keyword] public string Address { get; set; } | ||
[Keyword] public string ImageUrl { get; set; } | ||
[Keyword] public string Symbol { get; set; } | ||
[Keyword] public string Decimals { get; set; } | ||
public long IssueChainId { get; set; } | ||
} |
This file contains 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,29 @@ | ||
using System.Threading.Tasks; | ||
using Asp.Versioning; | ||
using EoaServer.Search; | ||
using EoaServer.Search.Dto; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Volo.Abp; | ||
using Volo.Abp.Application.Dtos; | ||
|
||
namespace EoaServer.Controllers; | ||
|
||
[RemoteService] | ||
[Area("app")] | ||
[ControllerName("Search")] | ||
[Route("api/app/search")] | ||
public class SearchController : EoaServerBaseController | ||
{ | ||
private readonly ISearchAppService _searchAppService; | ||
|
||
public SearchController(ISearchAppService searchAppService) | ||
{ | ||
_searchAppService = searchAppService; | ||
} | ||
|
||
[HttpGet("chainsinfoindex")] | ||
public async Task<PagedResultDto<ChainsInfoDto>> GetChainsInfoAsync() | ||
{ | ||
return await _searchAppService.GetChainsInfoAsync(); | ||
} | ||
} |