109 lines
3.6 KiB
C#
109 lines
3.6 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// 历史搜索控制器Api
|
|
///
|
|
/// @author lwh
|
|
/// @date 2023-10-09
|
|
/// </summary>
|
|
[Verify]
|
|
[Route("api/[controller]")]
|
|
public class HistorySearchApiController : BaseController
|
|
{
|
|
private readonly IHistorySearchServiceApi _HistorySearchServiceApi;
|
|
|
|
/// <summary>
|
|
/// 依赖注入
|
|
/// </summary>
|
|
/// <param name="HistorySearchServiceApi">历史搜索历史搜索Api服务</param>
|
|
public HistorySearchApiController(IHistorySearchServiceApi HistorySearchServiceApi)
|
|
{
|
|
_HistorySearchServiceApi = HistorySearchServiceApi;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取历史搜索列表(Api)
|
|
/// </summary>
|
|
/// <param name="parm">查询参数</param>
|
|
/// <returns></returns>
|
|
[HttpGet("getHistorySearchList")]
|
|
public async Task<IActionResult> GetHistorySearchListApi([FromQuery] HistorySearchQueryDtoApi parm)
|
|
{
|
|
var user = JwtUtil.GetLoginUser(App.HttpContext);
|
|
parm.CustomerGuid = user.UserId;
|
|
var res = await _HistorySearchServiceApi.GetHistorySearchListApi(parm);
|
|
return SUCCESS(res);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取热门搜索列表(Api)
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet("getHotSearchList")]
|
|
public async Task<IActionResult> GetHotSearchListApi()
|
|
{
|
|
var res = await _HistorySearchServiceApi.GetHotSearchListApi();
|
|
return SUCCESS(res);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 添加历史搜索
|
|
/// </summary>
|
|
/// <param name="parm"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("addHistorySearch")]
|
|
[Log(Title = "添加历史搜索", BusinessType = BusinessType.ADDORUPDATE)]
|
|
public async Task<IActionResult> AddHistorySearch([FromBody] HistorySearchDto parm)
|
|
{
|
|
if (parm == null) { throw new CustomException("请求参数错误"); }
|
|
|
|
var modal = parm.Adapt<HistorySearch>().ToCreate(HttpContext);
|
|
var user = JwtUtil.GetLoginUser(App.HttpContext);
|
|
modal.CustomerGuid = user.UserId;
|
|
|
|
var res = await _HistorySearchServiceApi.AddHistorySearch(modal);
|
|
return SUCCESS(res);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除历史搜索
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[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("删除成功!");
|
|
}
|
|
|
|
|
|
}
|
|
}
|