细节调整
This commit is contained in:
		
							parent
							
								
									a22e22a15b
								
							
						
					
					
						commit
						3623be9c45
					
				| 
						 | 
					@ -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
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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; }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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 //雪花算法的wordId,多台服务器时,需要配置不同的wordId,最多32个节点,可以考虑加到环境变量中
 | 
					  "SnowFlakeWordId": 1 //雪花算法的wordId,多台服务器时,需要配置不同的wordId,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue