using System; using Learun.Application.AppMagager; using Learun.Util; using Nancy; using System.Collections.Generic; using System.Linq; using Learun.Application.Base.SystemModule; using Learun.Application.TwoDevelopment.LR_Desktop; using System.Text; using System.Data; using Learun.Application.OA; namespace Learun.Application.WebApi.Modules { public class NewsApi : BaseApi { private NoticeIBLL noticeIBLL = new NoticeBLL(); LR_OA_NewsReadIBLL lR_OA_NewsReadIBLL=new LR_OA_NewsReadBLL(); public NewsApi() : base("/learun/news") { Get["/list"] = GetList; Post["/newsRead"] = NewsRead; } #region 私有类 private class NoticeEntity { public string ProgressId { get; set; } public string newsId { get; set; } } #endregion /// /// 阅读通知公告 /// /// public Response NewsRead(dynamic _) { var loginUserInfo = LoginUserInfo.Get(); NoticeEntity parameter = this.GetReqData(); //判断当前用户是否阅读当前通知公告 var entity = lR_OA_NewsReadIBLL.GetLR_OA_NewsReadEntityByNewsIdAndUserId(parameter.newsId, loginUserInfo.userId); if (entity == null) { var lR_OA_NewsRead = new LR_OA_NewsReadEntity() { NewsId = parameter.newsId, RUserId = loginUserInfo.userId, RUserName = loginUserInfo.realName, RTime = DateTime.Now }; lR_OA_NewsReadIBLL.SaveEntity("", lR_OA_NewsRead); //修改当前通知公告的浏览量 lR_OA_NewsReadIBLL.UpdateNewsPV(parameter.newsId); } return Success("阅读成功!"); } /// /// 获取页面显示列表数据 /// /// /// public Response GetList(dynamic _) { var userinfo = LoginUserInfo.Get(); Pagination paginationobj = new Pagination(); var newsList = noticeIBLL.GetList("",(Request.Query["F_CategoryId"]!=null?Request.Query["F_CategoryId"].ToString():"")); //var newsListOfSelf = new List(); //foreach (var newsitemEntity in newsList) //{ // if (!string.IsNullOrEmpty(newsitemEntity.F_SendPostId)) // { // if (!string.IsNullOrEmpty(userinfo.postIds)) // { // if (userinfo.postIds.Contains(",")) // { // foreach (var postid in userinfo.postIds.Split(',')) // { // if (newsitemEntity.F_SendPostId.Contains(postid)) // { // newsListOfSelf.Add(newsitemEntity); // break; // } // } // } // else // { // if (newsitemEntity.F_SendPostId.Contains(userinfo.postIds)) // { // newsListOfSelf.Add(newsitemEntity); // } // } // } // } // else // { // if (!string.IsNullOrEmpty(newsitemEntity.F_SendDeptId)) // { // if (newsitemEntity.F_SendDeptId.Contains(userinfo.departmentId)) // { // newsListOfSelf.Add(newsitemEntity); // } // } // else // { // newsListOfSelf.Add(newsitemEntity); // } // } //} var jsonData = new { rows = newsList, total = newsList.Count, page = 0, records = newsList.Count }; return Success(jsonData); } } }