|
- 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;
- using Learun.Application.Organization;
- using System;
-
- namespace Learun.Application.WebApi.Modules
- {
-
- public class NewsApi : BaseApi
- {
- private NoticeIBLL noticeIBLL = new NoticeBLL();
- private DepartmentIBLL departmentIBLL = new DepartmentBLL();
- private PostIBLL postIBLL = new PostBLL();
- private LR_OA_NewsReadIBLL lR_OA_NewsReadIBLL = new LR_OA_NewsReadBLL();
-
- public NewsApi()
- : base("/learun/news")
- {
- Get["/list"] = GetList;
- Get["/pageList"] = GetPageList;
- Get["/shList"] = GetshList;
-
- Post["/newsRead"] = NewsRead;
- }
-
-
- /// <summary>
- /// 获取页面显示列表数据
- /// <summary>
- /// <param name="_"></param>
- /// <returns></returns>
- 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<NewsEntity>();
-
- //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);
- }
-
- /// <summary>
- /// 获取页面显示列表数据
- /// <summary>
- /// <param name="_"></param>
- /// <returns></returns>
- public Response GetPageList(dynamic _)
- {
- var userinfo = LoginUserInfo.Get();
- ReqPageParam parameter = this.GetReqData<ReqPageParam>();
- var data = noticeIBLL.GetListApp(parameter.pagination, parameter.queryJson);
- var jsonData = new
- {
- rows = data,
- total = parameter.pagination.total,
- page = parameter.pagination.page,
- records = parameter.pagination.records
- };
- return Success(jsonData);
- }
- /// <summary>
- /// 获取页面显示列表数据
- /// <summary>
- /// <param name="_"></param>
- /// <returns></returns>
- public Response GetshList(dynamic _)
- {
- NoticeEntity parameter = this.GetReqData<NoticeEntity>();
- var shlist = noticeIBLL.GetEntityByProcessId(parameter.ProgressId);
- if (!shlist.F_SendDeptId.IsEmpty())
- {
- var Array = shlist.F_SendDeptId.Split(',');
- var deept = departmentIBLL.GetAllList();
- var SendDeptId = "";
- foreach (var item in Array)
- {
-
- for (int i = 0; i < deept.Count; i++)
- {
- if (item == deept[i].F_DepartmentId)
- {
- SendDeptId += deept[i].F_FullName + ",";
- }
- }
- }
- SendDeptId.Trim(',');
- shlist.F_SendDeptId = SendDeptId;
- }
- if (!shlist.F_SendPostId.IsEmpty())
- {
- var Array1 = shlist.F_SendPostId.Split(',');
- var post = postIBLL.GetAllList();
- var F_SendPostId = "";
- foreach (var item in Array1)
- {
- for (int i = 0; i < post.Count; i++)
- {
- if (item == post[i].F_PostId)
- {
- F_SendPostId += post[i].F_Name + ",";
- }
- }
- }
- F_SendPostId.Trim(',');
- shlist.F_SendPostId = F_SendPostId;
- }
- if (!shlist.F_NewsContent.IsEmpty())
- {
- shlist.F_NewsContent = WebHelper.HtmlDecode(shlist.F_NewsContent);
- }
- return Success(shlist);
- }
-
- /// <summary>
- /// 阅读通知公告
- /// <summary>
- /// <returns></returns>
- public Response NewsRead(dynamic _)
- {
- var loginUserInfo = LoginUserInfo.Get();
- NoticeEntity parameter = this.GetReqData<NoticeEntity>();
-
- //判断当前用户是否阅读当前通知公告
- 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("阅读成功!");
- }
- #region 私有类
- private class NoticeEntity
- {
- public string ProgressId { get; set; }
- public string newsId { get; set; }
- }
- #endregion
-
- }
-
- }
|