|
@@ -104,7 +104,7 @@ namespace Masuit.MyBlogs.Core.Controllers
|
|
|
/// <param name="size"></param>
|
|
|
/// <param name="orderBy"></param>
|
|
|
/// <returns></returns>
|
|
|
- [Route("tag/{id}/{page:int?}/{size:int?}/{orderBy:int?}"), ResponseCache(Duration = 600, VaryByQueryKeys = new[] { "id", "page", "size", "orderBy" }, VaryByHeader = "Cookie")]
|
|
|
+ [Route("tag/{id}"), ResponseCache(Duration = 600, VaryByQueryKeys = new[] { "page", "size", "orderBy" }, VaryByHeader = "Cookie")]
|
|
|
public async Task<ActionResult> Tag(string id, [Optional] OrderBy? orderBy, [Range(1, int.MaxValue, ErrorMessage = "页码必须大于0")] int page = 1, [Range(1, 50, ErrorMessage = "页大小必须在0到50之间")] int size = 15)
|
|
|
{
|
|
|
var posts = await PostService.GetQuery<PostDto>(p => p.Label.Contains(id) && (p.Status == Status.Published || CurrentUser.IsAdmin)).OrderBy($"{nameof(PostDto.IsFixedTop)} desc,{(orderBy ?? OrderBy.ModifyDate).GetDisplay()} desc").ToCachedPagedListAsync(page, size);
|
|
@@ -124,7 +124,7 @@ namespace Masuit.MyBlogs.Core.Controllers
|
|
|
/// <param name="size"></param>
|
|
|
/// <param name="orderBy"></param>
|
|
|
/// <returns></returns>
|
|
|
- [Route("author/{author}/{page:int?}/{size:int?}/{orderBy:int?}"), ResponseCache(Duration = 600, VaryByQueryKeys = new[] { "author", "page", "size", "orderBy" }, VaryByHeader = "Cookie")]
|
|
|
+ [Route("author/{author}"), ResponseCache(Duration = 600, VaryByQueryKeys = new[] { "page", "size", "orderBy" }, VaryByHeader = "Cookie")]
|
|
|
public async Task<ActionResult> Author(string author, [Optional] OrderBy? orderBy, [Range(1, int.MaxValue, ErrorMessage = "页码必须大于0")] int page = 1, [Range(1, 50, ErrorMessage = "页大小必须在0到50之间")] int size = 15)
|
|
|
{
|
|
|
Expression<Func<Post, bool>> where = p => p.Author.Equals(author) || p.Modifier.Equals(author) || p.Email.Equals(author) || p.PostHistoryVersion.Any(v => v.Modifier.Equals(author) || v.ModifierEmail.Equals(author));
|
|
@@ -147,8 +147,7 @@ namespace Masuit.MyBlogs.Core.Controllers
|
|
|
/// <param name="size"></param>
|
|
|
/// <param name="orderBy"></param>
|
|
|
/// <returns></returns>
|
|
|
- [Route("cat/{id:int}"), ResponseCache(Duration = 600, VaryByQueryKeys = new[] { "id", "page", "size", "orderBy" }, VaryByHeader = "Cookie")]
|
|
|
- [Route("cat/{id:int}/{page:int?}/{size:int?}/{orderBy:int?}")]
|
|
|
+ [Route("cat/{id:int}"), ResponseCache(Duration = 600, VaryByQueryKeys = new[] { "page", "size", "orderBy" }, VaryByHeader = "Cookie")]
|
|
|
public async Task<ActionResult> Category(int id, [Optional] OrderBy? orderBy, [Range(1, int.MaxValue, ErrorMessage = "页码必须大于0")] int page = 1, [Range(1, 50, ErrorMessage = "页大小必须在0到50之间")] int size = 15)
|
|
|
{
|
|
|
var cat = await CategoryService.GetByIdAsync(id) ?? throw new NotFoundException("文章分类未找到");
|