From 32d6c2ea8039b4771fd6b1ded8b022733e32352f Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期六, 03 四月 2021 18:56:57 +0800
Subject: [PATCH] 首页瀑布流

---
 src/main/java/com/yeshi/buwan/service/imp/HomeTypeService.java |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/src/main/java/com/yeshi/buwan/service/imp/HomeTypeService.java b/src/main/java/com/yeshi/buwan/service/imp/HomeTypeService.java
index ca47e0b..801b765 100644
--- a/src/main/java/com/yeshi/buwan/service/imp/HomeTypeService.java
+++ b/src/main/java/com/yeshi/buwan/service/imp/HomeTypeService.java
@@ -86,7 +86,7 @@
                                 ht.setIosControl(obj[6] + "");
                                 ht.setNumber(Integer.parseInt(obj[7] + ""));
                                 ht.setRefreshPosition(Integer.parseInt(obj[25] + ""));
-                                ht.setMoreTag(obj[26]+"");
+                                ht.setMoreTag(obj[26] + "");
 
 
                                 ht.setOrderby(obj[21] + "");
@@ -96,7 +96,7 @@
                                 hv.setId(obj[8] + "");
                                 hv.setPicture(obj[10] + "");
                                 hv.setTag(obj[11] + "");
-                                hv.setBigPicture(Integer.parseInt(obj[24] + "")>0);
+                                hv.setBigPicture(Integer.parseInt(obj[24] + "") > 0);
 
                                 VideoInfo video = new VideoInfo();
                                 video.setId(obj[12] + "");
@@ -203,6 +203,17 @@
         return homeTypeList;
     }
 
+    @Cacheable(value = "homeCache", key = "'getHomeTypeList'+'-'+#detailSystem+'-'+#version+'-'+#dataKey+'-'+#page+'-'+#pageSize")
+    public List<HomeType> getHomeTypeList(String detailSystem, int version, String dataKey, int page, int pageSize) {
+        return homeTypeDao.list("select sht.homeType from SuperHomeType sht where sht.detailSystem.id=? and sht.homeType.specialDataKey=? order by sht.homeType.orderby DESC,sht.homeType.createtime DESC", (page - 1) * pageSize, pageSize, new Serializable[]{detailSystem, dataKey});
+    }
+
+    @Cacheable(value = "homeCache", key = "'countHomeType'+'-'+#detailSystem+'-'+#version+'-'+#dataKey")
+    public long countHomeType(String detailSystem, int version, String dataKey) {
+        return homeTypeDao.getCount("select count(*) from SuperHomeType sht where sht.detailSystem.id=? and sht.homeType.specialDataKey=?", new Serializable[]{detailSystem, dataKey});
+    }
+
+
     private void orderByType(List<HomeType> homeTypeList) {
         Collections.sort(homeTypeList, new Comparator<HomeType>() {
             public int compare(HomeType o1, HomeType o2) {
@@ -210,6 +221,7 @@
             }
         });
     }
+
 
     private int index(List<HomeType> list, HomeType ht) {
         if (list == null)
@@ -353,7 +365,8 @@
     }
 
 
-    public List<HomeVideo> getHomeVideoList(String homeId, List<Long> resourceIds, Boolean bigPicture, int page, int pageSize) {
+    @Cacheable(value = "homeCache", key = "'getHomeVideoList-'+#homeId+'-'+#resourceKey+'-'+#bigPicture+'-'+#page+'-'+#pageSize")
+    public List<HomeVideo> getHomeVideoList(String homeId, String resourceKey, List<Long> resourceIds, Boolean bigPicture, int page, int pageSize) {
         List<HomeVideo> homeVideos = (List<HomeVideo>) homeVideoDao.excute(new HibernateCallback<List<HomeVideo>>() {
             @Override
             public List<HomeVideo> doInHibernate(Session session) throws HibernateException {
@@ -383,8 +396,8 @@
         return homeVideos;
     }
 
-
-    public long getHomeVideoListCount(String homeId, List<Long> resourceIds, Boolean bigPicture) {
+    @Cacheable(value = "homeCache", key = "'getHomeVideoListCount'+'-'+#resourceKey+'-'+#bigPicture")
+    public long getHomeVideoListCount(String homeId, String resourceKey, List<Long> resourceIds, Boolean bigPicture) {
         return (Long) homeVideoDao.excute(new HibernateCallback<Long>() {
             @Override
             public Long doInHibernate(Session session) throws HibernateException {

--
Gitblit v1.8.0