🚀增加分页模型分页及示例

This commit is contained in:
KaneLeung
2021-03-30 11:09:09 +08:00
parent cad97b37ba
commit 0002cec8b4
8 changed files with 203 additions and 0 deletions

View File

@ -63,6 +63,17 @@ namespace restful.Controllers
return _songRepository.Select.WhereIf(!string.IsNullOrEmpty(key), a => a.Title.Contains(key)).Page(page, limit).ToListAsync();
}
/// <summary>
/// curl -X GET "http://localhost:5000/restapi/Songs/GetPagingItems?key=FreeSql&PageNumber=2&PageSize=10" -H "accept: text/plain"
/// </summary>
/// <param name="pagingInfo"></param>
/// <returns></returns>
[HttpGet("GetPagingItems")]
public Task<List<Song>> GetPagingItems([FromQuery] string key, [FromQuery] PagingInfo pagingInfo)
{
return _songRepository.Select.WhereIf(!string.IsNullOrEmpty(key), a => a.Title.Contains(key)).Page(pagingInfo).ToListAsync();
}
[HttpGet("{id}")]
public Task<Song> GetItem([FromRoute] int id)
{