From 97c4384521654c55874ce296c3566ba30d764fa0 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Fri, 19 Jul 2024 20:49:40 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E6=9C=8D=E5=8A=A1=E7=AB=AF=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Order/Controllers/OrdersController.cs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Src/Dlhis.Canteen/Order/Controllers/OrdersController.cs b/Src/Dlhis.Canteen/Order/Controllers/OrdersController.cs index 35bdf155..9902e541 100644 --- a/Src/Dlhis.Canteen/Order/Controllers/OrdersController.cs +++ b/Src/Dlhis.Canteen/Order/Controllers/OrdersController.cs @@ -1,10 +1,12 @@ -using Dlhis.Canteen.Dishes.Request; +using System.Diagnostics; +using Dlhis.Canteen.Dishes.Request; using Dlhis.Canteen.Order.Request; using Dlhis.Canteen.Order.Response; using Dlhis.Canteen.Order.Services; using Kurisu.AspNetCore.DataAccess.Dto; using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop; using Kurisu.AspNetCore.UnifyResultAndValidation; +using Kurisu.AspNetCore.Utils.Extensions; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -20,11 +22,13 @@ public class OrdersController : ControllerBase { private readonly IOrderService _orderService; private readonly IBookingOrderService _bookingOrderService; + private readonly ILogger _logger; - public OrdersController(IOrderService orderService, IBookingOrderService bookingOrderService) + public OrdersController(IOrderService orderService, IBookingOrderService bookingOrderService, ILogger logger) { _orderService = orderService; _bookingOrderService = bookingOrderService; + _logger = logger; } /// @@ -37,7 +41,15 @@ public class OrdersController : ControllerBase [IgnoreTenant] public async Task> AddAsync(OrderAddRequest request) { - return await _orderService.AddAsync(request); + var sw = Stopwatch.StartNew(); + try + { + return await _orderService.AddAsync(request); + } + finally + { + _logger.LogInformation("消费请求:{json}. 耗时:{time}", request.ToJson(), sw.ElapsedMilliseconds); + } } ///