Infrastructure/OpenAuth.App/ServiceApp/IdleNongJi/IdleNongjiApp.cs

69 lines
1.6 KiB
C#

using OpenAuth.App.Interface;
using OpenAuth.App.Response;
using OpenAuth.Repository.Domain;
using Infrastructure;
using OpenAuth.App.Request;
using OpenAuth.Repository;
using SqlSugar;
namespace OpenAuth.App
{
public class IdleNongjiApp : SqlSugarBaseApp<IdleNongji, SugarDbContext>
{
public IdleNongjiApp(
ISugarUnitOfWork<SugarDbContext> unitWork,
ISimpleClient<IdleNongji> repository,
IAuth auth
) : base(unitWork, repository, auth)
{
}
#region 查询
/// <summary>
/// 分页
/// </summary>
public async Task<Response<PageInfo<List<IdleNongji>>>> LoadPage(PageReq request)
{
RefAsync<int> totalCount = 0;
var result = new PageInfo<IdleNongji>();
var list = await base.Repository.AsQueryable()
.WhereIF(!string.IsNullOrEmpty(request.key), a => a.Id.Contains(request.key))
.OrderByDescending(a => a.CreationTime)
.ToPageListAsync(request.page, request.limit, totalCount);
return new Response<PageInfo<List<IdleNongji>>>
{
Result = new PageInfo<List<IdleNongji>>
{
Items = list,
Total = totalCount
}
};
}
/// <summary>
/// 详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<IdleNongji> Detail(string id)
{
return await Repository.GetByIdAsync(id);
}
#endregion
}
}