fix 调整无授权处理,增加检查设备是否存在接口
This commit is contained in:
@@ -74,6 +74,7 @@ public class BusinessPlacesController : ControllerBase
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="request"></param>
|
/// <param name="request"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
[AllowAnonymous]
|
||||||
[HttpGet("shifts")]
|
[HttpGet("shifts")]
|
||||||
public async Task<BusinessPlaceWithShiftResponse> GetShiftsByPlaceCustomCodeHttpGetAsync([FromQuery] BusinessPlaceGetShiftsRequest request)
|
public async Task<BusinessPlaceWithShiftResponse> GetShiftsByPlaceCustomCodeHttpGetAsync([FromQuery] BusinessPlaceGetShiftsRequest request)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ public class DevicesController : ControllerBase
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="request"></param>
|
/// <param name="request"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
[AllowAnonymous]
|
||||||
[HttpPost("resigter")]
|
[HttpPost("resigter")]
|
||||||
public async Task<string> ResigterAsync(DeviceResigterRequest request)
|
public async Task<string> ResigterAsync(DeviceResigterRequest request)
|
||||||
{
|
{
|
||||||
@@ -114,4 +115,14 @@ public class DevicesController : ControllerBase
|
|||||||
{
|
{
|
||||||
await _deviceConnectService.HeartbeatAsync(request);
|
await _deviceConnectService.HeartbeatAsync(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 检查设备是否存在
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("exists")]
|
||||||
|
public async Task<bool> CheckExistsAsync(string deviceUniqueNo)
|
||||||
|
{
|
||||||
|
return await _deviceService.CheckExistsAsync(deviceUniqueNo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,4 +9,6 @@ public interface IDeviceService : IScopeDependency
|
|||||||
Task<Pagination<DeviceResponse>> GetPageAsync(DevicePageRequest request);
|
Task<Pagination<DeviceResponse>> GetPageAsync(DevicePageRequest request);
|
||||||
|
|
||||||
Task SaveAsync(DeviceSaveRequest request);
|
Task SaveAsync(DeviceSaveRequest request);
|
||||||
|
|
||||||
|
Task<bool> CheckExistsAsync(string deviceUniqueNo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,9 +35,10 @@ public class DeviceConnectService : IDeviceConnectService
|
|||||||
RegisterTime = DateTime.Now,
|
RegisterTime = DateTime.Now,
|
||||||
BusinessPlaceCode = businessPlace?.Code,
|
BusinessPlaceCode = businessPlace?.Code,
|
||||||
BusinessPlaceCustomCode = businessPlace?.CustomCode,
|
BusinessPlaceCustomCode = businessPlace?.CustomCode,
|
||||||
|
TenantId = device.TenantId,
|
||||||
};
|
};
|
||||||
await _dbContext.InsertAsync(registry);
|
|
||||||
|
|
||||||
|
await _dbContext.InsertAsync(registry);
|
||||||
return "设备注册成功";
|
return "设备注册成功";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,8 +94,8 @@ public class DeviceConnectService : IDeviceConnectService
|
|||||||
private async Task<DeviceEntity> GetEnableDeviceAsync(string uniqueNo)
|
private async Task<DeviceEntity> GetEnableDeviceAsync(string uniqueNo)
|
||||||
{
|
{
|
||||||
var device = await _dbContext.Queryable<DeviceEntity>()
|
var device = await _dbContext.Queryable<DeviceEntity>()
|
||||||
.Where(x => x.UniqueNo == uniqueNo)
|
.Where(x => x.UniqueNo == uniqueNo)
|
||||||
.FirstAsync();
|
.FirstAsync();
|
||||||
|
|
||||||
device.ThrowIfNull($"未知的设备唯一编码{uniqueNo}");
|
device.ThrowIfNull($"未知的设备唯一编码{uniqueNo}");
|
||||||
device.Enable.ThrowIfFalse("设备尚未启用");
|
device.Enable.ThrowIfFalse("设备尚未启用");
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
using Dlhis.Basic.Device.Request;
|
using Dlhis.Basic.Device.Request;
|
||||||
using Dlhis.Basic.Device.Response;
|
using Dlhis.Basic.Device.Response;
|
||||||
using Dlhis.Entity.Basic.Entity;
|
using Dlhis.Entity.Basic.Entity;
|
||||||
|
using Dlhis.Entity.Device.Entities;
|
||||||
using Kurisu.AspNetCore.UnifyResultAndValidation;
|
using Kurisu.AspNetCore.UnifyResultAndValidation;
|
||||||
using Kurisu.AspNetCore.Utils.Extensions;
|
using Kurisu.AspNetCore.Utils.Extensions;
|
||||||
using Kurisu.Core.DataAccess.Dto;
|
using Kurisu.Core.DataAccess.Dto;
|
||||||
|
using Kurisu.SqlSugar.Attributes;
|
||||||
using Kurisu.SqlSugar.Extensions;
|
using Kurisu.SqlSugar.Extensions;
|
||||||
using Kurisu.SqlSugar.Services;
|
using Kurisu.SqlSugar.Services;
|
||||||
using Mapster;
|
using Mapster;
|
||||||
@@ -34,6 +36,7 @@ public class DeviceService : IDeviceService
|
|||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Transactional]
|
||||||
public async Task SaveAsync(DeviceSaveRequest request)
|
public async Task SaveAsync(DeviceSaveRequest request)
|
||||||
{
|
{
|
||||||
await CheckUniqueNoExistsAsync(request);
|
await CheckUniqueNoExistsAsync(request);
|
||||||
@@ -46,6 +49,21 @@ public class DeviceService : IDeviceService
|
|||||||
entity.Code = Guid.NewGuid();
|
entity.Code = Guid.NewGuid();
|
||||||
entity.Brand = template.Brand;
|
entity.Brand = template.Brand;
|
||||||
await _dbContext.InsertAsync(entity);
|
await _dbContext.InsertAsync(entity);
|
||||||
|
//同时保存注册信息
|
||||||
|
var registry = await _dbContext.Queryable<DeviceRegistryEntity>().Where(x => x.DeviceUniqueNo == request.UniqueNo).FirstAsync();
|
||||||
|
if (registry == null)
|
||||||
|
{
|
||||||
|
registry = new DeviceRegistryEntity()
|
||||||
|
{
|
||||||
|
DeviceUniqueNo = request.UniqueNo,
|
||||||
|
LastHeartbeatTime = DateTime.Now,
|
||||||
|
RegisterTime = DateTime.Now,
|
||||||
|
BusinessPlaceCode = null,
|
||||||
|
BusinessPlaceCustomCode = null,
|
||||||
|
};
|
||||||
|
|
||||||
|
await _dbContext.InsertAsync(registry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -119,5 +137,13 @@ public class DeviceService : IDeviceService
|
|||||||
|
|
||||||
exists.ThrowIfTrue("唯一号已经存在");
|
exists.ThrowIfTrue("唯一号已经存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[IgnoreTenant]
|
||||||
|
public async Task<bool> CheckExistsAsync(string deviceUniqueNo)
|
||||||
|
{
|
||||||
|
return await _dbContext.Queryable<DeviceEntity>()
|
||||||
|
.Where(x => x.UniqueNo == deviceUniqueNo && x.Enable)
|
||||||
|
.AnyAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class MealUserService : IMealUserService
|
|||||||
//todo 获取档案信息
|
//todo 获取档案信息
|
||||||
|
|
||||||
var gainfoEntity = await _gainfoStore.Queryable(GainfoStatusEnumType.Working)
|
var gainfoEntity = await _gainfoStore.Queryable(GainfoStatusEnumType.Working)
|
||||||
.Where(x => x.Guestno.ToString() == request.UserId)
|
.Where(x => x.No.ToString() == request.UserId)
|
||||||
.FirstAsync();
|
.FirstAsync();
|
||||||
|
|
||||||
gainfoEntity.ThrowIfNull($"档案[{request.UserId}]不存在");
|
gainfoEntity.ThrowIfNull($"档案[{request.UserId}]不存在");
|
||||||
@@ -44,7 +44,7 @@ public class MealUserService : IMealUserService
|
|||||||
{
|
{
|
||||||
UserId = request.UserId,
|
UserId = request.UserId,
|
||||||
UserType = request.UserType,
|
UserType = request.UserType,
|
||||||
UserCode = gainfoEntity.Ename,
|
UserCode = gainfoEntity.Code,
|
||||||
CarNo = gainfoEntity.CarNo,
|
CarNo = gainfoEntity.CarNo,
|
||||||
Balance = 0,
|
Balance = 0,
|
||||||
BalanceOfRecharge = 0,
|
BalanceOfRecharge = 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user