using System.Threading.Tasks; using GxPress.Auth; using GxPress.Common.Page; using GxPress.Common.Tools; using GxPress.Request.App.ElasticSearch; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace GxPress.Api.AppControllers { [Route("api/app/elastics")] [ApiController] [Authorize] public class ElasticsSearchController : ControllerBase { private readonly ILoginContext _loginContext; public ElasticsSearchController(ILoginContext loginContext) { _loginContext = loginContext; } /// /// 删除 /// /// [HttpDelete("{id}")] public async Task Delete(string id) { var elasticsSearchHelper = new ElasticSearchHelper(); return await elasticsSearchHelper.Delete(id); } /// /// 搜索结果 /// /// /// [HttpPost("search")] public async Task> Search(ElasticSearchRequest request) { var elasticsSearchHelper = new ElasticSearchHelper(); var searchResult = await elasticsSearchHelper.SearchAsync(request.Key,request.SearchType,_loginContext.AccountId,request.Page,request.PerPage); return searchResult; } /// /// 根据ID查询 /// /// /// [HttpPut("{id}")] public async Task Get(string id) { var elasticsSearchHelper = new ElasticSearchHelper(); return await elasticsSearchHelper.Get(id); } } }