From 7f7e12f3ab097de5481654cff46548c2ae2e9460 Mon Sep 17 00:00:00 2001 From: zhangli <1109134334@qq.com> Date: Wed, 28 Sep 2022 14:39:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E7=94=A8=E6=88=B7=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=87=AA=E5=B7=B1=E6=8E=A5=E6=94=B6=E7=9A=84=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E5=85=AC=E5=91=8A=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/NoticeController.cs | 184 +++++++++--------- .../Modules/NewsApi.cs | 92 ++++----- .../Learun.Application.OA/Notice/NoticeBLL.cs | 4 +- .../Notice/NoticeIBLL.cs | 2 +- .../Notice/NoticeService.cs | 42 +++- 5 files changed, 179 insertions(+), 145 deletions(-) diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Controllers/NoticeController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Controllers/NoticeController.cs index 0b992dc31..477560d6c 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Controllers/NoticeController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_OAModule/Controllers/NoticeController.cs @@ -136,52 +136,52 @@ namespace Learun.Application.Web.Areas.LR_OAModule.Controllers { var userinfo = LoginUserInfo.Get(); Pagination paginationobj = new Pagination(); - var newsList = noticeIBLL.GetList(keyword, userinfo.userId, categoryId); - 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); - } - } - } - - return JsonResult(newsListOfSelf); + var newsList = noticeIBLL.GetList(keyword, categoryId); + //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); + // } + // } + //} + + return JsonResult(newsList); } /// /// 查看通知公告 @@ -193,53 +193,53 @@ namespace Learun.Application.Web.Areas.LR_OAModule.Controllers { var userinfo = LoginUserInfo.Get(); Pagination paginationobj = new Pagination(); - var newsList = noticeIBLL.GetList(keyword, userinfo.userId, categoryId). + var newsList = noticeIBLL.GetList(keyword, categoryId). Where(a => a.F_Status == "2"); - 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); - } - } - } - - return JsonResult(newsListOfSelf); + //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); + // } + // } + //} + + return JsonResult(newsList); } /// /// 获取实体数据 diff --git a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/NewsApi.cs b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/NewsApi.cs index 9fa30d0a7..20394b036 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/NewsApi.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.WebApi/Modules/NewsApi.cs @@ -32,56 +32,56 @@ namespace Learun.Application.WebApi.Modules { 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(); + 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); - } - } - } + //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, + rows = newsList, + total = newsList.Count, page = 0, - records = newsListOfSelf.Count + records = newsList.Count }; return Success(jsonData); } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeBLL.cs index 2c40de9f2..eea23e15d 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeBLL.cs @@ -121,11 +121,11 @@ namespace Learun.Application.OA /// /// 关键词 /// - public IEnumerable GetList(string keyword, string userId, string categoryId = null) + public IEnumerable GetList(string keyword, string categoryId = null) { try { - return noticeService.GetList(keyword, userId, categoryId); + return noticeService.GetList(keyword, categoryId); } catch (Exception ex) { diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeIBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeIBLL.cs index 379dae654..5b322b1aa 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeIBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeIBLL.cs @@ -49,7 +49,7 @@ namespace Learun.Application.OA /// /// 关键词 /// - IEnumerable GetList(string keyword, string userId,string categoryId=null); + IEnumerable GetList(string keyword,string categoryId=null); #endregion diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeService.cs index 88da9ca7f..4351fd056 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.OA/Notice/NoticeService.cs @@ -154,21 +154,55 @@ namespace Learun.Application.OA /// /// 关键词 /// - public IEnumerable GetList(string keyword, string userId, string categoryId = null) + public IEnumerable GetList(string keyword, string categoryId = null) { try { + var userinfo = LoginUserInfo.Get(); + var userId = userinfo.userId; + var deptId = userinfo.departmentId; + var postIds = userinfo.postIds; var strSql = new StringBuilder(); strSql.Append("SELECT t.*,r.RNewsId,r.RTime FROM LR_OA_News t "); strSql.Append(" left join LR_OA_NewsRead r on t.F_NewsId = r.NewsId and r.RUserId=@userId "); - strSql.Append(" WHERE t.F_TypeId = 2 and t.F_DeleteMark=0 "); + strSql.Append(" WHERE t.F_TypeId = 2 and t.F_DeleteMark=0 and t.F_EnabledMark=1 "); + strSql.Append($@" and ( +((t.F_SendDeptId is null or len(t.F_SendDeptId)=0) and (t.F_SendPostId is null or len(t.F_SendPostId)=0)) +"); + if (!string.IsNullOrEmpty(deptId)) + { + strSql.Append($" or (t.F_SendDeptId is not null and t.F_SendDeptId like '%{deptId}%')"); + } + if (!string.IsNullOrEmpty(postIds)) + { + strSql.Append(" or (t.F_SendPostId is not null and "); + if (postIds.Contains(",")) + { + string postidSql = " ("; + foreach (var postId in postIds) + { + postidSql += $" t.F_SendPostId like '%{postId}%' or"; + } + + postidSql = postidSql.Substring(0, postidSql.LastIndexOf("or")) + ")"; + strSql.Append(postidSql); + } + else + { + strSql.Append($" t.F_SendPostId like '%{postIds}%'"); + } + + strSql.Append(")"); + } + + strSql.Append(") "); if (!string.IsNullOrEmpty(categoryId)) { - strSql.Append($" AND F_CategoryId = '{categoryId}'"); + strSql.Append($" AND t.F_CategoryId = '{categoryId}'"); } if (!string.IsNullOrEmpty(keyword)) { - strSql.Append(" AND F_FullHead like @keyword"); + strSql.Append(" AND t.F_FullHead like @keyword"); } strSql.Append(" ORDER BY t.F_ReleaseTime DESC "); return this.BaseRepository().FindList(strSql.ToString(), new { keyword = "%" + keyword + "%", userId = userId });