|
@@ -21,15 +21,24 @@ using Hotline.Share.Dtos.WebPortal;
|
|
|
using Hotline.Share.Enums.KnowledgeBase;
|
|
|
using Hotline.Share.Enums.Order;
|
|
|
using Hotline.Share.Enums.Push;
|
|
|
+using Hotline.Share.Tools;
|
|
|
+using Hotline.Tools;
|
|
|
using Hotline.WebPortal;
|
|
|
+using Hotline.YbEnterprise.Sdk;
|
|
|
using MapsterMapper;
|
|
|
using MathNet.Numerics;
|
|
|
using MediatR;
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
using Microsoft.Extensions.Options;
|
|
|
+using MongoDB.Driver.Core.WireProtocol.Messages;
|
|
|
+using Newtonsoft.Json.Linq;
|
|
|
using Senparc.Weixin.WxOpen.AdvancedAPIs.WxApp.WxAppJson;
|
|
|
+using Senparc.Weixin.WxOpen.Entities;
|
|
|
+using SharpCompress.Common;
|
|
|
using SqlSugar;
|
|
|
+using System.Text.Json;
|
|
|
+using System.Threading;
|
|
|
using XF.Domain.Authentications;
|
|
|
using XF.Domain.Cache;
|
|
|
using XF.Domain.Filters;
|
|
@@ -66,6 +75,7 @@ namespace Hotline.Api.Controllers
|
|
|
private readonly IRepository<KnowledgeWord> _knowledgeWordRepository;
|
|
|
private readonly ISystemDicDataCacheManager _sysDicDataCacheManager;
|
|
|
private readonly IIdentityAppService _identityAppService;
|
|
|
+ private readonly IHttpClientFactory _httpClientFactory;
|
|
|
|
|
|
public FwThirdController(IMapper mapper,
|
|
|
IMediator mediator,
|
|
@@ -91,7 +101,8 @@ namespace Hotline.Api.Controllers
|
|
|
ITypedCache<string> getVailData,
|
|
|
IRepository<KnowledgeWord> knowledgeWordRepository,
|
|
|
ISystemDicDataCacheManager sysDicDataCacheManager,
|
|
|
- IIdentityAppService identityAppService
|
|
|
+ IIdentityAppService identityAppService,
|
|
|
+ IHttpClientFactory httpClientFactory
|
|
|
)
|
|
|
{
|
|
|
_mapper = mapper;
|
|
@@ -119,6 +130,7 @@ namespace Hotline.Api.Controllers
|
|
|
_knowledgeWordRepository = knowledgeWordRepository;
|
|
|
_sysDicDataCacheManager = sysDicDataCacheManager;
|
|
|
_identityAppService = identityAppService;
|
|
|
+ _httpClientFactory = httpClientFactory;
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
@@ -142,7 +154,6 @@ namespace Hotline.Api.Controllers
|
|
|
/// <param name="dto"></param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost("getacceptancetypestatisticsbymonth")]
|
|
|
- [AllowAnonymous]
|
|
|
public async Task<List<OrderFormCount>> GetAcceptanceTypeStatisticsByMonth([FromBody] OrderFormByMonthDto dto)
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(dto.StartTime))
|
|
@@ -199,7 +210,6 @@ namespace Hotline.Api.Controllers
|
|
|
/// <param name="dto"></param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost("getacceptancetypestatisticsbymonthend")]
|
|
|
- [AllowAnonymous]
|
|
|
public async Task<List<OrderFormCount>> GetAcceptanceTypeStatisticsByMonthEnd([FromBody] OrderFormByMonthDto dto)
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(dto.StartTime))
|
|
@@ -253,7 +263,6 @@ namespace Hotline.Api.Controllers
|
|
|
/// </summary>
|
|
|
/// <param name="dto"></param>
|
|
|
/// <returns></returns>
|
|
|
- [AllowAnonymous]
|
|
|
[HttpPost("getarticlelistbynum")]
|
|
|
public async Task<IReadOnlyList<DataListTopDto>> GetArticleListByNum([FromBody] ArticleIdByNumDto dto)
|
|
|
{
|
|
@@ -288,7 +297,6 @@ namespace Hotline.Api.Controllers
|
|
|
/// </summary>
|
|
|
/// <param name="dto"></param>
|
|
|
/// <returns></returns>
|
|
|
- [AllowAnonymous]
|
|
|
[HttpPost("getarticledetails")]
|
|
|
public async Task<List<ArticleDetailsDto>> GetArticleDetails([FromBody] ArticleIdDto dto)
|
|
|
{
|
|
@@ -330,7 +338,6 @@ namespace Hotline.Api.Controllers
|
|
|
/// <param name="dto"></param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost("get_order_list_publish_all")]
|
|
|
- [AllowAnonymous]
|
|
|
public async Task<OrderListReturnDto> GetOrderByListAllOpen([FromBody] QueryOrderListDto dto)
|
|
|
{
|
|
|
var queryNew = _orderPublishRepository.Queryable()
|
|
@@ -405,7 +412,6 @@ namespace Hotline.Api.Controllers
|
|
|
/// </summary>
|
|
|
/// <param name="dto"></param>
|
|
|
/// <returns></returns>
|
|
|
- [AllowAnonymous]
|
|
|
[HttpPost("getorderdetailbyid")]
|
|
|
public async Task<OrderDetail> GetOrderDetailById([FromBody] ArticleIdDto dto)
|
|
|
{
|
|
@@ -456,12 +462,13 @@ namespace Hotline.Api.Controllers
|
|
|
|
|
|
#region 知识库
|
|
|
|
|
|
+ #region 知识库分类
|
|
|
+
|
|
|
/// <summary>
|
|
|
- /// 获取知识库分类
|
|
|
+ /// 知识库分类
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost("getknowledgetype")]
|
|
|
- [AllowAnonymous]
|
|
|
public async Task<object> GetKnowledgeType()
|
|
|
{
|
|
|
//查询知识分类
|
|
@@ -489,65 +496,73 @@ namespace Hotline.Api.Controllers
|
|
|
return rsp;
|
|
|
}
|
|
|
|
|
|
- ///// <summary>
|
|
|
- ///// 知识库查询
|
|
|
- ///// </summary>
|
|
|
- ///// <param name="dto"></param>
|
|
|
- ///// <returns></returns>
|
|
|
- //[HttpPost("getknowledgelist")]
|
|
|
- //[AllowAnonymous]
|
|
|
- //public async Task<PagedDto<KnowledgeInfoDto>> GetKnowledgeList([FromBody] QueryKnowledgeList dto)
|
|
|
- //{
|
|
|
- // var typeSpliceName = string.Empty;
|
|
|
- // if (!string.IsNullOrEmpty(dto.KnowledgeTypeId))
|
|
|
- // {
|
|
|
- // var type = await _knowledgeTypeRepository.GetAsync(x => x.Name == dto.KnowledgeTypeId);
|
|
|
- // typeSpliceName = type?.SpliceName;
|
|
|
- // }
|
|
|
-
|
|
|
- // var typeSpliceNameTags = string.Empty;
|
|
|
- // if (!string.IsNullOrEmpty(dto.KnowledgeBaseTags))
|
|
|
- // {
|
|
|
- // var type = await _knowledgeWordRepository.GetAsync(x => x.Tag == dto.KnowledgeBaseTags && x.IsEnable == 1);
|
|
|
- // typeSpliceNameTags = type?.Id;
|
|
|
- // }
|
|
|
-
|
|
|
- // var (total, items) = await _knowledgeRepository.Queryable()
|
|
|
- // .Where(p => p.IsPublic == true && p.Status == EKnowledgeStatus.OnShelf)
|
|
|
- // .WhereIF(!string.IsNullOrEmpty(dto.Title), p => p.Title.Contains(dto.Title))
|
|
|
- // .WhereIF(!string.IsNullOrEmpty(typeSpliceNameTags), p => SqlFunc.JsonArrayAny(p.Keywords, typeSpliceNameTags) == true)
|
|
|
- // .WhereIF(!string.IsNullOrEmpty(typeSpliceName), x => x.KnowledgeType.Any(t => t.KnowledgeTypeSpliceName.EndsWith(typeSpliceName)))
|
|
|
- // .OrderByDescending(p => p.CreationTime)
|
|
|
- // .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted);
|
|
|
-
|
|
|
- // var data = new PagedDto<KnowledgeInfoDto>(total, _mapper.Map<IReadOnlyList<KnowledgeInfoDto>>(items));
|
|
|
- // return data;
|
|
|
- //}
|
|
|
-
|
|
|
- ///// <summary>
|
|
|
- ///// 获取知识库详情
|
|
|
- ///// </summary>
|
|
|
- ///// <param name="dto"></param>
|
|
|
- ///// <returns></returns>
|
|
|
- //[HttpPost("getknowledgeinfo")]
|
|
|
- //[AllowAnonymous]
|
|
|
- //public async Task<KnowledgeInfoDto> GetKnowledgeInfo([FromBody] QueryKnowledgeInfo dto)
|
|
|
- //{
|
|
|
- // var data = await _knowledgeRepository.GetAsync(p => p.Id == dto.Id, HttpContext.RequestAborted);
|
|
|
- // KnowledgeInfoDto detailsDto = null;
|
|
|
- // if (data != null)
|
|
|
- // {
|
|
|
- // detailsDto = _mapper.Map<KnowledgeInfoDto>(data);
|
|
|
-
|
|
|
- // if (detailsDto != null && !string.IsNullOrEmpty(detailsDto.Content))
|
|
|
- // data.Content = _bulletinApplication.GetSiteUrls(data.Content);
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- // detailsDto = new();
|
|
|
- // }
|
|
|
- // return detailsDto;
|
|
|
- //}
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 知识库查询
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 知识库查询
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("getknowledgelist")]
|
|
|
+ public async Task<PagedDto<KnowledgeInfoThirdDto>> GetKnowledgeList([FromBody] QueryKnowledgeList dto)
|
|
|
+ {
|
|
|
+ var typeSpliceName = string.Empty;
|
|
|
+ if (!string.IsNullOrEmpty(dto.KnowledgeTypeId))
|
|
|
+ {
|
|
|
+ var type = await _knowledgeTypeRepository.GetAsync(x => x.Name == dto.KnowledgeTypeId);
|
|
|
+ typeSpliceName = type?.SpliceName;
|
|
|
+ }
|
|
|
+
|
|
|
+ var typeSpliceNameTags = string.Empty;
|
|
|
+ if (!string.IsNullOrEmpty(dto.KnowledgeBaseTags))
|
|
|
+ {
|
|
|
+ var type = await _knowledgeWordRepository.GetAsync(x => x.Tag == dto.KnowledgeBaseTags && x.IsEnable == 1);
|
|
|
+ typeSpliceNameTags = type?.Id;
|
|
|
+ }
|
|
|
+
|
|
|
+ var (total, items) = await _knowledgeRepository.Queryable()
|
|
|
+ .Where(p => p.IsPublic == true && p.Status == EKnowledgeStatus.OnShelf)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.Title), p => p.Title.Contains(dto.Title))
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(typeSpliceNameTags), p => SqlFunc.JsonArrayAny(p.Keywords, typeSpliceNameTags) == true)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(typeSpliceName), x => x.KnowledgeType.Any(t => t.KnowledgeTypeSpliceName.EndsWith(typeSpliceName)))
|
|
|
+ .OrderByDescending(p => p.CreationTime)
|
|
|
+ .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted);
|
|
|
+
|
|
|
+ var data = new PagedDto<KnowledgeInfoThirdDto>(total, _mapper.Map<IReadOnlyList<KnowledgeInfoThirdDto>>(items));
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 知识库详情
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 知识库详情
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("getknowledgeinfo")]
|
|
|
+ public async Task<KnowledgeInfoThirdDto> GetKnowledgeInfo([FromBody] QueryKnowledgeInfo dto)
|
|
|
+ {
|
|
|
+ var data = await _knowledgeRepository.GetAsync(p => p.Id == dto.Id, HttpContext.RequestAborted);
|
|
|
+ KnowledgeInfoThirdDto detailsDto = null;
|
|
|
+ if (data != null)
|
|
|
+ {
|
|
|
+ detailsDto = _mapper.Map<KnowledgeInfoThirdDto>(data);
|
|
|
+
|
|
|
+ if (detailsDto != null && !string.IsNullOrEmpty(detailsDto.Content))
|
|
|
+ data.Content = _bulletinApplication.GetSiteUrls(data.Content);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ detailsDto = new();
|
|
|
+ }
|
|
|
+ return detailsDto;
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
|
|
|
#endregion
|
|
|
|
|
@@ -558,7 +573,6 @@ namespace Hotline.Api.Controllers
|
|
|
/// </summary>
|
|
|
/// <param name="dto"></param>
|
|
|
/// <returns></returns>
|
|
|
- [AllowAnonymous]
|
|
|
[HttpPost("orderacceptance")]
|
|
|
public async Task<OpenResponse> OrderAcceptance([FromBody] WebFlowAcceptDto dto)
|
|
|
{
|
|
@@ -566,6 +580,12 @@ namespace Hotline.Api.Controllers
|
|
|
if (!string.IsNullOrEmpty(dto.Mobile))
|
|
|
dto.Mobile = dto.Mobile.Trim();
|
|
|
|
|
|
+ string strResult = dto.ValidateObject();
|
|
|
+ if (!string.IsNullOrEmpty(strResult))
|
|
|
+ {
|
|
|
+ return OpenResponse.Ok(WebPortalDeResponse<OrderAcceptanceReturnDto>.Failed("数据验证不通过!"));
|
|
|
+ }
|
|
|
+
|
|
|
var data = _mapper.Map<Hotline.Share.Dtos.Order.AddOrderDto>(dto);
|
|
|
data.Source = ESource.WebPortal;
|
|
|
data.SourceChannel = "因特网";
|
|
@@ -630,7 +650,50 @@ namespace Hotline.Api.Controllers
|
|
|
|
|
|
#region 附件上传
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 附件上传
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("uploadfiles")]
|
|
|
+ public async Task<GetResultDto> uploadfiles(IFormFile fileData)
|
|
|
+ {
|
|
|
+ if (fileData == null || fileData.Length == 0)
|
|
|
+ {
|
|
|
+ return new GetResultDto();
|
|
|
+ }
|
|
|
+
|
|
|
+ Stream stream = fileData.OpenReadStream();
|
|
|
+ byte[] fileContentBytes = StreamToBytes(stream);
|
|
|
+ var client = _httpClientFactory.CreateClient("fileData");
|
|
|
+
|
|
|
+ using (var content = new MultipartFormDataContent())
|
|
|
+ {
|
|
|
+ var fileContent = new ByteArrayContent(fileContentBytes);
|
|
|
+ fileContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data")
|
|
|
+ {
|
|
|
+ Name = fileData.Name,
|
|
|
+ FileName = fileData.FileName
|
|
|
+ };
|
|
|
+ content.Add(fileContent, "fileData", fileData.FileName);
|
|
|
|
|
|
+ var response = await client.PostAsync($"{_appOptions.Value.FileUpload.Url.TrimEnd('/')}/file/upload?source=HotlineWeb", content);
|
|
|
+ if (response.IsSuccessStatusCode)
|
|
|
+ {
|
|
|
+ var result = await response.Content.ReadFromJsonAsync<GetFileDto>();
|
|
|
+ return new GetResultDto()
|
|
|
+ {
|
|
|
+ id = result.result.id,
|
|
|
+ fileName = result.result.fileName,
|
|
|
+ path = result.result.path,
|
|
|
+ };
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return new GetResultDto();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
#endregion
|
|
|
|
|
@@ -641,7 +704,6 @@ namespace Hotline.Api.Controllers
|
|
|
/// </summary>
|
|
|
/// <param name="dto"></param>
|
|
|
/// <returns></returns>
|
|
|
- [AllowAnonymous]
|
|
|
[HttpPost("getorderdetailbyno")]
|
|
|
public async Task<OrderDetail> GetOrderDetailByNo([FromBody] GetOrderCodePwd dto)
|
|
|
{
|
|
@@ -692,6 +754,24 @@ namespace Hotline.Api.Controllers
|
|
|
}
|
|
|
|
|
|
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 私有方法
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 将文件转化为文件流
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="stream"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private byte[] StreamToBytes(Stream stream)
|
|
|
+ {
|
|
|
+ byte[] bytes = new byte[stream.Length];
|
|
|
+ stream.Read(bytes, 0, bytes.Length);
|
|
|
+ // 设置当前流的位置为流的开始
|
|
|
+ stream.Seek(0, SeekOrigin.Begin);
|
|
|
+ return bytes;
|
|
|
+ }
|
|
|
+
|
|
|
#endregion
|
|
|
}
|
|
|
}
|