Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

208 rindas
7.2 KiB

  1. using Learun.Application.AppMagager;
  2. using Learun.Util;
  3. using Nancy;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using Learun.Application.Base.SystemModule;
  7. using Learun.Application.TwoDevelopment.LR_Desktop;
  8. using System.Text;
  9. using System.Data;
  10. using Learun.Application.OA;
  11. using Learun.Application.Organization;
  12. using System;
  13. namespace Learun.Application.WebApi.Modules
  14. {
  15. public class NewsApi : BaseApi
  16. {
  17. private NoticeIBLL noticeIBLL = new NoticeBLL();
  18. private DepartmentIBLL departmentIBLL = new DepartmentBLL();
  19. private PostIBLL postIBLL = new PostBLL();
  20. private LR_OA_NewsReadIBLL lR_OA_NewsReadIBLL = new LR_OA_NewsReadBLL();
  21. public NewsApi()
  22. : base("/learun/news")
  23. {
  24. Get["/list"] = GetList;
  25. Get["/pageList"] = GetPageList;
  26. Get["/shList"] = GetshList;
  27. Post["/newsRead"] = NewsRead;
  28. }
  29. /// <summary>
  30. /// 获取页面显示列表数据
  31. /// <summary>
  32. /// <param name="_"></param>
  33. /// <returns></returns>
  34. public Response GetList(dynamic _)
  35. {
  36. var userinfo = LoginUserInfo.Get();
  37. Pagination paginationobj = new Pagination();
  38. var newsList = noticeIBLL.GetList("",(Request.Query["F_CategoryId"]!=null?Request.Query["F_CategoryId"].ToString():""));
  39. //var newsListOfSelf = new List<NewsEntity>();
  40. //foreach (var newsitemEntity in newsList)
  41. //{
  42. // if (!string.IsNullOrEmpty(newsitemEntity.F_SendPostId))
  43. // {
  44. // if (!string.IsNullOrEmpty(userinfo.postIds))
  45. // {
  46. // if (userinfo.postIds.Contains(","))
  47. // {
  48. // foreach (var postid in userinfo.postIds.Split(','))
  49. // {
  50. // if (newsitemEntity.F_SendPostId.Contains(postid))
  51. // {
  52. // newsListOfSelf.Add(newsitemEntity);
  53. // break;
  54. // }
  55. // }
  56. // }
  57. // else
  58. // {
  59. // if (newsitemEntity.F_SendPostId.Contains(userinfo.postIds))
  60. // {
  61. // newsListOfSelf.Add(newsitemEntity);
  62. // }
  63. // }
  64. // }
  65. // }
  66. // else
  67. // {
  68. // if (!string.IsNullOrEmpty(newsitemEntity.F_SendDeptId))
  69. // {
  70. // if (newsitemEntity.F_SendDeptId.Contains(userinfo.departmentId))
  71. // {
  72. // newsListOfSelf.Add(newsitemEntity);
  73. // }
  74. // }
  75. // else
  76. // {
  77. // newsListOfSelf.Add(newsitemEntity);
  78. // }
  79. // }
  80. //}
  81. var jsonData = new
  82. {
  83. rows = newsList,
  84. total = newsList.Count,
  85. page = 0,
  86. records = newsList.Count
  87. };
  88. return Success(jsonData);
  89. }
  90. /// <summary>
  91. /// 获取页面显示列表数据
  92. /// <summary>
  93. /// <param name="_"></param>
  94. /// <returns></returns>
  95. public Response GetPageList(dynamic _)
  96. {
  97. var userinfo = LoginUserInfo.Get();
  98. ReqPageParam parameter = this.GetReqData<ReqPageParam>();
  99. var data = noticeIBLL.GetListApp(parameter.pagination, parameter.queryJson);
  100. var jsonData = new
  101. {
  102. rows = data,
  103. total = parameter.pagination.total,
  104. page = parameter.pagination.page,
  105. records = parameter.pagination.records
  106. };
  107. return Success(jsonData);
  108. }
  109. /// <summary>
  110. /// 获取页面显示列表数据
  111. /// <summary>
  112. /// <param name="_"></param>
  113. /// <returns></returns>
  114. public Response GetshList(dynamic _)
  115. {
  116. NoticeEntity parameter = this.GetReqData<NoticeEntity>();
  117. var shlist = noticeIBLL.GetEntityByProcessId(parameter.ProgressId);
  118. if (!shlist.F_SendDeptId.IsEmpty())
  119. {
  120. var Array = shlist.F_SendDeptId.Split(',');
  121. var deept = departmentIBLL.GetAllList();
  122. var SendDeptId = "";
  123. foreach (var item in Array)
  124. {
  125. for (int i = 0; i < deept.Count; i++)
  126. {
  127. if (item == deept[i].F_DepartmentId)
  128. {
  129. SendDeptId += deept[i].F_FullName + ",";
  130. }
  131. }
  132. }
  133. SendDeptId.Trim(',');
  134. shlist.F_SendDeptId = SendDeptId;
  135. }
  136. if (!shlist.F_SendPostId.IsEmpty())
  137. {
  138. var Array1 = shlist.F_SendPostId.Split(',');
  139. var post = postIBLL.GetAllList();
  140. var F_SendPostId = "";
  141. foreach (var item in Array1)
  142. {
  143. for (int i = 0; i < post.Count; i++)
  144. {
  145. if (item == post[i].F_PostId)
  146. {
  147. F_SendPostId += post[i].F_Name + ",";
  148. }
  149. }
  150. }
  151. F_SendPostId.Trim(',');
  152. shlist.F_SendPostId = F_SendPostId;
  153. }
  154. if (!shlist.F_NewsContent.IsEmpty())
  155. {
  156. shlist.F_NewsContent = WebHelper.HtmlDecode(shlist.F_NewsContent);
  157. }
  158. return Success(shlist);
  159. }
  160. /// <summary>
  161. /// 阅读通知公告
  162. /// <summary>
  163. /// <returns></returns>
  164. public Response NewsRead(dynamic _)
  165. {
  166. var loginUserInfo = LoginUserInfo.Get();
  167. NoticeEntity parameter = this.GetReqData<NoticeEntity>();
  168. //判断当前用户是否阅读当前通知公告
  169. var entity = lR_OA_NewsReadIBLL.GetLR_OA_NewsReadEntityByNewsIdAndUserId(parameter.newsId, loginUserInfo.userId);
  170. if (entity == null)
  171. {
  172. var lR_OA_NewsRead = new LR_OA_NewsReadEntity()
  173. {
  174. NewsId = parameter.newsId,
  175. RUserId = loginUserInfo.userId,
  176. RUserName = loginUserInfo.realName,
  177. RTime = DateTime.Now
  178. };
  179. lR_OA_NewsReadIBLL.SaveEntity("", lR_OA_NewsRead);
  180. //修改当前通知公告的浏览量
  181. lR_OA_NewsReadIBLL.UpdateNewsPV(parameter.newsId);
  182. }
  183. return Success("阅读成功!");
  184. }
  185. #region 私有类
  186. private class NoticeEntity
  187. {
  188. public string ProgressId { get; set; }
  189. public string newsId { get; set; }
  190. }
  191. #endregion
  192. }
  193. }