|
|
@@ -226,10 +226,44 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
|
|
|
|
|
|
@Override
|
|
|
+ public List<LikeListVo> queryLikesPage(Integer articleId, int page, int rows) {
|
|
|
+ int start = (page - 1) * rows;// 每页的起始下标
|
|
|
+ String sql = "select (select IFNULL(count(*),0) from article_tweet where user_id = al.like_id) as article_number,(select IFNULL(count(*),0) from user_collect where is_lose = 0 and parent_userid = al.like_id) as fans_number,al.like_id as id,al.like_image as image,al.like_name as name " +
|
|
|
+ "from article_likes al\n" +
|
|
|
+ "where al.is_lose = 0 and al.article_id = :articleId order by al.create_date desc limit :start,:rows";
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
+ sps.addValue("start", start);
|
|
|
+ sps.addValue("rows", rows);
|
|
|
+ sps.addValue("articleId", articleId);
|
|
|
+ List<LikeListVo> list = null;
|
|
|
+ try {
|
|
|
+ list = namedParameterJdbcTemplate.query(sql, sps, new BeanPropertyRowMapper<>(LikeListVo.class));
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int queryLikesTotal(Integer articleId) {
|
|
|
+ String sql ="select count(*) from article_likes " +
|
|
|
+ "where is_lose = 0 and article_id = :articleId order by create_date desc";
|
|
|
+ MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
+ sps.addValue("articleId", articleId);
|
|
|
+
|
|
|
+ return namedParameterJdbcTemplate.queryForInt(sql, sps);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
public List<LikeListVo> queryArticleLikes(Integer articleId) {
|
|
|
String sql = "select (select IFNULL(count(*),0) from article_tweet where user_id = al.like_id) as article_number,(select IFNULL(count(*),0) from user_collect where is_lose = 0 and parent_userid = al.like_id) as fans_number,al.like_id as id,al.like_image as image,al.like_name as name " +
|
|
|
"from article_likes al\n" +
|
|
|
- "where al.is_lose = 0 and al.article_id = :articleId order by al.create_date desc limit 0,10";
|
|
|
+ "where al.is_lose = 0 and al.article_id = :articleId order by al.create_date desc";
|
|
|
MapSqlParameterSource sps = new MapSqlParameterSource();
|
|
|
sps.addValue("articleId", articleId);
|
|
|
List<LikeListVo> list = null;
|
|
|
@@ -244,6 +278,7 @@ public class ArticleTweetImplDao implements ArticleTweetDao {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
public List<ArticleCommentVo> queryArticleComment(Integer articleId) {
|
|
|
String sql = "select id,comment_parent_id as parent_id,comment_id as user_id,comment_name as user_name,comment_image as image,content,create_date as date " +
|