ArticleTweetImplService.java 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. package com.happy.service.impl;
  2. import com.happy.Model.*;
  3. import com.happy.dao.ArticleTweetDao;
  4. import com.happy.dto.IPage;
  5. import com.happy.service.ArticleTweetService;
  6. import com.happy.vo.*;
  7. import org.springframework.stereotype.Service;
  8. import javax.annotation.Resource;
  9. import java.util.ArrayList;
  10. import java.util.List;
  11. @Service("ArticleTweetService")
  12. public class ArticleTweetImplService implements ArticleTweetService {
  13. @Resource
  14. public ArticleTweetDao articleTweetDao;
  15. @Override
  16. public ArticleTweet queryArticleById(String id, Integer userId) {
  17. ArticleTweet num = articleTweetDao.queryArticleById(id, userId);
  18. return num;
  19. }
  20. @Override
  21. public int insert(ArticleTweet articleTweet) {
  22. int num = articleTweetDao.insert(articleTweet);
  23. return num;
  24. }
  25. @Override
  26. public int updateArticleApprove(ArticleTweet articleTweet) {
  27. int num = articleTweetDao.updateArticleApprove(articleTweet);
  28. return num;
  29. }
  30. @Override
  31. public int insertArticleFileBatch(List<ArticleFileInfo> articleFileInfos) {
  32. int num = articleTweetDao.insertArticleFileBatch(articleFileInfos);
  33. return num;
  34. }
  35. @Override
  36. public IPage<HotelVo> queryHotelPage(String sqlx, int page, int rows) {
  37. IPage<HotelVo> iPage = new IPage();
  38. List<HotelVo> hotelList = articleTweetDao.queryHotelPage(sqlx, page, rows);
  39. int total = articleTweetDao.queryHotelTotal(sqlx);
  40. iPage.setPageList(hotelList == null ? new ArrayList<>() : hotelList);
  41. iPage.setPage(page);
  42. iPage.setTotalPage((int) Math.ceil((double) total / rows));
  43. iPage.setRows(rows);
  44. iPage.setTotal(total);
  45. return iPage;
  46. }
  47. @Override
  48. public List<HotelVo> queryHotels(String sqlx) {
  49. List<HotelVo> hotels = articleTweetDao.queryHotels(sqlx);
  50. return hotels;
  51. }
  52. @Override
  53. public IPage<HotelVo> queryHotelPageByHotleId(String sqlx, int page, int rows) {
  54. IPage<HotelVo> iPage = new IPage();
  55. List<HotelVo> hotelList = articleTweetDao.queryHotelPageByHotleId(sqlx, page, rows);
  56. int total = articleTweetDao.queryHotelTotalByHotleId(sqlx);
  57. iPage.setPageList(hotelList == null ? new ArrayList<>() : hotelList);
  58. iPage.setPage(page);
  59. iPage.setTotalPage((int) Math.ceil((double) total / rows));
  60. iPage.setRows(rows);
  61. iPage.setTotal(total);
  62. return iPage;
  63. }
  64. @Override
  65. public List<FileInfo> queryList(String sqlx) {
  66. List<FileInfo> result = articleTweetDao.queryList(sqlx);
  67. return result;
  68. }
  69. @Override
  70. public UserCollect queryUserCollect(Integer parentId, Integer userId) {
  71. UserCollect result = articleTweetDao.queryUserCollect(parentId, userId);
  72. return result;
  73. }
  74. @Override
  75. public List<LikeListVo> queryArticleLikes(Integer articleId) {
  76. List<LikeListVo> result = articleTweetDao.queryArticleLikes(articleId);
  77. return result;
  78. }
  79. @Override
  80. public List<ArticleCommentVo> queryArticleComment(Integer articleId) {
  81. List<ArticleCommentVo> result = articleTweetDao.queryArticleComment(articleId);
  82. return result;
  83. }
  84. @Override
  85. public int queryArticleCommentTotal(Integer articleId) {
  86. int result = articleTweetDao.queryArticleCommentTotal(articleId);
  87. return result;
  88. }
  89. @Override
  90. public IPage<ArticleCommentVo> queryCommentPageByArticle(Integer articleId, int page, int rows) {
  91. IPage<ArticleCommentVo> iPage = new IPage();
  92. List<ArticleCommentVo> commentList = articleTweetDao.queryCommentPageByArticle(articleId, page, rows);
  93. int total = articleTweetDao.queryCommentTotalByArticle(articleId);
  94. iPage.setPageList(commentList == null ? new ArrayList<>() : commentList);
  95. iPage.setPage(page);
  96. iPage.setTotalPage((int) Math.ceil((double) total / rows));
  97. iPage.setRows(rows);
  98. iPage.setTotal(total);
  99. return iPage;
  100. }
  101. @Override
  102. public List<ArticleCommentVo> queryCommentsByArticle(Integer articleId) {
  103. List<ArticleCommentVo> result = articleTweetDao.queryCommentsByArticle(articleId);
  104. return result;
  105. }
  106. @Override
  107. public articleUserVo queryUserInfo(Integer userId) {
  108. articleUserVo result = articleTweetDao.queryUserInfo(userId);
  109. return result;
  110. }
  111. @Override
  112. public IPage<OwnerArticleVo> queryOwnerArticlePage(Integer userId, String sqlWhere, int page, int rows) {
  113. IPage<OwnerArticleVo> iPage = new IPage();
  114. List<OwnerArticleVo> commentList = articleTweetDao.queryOwnerArticlePage(userId, sqlWhere, page, rows);
  115. int total = articleTweetDao.queryOwnerArticleTotal(userId, sqlWhere);
  116. iPage.setPageList(commentList == null ? new ArrayList<>() : commentList);
  117. iPage.setPage(page);
  118. iPage.setTotalPage((int) Math.ceil((double) total / rows));
  119. iPage.setRows(rows);
  120. iPage.setTotal(total);
  121. return iPage;
  122. }
  123. @Override
  124. public IPage<ArticleListVo> queryArticlesPage(String keyWord, String townId, Integer userId, Integer type, int page, int rows) {
  125. IPage<ArticleListVo> iPage = new IPage();
  126. List<ArticleListVo> commentList = articleTweetDao.queryArticlesPage(keyWord, townId, userId, type, page, rows);
  127. int total = articleTweetDao.queryArticlesTotal(keyWord, townId, userId, type);
  128. iPage.setPageList(commentList == null ? new ArrayList<>() : commentList);
  129. iPage.setPage(page);
  130. iPage.setTotalPage((int) Math.ceil((double) total / rows));
  131. iPage.setRows(rows);
  132. iPage.setTotal(total);
  133. return iPage;
  134. }
  135. @Override
  136. public IPage<ArticleListVo> relatedTweetPage(Integer userId, String townId, Integer articleId, int page, int rows) {
  137. IPage<ArticleListVo> iPage = new IPage();
  138. List<ArticleListVo> commentList = articleTweetDao.relatedTweetPage(userId, townId, articleId, page, rows);
  139. int total = articleTweetDao.relatedTweetTotal(townId, articleId);
  140. iPage.setPageList(commentList == null ? new ArrayList<>() : commentList);
  141. iPage.setPage(page);
  142. iPage.setTotalPage((int) Math.ceil((double) total / rows));
  143. iPage.setRows(rows);
  144. iPage.setTotal(total);
  145. return iPage;
  146. }
  147. @Override
  148. public ArticleCollect queryArticleCollect(Integer articleId, Integer userId) {
  149. ArticleCollect result = articleTweetDao.queryArticleCollect(articleId, userId);
  150. return result;
  151. }
  152. @Override
  153. public int updateArticleCollect(ArticleCollect articleCollect) {
  154. int result = articleTweetDao.updateArticleCollect(articleCollect);
  155. return result;
  156. }
  157. ;
  158. @Override
  159. public int insertArticleComment(ArticleComment articleComment) {
  160. int result = articleTweetDao.insertArticleComment(articleComment);
  161. return result;
  162. }
  163. /**
  164. * 查询用户关注记录数据
  165. *
  166. * @param authorId
  167. * @param userId
  168. * @return
  169. */
  170. public UserCollect queryUserCollectNoLose(Integer authorId, Integer userId) {
  171. UserCollect result = articleTweetDao.queryUserCollectNoLose(authorId, userId);
  172. return result;
  173. }
  174. /**
  175. * 关注或取消关注操作
  176. *
  177. * @param userCollect
  178. * @return
  179. */
  180. public int updateUserCollect(UserCollect userCollect) {
  181. int result = articleTweetDao.updateUserCollect(userCollect);
  182. return result;
  183. }
  184. /**
  185. * 查询用户点赞记录数据
  186. *
  187. * @param articleId
  188. * @param userId
  189. * @return
  190. */
  191. public ArticleLikes queryArticleLike(Integer articleId, Integer userId) {
  192. ArticleLikes result = articleTweetDao.queryArticleLike(articleId, userId);
  193. return result;
  194. }
  195. /**
  196. * 点赞文章
  197. *
  198. * @param articleLikes
  199. * @return
  200. */
  201. public int updateArticleLike(ArticleLikes articleLikes) {
  202. int num = articleTweetDao.updateArticleLike(articleLikes);
  203. return num;
  204. }
  205. /**
  206. * 更新用户简介
  207. *
  208. * @param authorId
  209. * @param descript
  210. * @return
  211. */
  212. public int updateDescript(Integer authorId, String descript) {
  213. int num = articleTweetDao.updateDescript(authorId, descript);
  214. return num;
  215. }
  216. @Override
  217. public IPage<LikeListVo> queryLikesPage(Integer articleId, int page, int rows) {
  218. IPage<LikeListVo> iPage = new IPage();
  219. List<LikeListVo> commentList = articleTweetDao.queryLikesPage(articleId, page, rows);
  220. int total = articleTweetDao.queryLikesTotal(articleId);
  221. iPage.setPageList(commentList == null ? new ArrayList<>() : commentList);
  222. iPage.setPage(page);
  223. iPage.setTotalPage((int) Math.ceil((double) total / rows));
  224. iPage.setRows(rows);
  225. iPage.setTotal(total);
  226. return iPage;
  227. }
  228. @Override
  229. public ArticleLikeMaxVo queryMaxArticleLike() {
  230. ArticleLikeMaxVo result = articleTweetDao.queryMaxArticleLike();
  231. return result;
  232. }
  233. @Override
  234. public IPage<WalkthroughVo> walkthroughPage(String strSql, Integer page, Integer rows) {
  235. IPage<WalkthroughVo> iPage = new IPage();
  236. List<WalkthroughVo> commentList = articleTweetDao.walkthroughPage(strSql, page, rows);
  237. int total = articleTweetDao.walkthroughTotal(strSql);
  238. iPage.setPageList(commentList == null ? new ArrayList<>() : commentList);
  239. iPage.setPage(page);
  240. iPage.setTotalPage((int) Math.ceil((double) total / rows));
  241. iPage.setRows(rows);
  242. iPage.setTotal(total);
  243. return iPage;
  244. }
  245. @Override
  246. public List<ArticleLikeMaxVo> queryTop3ArticleLike() {
  247. List<ArticleLikeMaxVo> result = articleTweetDao.queryTop3ArticleLike();
  248. return result;
  249. }
  250. }