Browse Source

优化GroupsController方法参数及日志功能

在GroupsController中:
- 将EnterpriseWeChatNotificationAsyncBaoPi方法的参数改为DTO对象,提升代码可扩展性。
- 新增日志记录功能,记录团组操作的详细信息。
- 移除冗余代码,优化代码结构。
- 调整异常处理逻辑,提升代码健壮性。

在Library中:
- 新增静态字段_groupLog,用于支持日志记录功能。

在GroupListDto中:
- 新增EnterpriseWeChatNotificationAsyncBaoPiDto类,用于封装方法参数。
Lyyyi 13 hours ago
parent
commit
db2131764b

+ 6 - 6
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -34,6 +34,7 @@ using OASystem.Domain.ViewModels.OCR;
 using OASystem.Infrastructure.Repositories.CRM;
 using OASystem.Infrastructure.Repositories.Financial;
 using OASystem.Infrastructure.Repositories.Groups;
+using Quartz.Logging;
 using Quartz.Util;
 using SqlSugar.Extensions;
 using System.Collections;
@@ -2753,12 +2754,13 @@ FROM
         /// <summary>
         /// 报批完成企微通知
         /// </summary>
-        /// <param name="currUserId"></param>
-        /// <param name="diid"></param>
+        /// <param name="dto"></param>
         /// <returns></returns>
         [HttpPost]
-        public async Task<IActionResult> EnterpriseWeChatNotificationAsyncBaoPi(int currUserId,int diid)
+        public async Task<IActionResult> EnterpriseWeChatNotificationAsyncBaoPi(EnterpriseWeChatNotificationAsyncBaoPiDto dto)
         {
+            int currUserId = dto.currUserId;
+            int diid = dto.diid;
             var jw = JsonView(true);
             var users = new List<string>();
             var ssd = _sqlSugar.Queryable<Sys_SetData>()
@@ -2768,7 +2770,7 @@ FROM
             {
                 users = JsonConvert.DeserializeObject<List<string>>(ssd.Remark);
                 var res = await AppNoticeLibrary.SendUserMsg_BaoPi_ToUser(users, diid);
-                
+
                 //消息通知成功 更改团组step、记录日志
                 if (res)
                 {
@@ -2791,7 +2793,6 @@ FROM
                     };
 
                     //记录日志
-
                     var teamName = _sqlSugar.Queryable<Grp_DelegationInfo>()
                         .Where(x => x.Id == diid && x.IsDel == 0)
                         .Select(x => x.TeamName)
@@ -2805,7 +2806,6 @@ FROM
                     _groupTextLogger.LogInformation("团组:【{teamName}({groupId})】 操作人:【{operationName}】 操作时间:【{operationTime}】{logContent}", teamName, diid, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), groupStepLabel);
 
                 }
-
             }
             catch (Exception ex)
             {

+ 2 - 0
OASystem/OASystem.Api/OAMethodLib/QiYeWeChatAPI/AppNotice/Library.cs

@@ -7,6 +7,7 @@ using OASystem.Domain.ViewModels.Groups;
 using OASystem.Domain.ViewModels.QiYeWeChat;
 using OASystem.Infrastructure.Repositories.Groups;
 using OASystem.Domain.Entities.WorkOrder;
+using OASystem.API.OAMethodLib.Logging;
 
 namespace OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice
 {
@@ -15,6 +16,7 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice
         private static readonly IQiYeWeChatApiService _qiYeWeChatApiService = AutofacIocManager.Instance.GetService<IQiYeWeChatApiService>();
 
         private static readonly DelegationInfoRepository _grpDeleRep = AutofacIocManager.Instance.GetService<DelegationInfoRepository>();
+        private static readonly IGroupTextFileLogger _groupLog = AutofacIocManager.Instance.GetService<IGroupTextFileLogger>();
 
         #region 获取企微Id
 

+ 4 - 0
OASystem/OASystem.Domain/Dtos/Groups/GroupListDto.cs

@@ -305,6 +305,10 @@ namespace OASystem.Domain.Dtos.Groups
         public int UserId { get; set; }
     }
 
+    public class EnterpriseWeChatNotificationAsyncBaoPiDto {
+        public int currUserId { get; set; }
+        public int diid { get; set; }
+    }
 
     public class tableSetting
     {