feat X-Requested-DeviceIp
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using Dlhis.Canteen.Order.Dto;
|
||||
using Dlhis.Canteen.Order.Dto;
|
||||
using Dlhis.Canteen.Setting.Services;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Canteen.Entities;
|
||||
@@ -23,15 +23,18 @@ namespace Dlhis.Canteen.Order.Services.Implements;
|
||||
public class OrderService : BaseOrderService, IOrderService
|
||||
{
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
public OrderService(ICanteenSettingService canteenSettingService,
|
||||
IDbContext dbContext,
|
||||
ICurrentUser currentUser,
|
||||
IServiceProvider serviceProvider,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
ILogger<OrderService> logger)
|
||||
: base(canteenSettingService, dbContext, currentUser, logger)
|
||||
{
|
||||
_serviceProvider = serviceProvider;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -51,6 +54,24 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
/// <returns></returns>
|
||||
public async Task<OrderResultResponseWithLogs> AddAsync(OrderAddRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_httpContextAccessor.HttpContext!.Request.Headers.TryGetValue("X-Requested-DeviceIp", out var ip))
|
||||
{
|
||||
var device = await DbContext.Queryable<DeviceEntity>().Where(x => x.UniqueNo == request.DeviceUniqueNo).SingleAsync();
|
||||
device.ConnectionInfo = new
|
||||
{
|
||||
ip = ip.ToString()
|
||||
}.ToJson();
|
||||
|
||||
await DbContext.UpdateAsync(device);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
|
||||
var gainfo = await GetUserAsync(request);
|
||||
|
||||
return new OrderResultResponseWithLogs
|
||||
|
||||
Reference in New Issue
Block a user