From 77e706cca33c97a4428879cc9a6f98aae085c142 Mon Sep 17 00:00:00 2001
From: admin <2780501319@qq.com>
Date: 星期六, 24 四月 2021 00:35:13 +0800
Subject: [PATCH] 0元购完善

---
 src/main/java/com/yeshi/buwan/service/imp/HomeTypeService.java |   35 ++++++++++++++++++++++++-----------
 1 files changed, 24 insertions(+), 11 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..e548bf1 100644
--- a/src/main/java/com/yeshi/buwan/service/imp/HomeTypeService.java
+++ b/src/main/java/com/yeshi/buwan/service/imp/HomeTypeService.java
@@ -66,7 +66,7 @@
                                 resourceWhere = resourceWhere.substring(0, resourceWhere.length() - 2);
                             List resultList = session
                                     .createSQLQuery(
-                                            "SELECT  ht.`id` as htid,ht.`name` as htname,ht.`columns` as htcolumns ,ht.`hasmore`,ht.`activity` ,ht.`params` ,ht.`ioscontrol`,ht.number,hvideo.id as hvid,hvideo.`videoid` AS hvvideoid,hvideo.`picture`as hvpicture ,hvideo.`tag` as hvtag,    v.`id` as vid ,v.`picture` as vpicture ,v.`name` as vname ,v.`tag` as vtag ,v.`hpicture` as vhpicture ,v.`latest_hpicture` as vlatest_hpicture ,v.`watchcount` as vwatchcount,v.commentcount,ht.icon as hicon,ht.orderby as htorder,hvideo.orderby as hvorder,need_ad,big_picture,refresh_position,more_tag FROM   (SELECT hv.* FROM `wk_resource_video` rv LEFT JOIN `wk_video_homevideo` hv ON rv.`videoid` =hv.`videoid` LEFT JOIN  `wk_video_video` v ON v.`id` =hv.`videoid`  LEFT JOIN `wk_video_banquan_video` bv ON bv.`videoid`=hv.`videoid` AND bv.`detailsystemid`="
+                                            "SELECT  ht.`id` as htid,ht.`name` as htname,ht.`columns` as htcolumns ,ht.`hasmore`,ht.`activity` ,ht.`params` ,ht.`ioscontrol`,ht.number,hvideo.id as hvid,hvideo.`videoid` AS hvvideoid,hvideo.`picture`as hvpicture ,hvideo.`tag` as hvtag,    v.`id` as vid ,v.`picture` as vpicture ,v.`name` as vname ,v.`tag` as vtag ,v.`hpicture` as vhpicture ,v.`latest_hpicture` as vlatest_hpicture ,v.`watchcount` as vwatchcount,v.commentcount,ht.icon as hicon,ht.orderby as htorder,hvideo.orderby as hvorder,need_ad,hvideo.big_picture,refresh_position,more_tag FROM   (SELECT hv.* FROM `wk_resource_video` rv LEFT JOIN `wk_video_homevideo` hv ON rv.`videoid` =hv.`videoid` LEFT JOIN  `wk_video_video` v ON v.`id` =hv.`videoid`  LEFT JOIN `wk_video_banquan_video` bv ON bv.`videoid`=hv.`videoid` AND bv.`detailsystemid`="
                                                     + detailSystem
                                                     + " AND bv.`show`=1 LEFT JOIN `wk_video_hometype` ht ON ht.id=hv.hometype WHERE (hv.`id`>0 AND v.`show` =1  AND ht.special_data_key='"
                                                     + dataKey + "'  AND (" + resourceWhere
@@ -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)
@@ -348,12 +360,13 @@
 
     public List<HomeVideo> getHomeVideoList(String homeId, String key, int page) {
         return homeVideoDao.list(
-                "from HomeVideo h where h.type.id=? and h.video.name like ? order by h.video.orderby desc,h.video.watchCount desc,h.createtime desc",
+                "from HomeVideo h where h.type.id=? and h.video.name like ? order by h.bigPicture desc, h.video.orderby desc,h.video.watchCount desc,h.createtime desc",
                 (page - 1) * Constant.pageCount, Constant.pageCount, new String[]{homeId, "%" + key + "%"});
     }
 
 
-    public List<HomeVideo> getHomeVideoList(String homeId, List<Long> resourceIds, Boolean bigPicture, int page, int pageSize) {
+    @Cacheable(value = "homeCache", key = "'getHomeVideoList-'+#homeId+'-'+#resourceKey+'-'+#hasBigPicture+'-'+#page+'-'+#pageSize")
+    public List<HomeVideo> getHomeVideoList(String homeId, String resourceKey, List<Long> resourceIds, Boolean hasBigPicture, int page, int pageSize) {
         List<HomeVideo> homeVideos = (List<HomeVideo>) homeVideoDao.excute(new HibernateCallback<List<HomeVideo>>() {
             @Override
             public List<HomeVideo> doInHibernate(Session session) throws HibernateException {
@@ -365,12 +378,12 @@
 
                 String sql = String.format("SELECT hv.* FROM wk_video_homevideo hv LEFT JOIN wk_resource_video rv ON rv.`videoid`=hv.`videoid` LEFT JOIN wk_video_video v ON v.`id`=hv.`videoid` WHERE v.show=1 and hv.`hometype`=%s AND (%s) ", homeId, org.yeshi.utils.StringUtil.concat(rids, " or "));
 
-                if (bigPicture != null) {
-                    sql += " and hv.big_picture=" + (bigPicture ? 1 : 0);
-                }
+//                if (bigPicture != null) {
+//                    sql += " and hv.big_picture=" + (bigPicture ? 1 : 0);
+//                }
                 sql += " GROUP BY hv.id ORDER BY hv.big_picture desc,hv.`orderby` DESC,hv.`createtime` DESC";
 
-                return session.createSQLQuery(sql).addEntity(HomeVideo.class).setFirstResult((page - 1) * pageSize).setMaxResults(pageSize).list();
+                return session.createSQLQuery(sql).addEntity(HomeVideo.class).setFirstResult((page - 1) * pageSize + (hasBigPicture!=null&&hasBigPicture ? 1 : 0)).setMaxResults(pageSize).list();
             }
         });
 
@@ -383,8 +396,8 @@
         return homeVideos;
     }
 
-
-    public long getHomeVideoListCount(String homeId, List<Long> resourceIds, Boolean bigPicture) {
+    @Cacheable(value = "homeCache", key = "'getHomeVideoListCount-'+#homeId+'-'+#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