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(); public NewsApi() : base("/learun/news") { Get["/list"] = GetList; } /// /// 获取页面显示列表数据 /// /// /// public Response GetList(dynamic _) { var userinfo = LoginUserInfo.Get(); Pagination paginationobj = new Pagination(); var newsList = noticeIBLL.GetList("", userinfo.userId,(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 = newsListOfSelf, total = newsListOfSelf.Count, page = 0, records = newsListOfSelf.Count }; return Success(jsonData); } } }