细节调整

This commit is contained in:
yanghongwei 2025-03-24 10:59:34 +08:00
parent a22e22a15b
commit 3623be9c45
4 changed files with 38 additions and 4 deletions

View File

@ -7,6 +7,9 @@ using Microsoft.AspNetCore.Mvc;
namespace LY.App.Controllers namespace LY.App.Controllers
{ {
/// <summary>
/// 首页控制器
/// </summary>
[Route("api/[controller]")] [Route("api/[controller]")]
[ApiController] [ApiController]
public class HomeController : ControllerBase public class HomeController : ControllerBase
@ -15,6 +18,12 @@ namespace LY.App.Controllers
private readonly DeviceManager deviceManager = DeviceManager.Instance; private readonly DeviceManager deviceManager = DeviceManager.Instance;
private readonly PositionService _positionService; private readonly PositionService _positionService;
private readonly RedisService _redisService; private readonly RedisService _redisService;
/// <summary>
///
/// </summary>
/// <param name="deviceService"></param>
/// <param name="positionService"></param>
/// <param name="redisService"></param>
public HomeController(DeviceService deviceService, PositionService positionService, RedisService redisService) public HomeController(DeviceService deviceService, PositionService positionService, RedisService redisService)
{ {
_deviceService = deviceService; _deviceService = deviceService;
@ -30,6 +39,13 @@ namespace LY.App.Controllers
{ {
ApiResult result = new ApiResult(); ApiResult result = new ApiResult();
var positions = await _positionService.Index(); 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 result.data = new
{ {
positions positions

View File

@ -17,6 +17,6 @@ namespace LY.App.Model
public double Lat { get; set; } public double Lat { get; set; }
public double Lon { get; set; } public double Lon { get; set; }
public string Model { get; set; } public string Model { get; set; }
public bool IsOnline { get; set; }
} }
} }

View File

@ -25,6 +25,11 @@ namespace LY.App.Service
} }
#region #region
/// <summary>
///
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<ApiResult> Add(AddUser input) public async Task<ApiResult> Add(AddUser input)
{ {
var exists = await _db.Queryable<UserEntity>().AnyAsync(s => s.Name == input.Name && s.Disable == false); var exists = await _db.Queryable<UserEntity>().AnyAsync(s => s.Name == input.Name && s.Disable == false);
@ -67,6 +72,11 @@ namespace LY.App.Service
} }
return "ids不能为空"; return "ids不能为空";
} }
/// <summary>
/// 获取用户信息
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public async Task<ApiResult> GetUserById(long userId) public async Task<ApiResult> GetUserById(long userId)
{ {
var entity = await _db.Queryable<UserEntity>().FirstAsync(s => s.Id == userId); var entity = await _db.Queryable<UserEntity>().FirstAsync(s => s.Id == userId);
@ -95,6 +105,11 @@ namespace LY.App.Service
} }
return false; return false;
} }
/// <summary>
/// 登录
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public async Task<ApiResult> Login(LoginModel input) public async Task<ApiResult> Login(LoginModel input)
{ {
if (await CheckLoginNum(input.username)) if (await CheckLoginNum(input.username))
@ -186,7 +201,10 @@ namespace LY.App.Service
{ {
RefAsync<int> total = 0; RefAsync<int> total = 0;
var query = await _db.Queryable<UserEntity>() var query = await _db.Queryable<UserEntity>()
.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 return new
{ {
total = total.Value, total = total.Value,

View File

@ -27,6 +27,6 @@
"ConnectionString": "101.43.201.20:6379,password=Aa123,abortConnect =false" "ConnectionString": "101.43.201.20:6379,password=Aa123,abortConnect =false"
}, },
"Vertify": 5, // "Vertify": 5, //
"BatchId": 60, // "BatchId": 60, //,
"SnowFlakeWordId": 1 //wordIdwordId32 "SnowFlakeWordId": 1 //wordIdwordId
} }