Commit 1da7424b authored by hanfeng's avatar hanfeng

修改新闻接口

parent ebd31ce4
...@@ -12,6 +12,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -12,6 +12,7 @@ import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.weekend.WeekendSqls; import tk.mybatis.mapper.weekend.WeekendSqls;
import java.security.SecureRandom;
import java.util.*; import java.util.*;
...@@ -31,6 +32,8 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> { ...@@ -31,6 +32,8 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> {
private final Integer HOME_PAGE_NUMBER = 4; private final Integer HOME_PAGE_NUMBER = 4;
/** /**
* 文章列表 * 文章列表
* *
...@@ -41,7 +44,7 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> { ...@@ -41,7 +44,7 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> {
*/ */
public PageInfo getArticleList(Integer page, Integer limit, Integer type) { public PageInfo getArticleList(Integer page, Integer limit, Integer type) {
PageHelper.startPage(page, limit); PageHelper.startPage(page, limit);
List articleList = mapper.getArticleList(type); List articleList = mapper.getArticleList(type,null);
return PageInfo.of(articleList); return PageInfo.of(articleList);
} }
...@@ -73,7 +76,7 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> { ...@@ -73,7 +76,7 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> {
*/ */
public List getThree(Integer type) { public List getThree(Integer type) {
List<Article> articleList = mapper.getArticleList(type); List<Article> articleList = mapper.getArticleList(type,null);
if (!Objects.isNull(articleList)) { if (!Objects.isNull(articleList)) {
int size = articleList.size(); int size = articleList.size();
if (RANDOM_NUMBER >= size) { if (RANDOM_NUMBER >= size) {
...@@ -100,16 +103,16 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> { ...@@ -100,16 +103,16 @@ public class ArticleBiz extends BaseBiz<ArticleMapper, Article> {
* @return * @return
*/ */
public List getHomePageArticle(Integer type) { public List getHomePageArticle(Integer type) {
List<Article> articleList = mapper.getArticleList(type); List<Article> articleList = mapper.getArticleList(type,HOME_PAGE_NUMBER);
if (Objects.isNull(articleList)) { // if (Objects.isNull(articleList)) {
return new ArrayList(); // return new ArrayList();
} else { // } else {
if (articleList.size() > HOME_PAGE_NUMBER) { // if (articleList.size() > HOME_PAGE_NUMBER) {
return articleList.subList(0, HOME_PAGE_NUMBER); // return articleList.subList(0, HOME_PAGE_NUMBER);
} else { // } else {
return articleList; return articleList;
} // }
} // }
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
......
...@@ -15,5 +15,5 @@ public interface ArticleMapper extends Mapper<Article> { ...@@ -15,5 +15,5 @@ public interface ArticleMapper extends Mapper<Article> {
* @param type * @param type
* @return * @return
*/ */
List<Article> getArticleList(@Param("type") Integer type); List<Article> getArticleList(@Param("type") Integer type,@Param( "limit") Integer limit);
} }
...@@ -5,7 +5,15 @@ ...@@ -5,7 +5,15 @@
<select id="getArticleList" resultType="com.xxfc.platform.uccn.entity.Article"> <select id="getArticleList" resultType="com.xxfc.platform.uccn.entity.Article">
select id, title,epitome,add_time,cover_image from article select id, title,epitome,add_time,cover_image from article
where is_del=0 and status=1 and (type=#{type} or type=0) order by weight ASC ,add_time DESC where
is_del=0
and status=1
and (type=#{type} or type=0)
order by
weight ASC ,add_time DESC
<if test="limit != null">
limit #{limit}
</if>
</select> </select>
</mapper> </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