mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-04-05 17:38:01 +08:00
56 lines
1.7 KiB
C#
56 lines
1.7 KiB
C#
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using OpenAuth.App.Request;
|
|
using OpenAuth.App.Response;
|
|
using OpenAuth.Repository;
|
|
using OpenAuth.Repository.Domain;
|
|
using OpenAuth.Repository.Interface;
|
|
|
|
|
|
namespace OpenAuth.App
|
|
{
|
|
public class SysLogApp : BaseStringApp<SysLog,OpenAuthDBContext>
|
|
{
|
|
|
|
/// <summary>
|
|
/// 加载列表
|
|
/// </summary>
|
|
public async Task<TableData> Load(QuerySysLogListReq request)
|
|
{
|
|
var result = new TableData();
|
|
var objs = UnitWork.Find<SysLog>(null);
|
|
if (!string.IsNullOrEmpty(request.key))
|
|
{
|
|
objs = objs.Where(u => u.Content.Contains(request.key) || u.Id.Contains(request.key));
|
|
}
|
|
|
|
result.data = await objs.OrderByDescending(u => u.CreateTime)
|
|
.Skip((request.page - 1) * request.limit)
|
|
.Take(request.limit).ToListAsync();
|
|
result.count = await objs.CountAsync();
|
|
return result;
|
|
}
|
|
|
|
public void Add(SysLog obj)
|
|
{
|
|
//程序类型取入口应用的名称,可以根据自己需要调整
|
|
obj.Application = Assembly.GetEntryAssembly().FullName.Split(',')[0];
|
|
Repository.Add(obj);
|
|
}
|
|
|
|
public void Update(SysLog obj)
|
|
{
|
|
UnitWork.Update<SysLog>(u => u.Id == obj.Id, u => new SysLog
|
|
{
|
|
//todo:要修改的字段赋值
|
|
});
|
|
|
|
}
|
|
|
|
public SysLogApp(IUnitWork<OpenAuthDBContext> unitWork, IRepository<SysLog,OpenAuthDBContext> repository) : base(unitWork, repository, null)
|
|
{
|
|
}
|
|
}
|
|
} |