lihao 4 年之前
父节点
当前提交
935ec44f2f

+ 6 - 0
gx_api/GxPress/Api/GxPress.Api/AppControllers/NoticeController.cs

@@ -140,5 +140,11 @@ namespace GxPress.Api.AppControllers
         {
             return await _noticeService.RecallAsync(id);
         }
+        [HttpGet("title")]
+        [AllowAnonymous]
+        public async Task<bool> UpdateNoticeTitleAsync()
+        {
+            return await _noticeService.UpdateNoticeTitleAsync();
+        }
     }
 }

+ 10 - 0
gx_api/GxPress/Repository/GxPress.Repository.Implement/NoticeRepository.cs

@@ -315,6 +315,16 @@ namespace GxPress.Repository.Implement
             return await _repository.UpdateAsync(query) > 0;
         }
         /// <summary>
+        /// 通知修改
+        /// </summary>
+        /// <param name="id"></param>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        public async Task<bool> UpdateAsync(Entity.Notice notice)
+        {
+            return await _repository.UpdateAsync(notice);
+        }
+        /// <summary>
         /// 获取通知列表
         /// </summary>
         /// <param name="request"></param>

+ 8 - 1
gx_api/GxPress/Repository/GxPress.Repository.Interface/INoticeRepository.cs

@@ -44,7 +44,7 @@ namespace GxPress.Repository.Interface
         /// </summary>
         /// <param name="request"></param>
         /// <returns></returns>
-        Task<PagedList<NoticeListPageResult>> GetNoticeListPageAsync(SqlKata.Query query,SqlKata.Query countQuery);
+        Task<PagedList<NoticeListPageResult>> GetNoticeListPageAsync(SqlKata.Query query, SqlKata.Query countQuery);
 
         /// <summary>
         /// 恢复删除的通知
@@ -71,5 +71,12 @@ namespace GxPress.Repository.Interface
         /// <returns></returns>
         Task<bool> UpdateAsync(SqlKata.Query query);
         Task<IEnumerable<Notice>> GetAllAsync(Query query);
+        /// <summary>
+        /// 通知修改
+        /// </summary>
+        /// <param name="id"></param>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        Task<bool> UpdateAsync(Entity.Notice notice);
     }
 }

+ 2 - 0
gx_api/GxPress/Service/GxPress.Service.Implement/Notice/NoticeService.Insert.cs

@@ -32,9 +32,11 @@ namespace GxPress.Service.Implement.Notice
                     var middleId = 0;
                     var addresseeUsers = new List<User>();
                     var ccUsers = new List<User>();
+                    request.Title = _contentJsonService.GetTitile(request.Title, request.Content);
                     //添加通知
                     if (request.Id == 0)
                     {
+
                         noticeId = await _noticeRepository.InsertAsync(request);
                         if (noticeId == 0) return false;
                         var middleInsertTypes = new MiddleInsertTypeRequest

+ 15 - 2
gx_api/GxPress/Service/GxPress.Service.Implement/Notice/NoticeService.cs

@@ -416,7 +416,7 @@ namespace GxPress.Service.Implement.Notice
             query.ForPage(request.Page, request.PerPage);
             query.Select(
                   "tede_middle.Id", "tede_middle.MiddleId", "tede_middle.IsTop", "tede_middle.AttributeValue", "tede_middle.FolderName", "tede_middle.CreatedDate"
-                , "tede_notice.{UserId,UserName,SourceId,Title,Content,TypeValue,IsRecall}"
+                , "tede_notice.{UserId,UserName,SourceId,Title,TypeValue,IsRecall}"
                 , "tede_user.{AvatarUrl}"
                 , "tede_addressee.{Id as NoticeAddresseeId, SourceId as NoticeId}");
 
@@ -463,7 +463,7 @@ namespace GxPress.Service.Implement.Notice
                         item.FlowState = FlowState.Checking;
                     }
                 }
-                item.Title = _contentJsonService.GetTitile(item.Title, item.Content);
+                // item.Title = _contentJsonService.GetTitile(item.Title, item.Content);
                 if (request.SearchType == 3)
                     item.NoticeStatus = 0;
                 else if (request.SearchType == 2)
@@ -520,5 +520,18 @@ namespace GxPress.Service.Implement.Notice
             }
             return true;
         }
+
+        public async Task<bool> UpdateNoticeTitleAsync()
+        {
+            var query = Q.NewQuery();
+            query.Where(n => n.OrWhereNull(nameof(Entity.Notice.Title)).OrWhere(nameof(Entity.Notice.Title), "=", ""));
+            var result = await _noticeRepository.GetAllAsync(query);
+            foreach (var item in result)
+            {
+                item.Title = _contentJsonService.GetTitile(item.Title, item.Content);
+                await _noticeRepository.UpdateAsync(item);
+            }
+            return true;
+        }
     }
 }

+ 1 - 0
gx_api/GxPress/Service/GxPress.Service.Interface/Notice/INoticeService.cs

@@ -59,5 +59,6 @@ namespace GxPress.Service.Interface.Notice
         /// <param name="request"></param>
         /// <returns></returns>
         Task<bool> AddNoticeFlowAsync(NoticeInRequest request);
+        Task<bool> UpdateNoticeTitleAsync();
     }
 }