diff --git a/ARW.Model/Dto/Api/Custom/HistorySearchs/HistorySearchApiDto.cs b/ARW.Model/Dto/Api/Custom/HistorySearchs/HistorySearchApiDto.cs
new file mode 100644
index 0000000..3e8044d
--- /dev/null
+++ b/ARW.Model/Dto/Api/Custom/HistorySearchs/HistorySearchApiDto.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using ARW.Model.Models.Business.Custom.HistorySearchs;
+
+namespace ARW.Model.Dto.Api.Custom.HistorySearchs
+{
+
+ ///
+ /// 历史搜索查询对象Api
+ ///
+ /// @author lwh
+ /// @date 2023-10-09
+ ///
+ public class HistorySearchQueryDtoApi
+ {
+ public long CustomerGuid { get; set; }
+ }
+
+}
diff --git a/ARW.Model/Dto/Business/Custom/HistorySearchs/HistorySearchDto.cs b/ARW.Model/Dto/Business/Custom/HistorySearchs/HistorySearchDto.cs
new file mode 100644
index 0000000..df42654
--- /dev/null
+++ b/ARW.Model/Dto/Business/Custom/HistorySearchs/HistorySearchDto.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using ARW.Model.Models.Business.Custom.HistorySearchs;
+
+namespace ARW.Model.Dto.Business.Custom.HistorySearchs
+{
+ ///
+ /// 历史搜索输入对象
+ ///
+ /// @author lwh
+ /// @date 2023-10-09
+ ///
+ public class HistorySearchDto
+ {
+
+ public int HistorySearchId { get; set; }
+
+ public long HistorySearchGuid { get; set; }
+
+ [Required(ErrorMessage = "搜索内容不能为空")]
+ public string HistorySearchContent { get; set; }
+
+
+
+
+
+ }
+
+
+ ///
+ /// 历史搜索查询对象
+ ///
+ /// @author lwh
+ /// @date 2023-10-09
+ ///
+ public class HistorySearchQueryDto : PagerInfo
+ {
+
+ public string ids { get; set; }
+ }
+
+
+
+
+}
diff --git a/ARW.Model/Models/Business/Custom/HistorySearchs/HistorySearch.cs b/ARW.Model/Models/Business/Custom/HistorySearchs/HistorySearch.cs
new file mode 100644
index 0000000..268b2eb
--- /dev/null
+++ b/ARW.Model/Models/Business/Custom/HistorySearchs/HistorySearch.cs
@@ -0,0 +1,58 @@
+using System;
+using System.Collections.Generic;
+using SqlSugar;
+using OfficeOpenXml.Attributes;
+using Newtonsoft.Json;
+
+namespace ARW.Model.Models.Business.Custom.HistorySearchs
+{
+ ///
+ /// 历史搜索,数据实体对象
+ ///
+ /// @author lwh
+ /// @date 2023-10-09
+ ///
+ [SugarTable("tb_history_search")]
+ public class HistorySearch : BusinessBase
+ {
+
+ ///
+ /// 描述 :
+ /// 空值 : false
+ ///
+ [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "history_search_id")]
+ public int HistorySearchId { get; set; }
+
+
+ ///
+ /// 描述 :
+ /// 空值 : false
+ ///
+ [JsonConverter(typeof(ValueToStringConverter))]
+ [SugarColumn(IsPrimaryKey = true, IsIdentity = false, ColumnName = "history_search_guid")]
+ public long HistorySearchGuid { get; set; }
+
+
+ ///
+ /// 描述 :客户guid
+ /// 空值 : false
+ ///
+ [JsonConverter(typeof(ValueToStringConverter))]
+ [SugarColumn(ColumnName = "customer_guid")]
+ public long CustomerGuid { get; set; }
+
+
+ ///
+ /// 描述 :搜索内容
+ /// 空值 : false
+ ///
+ [SugarColumn(ColumnName = "history_search_content")]
+ public string HistorySearchContent { get; set; }
+
+
+
+
+
+
+ }
+}
\ No newline at end of file
diff --git a/ARW.Model/Vo/Api/Custom/HistorySearchs/HistorySearchApiVo.cs b/ARW.Model/Vo/Api/Custom/HistorySearchs/HistorySearchApiVo.cs
new file mode 100644
index 0000000..fc4fb79
--- /dev/null
+++ b/ARW.Model/Vo/Api/Custom/HistorySearchs/HistorySearchApiVo.cs
@@ -0,0 +1,46 @@
+using Newtonsoft.Json;
+using OfficeOpenXml.Attributes;
+using SqlSugar;
+using System;
+
+namespace ARW.Model.Vo.Api.Custom.HistorySearchs
+{
+ ///
+ /// 历史搜索展示对象Api
+ ///
+ /// @author lwh
+ /// @date 2023-10-09
+ ///
+ public class HistorySearchVoApi
+ {
+
+
+ ///
+ /// 描述 :
+ ///
+ public int HistorySearchId { get; set; }
+
+
+ ///
+ /// 描述 :
+ ///
+ [JsonConverter(typeof(ValueToStringConverter))]
+ public long HistorySearchGuid { get; set; }
+
+
+ ///
+ /// 描述 :客户guid
+ ///
+ [JsonConverter(typeof(ValueToStringConverter))]
+ public long CustomerGuid { get; set; }
+
+
+ ///
+ /// 描述 :搜索内容
+ ///
+ public string HistorySearchContent { get; set; }
+
+ }
+
+
+}
diff --git a/ARW.Model/Vo/Api/Custom/HistorySearchs/SearchTermCount.cs b/ARW.Model/Vo/Api/Custom/HistorySearchs/SearchTermCount.cs
new file mode 100644
index 0000000..ad530c0
--- /dev/null
+++ b/ARW.Model/Vo/Api/Custom/HistorySearchs/SearchTermCount.cs
@@ -0,0 +1,20 @@
+using Newtonsoft.Json;
+using OfficeOpenXml.Attributes;
+using SqlSugar;
+using System;
+
+namespace ARW.Model.Vo.Api.Custom.HistorySearchs
+{
+ ///
+ /// 热门搜索对象Api
+ ///
+ /// @author lwh
+ /// @date 2023-10-09
+ ///
+ public class SearchTermCount
+ {
+ public string SearchTerm { get; set; }
+ public int Count { get; set; }
+ }
+
+}
diff --git a/ARW.Model/Vo/Business/Custom/HistorySearchs/HistorySearchVo.cs b/ARW.Model/Vo/Business/Custom/HistorySearchs/HistorySearchVo.cs
new file mode 100644
index 0000000..4fdabac
--- /dev/null
+++ b/ARW.Model/Vo/Business/Custom/HistorySearchs/HistorySearchVo.cs
@@ -0,0 +1,44 @@
+using Newtonsoft.Json;
+using OfficeOpenXml.Attributes;
+using SqlSugar;
+using System;
+
+namespace ARW.Model.Vo.Business.Custom.HistorySearchs
+{
+ ///
+ /// 历史搜索展示对象
+ ///
+ /// @author lwh
+ /// @date 2023-10-09
+ ///
+ public class HistorySearchVo
+ {
+
+
+ ///
+ /// 描述 :
+ ///
+ public int HistorySearchId { get; set; }
+
+
+ ///
+ /// 描述 :
+ ///
+ [JsonConverter(typeof(ValueToStringConverter))]
+ public long HistorySearchGuid { get; set; }
+
+
+ ///
+ /// 描述 :客户guid
+ ///
+ [JsonConverter(typeof(ValueToStringConverter))]
+ public long CustomerGuid { get; set; }
+
+
+ ///
+ /// 描述 :搜索内容
+ ///
+ public string HistorySearchContent { get; set; }
+
+ }
+}
diff --git a/ARW.Repository/Business/Custom/HistorySearchs/HistorySearchRepository.cs b/ARW.Repository/Business/Custom/HistorySearchs/HistorySearchRepository.cs
new file mode 100644
index 0000000..3d0d56c
--- /dev/null
+++ b/ARW.Repository/Business/Custom/HistorySearchs/HistorySearchRepository.cs
@@ -0,0 +1,20 @@
+using System;
+using Infrastructure.Attribute;
+using ARW.Repository.System;
+using ARW.Model.Models.Business.Custom.HistorySearchs;
+
+namespace ARW.Repository.Business.Custom.HistorySearchs
+{
+ ///
+ /// 历史搜索仓储
+ ///
+ /// @author lwh
+ /// @date 2023-10-09
+ ///
+ [AppService(ServiceLifetime = LifeTime.Transient)]
+ public class HistorySearchRepository : BaseRepository
+ {
+ #region 业务逻辑代码
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/ARW.Service/Api/BusinessService/Custom/HistorySearchs/HistorySearchServiceApi.cs b/ARW.Service/Api/BusinessService/Custom/HistorySearchs/HistorySearchServiceApi.cs
new file mode 100644
index 0000000..955bb9d
--- /dev/null
+++ b/ARW.Service/Api/BusinessService/Custom/HistorySearchs/HistorySearchServiceApi.cs
@@ -0,0 +1,121 @@
+using Infrastructure.Attribute;
+using Microsoft.AspNetCore.Http;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ARW.Model;
+using ARW.Repository;
+using ARW.Repository.Business.Custom.HistorySearchs;
+using ARW.Service.Api.IBusinessService.Custom.HistorySearchs;
+using ARW.Model.Dto.Api.Custom.HistorySearchs;
+using ARW.Model.Models.Business.Custom.HistorySearchs;
+using ARW.Model.Vo.Api.Custom.HistorySearchs;
+
+namespace ARW.Service.Api.BusinessService.Custom.HistorySearchs
+{
+ ///
+ /// 历史搜索接口实现类Api
+ ///
+ /// @author lwh
+ /// @date 2023-10-09
+ ///
+ [AppService(ServiceType = typeof(IHistorySearchServiceApi), ServiceLifetime = LifeTime.Transient)]
+ public class HistorySearchServiceImplApi : BaseService, IHistorySearchServiceApi
+ {
+ private readonly HistorySearchRepository _HistorySearchRepository;
+
+ public HistorySearchServiceImplApi(HistorySearchRepository HistorySearchRepository)
+ {
+ this._HistorySearchRepository = HistorySearchRepository;
+ }
+
+ #region Api接口代码
+
+
+ ///
+ /// 查询历史搜索列表(Api)
+ ///
+ ///
+ ///
+ public async Task> GetHistorySearchListApi(HistorySearchQueryDtoApi parm)
+ {
+ //开始拼装查询条件d
+ var predicate = Expressionable.Create();
+ predicate = predicate.AndIF(parm.CustomerGuid != 0, s => s.CustomerGuid == parm.CustomerGuid);
+
+ var query = _HistorySearchRepository
+ .Queryable()
+ .Where(predicate.ToExpression())
+ .OrderBy(s => s.Create_time, OrderByType.Desc)
+ .Select(s => new HistorySearchVoApi
+ {
+ HistorySearchId = s.HistorySearchId,
+ HistorySearchGuid = s.HistorySearchGuid,
+ CustomerGuid = s.CustomerGuid,
+ HistorySearchContent = s.HistorySearchContent,
+ });
+
+
+ return await query.ToListAsync();
+ }
+
+
+ ///
+ /// 获取热门搜索列表(Api)
+ ///
+ ///
+ public async Task> GetHotSearchListApi()
+ {
+ // 获取当天开始和结束时间
+ DateTime todayStart = DateTime.Today;
+ DateTime todayEnd = todayStart.AddDays(1).AddSeconds(-1);
+
+ var predicate = Expressionable.Create();
+
+ var query = _HistorySearchRepository
+ .Queryable()
+ .Where(s => s.Create_time >= todayStart && s.Create_time <= todayEnd) // 仅选择当天的搜索记录
+ .Where(predicate.ToExpression())
+ .OrderBy(s => s.Create_time, OrderByType.Desc)
+ .Select(s => new HistorySearchVoApi
+ {
+ HistorySearchId = s.HistorySearchId,
+ HistorySearchGuid = s.HistorySearchGuid,
+ CustomerGuid = s.CustomerGuid,
+ HistorySearchContent = s.HistorySearchContent,
+ });
+
+ var searchTerms = await query.ToListAsync();
+
+ var searchTermCounts = searchTerms
+ .GroupBy(s => s.HistorySearchContent)
+ .Select(g => new SearchTermCount
+ {
+ SearchTerm = g.Key,
+ Count = g.Count()
+ })
+ .OrderByDescending(g => g.Count) // 按照搜索次数降序排列
+ .Take(20)
+ .ToList();
+
+ return searchTermCounts;
+ }
+
+
+ ///
+ /// 添加历史搜索
+ ///
+ public async Task AddHistorySearch(HistorySearch model)
+ {
+ var response = await _HistorySearchRepository.InsertReturnSnowflakeIdAsync(model);
+ return "添加成功!";
+ }
+
+
+ #endregion
+
+ }
+}
diff --git a/ARW.Service/Api/IBusinessService/Custom/HistorySearchs/IHistorySearchServiceApi.cs b/ARW.Service/Api/IBusinessService/Custom/HistorySearchs/IHistorySearchServiceApi.cs
new file mode 100644
index 0000000..a61951f
--- /dev/null
+++ b/ARW.Service/Api/IBusinessService/Custom/HistorySearchs/IHistorySearchServiceApi.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ARW.Model;
+using ARW.Model.Dto.Api.Custom.HistorySearchs;
+using ARW.Model.Models.Business.Custom.HistorySearchs;
+using ARW.Model.Vo.Api.Custom.HistorySearchs;
+
+namespace ARW.Service.Api.IBusinessService.Custom.HistorySearchs
+{
+ ///
+ /// 历史搜索接口类Api
+ ///
+ /// @author lwh
+ /// @date 2023-10-09
+ ///
+ public interface IHistorySearchServiceApi : IBaseService
+ {
+ ///
+ /// 获取历史搜索分页列表(Api)
+ ///
+ ///
+ ///
+ Task> GetHistorySearchListApi(HistorySearchQueryDtoApi parm);
+
+
+ ///
+ /// 获取热门搜索列表(Api)
+ ///
+ ///
+ Task> GetHotSearchListApi();
+
+
+ ///
+ /// 添加历史搜索
+ ///
+ ///
+ ///
+ Task AddHistorySearch(HistorySearch parm);
+
+ }
+}
diff --git a/ARW.Service/Business/BusinessService/Custom/HistorySearchs/HistorySearchService.cs b/ARW.Service/Business/BusinessService/Custom/HistorySearchs/HistorySearchService.cs
new file mode 100644
index 0000000..16fac82
--- /dev/null
+++ b/ARW.Service/Business/BusinessService/Custom/HistorySearchs/HistorySearchService.cs
@@ -0,0 +1,91 @@
+using Infrastructure.Attribute;
+using Microsoft.AspNetCore.Http;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Infrastructure;
+using ARW.Model;
+using ARW.Repository;
+using ARW.Repository.Business.Custom.HistorySearchs;
+using ARW.Service.Business.IBusinessService.Custom.HistorySearchs;
+using ARW.Model.Dto.Business.Custom.HistorySearchs;
+using ARW.Model.Models.Business.Custom.HistorySearchs;
+using ARW.Model.Vo.Business.Custom.HistorySearchs;
+
+namespace ARW.Service.Business.BusinessService.Custom.HistorySearchs
+{
+ ///
+ /// 历史搜索接口实现类
+ ///
+ /// @author lwh
+ /// @date 2023-10-09
+ ///
+ [AppService(ServiceType = typeof(IHistorySearchService), ServiceLifetime = LifeTime.Transient)]
+ public class HistorySearchServiceImpl : BaseService, IHistorySearchService
+ {
+ private readonly HistorySearchRepository _HistorySearchRepository;
+
+ public HistorySearchServiceImpl(HistorySearchRepository HistorySearchRepository)
+ {
+ this._HistorySearchRepository = HistorySearchRepository;
+ }
+
+ #region 业务逻辑代码
+
+
+ ///
+ /// 查询历史搜索分页列表
+ ///
+ public async Task> GetHistorySearchList(HistorySearchQueryDto parm)
+ {
+ //开始拼装查询条件d
+ var predicate = Expressionable.Create();
+
+ var query = _HistorySearchRepository
+ .Queryable()
+ .Where(predicate.ToExpression())
+ .OrderBy(s => s.Create_time, OrderByType.Desc)
+ .Select(s => new HistorySearchVo
+ {
+ HistorySearchId = s.HistorySearchId,
+ HistorySearchGuid = s.HistorySearchGuid,
+ CustomerGuid = s.CustomerGuid,
+ HistorySearchContent = s.HistorySearchContent,
+ });
+
+
+ return await query.ToPageAsync(parm);
+ }
+
+ ///
+ /// 添加或修改历史搜索
+ ///
+ public async Task AddOrUpdateHistorySearch(HistorySearch model)
+ {
+ if (model.HistorySearchId != 0)
+ {
+ var response = await _HistorySearchRepository.UpdateAsync(model);
+ return "修改成功!";
+ }
+ else
+ {
+
+ var response = await _HistorySearchRepository.InsertReturnSnowflakeIdAsync(model);
+ return "添加成功!";
+ }
+ }
+
+ #region Excel处理
+
+
+ #endregion
+
+
+
+ #endregion
+
+ }
+}
diff --git a/ARW.Service/Business/IBusinessService/Custom/HistorySearchs/IHistorySearchService.cs b/ARW.Service/Business/IBusinessService/Custom/HistorySearchs/IHistorySearchService.cs
new file mode 100644
index 0000000..3a1a764
--- /dev/null
+++ b/ARW.Service/Business/IBusinessService/Custom/HistorySearchs/IHistorySearchService.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ARW.Model;
+using ARW.Model.Dto.Business.Custom.HistorySearchs;
+using ARW.Model.Models.Business.Custom.HistorySearchs;
+using ARW.Model.Vo.Business.Custom.HistorySearchs;
+
+namespace ARW.Service.Business.IBusinessService.Custom.HistorySearchs
+{
+ ///
+ /// 历史搜索接口类
+ ///
+ /// @author lwh
+ /// @date 2023-10-09
+ ///
+ public interface IHistorySearchService : IBaseService
+ {
+ ///
+ /// 获取历史搜索分页列表
+ ///
+ ///
+ ///
+ Task> GetHistorySearchList(HistorySearchQueryDto parm);
+
+
+ ///
+ /// 添加或修改历史搜索
+ ///
+ ///
+ ///
+ Task AddOrUpdateHistorySearch(HistorySearch parm);
+
+
+
+
+
+ }
+}
diff --git a/ARW.WebApi/Controllers/Api/Custom/HistorySearchs/HistorySearchApiController.cs b/ARW.WebApi/Controllers/Api/Custom/HistorySearchs/HistorySearchApiController.cs
new file mode 100644
index 0000000..56cb78c
--- /dev/null
+++ b/ARW.WebApi/Controllers/Api/Custom/HistorySearchs/HistorySearchApiController.cs
@@ -0,0 +1,108 @@
+using Infrastructure;
+using Infrastructure.Attribute;
+using Infrastructure.Enums;
+using Infrastructure.Model;
+using Mapster;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using ARW.Admin.WebApi.Extensions;
+using ARW.Admin.WebApi.Filters;
+using ARW.Common;
+using ARW.Admin.WebApi.Controllers;
+using ARW.Model.Dto.Api.Custom.HistorySearchs;
+using ARW.Service.Api.IBusinessService.Custom.HistorySearchs;
+using ARW.Model.Models.Business.Custom.HistorySearchs;
+using ARW.Model.Vo.Api.Custom.HistorySearchs;
+using Microsoft.AspNetCore.Authorization;
+using Geocoding;
+using ARW.Model.Dto.Business.Custom.HistorySearchs;
+using ARW.Service.Business.IBusinessService.Custom.HistorySearchs;
+using ARW.Admin.WebApi.Framework;
+
+namespace ARW.WebApi.Controllers.Api.Custom.HistorySearchs
+{
+ ///
+ /// 历史搜索控制器Api
+ ///
+ /// @author lwh
+ /// @date 2023-10-09
+ ///
+ [Verify]
+ [Route("api/[controller]")]
+ public class HistorySearchApiController : BaseController
+ {
+ private readonly IHistorySearchServiceApi _HistorySearchServiceApi;
+
+ ///
+ /// 依赖注入
+ ///
+ /// 历史搜索历史搜索Api服务
+ public HistorySearchApiController(IHistorySearchServiceApi HistorySearchServiceApi)
+ {
+ _HistorySearchServiceApi = HistorySearchServiceApi;
+ }
+
+
+ ///
+ /// 获取历史搜索列表(Api)
+ ///
+ /// 查询参数
+ ///
+ [HttpGet("getHistorySearchList")]
+ public async Task GetHistorySearchListApi([FromQuery] HistorySearchQueryDtoApi parm)
+ {
+ var user = JwtUtil.GetLoginUser(App.HttpContext);
+ parm.CustomerGuid = user.UserId;
+ var res = await _HistorySearchServiceApi.GetHistorySearchListApi(parm);
+ return SUCCESS(res);
+ }
+
+
+ ///
+ /// 获取热门搜索列表(Api)
+ ///
+ ///
+ [HttpGet("getHotSearchList")]
+ public async Task GetHotSearchListApi()
+ {
+ var res = await _HistorySearchServiceApi.GetHotSearchListApi();
+ return SUCCESS(res);
+ }
+
+
+ ///
+ /// 添加历史搜索
+ ///
+ ///
+ ///
+ [HttpPost("addHistorySearch")]
+ [Log(Title = "添加历史搜索", BusinessType = BusinessType.ADDORUPDATE)]
+ public async Task AddHistorySearch([FromBody] HistorySearchDto parm)
+ {
+ if (parm == null) { throw new CustomException("请求参数错误"); }
+
+ var modal = parm.Adapt().ToCreate(HttpContext);
+ var user = JwtUtil.GetLoginUser(App.HttpContext);
+ modal.CustomerGuid = user.UserId;
+
+ var res = await _HistorySearchServiceApi.AddHistorySearch(modal);
+ return SUCCESS(res);
+ }
+
+ ///
+ /// 删除历史搜索
+ ///
+ ///
+ [HttpDelete("{ids}")]
+ [Log(Title = "历史搜索删除", BusinessType = BusinessType.DELETE)]
+ public IActionResult Delete(string ids)
+ {
+ long[] idsArr = Tools.SpitLongArrary(ids);
+ if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); }
+ var response = _HistorySearchServiceApi.Delete(idsArr);
+ return SUCCESS("删除成功!");
+ }
+
+
+ }
+}