|
@@ -12,7 +12,6 @@ using GxPress.Entity;
|
|
|
using GxPress.EnumConst;
|
|
|
using GxPress.Repository.Interface;
|
|
|
using GxPress.Request.Analyze;
|
|
|
-using GxPress.Request.App.Middle;
|
|
|
using GxPress.Request.Notice;
|
|
|
using GxPress.Result;
|
|
|
using GxPress.Result.Notice;
|
|
@@ -22,6 +21,7 @@ using GxPress.Service.Interface.Notice;
|
|
|
using GxPress.Service.Interface.Visit;
|
|
|
using Newtonsoft.Json;
|
|
|
using GxPress.Service.Interface.UserMiddle;
|
|
|
+using GxPress.Service.Interface.ContentJson;
|
|
|
|
|
|
namespace GxPress.Service.Implement.Notice
|
|
|
{
|
|
@@ -29,8 +29,8 @@ namespace GxPress.Service.Implement.Notice
|
|
|
{
|
|
|
private readonly IUserRepository _userRepository;
|
|
|
private readonly INoticeRepository _noticeRepository;
|
|
|
- private readonly INoticeCcRepository _noticeCcRepository;
|
|
|
- private readonly INoticeAddresseeRepository _noticeAddresseeRepository;
|
|
|
+ private readonly ICcRepository _ccRepository;
|
|
|
+ private readonly IAddresseeRepository _addresseeRepository;
|
|
|
private readonly IDepartmentRepository _departmentRepository;
|
|
|
private readonly IMiddleService _middleService;
|
|
|
private readonly IMiddleRepository _middleRepository;
|
|
@@ -39,15 +39,16 @@ namespace GxPress.Service.Implement.Notice
|
|
|
private readonly IVisitService _visitService;
|
|
|
private readonly ICommentRepository _commentRepository;
|
|
|
private readonly IUserMiddleService _userMiddleService;
|
|
|
+ private readonly IContentJsonService _contentJsonService;
|
|
|
public NoticeService(IUserRepository userRepository, IMapper mapper, INoticeRepository noticeRepository,
|
|
|
- INoticeCcRepository noticeCcRepository, INoticeAddresseeRepository noticeAddresseeRepository,
|
|
|
+ ICcRepository ccRepository, IAddresseeRepository addresseeRepository,
|
|
|
IDepartmentRepository departmentRepository, IMiddleService middleService,
|
|
|
- IMiddleRepository middleRepository, IAnalyzeService analyzeService, ICommentRepository commentRepository, IVisitService visitService, IUserMiddleService userMiddleService)
|
|
|
+ IMiddleRepository middleRepository, IAnalyzeService analyzeService, ICommentRepository commentRepository, IVisitService visitService, IUserMiddleService userMiddleService, IContentJsonService contentJsonService)
|
|
|
{
|
|
|
_noticeRepository = noticeRepository;
|
|
|
_userRepository = userRepository;
|
|
|
- _noticeAddresseeRepository = noticeAddresseeRepository;
|
|
|
- _noticeCcRepository = noticeCcRepository;
|
|
|
+ _addresseeRepository = addresseeRepository;
|
|
|
+ _ccRepository = ccRepository;
|
|
|
_departmentRepository = departmentRepository;
|
|
|
_mapper = mapper;
|
|
|
_middleService = middleService;
|
|
@@ -56,6 +57,7 @@ namespace GxPress.Service.Implement.Notice
|
|
|
_commentRepository = commentRepository;
|
|
|
_visitService = visitService;
|
|
|
_userMiddleService = userMiddleService;
|
|
|
+ _contentJsonService = contentJsonService;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取通知的点赞列表
|
|
@@ -82,21 +84,21 @@ namespace GxPress.Service.Implement.Notice
|
|
|
//获取用户
|
|
|
var user = await _userRepository.GetAsync(result.UserId);
|
|
|
result.UserName = user.Name;
|
|
|
- result.AllCount = await _noticeAddresseeRepository.CountAsync(Q.Where(nameof(NoticeAddressee.NoticeId), id));
|
|
|
- result.ReadCount = await _noticeAddresseeRepository.CountAsync(Q.Where(nameof(NoticeAddressee.NoticeId), id).Where(nameof(NoticeAddressee.IsRead), true));
|
|
|
+ result.AllCount = await _addresseeRepository.CountAsync(Q.Where(nameof(Addressee.SourceId), id));
|
|
|
+ result.ReadCount = await _addresseeRepository.CountAsync(Q.Where(nameof(Addressee.SourceId), id).Where(nameof(Addressee.IsRead), true));
|
|
|
//获取收件人
|
|
|
var noticeAddresseeList =
|
|
|
- await _noticeAddresseeRepository.GetUserByNoticeIdAsync(id);
|
|
|
+ await _addresseeRepository.GetUserByNoticeIdAsync(id);
|
|
|
result.NoticeAddresseeNames = noticeAddresseeList.Select(n => n.Name).ToList();
|
|
|
- var IsRead = await _noticeAddresseeRepository.ExistsAsync(Q.Where(nameof(Entity.Middle.Middle.IsRead), true)
|
|
|
- .Where(nameof(NoticeAddressee.NoticeId), id)
|
|
|
- .Where(nameof(NoticeAddressee.UserId), userId));
|
|
|
+ var IsRead = await _addresseeRepository.ExistsAsync(Q.Where(nameof(Entity.Middle.Middle.IsRead), true)
|
|
|
+ .Where(nameof(Addressee.SourceId), id)
|
|
|
+ .Where(nameof(Addressee.UserId), userId));
|
|
|
//修改阅读量
|
|
|
if (IsRead == false)
|
|
|
{
|
|
|
- if (await _noticeAddresseeRepository.UpdateAsync(Q.Set(nameof(Entity.Middle.Middle.IsRead), true)
|
|
|
- .Where(nameof(NoticeAddressee.NoticeId), id)
|
|
|
- .Where(nameof(NoticeAddressee.UserId), userId)))
|
|
|
+ if (await _addresseeRepository.UpdateAsync(Q.Set(nameof(Entity.Middle.Middle.IsRead), true)
|
|
|
+ .Where(nameof(Addressee.SourceId), id)
|
|
|
+ .Where(nameof(Addressee.UserId), userId)))
|
|
|
result.ReadCount++;
|
|
|
}
|
|
|
//修改访问量
|
|
@@ -147,9 +149,9 @@ namespace GxPress.Service.Implement.Notice
|
|
|
var notice = await _noticeRepository.GetAsync(id);
|
|
|
var result = _mapper.Map<NoticeEditDetailResult>(notice);
|
|
|
//抄送人
|
|
|
- var noticeCcList = await _noticeCcRepository.GetNoticeCcByNoticeIdAsync(id);
|
|
|
+ var noticeCcList = await _ccRepository.GetNoticeCcByNoticeIdAsync(id, GxPress.EnumConst.FolderTypeConst.Notice.GetHashCode());
|
|
|
//收件人
|
|
|
- var noticeAddressee = await _noticeAddresseeRepository.GetNoticeAddresseeByNoticeIdAsync(id);
|
|
|
+ var noticeAddressee = await _addresseeRepository.GetNoticeAddresseeByNoticeIdAsync(id);
|
|
|
//获取新版
|
|
|
result.AddresseeUserMiddles = await _userMiddleService.FindUserMiddlesAsync(10, id);
|
|
|
result.CcUserMiddles = await _userMiddleService.FindUserMiddlesAsync(20, id);
|
|
@@ -200,18 +202,18 @@ namespace GxPress.Service.Implement.Notice
|
|
|
var user = await _userRepository.GetAsync(result.UserId);
|
|
|
result.UserName = user.Name;
|
|
|
result.AllCount =
|
|
|
- await _noticeAddresseeRepository.CountAsync(Q.Where(nameof(NoticeAddressee.NoticeId), id));
|
|
|
- result.ReadCount = await _noticeAddresseeRepository.CountAsync(Q
|
|
|
- .Where(nameof(NoticeAddressee.NoticeId), id).Where(nameof(NoticeAddressee.IsRead), true));
|
|
|
+ await _addresseeRepository.CountAsync(Q.Where(nameof(Addressee.SourceId), id));
|
|
|
+ result.ReadCount = await _addresseeRepository.CountAsync(Q
|
|
|
+ .Where(nameof(Addressee.SourceId), id).Where(nameof(Addressee.IsRead), true));
|
|
|
//获取收件人
|
|
|
var noticeAddresseeList =
|
|
|
- await _noticeAddresseeRepository.GetAllAsync(Q.Where(nameof(NoticeAddressee.NoticeId), id)
|
|
|
+ await _addresseeRepository.GetAllAsync(Q.Where(nameof(Addressee.SourceId), id)
|
|
|
.Where(nameof(Entity.Middle.Middle.IsAdmin), false));
|
|
|
result.NoticeAddresseeNames = noticeAddresseeList.Select(n => n.UserName).ToList();
|
|
|
//修改阅读量
|
|
|
- await _noticeAddresseeRepository.UpdateAsync(Q.Set(nameof(Entity.Middle.Middle.IsRead), true)
|
|
|
- .Where(nameof(NoticeAddressee.NoticeId), id)
|
|
|
- .Where(nameof(NoticeAddressee.UserId), userId));
|
|
|
+ await _addresseeRepository.UpdateAsync(Q.Set(nameof(Entity.Middle.Middle.IsRead), true)
|
|
|
+ .Where(nameof(Addressee.SourceId), id)
|
|
|
+ .Where(nameof(Addressee.UserId), userId));
|
|
|
//修改middle的阅读
|
|
|
await _middleRepository.UpdateAsync(Q.Set(nameof(Entity.Middle.Middle.IsRead), true).Where(nameof(Entity.Middle.Middle.UserId), userId).Where(nameof(Entity.Middle.Middle.MiddleId), id).Where(nameof(Entity.Middle.Middle.FolderType), 1));
|
|
|
var analyzeRequest = new Request.App.Analyze.AnalyzeRequest();
|
|
@@ -276,7 +278,7 @@ namespace GxPress.Service.Implement.Notice
|
|
|
//删除
|
|
|
await _noticeRepository.DeleteAsync(Q.Where(nameof(Entity.Notice.Id), notice.Id));
|
|
|
//删除middle
|
|
|
- await _middleRepository.DeleteAsync(Q.Where(nameof(Entity.Middle.Middle.MiddleId), notice.Id).Where(nameof(Entity.Middle.Middle.FolderType), 1));
|
|
|
+ await _middleRepository.DeleteAsync(notice.Id, GxPress.EnumConst.FolderTypeConst.Notice.GetHashCode());
|
|
|
if (notice.SourceId > 0)
|
|
|
{
|
|
|
var noticeSource = await _noticeRepository.GetAsync(notice.SourceId);
|
|
@@ -313,124 +315,7 @@ namespace GxPress.Service.Implement.Notice
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
- /// <summary>
|
|
|
- /// 发送通知
|
|
|
- /// </summary>
|
|
|
- /// <param name="request"></param>
|
|
|
- /// <returns></returns>
|
|
|
- public async Task<bool> SendNoticeAsync(NoticeUpRequest request)
|
|
|
- {
|
|
|
- if (request.AddresseeUserMiddles.Count > 0)
|
|
|
- {
|
|
|
- await _userMiddleService.DeleteAsync(Q.Where(nameof(Entity.UserMiddle.UserMiddle.MiddleType), 10).Where(nameof(Entity.UserMiddle.UserMiddle.DataSourceId), request.Id));
|
|
|
- foreach (var item in request.AddresseeUserMiddles)
|
|
|
- {
|
|
|
- item.DataSourceId = request.Id;
|
|
|
- item.MiddleType = 10;
|
|
|
- }
|
|
|
- await _userMiddleService.AddUserMiddleAsync(request.AddresseeUserMiddles);
|
|
|
- var users = await _userMiddleService.FindUsersAsync(request.AddresseeUserMiddles, request.UserId);
|
|
|
- request.NoticeAddresseeUserIds = users.Select(n => n.Id).ToList();
|
|
|
- request.NoticeAddresseeUserIds.Remove(request.UserId);
|
|
|
- }
|
|
|
- if (request.CcUserMiddles.Count > 0)
|
|
|
- {
|
|
|
- await _userMiddleService.DeleteAsync(Q.Where(nameof(Entity.UserMiddle.UserMiddle.MiddleType), 20).Where(nameof(Entity.UserMiddle.UserMiddle.DataSourceId), request.Id));
|
|
|
- foreach (var item in request.CcUserMiddles)
|
|
|
- {
|
|
|
- item.DataSourceId = request.Id;
|
|
|
- item.MiddleType = 20;
|
|
|
- }
|
|
|
- await _userMiddleService.AddUserMiddleAsync(request.CcUserMiddles);
|
|
|
- var users = await _userMiddleService.FindUsersAsync(request.CcUserMiddles, request.UserId);
|
|
|
- request.NoticeCcUserIds = users.Select(n => n.Id).ToList();
|
|
|
- request.NoticeCcUserIds.Remove(request.UserId);
|
|
|
- }
|
|
|
- if (request.NoticeAddresseeUserIds.Count > 0)
|
|
|
- {
|
|
|
- //删除接收人
|
|
|
- await _noticeAddresseeRepository.DeleteAsync(request.Id);
|
|
|
- //删除middle
|
|
|
- await _middleRepository.DeleteAsync(Q.Where(nameof(Entity.Middle.Middle.MiddleId), request.Id).Where(nameof(Entity.Middle.Middle.FolderType), 1));
|
|
|
- if (request.NoticeType == NoticeTypeConst.Send)
|
|
|
- {
|
|
|
- var userEntity = await _userRepository.GetAsync(request.UserId);
|
|
|
- //创建人
|
|
|
- var noticeAddresseeEntity = new NoticeAddressee
|
|
|
- {
|
|
|
- NoticeId = request.Id,
|
|
|
- UserId = request.UserId,
|
|
|
- UserName = userEntity.Name,
|
|
|
- IsAdmin = true,
|
|
|
- NoticeAddresseeType = request.NoticeType,
|
|
|
- IsTop = false
|
|
|
- };
|
|
|
- var noticeAddresseeId = await _noticeAddresseeRepository.InsertAsync(noticeAddresseeEntity);
|
|
|
- //添加文件
|
|
|
- var middleInsertTypes = new MiddleInsertTypeRequest
|
|
|
- {
|
|
|
- FolderId = 0,
|
|
|
- MiddleId = request.Id,
|
|
|
- FolderType = 1,
|
|
|
- UserId = request.UserId,
|
|
|
- MiddleSonId = noticeAddresseeId,
|
|
|
- NoticeAddresseeType = request.NoticeType,
|
|
|
- AttributeValue = 1,
|
|
|
- IsAdmin = true
|
|
|
- };
|
|
|
- await _middleService.InsertAsync(middleInsertTypes);
|
|
|
- }
|
|
|
- //收件人
|
|
|
- foreach (var noticeAddresseeUserId in request.NoticeAddresseeUserIds)
|
|
|
- {
|
|
|
- var user = await _userRepository.GetAsync(noticeAddresseeUserId);
|
|
|
- if (user.Id == request.UserId)
|
|
|
- continue;
|
|
|
- var noticeAddressee = new NoticeAddressee
|
|
|
- {
|
|
|
- NoticeId = request.Id,
|
|
|
- UserId = noticeAddresseeUserId,
|
|
|
- UserName = user.Name,
|
|
|
- NoticeAddresseeType = request.NoticeType
|
|
|
- };
|
|
|
- var noticeAddresseeId = await _noticeAddresseeRepository.InsertAsync(noticeAddressee);
|
|
|
- if (request.NoticeType == NoticeTypeConst.Send)
|
|
|
- {
|
|
|
- //添加文件
|
|
|
- var middleInsertType = new MiddleInsertTypeRequest
|
|
|
- {
|
|
|
- FolderId = 0,
|
|
|
- MiddleId = request.Id,
|
|
|
- FolderType = 1,
|
|
|
- UserId = noticeAddresseeUserId,
|
|
|
- MiddleSonId = noticeAddresseeId,
|
|
|
- AttributeValue = 1
|
|
|
- };
|
|
|
- await _middleService.InsertAsync(middleInsertType);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (request.NoticeCcUserIds.Count > 0)
|
|
|
- {
|
|
|
- //删除抄送人
|
|
|
- await _noticeCcRepository.DeleteAsync(request.Id);
|
|
|
- //创建
|
|
|
- //抄送
|
|
|
- foreach (var noticeCcUserId in request.NoticeCcUserIds)
|
|
|
- {
|
|
|
- var user = await _userRepository.GetAsync(noticeCcUserId);
|
|
|
- var noticeCc = new NoticeCc
|
|
|
- {
|
|
|
- UserId = noticeCcUserId,
|
|
|
- NoticeId = request.Id,
|
|
|
- UserName = user.Name,
|
|
|
- NoticeCcType = request.NoticeType
|
|
|
- };
|
|
|
- await _noticeCcRepository.InsertAsync(noticeCc);
|
|
|
- }
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 根据已读未读查询通知数据
|
|
|
/// </summary>
|
|
@@ -438,7 +323,7 @@ namespace GxPress.Service.Implement.Notice
|
|
|
/// <returns></returns>
|
|
|
public async Task<IEnumerable<NoticeReadListResult>> NoticeReadListAsync(NoticeReadListRequest request)
|
|
|
{
|
|
|
- var noticeReadListResults = await _noticeAddresseeRepository.GetNoticeAddresseeByUserIdIdAsync(request);
|
|
|
+ var noticeReadListResults = await _addresseeRepository.GetNoticeAddresseeByUserIdIdAsync(request);
|
|
|
return noticeReadListResults;
|
|
|
}
|
|
|
|
|
@@ -452,59 +337,7 @@ namespace GxPress.Service.Implement.Notice
|
|
|
var result = await _noticeRepository.GetNoticeListPageAsync(request);
|
|
|
foreach (var item in result.Items)
|
|
|
{
|
|
|
- // var userMiddles = await _userMiddleService.FindUserMiddlesAsync(10, item.MiddleId);
|
|
|
- // item.EnjoyUser = StringUtils.ObjectCollectionToString(userMiddles.Select(n => n.SourceName).ToList(), "、");
|
|
|
- //分析title
|
|
|
- if (string.IsNullOrWhiteSpace(item.Title))
|
|
|
- {
|
|
|
- var data = JsonConvert.DeserializeObject<List<ContentJsonData>>(item.Content);
|
|
|
- if (data.Count > 0)
|
|
|
- {
|
|
|
- var first = data.First();
|
|
|
- if (first.TypeValue == OldTextEditorTypeConst.Text.GetHashCode() && !string.IsNullOrWhiteSpace(first.Text))
|
|
|
- item.Title = first.Text;
|
|
|
- else
|
|
|
- {
|
|
|
- foreach (var contentJsonData in data)
|
|
|
- {
|
|
|
- //是否是文本
|
|
|
- if (contentJsonData.TypeValue == OldTextEditorTypeConst.Text.GetHashCode())
|
|
|
- continue;
|
|
|
- else if (contentJsonData.TypeValue == OldTextEditorTypeConst.Image.GetHashCode())
|
|
|
- {
|
|
|
- item.Title = "[图片]";
|
|
|
- break;
|
|
|
- }
|
|
|
- else if (contentJsonData.TypeValue == OldTextEditorTypeConst.File.GetHashCode())
|
|
|
- {
|
|
|
- item.Title = "[附件]";
|
|
|
- break;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- item.Title = "[附件]";
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- // //图片 文件类型
|
|
|
- // var typeList = new List<int> { OldTextEditorTypeConst.Image.GetHashCode(), OldTextEditorTypeConst.File.GetHashCode() };
|
|
|
- // if (data.Any(n => (n.TypeValue == OldTextEditorTypeConst.Image.GetHashCode() && n.TypeValue == OldTextEditorTypeConst.File.GetHashCode())))
|
|
|
- // item.Title = "[图片][附件]";
|
|
|
- // else
|
|
|
- // {
|
|
|
- // if (data.Any(n => n.TypeValue == OldTextEditorTypeConst.Image.GetHashCode()))
|
|
|
- // item.Title = "[图片]";
|
|
|
- // else if (data.Any(n => n.TypeValue == OldTextEditorTypeConst.File.GetHashCode()))
|
|
|
- // item.Title = "[附件]";
|
|
|
- // else
|
|
|
- // {
|
|
|
- // if (data.Any(n => !typeList.Contains(n.TypeValue)))
|
|
|
- // item.Title = "[附件]";
|
|
|
- // }
|
|
|
- // }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ item.Title = _contentJsonService.GetTitile(item.Title, item.Content);
|
|
|
if (item.IsDelete == true)
|
|
|
item.NoticeStatus = 0;
|
|
|
else if (item.NoticeAddresseeType == NoticeTypeConst.Draft)
|
|
@@ -527,9 +360,9 @@ namespace GxPress.Service.Implement.Notice
|
|
|
using (TransactionScope transactionScope = new TransactionScope())
|
|
|
{
|
|
|
//删除middle
|
|
|
- await _middleRepository.DeleteAsync(Q.Where(nameof(Entity.Middle.Middle.MiddleId), id).Where(nameof(Entity.Middle.Middle.FolderType), 1).Where(nameof(Entity.Middle.Middle.IsAdmin), false));
|
|
|
+ await _middleRepository.DeleteAsync(Q.Where(nameof(Entity.Middle.Middle.MiddleId), id).Where(nameof(Entity.Middle.Middle.FolderType),GxPress.EnumConst.FolderTypeConst.Notice.GetHashCode()).Where(nameof(Entity.Middle.Middle.IsAdmin), false));
|
|
|
//修改为草稿箱
|
|
|
- await _middleRepository.UpdateAsync(Q.Where(nameof(Entity.Middle.Middle.MiddleId), id).Where(nameof(Entity.Middle.Middle.FolderType), 1).Where(nameof(Entity.Middle.Middle.IsAdmin), true).Set(nameof(Entity.Middle.Middle.NoticeAddresseeType), 2));
|
|
|
+ await _middleRepository.UpdateAsync(Q.Where(nameof(Entity.Middle.Middle.MiddleId), id).Where(nameof(Entity.Middle.Middle.FolderType), GxPress.EnumConst.FolderTypeConst.Notice.GetHashCode()).Where(nameof(Entity.Middle.Middle.IsAdmin), true).Set(nameof(Entity.Middle.Middle.NoticeAddresseeType), 2));
|
|
|
//修改
|
|
|
await _noticeRepository.UpdateAsync(Q.Where(nameof(Entity.Notice.Id), id).Set(nameof(Entity.Notice.NoticeType), NoticeTypeConst.Draft.GetHashCode()));
|
|
|
transactionScope.Complete();
|