日志列表,细节调整
This commit is contained in:
parent
503c1dc950
commit
a863d3772c
|
|
@ -49,7 +49,7 @@ namespace LY.App.Controllers
|
|||
[HttpPost("updata")]
|
||||
public async Task<IActionResult> Updata(UpdateDevice input)
|
||||
{
|
||||
var result = _deviceService.updata(input);
|
||||
var result = await _deviceService.updata(input);
|
||||
return Ok(result);
|
||||
}
|
||||
[HttpDelete("delete")]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
using LY.App.Service;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LY.App.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 日志控制器
|
||||
/// </summary>
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class LogController : ControllerBase
|
||||
{
|
||||
private readonly LogService _logService;
|
||||
public LogController(LogService logService)
|
||||
{
|
||||
_logService = logService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取日志列表
|
||||
/// </summary>
|
||||
/// <param name="pageNum">页码</param>
|
||||
/// <param name="pageSize">页大小</param>
|
||||
/// <param name="key">页大小</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("list")]
|
||||
public async Task<IActionResult> GetLogs(int pageNum = 1, int pageSize = 10, string key = null)
|
||||
{
|
||||
var result = await _logService.List(pageNum, pageSize, key);
|
||||
return Ok(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<!-- 移除多语言文件 -->
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
<!--<SatelliteResourceLanguages>en</SatelliteResourceLanguages>-->
|
||||
<Nullable>disable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
|
|
|
|||
11
Program.cs
11
Program.cs
|
|
@ -102,11 +102,12 @@ app.UseStaticFiles(new StaticFileOptions()
|
|||
RequestPath = "/upload"
|
||||
});
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
//if (app.Environment.IsDevelopment())
|
||||
//{
|
||||
|
||||
//}
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
//·ÓÉÆ¥Åä
|
||||
app.UseRouting();
|
||||
app.UseAuthorization();
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ namespace LY.App.Service
|
|||
/// <param name="pageSize"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<object> List(int pageNum, int pageSize, string key)
|
||||
public async Task<ApiResult> List(int pageNum, int pageSize, string key)
|
||||
{
|
||||
RefAsync<int> total = 0;
|
||||
var items = await _db.Queryable<DeviceEntity>()
|
||||
|
|
@ -40,10 +40,13 @@ namespace LY.App.Service
|
|||
.WhereIF(!string.IsNullOrEmpty(key), s => s.Name.Contains(key) || s.DeviceSN.Contains(key))
|
||||
.OrderByDescending(s => s.Id)
|
||||
.ToPageListAsync(pageNum, pageSize, total);
|
||||
return new
|
||||
return new ApiResult()
|
||||
{
|
||||
total = total.Value,
|
||||
items
|
||||
data = new
|
||||
{
|
||||
total = total.Value,
|
||||
items
|
||||
}
|
||||
};
|
||||
}
|
||||
/// <summary>
|
||||
|
|
@ -137,7 +140,7 @@ namespace LY.App.Service
|
|||
try
|
||||
{
|
||||
var input = JsonConvert.DeserializeObject<RevData>(data);
|
||||
// Console.WriteLine($"rev data:{data}");
|
||||
// Console.WriteLine($"rev data:{data}");
|
||||
await _alarmService.AddAlarm(input);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -165,7 +168,7 @@ namespace LY.App.Service
|
|||
}
|
||||
// 加载阵地信息
|
||||
var position = await _db.Queryable<PositionInfo>()
|
||||
.Where(s=>s.IsDeleted==false).ToListAsync();
|
||||
.Where(s => s.IsDeleted == false).ToListAsync();
|
||||
foreach (var item in position)
|
||||
{
|
||||
var key = RedisKeyList.PositioinRegion(item.Id);
|
||||
|
|
|
|||
|
|
@ -20,5 +20,28 @@ namespace LY.App.Service
|
|||
var entity = input.Adapt<LogEntity>();
|
||||
await _db.Insertable(entity).ExecuteReturnSnowflakeIdAsync();
|
||||
}
|
||||
/// <summary>
|
||||
/// 分页查询
|
||||
/// </summary>
|
||||
/// <param name="pageNum"></param>
|
||||
/// <param name="pageSize"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ApiResult> List(int pageNum, int pageSize, string key)
|
||||
{
|
||||
RefAsync<int> total = 0;
|
||||
var items = await _db.Queryable<LogEntity>()
|
||||
.WhereIF(!string.IsNullOrEmpty(key), s => s.Message.Contains(key))
|
||||
.OrderByDescending(s => s.Id)
|
||||
.ToPageListAsync(pageNum, pageSize, total);
|
||||
return new ApiResult()
|
||||
{
|
||||
data = new
|
||||
{
|
||||
total = total.Value,
|
||||
items
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue