You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

129 lines
4.3 KiB

  1. using System;
  2. using Learun.Application.AppMagager;
  3. using Learun.Util;
  4. using Nancy;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using Learun.Application.Base.SystemModule;
  8. using Learun.Application.TwoDevelopment.LR_Desktop;
  9. using System.Text;
  10. using System.Data;
  11. using Learun.Application.OA;
  12. namespace Learun.Application.WebApi.Modules
  13. {
  14. public class NewsApi : BaseApi
  15. {
  16. private NoticeIBLL noticeIBLL = new NoticeBLL();
  17. LR_OA_NewsReadIBLL lR_OA_NewsReadIBLL=new LR_OA_NewsReadBLL();
  18. public NewsApi()
  19. : base("/learun/news")
  20. {
  21. Get["/list"] = GetList;
  22. Post["/newsRead"] = NewsRead;
  23. }
  24. #region 私有类
  25. private class NoticeEntity
  26. {
  27. public string ProgressId { get; set; }
  28. public string newsId { get; set; }
  29. }
  30. #endregion
  31. /// <summary>
  32. /// 阅读通知公告
  33. /// <summary>
  34. /// <returns></returns>
  35. public Response NewsRead(dynamic _)
  36. {
  37. var loginUserInfo = LoginUserInfo.Get();
  38. NoticeEntity parameter = this.GetReqData<NoticeEntity>();
  39. //判断当前用户是否阅读当前通知公告
  40. var entity = lR_OA_NewsReadIBLL.GetLR_OA_NewsReadEntityByNewsIdAndUserId(parameter.newsId, loginUserInfo.userId);
  41. if (entity == null)
  42. {
  43. var lR_OA_NewsRead = new LR_OA_NewsReadEntity()
  44. {
  45. NewsId = parameter.newsId,
  46. RUserId = loginUserInfo.userId,
  47. RUserName = loginUserInfo.realName,
  48. RTime = DateTime.Now
  49. };
  50. lR_OA_NewsReadIBLL.SaveEntity("", lR_OA_NewsRead);
  51. //修改当前通知公告的浏览量
  52. lR_OA_NewsReadIBLL.UpdateNewsPV(parameter.newsId);
  53. }
  54. return Success("阅读成功!");
  55. }
  56. /// <summary>
  57. /// 获取页面显示列表数据
  58. /// <summary>
  59. /// <param name="_"></param>
  60. /// <returns></returns>
  61. public Response GetList(dynamic _)
  62. {
  63. var userinfo = LoginUserInfo.Get();
  64. Pagination paginationobj = new Pagination();
  65. var newsList = noticeIBLL.GetList("",(Request.Query["F_CategoryId"]!=null?Request.Query["F_CategoryId"].ToString():""));
  66. //var newsListOfSelf = new List<NewsEntity>();
  67. //foreach (var newsitemEntity in newsList)
  68. //{
  69. // if (!string.IsNullOrEmpty(newsitemEntity.F_SendPostId))
  70. // {
  71. // if (!string.IsNullOrEmpty(userinfo.postIds))
  72. // {
  73. // if (userinfo.postIds.Contains(","))
  74. // {
  75. // foreach (var postid in userinfo.postIds.Split(','))
  76. // {
  77. // if (newsitemEntity.F_SendPostId.Contains(postid))
  78. // {
  79. // newsListOfSelf.Add(newsitemEntity);
  80. // break;
  81. // }
  82. // }
  83. // }
  84. // else
  85. // {
  86. // if (newsitemEntity.F_SendPostId.Contains(userinfo.postIds))
  87. // {
  88. // newsListOfSelf.Add(newsitemEntity);
  89. // }
  90. // }
  91. // }
  92. // }
  93. // else
  94. // {
  95. // if (!string.IsNullOrEmpty(newsitemEntity.F_SendDeptId))
  96. // {
  97. // if (newsitemEntity.F_SendDeptId.Contains(userinfo.departmentId))
  98. // {
  99. // newsListOfSelf.Add(newsitemEntity);
  100. // }
  101. // }
  102. // else
  103. // {
  104. // newsListOfSelf.Add(newsitemEntity);
  105. // }
  106. // }
  107. //}
  108. var jsonData = new
  109. {
  110. rows = newsList,
  111. total = newsList.Count,
  112. page = 0,
  113. records = newsList.Count
  114. };
  115. return Success(jsonData);
  116. }
  117. }
  118. }