| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- 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, $"搜索服务暂时不可用!"));
- }
- }
- }
- }
|