diff --git a/Controllers/HomeController.cs b/Controllers/HomeController.cs
index 5400e01..de97d07 100644
--- a/Controllers/HomeController.cs
+++ b/Controllers/HomeController.cs
@@ -7,6 +7,9 @@ using Microsoft.AspNetCore.Mvc;
namespace LY.App.Controllers
{
+ ///
+ /// 首页控制器
+ ///
[Route("api/[controller]")]
[ApiController]
public class HomeController : ControllerBase
@@ -15,6 +18,12 @@ namespace LY.App.Controllers
private readonly DeviceManager deviceManager = DeviceManager.Instance;
private readonly PositionService _positionService;
private readonly RedisService _redisService;
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public HomeController(DeviceService deviceService, PositionService positionService, RedisService redisService)
{
_deviceService = deviceService;
@@ -30,6 +39,13 @@ namespace LY.App.Controllers
{
ApiResult result = new ApiResult();
var positions = await _positionService.Index();
+ positions.ForEach(async p =>
+ {
+ foreach (var item in p.Devices)
+ {
+ item.IsOnline = await _redisService.ExistsAsync(RedisKeyList.DeviceStatus(item.DeviceSN));
+ }
+ });
result.data = new
{
positions
diff --git a/Model/PositionDeviceDto.cs b/Model/PositionDeviceDto.cs
index 211d0e0..6841382 100644
--- a/Model/PositionDeviceDto.cs
+++ b/Model/PositionDeviceDto.cs
@@ -17,6 +17,6 @@ namespace LY.App.Model
public double Lat { get; set; }
public double Lon { get; set; }
public string Model { get; set; }
-
+ public bool IsOnline { get; set; }
}
}
diff --git a/Service/UserService.cs b/Service/UserService.cs
index c06d684..a6863df 100644
--- a/Service/UserService.cs
+++ b/Service/UserService.cs
@@ -25,6 +25,11 @@ namespace LY.App.Service
}
#region 增删改查
+ ///
+ ///
+ ///
+ ///
+ ///
public async Task Add(AddUser input)
{
var exists = await _db.Queryable().AnyAsync(s => s.Name == input.Name && s.Disable == false);
@@ -67,6 +72,11 @@ namespace LY.App.Service
}
return "ids不能为空";
}
+ ///
+ /// 获取用户信息
+ ///
+ ///
+ ///
public async Task GetUserById(long userId)
{
var entity = await _db.Queryable().FirstAsync(s => s.Id == userId);
@@ -95,6 +105,11 @@ namespace LY.App.Service
}
return false;
}
+ ///
+ /// 登录
+ ///
+ ///
+ ///
public async Task Login(LoginModel input)
{
if (await CheckLoginNum(input.username))
@@ -186,7 +201,10 @@ namespace LY.App.Service
{
RefAsync total = 0;
var query = await _db.Queryable()
- .Where(s => s.Disable == false).ToPageListAsync(pageNum, pageSize, total);
+ .Where(s => s.Disable == false)
+ .WhereIF(!string.IsNullOrEmpty(key), s => s.Name.Contains(key))
+ .OrderBy(s => s.Id)
+ .ToPageListAsync(pageNum, pageSize, total);
return new
{
total = total.Value,
diff --git a/appsettings.json b/appsettings.json
index 36b653f..5ebb9fb 100644
--- a/appsettings.json
+++ b/appsettings.json
@@ -27,6 +27,6 @@
"ConnectionString": "101.43.201.20:6379,password=Aa123,abortConnect =false"
},
"Vertify": 5, //登录失败次数
- "BatchId": 60, //无人机批次连续时间
- "SnowFlakeWordId": 1 //雪花算法的wordId,多台服务器时,需要配置不同的wordId,最多32个节点,可以考虑加到环境变量中
+ "BatchId": 60, //无人机批次连续时间,如果超过这个时间,则变成下一个批次
+ "SnowFlakeWordId": 1 //雪花算法的wordId,多台服务器时,需要配置不同的wordId,
}