|
@@ -8,6 +8,7 @@ using Hotline.KnowledgeBase;
|
|
|
using Hotline.Orders;
|
|
|
using Hotline.Push.Notifies;
|
|
|
using Hotline.Repository.SqlSugar.Extensions;
|
|
|
+using Hotline.Repository.SqlSugar.Knowledge;
|
|
|
using Hotline.Settings;
|
|
|
using Hotline.Settings.Hotspots;
|
|
|
using Hotline.Share.Dtos;
|
|
@@ -25,6 +26,7 @@ using MediatR;
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
using Microsoft.Extensions.Options;
|
|
|
+using Senparc.Weixin.WxOpen.AdvancedAPIs.WxApp.WxAppJson;
|
|
|
using SqlSugar;
|
|
|
using XF.Domain.Authentications;
|
|
|
using XF.Domain.Cache;
|
|
@@ -398,6 +400,366 @@ namespace Hotline.Api.Controllers
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
+ #region 通知-宜宾
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 获取列表
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ [AllowAnonymous]
|
|
|
+ [HttpPost("getarticlelist_yibin")]
|
|
|
+ public async Task<OpenResponse> GetArticleListYiBin([FromBody] QueryArticleListDto dto)
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(dto.PushRanges))
|
|
|
+ dto.PushRanges = "2";
|
|
|
+
|
|
|
+ RefAsync<int> total = 0;
|
|
|
+ var items1 = _bulletinRepository.Queryable()
|
|
|
+ .Where(p => p.LoseEfficacyTime >= DateTime.Now)
|
|
|
+ .Where(p => p.IsArrive == true)
|
|
|
+ .Where(p => SqlFunc.JsonListObjectAny(p.PushRanges, "Key", dto.PushRanges))
|
|
|
+ .Where(p => p.BulletinTypeId == dto.NoticeType)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.Condition), p => p.Title.Contains(dto.Condition))
|
|
|
+ .Select(it => new ArticleListDto
|
|
|
+ {
|
|
|
+ Page = 0,
|
|
|
+ NoticeID = it.Id,
|
|
|
+ //NoticeContent = it.Content,
|
|
|
+ NoticeTypeName = it.BulletinTypeName,
|
|
|
+ NoticeTitle = it.Title,
|
|
|
+ NoticeBMName = it.SourceOrgName,
|
|
|
+ NoticeCreateDate = it.CreationTime,
|
|
|
+ VideoUrl = "",
|
|
|
+ WNLT_FullCode = ""
|
|
|
+ });
|
|
|
+
|
|
|
+ List<ArticleListDto> items = new List<ArticleListDto>();
|
|
|
+ if (dto.NoticeType == "6")
|
|
|
+ {
|
|
|
+ //知识库
|
|
|
+ var items2 = _knowledgeRepository.Queryable()
|
|
|
+ .Where(k => k.IsPublic == true)
|
|
|
+ .Where(k => k.Status == EKnowledgeStatus.OnShelf)
|
|
|
+ .Where(k => k.Attribution == "部门知识库")
|
|
|
+ .Select(it => new ArticleListDto
|
|
|
+ {
|
|
|
+ Page = 0,
|
|
|
+ NoticeID = it.Id,
|
|
|
+ //NoticeContent = it.Content,
|
|
|
+ NoticeTypeName = "知识库",
|
|
|
+ NoticeTitle = it.Title,
|
|
|
+ NoticeBMName = it.CreatorOrgName,
|
|
|
+ NoticeCreateDate = it.CreationTime,
|
|
|
+ VideoUrl = "",
|
|
|
+ WNLT_FullCode = ""
|
|
|
+ });
|
|
|
+
|
|
|
+ items = await _orderRepository.UnionAll(items1, items2)
|
|
|
+ .Select(x => new ArticleListDto
|
|
|
+ {
|
|
|
+ Page = SqlFunc.RowNumber($"{x.NoticeCreateDate} desc "),
|
|
|
+ NoticeID = x.NoticeID,
|
|
|
+ //NoticeContent = x.NoticeContent,
|
|
|
+ NoticeTypeName = x.NoticeTypeName,
|
|
|
+ NoticeTitle = x.NoticeTitle,
|
|
|
+ NoticeBMName = x.NoticeBMName,
|
|
|
+ NoticeCreateDate = x.NoticeCreateDate,
|
|
|
+ VideoUrl = x.VideoUrl,
|
|
|
+ WNLT_FullCode = x.WNLT_FullCode
|
|
|
+ })
|
|
|
+ .OrderByDescending(p => p.NoticeCreateDate)
|
|
|
+ .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ items = await items1
|
|
|
+ .OrderByDescending(p => p.NoticeCreateDate)
|
|
|
+ .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //计算总页数
|
|
|
+ int nPageCount = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(total) / dto.PageSize));
|
|
|
+ ArticleListDataDto dataDto = new()
|
|
|
+ {
|
|
|
+ PageCount = nPageCount,
|
|
|
+ Total = total,
|
|
|
+ data = _mapper.Map<IReadOnlyList<ArticleListDto>>(items)
|
|
|
+ };
|
|
|
+
|
|
|
+ return OpenResponse.Ok(WebPortalDeResponse<ArticleListDataDto>.Success(dataDto));
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 获取详情,修改阅读次数
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [AllowAnonymous]
|
|
|
+ [HttpPost("getarticledetails_yibin")]
|
|
|
+ public async Task<OpenResponse> GetArticleDetailsYiBin([FromBody] ArticleIdDto dto)
|
|
|
+ {
|
|
|
+ ArticleDetailsDto detailsDto = null;
|
|
|
+ if (dto.TypeName == "知识库")
|
|
|
+ {
|
|
|
+ var data = await _knowledgeRepository.GetAsync(p => p.Id == dto.Id, HttpContext.RequestAborted);
|
|
|
+ if (data != null)
|
|
|
+ {
|
|
|
+ data.PageView = data.PageView++;
|
|
|
+ await _knowledgeRepository.UpdateAsync(data, HttpContext.RequestAborted);
|
|
|
+ detailsDto = new()
|
|
|
+ {
|
|
|
+ NoticeID = data.Id,
|
|
|
+ NoticeTypeName = "知识库",
|
|
|
+ NoticeTitle = data.Title,
|
|
|
+ NoticeBMName = data.CreatorOrgName,
|
|
|
+ NoticeCreateDate = data.CreationTime,
|
|
|
+ NoticeRCount = data.PageView,
|
|
|
+ WNED_VideoUrl = "",
|
|
|
+ NoticeContent = data.Content
|
|
|
+ };
|
|
|
+ if (data != null && !string.IsNullOrEmpty(data.Content))
|
|
|
+ data.Content = _bulletinApplication.GetSiteUrls(data.Content);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ detailsDto = new();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var data = await _bulletinRepository.GetAsync(p => p.Id == dto.Id, HttpContext.RequestAborted);
|
|
|
+ if (data != null)
|
|
|
+ {
|
|
|
+ data.ReadedNum = data.ReadedNum++;
|
|
|
+ await _bulletinRepository.UpdateAsync(data, HttpContext.RequestAborted);
|
|
|
+ detailsDto = new()
|
|
|
+ {
|
|
|
+ NoticeID = data.Id,
|
|
|
+ NoticeTypeName = data.BulletinTypeName,
|
|
|
+ NoticeTitle = data.Title,
|
|
|
+ NoticeBMName = data.SourceOrgName,
|
|
|
+ NoticeCreateDate = data.CreationTime,
|
|
|
+ NoticeRCount = data.ReadedNum,
|
|
|
+ WNED_VideoUrl = "",
|
|
|
+ NoticeContent = data.Content
|
|
|
+ };
|
|
|
+ if (data != null && !string.IsNullOrEmpty(data.Content))
|
|
|
+ data.Content = _bulletinApplication.GetSiteUrls(data.Content);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ detailsDto = new();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ArticleDetailsDto> dataDto = new() { detailsDto };
|
|
|
+ return OpenResponse.Ok(WebPortalDeResponse<IReadOnlyList<ArticleDetailsDto>>.Success(dataDto));
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 上一条和下一条
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [AllowAnonymous]
|
|
|
+ [HttpPost("getpreviousandnext_yibin")]
|
|
|
+ public async Task<OpenResponse> GetPreviousAndNextYiBin([FromBody] ArticlePreviousAndNextDto dto)
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(dto.PushRanges))
|
|
|
+ dto.PushRanges = "2";
|
|
|
+
|
|
|
+ var sugar = _bulletinRepository.Queryable()
|
|
|
+ .Where(p => p.LoseEfficacyTime >= DateTime.Now)
|
|
|
+ .Where(p => p.IsArrive == true)
|
|
|
+ .Where(p => SqlFunc.JsonListObjectAny(p.PushRanges, "Key", dto.PushRanges));
|
|
|
+
|
|
|
+ if (dto.FullSearch == "1")//全文搜索
|
|
|
+ {
|
|
|
+ if (_appOptions.Value.IsYiBin)
|
|
|
+ {
|
|
|
+ sugar.Where(p => p.BulletinTypeId == "1" || p.BulletinTypeId == "5" || p.BulletinTypeId == "6" || p.BulletinTypeId == "7" || p.BulletinTypeId == "3" || p.BulletinTypeId == "4")
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.Condition), p => p.Content.Contains(dto.Condition) || p.Title.Contains(dto.Condition));
|
|
|
+ }
|
|
|
+ if (_appOptions.Value.IsZiGong)
|
|
|
+ {
|
|
|
+ sugar.Where(p => p.BulletinTypeId == "5013" || p.BulletinTypeId == "5016" || p.BulletinTypeId == "5011" || p.BulletinTypeId == "5015" || p.BulletinTypeId == "5017")
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.Condition), p => p.Content.Contains(dto.Condition) || p.Title.Contains(dto.Condition));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else//指定分类
|
|
|
+ {
|
|
|
+ sugar.WhereIF(!string.IsNullOrEmpty(dto.Condition), p => p.Title.Contains(dto.Condition))
|
|
|
+ .Where(p => p.BulletinTypeId == dto.NoticeTypeId);
|
|
|
+ }
|
|
|
+
|
|
|
+ var items1 = sugar.Select(it => new ArticleDetailDataDto
|
|
|
+ {
|
|
|
+ Page = SqlFunc.RowNumber($"{it.CreationTime} desc "),// SqlFunc.MappingColumn(default(int), " row_number() over( order by 'NoticeCreateDate' ) "),
|
|
|
+ NoticeID = it.Id,
|
|
|
+ NoticeTitle = it.Title,
|
|
|
+ NoticeCreateDate = it.CreationTime
|
|
|
+ });
|
|
|
+
|
|
|
+ List<ArticleDetailDataDto> list = new List<ArticleDetailDataDto>();
|
|
|
+ if (dto.NoticeTypeId == "6")
|
|
|
+ {
|
|
|
+ //知识库
|
|
|
+ var items2 = _knowledgeRepository.Queryable()
|
|
|
+ .Where(k => k.IsPublic == true)
|
|
|
+ .Where(k => k.Status == EKnowledgeStatus.OnShelf)
|
|
|
+ .Where(k => k.Attribution == "部门知识库")
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.Condition), k => k.Content.Contains(dto.Condition) || k.Title.Contains(dto.Condition))
|
|
|
+ .Select(it => new ArticleDetailDataDto
|
|
|
+ {
|
|
|
+ Page = 0,
|
|
|
+ NoticeID = it.Id,
|
|
|
+ NoticeTitle = it.Title,
|
|
|
+ NoticeCreateDate = it.CreationTime
|
|
|
+ });
|
|
|
+
|
|
|
+ list = await _orderRepository.UnionAll(items1, items2)
|
|
|
+ .Select(x => new ArticleDetailDataDto
|
|
|
+ {
|
|
|
+ Page = SqlFunc.RowNumber($"{x.NoticeCreateDate} desc "),
|
|
|
+ NoticeID = x.NoticeID,
|
|
|
+ NoticeTitle = x.NoticeTitle,
|
|
|
+ NoticeCreateDate = x.NoticeCreateDate
|
|
|
+ })
|
|
|
+ .OrderByDescending(x => x.NoticeCreateDate)
|
|
|
+ .ToListAsync();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ list = await items1.OrderByDescending(x => x.NoticeCreateDate).ToListAsync();
|
|
|
+ }
|
|
|
+
|
|
|
+ //数据为空返回空数据
|
|
|
+ if (list == null || list.Count == 0)
|
|
|
+ return OpenResponse.Ok(WebPortalDeResponse<List<ArticlePreviousAndNextDataDto>>.Success(null));
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var temp = list.Find(p => p.NoticeID == dto.ID);
|
|
|
+ if (temp != null)
|
|
|
+ {
|
|
|
+ List<ArticlePreviousAndNextDataDto> returnDto = new();
|
|
|
+ //上一条
|
|
|
+ var pTemp = list.Find(p => p.Page == temp.Page - 1);
|
|
|
+ if (pTemp != null)
|
|
|
+
|
|
|
+ returnDto.Add(new()
|
|
|
+ {
|
|
|
+ NoticeID = pTemp.NoticeID,
|
|
|
+ NoticeTitle = pTemp.NoticeTitle,
|
|
|
+ pntype = "p"
|
|
|
+ });
|
|
|
+
|
|
|
+ //下一条
|
|
|
+ var nTemp = list.Find(p => p.Page == temp.Page + 1);
|
|
|
+ if (nTemp != null)
|
|
|
+ returnDto.Add(new()
|
|
|
+ {
|
|
|
+ NoticeID = nTemp.NoticeID,
|
|
|
+ NoticeTitle = nTemp.NoticeTitle,
|
|
|
+ pntype = "n"
|
|
|
+ });
|
|
|
+ return OpenResponse.Ok(WebPortalDeResponse<List<ArticlePreviousAndNextDataDto>>.Success(returnDto));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ return OpenResponse.Ok(WebPortalDeResponse<List<ArticlePreviousAndNextDataDto>>.Success(null));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 全文检索
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [AllowAnonymous]
|
|
|
+ [HttpPost("getfulltextsearchlist_yibin")]
|
|
|
+ public async Task<OpenResponse> GetFullTextSearchList_YiBin([FromBody] QueryArticleListDto dto)
|
|
|
+ {
|
|
|
+ if (string.IsNullOrEmpty(dto.PushRanges))
|
|
|
+ dto.PushRanges = "2";
|
|
|
+
|
|
|
+ if (string.IsNullOrEmpty(dto.Condition))
|
|
|
+ return OpenResponse.Ok(WebPortalDeResponse<FullTextSearchListDataDto>.Success(null));
|
|
|
+
|
|
|
+ RefAsync<int> total = 0;
|
|
|
+ var items1 = _bulletinRepository.Queryable()
|
|
|
+ .Where(p => p.LoseEfficacyTime >= DateTime.Now)
|
|
|
+ .Where(p => p.IsArrive == true)
|
|
|
+ .Where(p => SqlFunc.JsonListObjectAny(p.PushRanges, "Key", dto.PushRanges))
|
|
|
+ .WhereIF(_appOptions.Value.IsYiBin, p => p.BulletinTypeId == "1" || p.BulletinTypeId == "5" || p.BulletinTypeId == "6" || p.BulletinTypeId == "7" || p.BulletinTypeId == "3" || p.BulletinTypeId == "4")
|
|
|
+ .WhereIF(_appOptions.Value.IsZiGong, p => p.BulletinTypeId == "5013" || p.BulletinTypeId == "5016" || p.BulletinTypeId == "5011" || p.BulletinTypeId == "5015" || p.BulletinTypeId == "5017")
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.Condition), p => p.Title.Contains(dto.Condition))
|
|
|
+ .OrderByDescending(p => p.CreationTime)
|
|
|
+ .Select(it => new FullTextSearchListDto
|
|
|
+ {
|
|
|
+ Page = 0,
|
|
|
+ NoticeID = it.Id,
|
|
|
+ //Content = it.Content,
|
|
|
+ NoticeTypeID = it.BulletinTypeId,
|
|
|
+ NoticeTypeName = it.BulletinTypeName,
|
|
|
+ NoticeTitle = it.Title,
|
|
|
+ NoticeBMName = it.SourceOrgName,
|
|
|
+ NoticeCreateDate = it.CreationTime.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
|
+ TypeCode = ""
|
|
|
+ });
|
|
|
+
|
|
|
+ List<FullTextSearchListDto> items = new List<FullTextSearchListDto>();
|
|
|
+ if (dto.NoticeType == "6")
|
|
|
+ {
|
|
|
+ //知识库
|
|
|
+ var items2 = _knowledgeRepository.Queryable()
|
|
|
+ .Where(k => k.IsPublic == true)
|
|
|
+ .Where(k => k.Status == EKnowledgeStatus.OnShelf)
|
|
|
+ .Where(k => k.Attribution == "部门知识库")
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.Condition), k => k.Content.Contains(dto.Condition) || k.Title.Contains(dto.Condition))
|
|
|
+ .Select(it => new FullTextSearchListDto
|
|
|
+ {
|
|
|
+ Page = 0,
|
|
|
+ NoticeID = it.Id,
|
|
|
+ //NoticeContent = it.Content,
|
|
|
+ NoticeTypeID = "6",
|
|
|
+ NoticeTypeName = "知识库",
|
|
|
+ NoticeTitle = it.Title,
|
|
|
+ NoticeBMName = it.CreatorOrgName,
|
|
|
+ NoticeCreateDate = it.CreationTime.ToString("yyyy-MM-dd HH:mm:ss"),
|
|
|
+ TypeCode = ""
|
|
|
+ });
|
|
|
+
|
|
|
+ items = await _orderRepository.UnionAll(items1, items2)
|
|
|
+ .Select(x => new FullTextSearchListDto
|
|
|
+ {
|
|
|
+ Page = SqlFunc.RowNumber($"{x.NoticeCreateDate} desc "),
|
|
|
+ NoticeID = x.NoticeID,
|
|
|
+ //NoticeContent = it.Content,
|
|
|
+ NoticeTypeID = x.NoticeTypeID,
|
|
|
+ NoticeTypeName = x.NoticeTypeName,
|
|
|
+ NoticeTitle = x.NoticeTitle,
|
|
|
+ NoticeBMName = x.NoticeBMName,
|
|
|
+ NoticeCreateDate = x.NoticeCreateDate,
|
|
|
+ TypeCode = ""
|
|
|
+ })
|
|
|
+ .OrderByDescending(p => p.NoticeCreateDate)
|
|
|
+ .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ items = await items1
|
|
|
+ .OrderByDescending(p => p.NoticeCreateDate)
|
|
|
+ .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
|
|
|
+ }
|
|
|
+
|
|
|
+ //计算总页数
|
|
|
+ int nPageCount = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(total) / dto.PageSize));
|
|
|
+ FullTextSearchListDataDto dataDto = new()
|
|
|
+ {
|
|
|
+ PageCount = nPageCount,
|
|
|
+ data = _mapper.Map<IReadOnlyList<FullTextSearchListDto>>(items)
|
|
|
+ };
|
|
|
+ return OpenResponse.Ok(WebPortalDeResponse<FullTextSearchListDataDto>.Success(dataDto));
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
#region 用户
|
|
|
/// <summary>
|
|
|
/// 添加统一认证用户数据
|