Commit ad97f753 authored by hanfeng's avatar hanfeng

修改新闻接口

parent 0af95d09
......@@ -44,7 +44,7 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> {
*/
public PageInfo getArticleList(Integer page, Integer limit, Integer type) {
PageHelper.startPage(page, limit);
List articleList = mapper.getArticleList(type,null);
List articleList = mapper.getArticleList(type,null,null);
return PageInfo.of(articleList);
}
......@@ -71,12 +71,15 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> {
/**
* 随机获取三条连续的文章
*
*
*
* @param type
* @param id
* @return
*/
public List getThree(Integer type) {
public List getThree( Integer type,Integer id) {
List<Article> articleList = mapper.getArticleList(type,null);
List<Article> articleList = mapper.getArticleList(type,null,id);
if (!Objects.isNull(articleList)) {
int size = articleList.size();
if (RANDOM_NUMBER >= size) {
......@@ -103,7 +106,7 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> {
* @return
*/
public List getHomePageArticle(Integer type) {
List<Article> articleList = mapper.getArticleList(type,HOME_PAGE_NUMBER);
List<Article> articleList = mapper.getArticleList(type,HOME_PAGE_NUMBER,null);
// if (Objects.isNull(articleList)) {
// return new ArrayList();
// } else {
......
......@@ -11,9 +11,11 @@ import java.util.List;
*/
public interface ArticleMapper extends Mapper<Article> {
/**
* 根据网站类型查询文章
* 获取获取文章信息
* @param type
* @param limit 已使用分业插件传null值即可,不要重复传
* @param id 当前文章id ,无就传null
* @return
*/
List<Article> getArticleList(@Param("type") Integer type,@Param( "limit") Integer limit);
List<Article> getArticleList(@Param("type") Integer type,@Param( "limit") Integer limit,@Param("id") Integer id);
}
......@@ -36,11 +36,16 @@ public class ArticleController extends BaseController<ArticleBiz, Article> {
return ObjectRestResponse.succ(baseBiz.getOne(id,urlType));
}
@GetMapping("/app/unauth/three/{type}")
/**
*
* @param type
* @param id 当前文章id
* @return
*/
@GetMapping("/app/unauth/three/{type}/{id}")
@ApiOperation(value = "随机获取三条数据")
public ObjectRestResponse randomAccessToThreeData(@PathVariable Integer type){
return ObjectRestResponse.succ(baseBiz.getThree(type));
public ObjectRestResponse randomAccessToThreeData(@PathVariable Integer type,@PathVariable Integer id){
return ObjectRestResponse.succ(baseBiz.getThree(type,id));
}
@GetMapping("/app/unauth/homePage/{type}")
......
......@@ -8,12 +8,18 @@
where
is_del=0
and status=1
<if test="id != null">
and id != #{id}
</if>
and (type=#{type} or type=0)
order by
weight ASC ,add_time DESC
<if test="limit != null">
limit #{limit}
</if>
</select>
</mapper>
\ No newline at end of file
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