Ver código fonte

Merge branch 'develop' of http://132.232.92.186:3000/XinXiBu/OA2023 into develop

yuanrf 2 meses atrás
pai
commit
5793c8341f

+ 92 - 0
OASystem/OASystem.Api/Controllers/SearchController.cs

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

+ 7 - 2
OASystem/OASystem.Api/Controllers/SystemController.cs

@@ -47,6 +47,7 @@ namespace OASystem.API.Controllers
         private readonly ApprovalProcessRepository _approvalProcessRep;
         private readonly IDeepSeekService _deepSeek;
         private readonly DynamicSearchService<Fin_DailyFeePayment> _dailyFeeSearchService;
+        private readonly DynamicSearchService<Grp_DelegationInfo> _groupSearchService;
 
         public SystemController(
             CompanyRepository syscom,
@@ -66,7 +67,8 @@ namespace OASystem.API.Controllers
             SetDataTypeRepository setDataTypeRep,
             ApprovalProcessRepository approvalProcessRep,
             IDeepSeekService deepSeek,
-            DynamicSearchService<Fin_DailyFeePayment> dailyFeeSearchService
+            DynamicSearchService<Fin_DailyFeePayment> dailyFeeSearchService,
+            DynamicSearchService<Grp_DelegationInfo> groupSearchService
             )
         {
             _syscomRep = syscom;
@@ -88,12 +90,13 @@ namespace OASystem.API.Controllers
             _approvalProcessRep = approvalProcessRep;
             _deepSeek = deepSeek;
             _dailyFeeSearchService = dailyFeeSearchService;
+            _groupSearchService = groupSearchService;
         }
 
         #region ALL OA 多词条搜索
 
         /// <summary>
-        ///  日付信息 关键字输入提示
+        ///  日付信息 单字段(申请原因)关键字输入提示
         /// </summary>
         /// <param name="keyword">关键字</param>
         /// <param name="auditType">审核类型 0 全部 1 张总未审核</param>
@@ -172,6 +175,8 @@ namespace OASystem.API.Controllers
 
         }
 
+        
+
         #endregion