ReplyService.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System.Collections.Generic;
  2. using System.Threading.Tasks;
  3. using GxPress.Request.Reply;
  4. using GxPress.Result.Reply;
  5. using GxPress.Service.Interface.Reply;
  6. using System.Linq;
  7. using GxPress.Repository.Interface.Analyze;
  8. using GxPress.Repository.Interface.Reply;
  9. namespace GxPress.Service.Implement.Reply
  10. {
  11. /// <summary>
  12. /// 回复
  13. /// </summary>
  14. public partial class ReplyService : IReplyService
  15. {
  16. private readonly IAnalyzeRepository analyzeRepository;
  17. private readonly IReplyRepository replyRepository;
  18. public ReplyService(IAnalyzeRepository analyzeRepository, IReplyRepository replyRepository)
  19. {
  20. this.analyzeRepository = analyzeRepository;
  21. this.replyRepository = replyRepository;
  22. }
  23. /// <summary>
  24. /// 获取我收到和我回复的评论
  25. /// </summary>
  26. /// <param name="request"></param>
  27. /// <returns></returns>
  28. public async Task<IEnumerable<ReplyResult>> GetReplyResults(ReplyRequest request)
  29. {
  30. var result = new List<ReplyResult>();
  31. //话题本
  32. result.AddRange(await GetReplyNoteOrTopicResults(request));
  33. //小组话题
  34. result.AddRange(await GetReplyGroupTopicResults(request));
  35. if (request.TypeValue == 0)
  36. result.AddRange(await GetReceiptCommentResult(request));
  37. else
  38. result.AddRange(await GetMyReceiptCommentResult(request));
  39. //站内信 通知
  40. result.AddRange(await GetReplyNoticeTopicResults(request));
  41. var data = result.OrderByDescending(n => n.CreatedDate);
  42. return data;
  43. }
  44. public async Task<IEnumerable<ReplyInfoResult>> GetReplysAsync(ReplyRequest request)
  45. {
  46. var result = await replyRepository.GetReplysAsync(request);
  47. await replyRepository.UpdateReplyUReadCountAsync(request.UserId);
  48. return result;
  49. }
  50. /// <summary>
  51. /// 获取回复我的阅读数量
  52. /// </summary>
  53. /// /// <param name="userId"></param>
  54. /// <returns></returns>
  55. public async Task<int> GetReplyUReadCountAsync(int userId)
  56. {
  57. return await replyRepository.GetReplyUReadCountAsync(userId);
  58. }
  59. }
  60. }