From 7804263c6061aef813f0db27cb3046f746572606 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期六, 06 三月 2021 16:07:26 +0800
Subject: [PATCH] 后台管理优化

---
 src/main/java/com/yeshi/buwan/dao/VideoInfoDao.java |  243 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 242 insertions(+), 1 deletions(-)

diff --git a/src/main/java/com/yeshi/buwan/dao/VideoInfoDao.java b/src/main/java/com/yeshi/buwan/dao/VideoInfoDao.java
index eb9c7aa..54656f8 100644
--- a/src/main/java/com/yeshi/buwan/dao/VideoInfoDao.java
+++ b/src/main/java/com/yeshi/buwan/dao/VideoInfoDao.java
@@ -1,6 +1,7 @@
 package com.yeshi.buwan.dao;
 
 import com.yeshi.buwan.dao.base.BaseDao;
+import com.yeshi.buwan.query.BaseQuery;
 import org.hibernate.HibernateException;
 import org.hibernate.Session;
 import org.springframework.orm.hibernate4.HibernateCallback;
@@ -17,6 +18,236 @@
 @Repository
 public class VideoInfoDao extends BaseDao<VideoInfo> {
 
+
+    /**
+     * 閫夋嫨鎬ф洿鏂�
+     *
+     * @param bean
+     */
+    public void updateSelective(VideoInfo bean) {
+        List<String> wheres = new ArrayList<>();
+        List<Serializable> params = new ArrayList<>();
+
+        if (bean.getTag() != null) {
+            wheres.add("vi.tag=?");
+            params.add(bean.getTag());
+        }
+        if (bean.getTotalNumber() != null) {
+            wheres.add("vi.totalNumber=?");
+            params.add(bean.getTotalNumber());
+        }
+
+        if (bean.getPicture() != null) {
+            wheres.add("vi.picture=?");
+            params.add(bean.getPicture());
+        }
+        if (bean.getName() != null) {
+            wheres.add("vi.name=?");
+            params.add(bean.getName());
+        }
+        if (bean.getIntroduction() != null) {
+            wheres.add("vi.introduction=?");
+            params.add(bean.getIntroduction());
+        }
+        if (bean.getDuration() != null) {
+            wheres.add("vi.duration=?");
+            params.add(bean.getDuration());
+        }
+        if (bean.getMainActor() != null) {
+            wheres.add("vi.mainActor=?");
+            params.add(bean.getMainActor());
+        }
+        if (bean.getYear() != null) {
+            wheres.add("vi.year=?");
+            params.add(bean.getYear());
+        }
+        if (bean.getBeizhu() != null) {
+            wheres.add("vi.beizhu=?");
+            params.add(bean.getBeizhu());
+        }
+        if (bean.getQulity() != null) {
+            wheres.add("vi.qulity=?");
+            params.add(bean.getQulity());
+        }
+        if (bean.getScore() != null) {
+            wheres.add("vi.score=?");
+            params.add(bean.getScore());
+        }
+        if (bean.getShare() != null) {
+            wheres.add("vi.share=?");
+            params.add(bean.getShare());
+        }
+        if (bean.getShow() != null) {
+            wheres.add("vi.show=?");
+            params.add(bean.getShow());
+        }
+        if (bean.getWatchCount() != null) {
+            wheres.add("vi.watchCount=?");
+            params.add(bean.getWatchCount());
+        }
+        if (bean.getOrderby() != null) {
+            wheres.add("vi.orderby=?");
+            params.add(bean.getOrderby());
+        }
+        if (bean.getNowNumber() != null) {
+            wheres.add("vi.nowNumber=?");
+            params.add(bean.getNowNumber());
+        }
+        if (bean.getFinish() != null) {
+            wheres.add("vi.finish=?");
+            params.add(bean.getFinish());
+        }
+        if (bean.getBaseurl() != null) {
+            wheres.add("vi.baseurl=?");
+            params.add(bean.getBaseurl());
+        }
+        if (bean.getMonth() != null) {
+            wheres.add("vi.month=?");
+            params.add(bean.getMonth());
+        }
+        if (bean.getDay() != null) {
+            wheres.add("vi.day=?");
+            params.add(bean.getDay());
+        }
+        if (bean.getArea() != null) {
+            wheres.add("vi.area=?");
+            params.add(bean.getArea());
+        }
+        if (bean.getFocus() != null) {
+            wheres.add("vi.focus=?");
+            params.add(bean.getFocus());
+        }
+        if (bean.getLeafctgs() != null) {
+            wheres.add("vi.leafctgs=?");
+            params.add(bean.getLeafctgs());
+        }
+        if (bean.getDirector() != null) {
+            wheres.add("vi.director=?");
+            params.add(bean.getDirector());
+        }
+        if (bean.getKeyword() != null) {
+            wheres.add("vi.keyword=?");
+            params.add(bean.getKeyword());
+        }
+        if (bean.getVpicture() != null) {
+            wheres.add("vi.vpicture=?");
+            params.add(bean.getVpicture());
+        }
+        if (bean.getHpicture() != null) {
+            wheres.add("vi.hpicture=?");
+            params.add(bean.getHpicture());
+        }
+        if (bean.getLatestVpicture() != null) {
+            wheres.add("vi.latestVpicture=?");
+            params.add(bean.getLatestVpicture());
+        }
+        if (bean.getLatestHpicture() != null) {
+            wheres.add("vi.latestHpicture=?");
+            params.add(bean.getLatestHpicture());
+        }
+        if (bean.getContentType() != null) {
+            wheres.add("vi.contentType=?");
+            params.add(bean.getContentType());
+        }
+        if (bean.getCanSave() != null) {
+            wheres.add("vi.canSave=?");
+            params.add(bean.getCanSave());
+        }
+        if (bean.getAdmin() != null) {
+            wheres.add("vi.admin=?");
+            params.add(bean.getAdmin());
+        }
+        if (bean.getVideoType() != null) {
+            wheres.add("vi.videoType=?");
+            params.add(bean.getVideoType());
+        }
+        if (bean.getCommentCount() != null) {
+            wheres.add("vi.commentCount=?");
+            params.add(bean.getCommentCount());
+        }
+        if (bean.getLatestWatchCount() != null) {
+            wheres.add("vi.latestWatchCount=?");
+            params.add(bean.getLatestWatchCount());
+        }
+        if (bean.getVideocount() != null) {
+            wheres.add("vi.videocount=?");
+            params.add(bean.getVideocount());
+        }
+
+
+        if (bean.getType() != null) {
+            wheres.add("vi.type=?");
+            params.add(bean.getType());
+        }
+
+        wheres.add("vi.updatetime=?");
+        params.add(System.currentTimeMillis() + "");
+
+        String hql = "update VideoInfo vi set " + StringUtil.concat(wheres, ",") + " where vi.id=" + bean.getId();
+
+        Serializable[] ps = new Serializable[params.size()];
+        params.toArray(ps);
+        update(hql, ps);
+    }
+
+
+    public List<VideoInfo> list(DaoQuery query) {
+        String hql = "from VideoInfo vi ";
+        List<Serializable> paramList = new ArrayList<>();
+        List<String> andList = new ArrayList<>();
+        if (query.show != null) {
+            andList.add("vi.show= ?");
+            paramList.add(query.show);
+        }
+
+        if (query.name != null) {
+            andList.add("vi.name= ?");
+            paramList.add(query.name);
+        }
+
+
+        if (query.minId != null) {
+            andList.add("vi.id>=" + query.minId);
+        }
+
+        if (andList.size() > 0) {
+            hql += "where " + StringUtil.concat(andList, " and ");
+        }
+
+        Serializable[] params = new Serializable[paramList.size()];
+        paramList.toArray(params);
+        return findList(hql, (int) query.start, query.count, params);
+    }
+
+    public long count(DaoQuery query) {
+        String hql = "from VideoInfo vi ";
+        List<Serializable> paramList = new ArrayList<>();
+        List<String> andList = new ArrayList<>();
+        if (query.show != null) {
+            andList.add("vi.show= ?");
+            paramList.add(query.show);
+        }
+
+        if (query.name != null) {
+            andList.add("vi.name= ?");
+            paramList.add(query.name);
+        }
+
+
+        if (query.minId != null) {
+            andList.add("vi.id>=" + query.minId);
+        }
+
+        if (andList.size() > 0) {
+            hql += "where " + StringUtil.concat(andList, " and ");
+        }
+
+
+        Serializable[] params = new Serializable[paramList.size()];
+        paramList.toArray(params);
+        return getCount(hql, params);
+    }
+
     /**
      * 鏍规嵁鍚嶅瓧鏌ヨ
      *
@@ -26,7 +257,11 @@
      * @return
      */
     public List<VideoInfo> listByName(String name, int start, int count) {
-        return list("from VideoInfo vi where vi.name=?", start, count, new Serializable[]{name});
+        DaoQuery query = new DaoQuery();
+        query.start = start;
+        query.count = count;
+        query.name = name;
+        return list(query);
     }
 
 
@@ -65,4 +300,10 @@
         });
     }
 
+    public static class DaoQuery extends BaseQuery {
+        public String show;
+        public String name;
+        public Long minId;
+    }
+
 }

--
Gitblit v1.8.0