Commit 13d4f81c by 段启岩

Merge remote-tracking branch 'origin/fix-issue#20'

parents 21929db8 2c095ab5
...@@ -19,6 +19,7 @@ import io.swagger.annotations.Api; ...@@ -19,6 +19,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -151,4 +152,13 @@ public class BlogApi { ...@@ -151,4 +152,13 @@ public class BlogApi {
return Response.error(e); return Response.error(e);
} }
} }
@Anonymous
@ApiOperation("热门博客")
@GetMapping("/blog/hots")
public Response<PageVO<Blog>> getHotBlogs (@Valid PageForm pageForm) {
IPage<Blog> blogPage = blogService.getHotBlogPage(pageForm.getPage(), pageForm.getSize());
PageVO<Blog> blogPageVO = new PageVO<>(blogPage);
return Response.success(blogPageVO);
}
} }
...@@ -80,6 +80,12 @@ public interface IBlogService extends IService<Blog> { ...@@ -80,6 +80,12 @@ public interface IBlogService extends IService<Blog> {
*/ */
void updateBlog(Blog blog , String content , List<String> topicIds , List<String> tagIds) throws BlogServiceException, BlogCategoryServiceException; void updateBlog(Blog blog , String content , List<String> topicIds , List<String> tagIds) throws BlogServiceException, BlogCategoryServiceException;
/**
* 热门博客列表
* @param pageNumber
* @param pageSize
* @return
*/
IPage<Blog> getHotBlogPage(Integer pageNumber , Integer pageSize);
} }
...@@ -420,4 +420,12 @@ public class BlogServiceImpl extends ServiceImpl<BlogMapper, Blog> implements IB ...@@ -420,4 +420,12 @@ public class BlogServiceImpl extends ServiceImpl<BlogMapper, Blog> implements IB
} }
} }
@Override
public IPage<Blog> getHotBlogPage(Integer pageNumber, Integer pageSize) {
QueryWrapper blogQueryWrapper = new QueryWrapper();
blogQueryWrapper.orderByDesc("view_number");
IPage<Blog> page = new Page<>(pageNumber, pageSize);
return blogMapper.selectPageWithTags(page, blogQueryWrapper);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment