OpenAuth.Net/OpenAuth.App/SysLogs/SysLogApp.cs
yubaolee 9fd0405721 同步openauth.Core:
采用代码生成器的表结构控制前端显示,删除以前按照dbset获取数据库结构
优化注释
升级EF及所有三方的版本
2021-10-18 00:42:29 +08:00

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)
{
}
}
}