refactor 代码优化
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
using System.Diagnostics;
|
||||
using Dlhis.Canteen.Dishes.Request;
|
||||
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;
|
||||
|
||||
@@ -22,13 +20,11 @@ public class OrdersController : ControllerBase
|
||||
{
|
||||
private readonly IOrderService _orderService;
|
||||
private readonly IBookingOrderService _bookingOrderService;
|
||||
private readonly ILogger<OrdersController> _logger;
|
||||
|
||||
public OrdersController(IOrderService orderService, IBookingOrderService bookingOrderService, ILogger<OrdersController> logger)
|
||||
public OrdersController(IOrderService orderService, IBookingOrderService bookingOrderService)
|
||||
{
|
||||
_orderService = orderService;
|
||||
_bookingOrderService = bookingOrderService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -41,27 +37,8 @@ public class OrdersController : ControllerBase
|
||||
[IgnoreTenant]
|
||||
public async Task<DefaultApiResult<OrderResultResponse>> AddAsync(OrderAddRequest request)
|
||||
{
|
||||
var sw = Stopwatch.StartNew();
|
||||
var result = await _orderService.AddAsync(request);
|
||||
try
|
||||
{
|
||||
return result.Response;
|
||||
}
|
||||
finally
|
||||
{
|
||||
var ms = sw.ElapsedMilliseconds;
|
||||
try
|
||||
{
|
||||
if (ms > 1000)
|
||||
{
|
||||
_logger.LogInformation("消费请求:{json}. 耗时记录:{log}", request.ToJson(), result.Logs.Join("\r\n"));
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
return result.Response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -74,27 +51,8 @@ public class OrdersController : ControllerBase
|
||||
[IgnoreTenant]
|
||||
public async Task<DefaultApiResult<OrderResultResponse>> DeviceConsume(OrderAddRequest request)
|
||||
{
|
||||
var sw = Stopwatch.StartNew();
|
||||
var result = await _orderService.AddAsync(request);
|
||||
try
|
||||
{
|
||||
return result.Response;
|
||||
}
|
||||
finally
|
||||
{
|
||||
var ms = sw.ElapsedMilliseconds;
|
||||
try
|
||||
{
|
||||
if (ms > 1000)
|
||||
{
|
||||
_logger.LogInformation("消费请求:{json}. 耗时记录:{log}", request.ToJson(), result.Logs.Join("\r\n"));
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
return result.Response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user