48 lines
1.4 KiB
C#
48 lines
1.4 KiB
C#
using Azure.Core;
|
|
using LY.App.Extensions.DI;
|
|
using LY.App.Model;
|
|
using Mapster;
|
|
using SqlSugar;
|
|
using System.Security.AccessControl;
|
|
|
|
namespace LY.App.Service
|
|
{
|
|
[ServiceInjection(InjectionType.Transient)]
|
|
public class LogService
|
|
{
|
|
private readonly SqlSugarClient _db;
|
|
public LogService(SqlSugarClient sqlSugarClient)
|
|
{
|
|
_db = sqlSugarClient;
|
|
}
|
|
public async Task AddLog(AddLog input)
|
|
{
|
|
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
|
|
}
|
|
};
|
|
}
|
|
}
|
|
}
|