Sfoglia il codice sorgente

增强日志记录功能

在 `FinancialController.cs` 文件中,添加了日志记录功能。在事务提交成功时,记录信息日志以表明操作成功,并包含请求参数;在事务回滚时,记录警告日志以表明操作失败,并同样包含请求参数。这些更改提升了系统的可追溯性和调试能力。
Lyyyi 2 settimane fa
parent
commit
2c1ebe7d15

+ 6 - 2
OASystem/OASystem.Api/Controllers/FinancialController.cs

@@ -3231,7 +3231,9 @@ namespace OASystem.API.Controllers
             if (changeStatus)
             {
                 _sqlSugar.CommitTran();
-
+                //todo:日志记录
+                _logger.LogInformation("【付款申请】【状态:操作成功!】请求参数: OpUserId: {UserId}, GroupIds: {GroupIds}, DailyPaymentIds: {DailyPaymentIds}, HotelSubIds: {HotelSubIds}",
+                    dto.UserId, string.Join(",", groupIds), string.Join(",", dailyPaymentIds), string.Join(",", hotelSubIds));
                 #region 应用推送
                 try
                 {
@@ -3255,6 +3257,9 @@ namespace OASystem.API.Controllers
                 return Ok(JsonView(true, "操作成功!"));
             }
             _sqlSugar.RollbackTran();
+            //todo:日志记录
+            _logger.LogWarning("【付款申请】【状态:操作失败!】 请求参数:OpUserId: {UserId}, GroupIds: {GroupIds}, DailyPaymentIds: {DailyPaymentIds}, HotelSubIds: {HotelSubIds}",
+                dto.UserId, string.Join(",", groupIds), string.Join(",", dailyPaymentIds), string.Join(",", hotelSubIds));
             return Ok(JsonView(false, "付款状态修改失败!"));
 
         }
@@ -3440,7 +3445,6 @@ namespace OASystem.API.Controllers
                 _appliedAmount = $"公转:CNY {(groupGZAmout + dailyGZAmout).ToString("#0.00")}\r\n私转:CNY {(groupSZAmout + dailySZAmout).ToString("#0.00")}";
                 #endregion
 
-
                 WorkbookDesigner designer = new WorkbookDesigner();
                 designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/付款申请书.xls");
                 designer.SetDataSource("Date", _requestPaymentDt);