|
|
@@ -0,0 +1,92 @@
|
|
|
+using Microsoft.AspNetCore.Http;
|
|
|
+using Microsoft.AspNetCore.Mvc;
|
|
|
+using OASystem.API.OAMethodLib.DeepSeekAPI;
|
|
|
+using OASystem.API.OAMethodLib.GenericSearch;
|
|
|
+using OASystem.Domain.Entities.Financial;
|
|
|
+using OASystem.Domain.Entities.Groups;
|
|
|
+using OASystem.Infrastructure.Repositories.System;
|
|
|
+
|
|
|
+namespace OASystem.API.Controllers
|
|
|
+{
|
|
|
+ /// <summary>
|
|
|
+ /// 搜索
|
|
|
+ /// </summary>
|
|
|
+ [Route("api/search")]
|
|
|
+ [ApiController]
|
|
|
+ public class SearchController : ControllerBase
|
|
|
+ {
|
|
|
+ private readonly DynamicSearchService<Grp_DelegationInfo> _groupSearchService;
|
|
|
+ public SearchController(
|
|
|
+ DynamicSearchService<Grp_DelegationInfo> groupSearchService
|
|
|
+ )
|
|
|
+ {
|
|
|
+ _groupSearchService = groupSearchService;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 接团信息 单字段(团组名称)关键字输入提示
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="keyword">关键字</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("group/{keyword}")]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> GroupKeywordSearch(string keyword)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ // 验证请求参数
|
|
|
+ if (string.IsNullOrEmpty(keyword))
|
|
|
+ {
|
|
|
+ return Ok(JsonView(true, $"暂无数据!"));
|
|
|
+ }
|
|
|
+
|
|
|
+ var searchRequest = new DynamicSearchRequest
|
|
|
+ {
|
|
|
+ Keyword = keyword,
|
|
|
+ RequireAllSingleChars = true,
|
|
|
+ PageIndex = 1,
|
|
|
+ PageSize = 999999,
|
|
|
+ FieldWeights = new Dictionary<string, int>
|
|
|
+ {
|
|
|
+ { "TeamName", 10 },
|
|
|
+ //{ "ClientUnit", 8 },
|
|
|
+ //{ "ClientName", 6 }
|
|
|
+ },
|
|
|
+ Filters = new List<SearchFilter>()
|
|
|
+ {
|
|
|
+ new(){Field = "IsDel",Operator="eq",Value="0" }
|
|
|
+ },
|
|
|
+ OrderBy = "TeamName",
|
|
|
+ ReturnFields = new List<string>() { "TeamName" }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 验证字段配置
|
|
|
+ var validation = _groupSearchService.ValidateFieldConfig(
|
|
|
+ searchRequest.FieldWeights,
|
|
|
+ searchRequest.ReturnFields);
|
|
|
+
|
|
|
+ if (!validation.IsValid)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(true, $"暂无数据!{validation.Message}"));
|
|
|
+ }
|
|
|
+
|
|
|
+ var result = await _groupSearchService.SearchAsync(searchRequest);
|
|
|
+
|
|
|
+ if (result.Success)
|
|
|
+ {
|
|
|
+ var data = result.Items.Select(x => new { x.Data.Id, x.Data.TeamName }).ToList();
|
|
|
+
|
|
|
+ return Ok(JsonView(true, result.Message, data, data.Count));
|
|
|
+ }
|
|
|
+
|
|
|
+ return Ok(JsonView(true, result.Message));
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ return Ok(JsonView(true, $"搜索服务暂时不可用!"));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|