From f13ed98e1de0ec7b85ed179212cc095f63480eed Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期四, 25 三月 2021 18:18:20 +0800 Subject: [PATCH] 全网搜优酷兼容 --- src/main/java/com/yeshi/buwan/service/imp/BanQuanService.java | 1008 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 505 insertions(+), 503 deletions(-) diff --git a/src/main/java/com/yeshi/buwan/service/imp/BanQuanService.java b/src/main/java/com/yeshi/buwan/service/imp/BanQuanService.java index 6a484fd..d001b28 100644 --- a/src/main/java/com/yeshi/buwan/service/imp/BanQuanService.java +++ b/src/main/java/com/yeshi/buwan/service/imp/BanQuanService.java @@ -6,6 +6,7 @@ import javax.annotation.Resource; +import com.yeshi.buwan.util.NumberUtil; import org.hibernate.HibernateException; import org.hibernate.Session; import org.springframework.cache.annotation.CacheEvict; @@ -30,588 +31,589 @@ @Service public class BanQuanService { - @Resource - private VideoBanQuanDao videoBanQuanDao; - @Resource - private VideoBanQuanVideoDao videoBanQuanVideoDao; - @Resource - private WebVideoDao webVideoDao; + @Resource + private VideoBanQuanDao videoBanQuanDao; + @Resource + private VideoBanQuanVideoDao videoBanQuanVideoDao; + @Resource + private WebVideoDao webVideoDao; - @SuppressWarnings("unchecked") - @CacheEvict(value = "topCache", allEntries = true) - public void addBanQuanVideo(final List<VideoBanQuanVideo> list) { - videoBanQuanDao.excute(new HibernateCallback() { - public Object doInHibernate(Session session) throws HibernateException { - try { - session.getTransaction().begin(); - for (int i = 0; i < list.size(); i++) { - List<VideoBanQuanVideo> bl = session - .createQuery("from VideoBanQuanVideo v where v.detailSystem.id=" - + list.get(i).getDetailSystem().getId() + " and v.info.id=" - + list.get(i).getInfo().getId()) - .list(); - if (bl == null || bl.size() == 0) { - session.persist(list.get(i)); - } - } - session.flush(); - session.getTransaction().commit(); - } catch (Exception e) { - e.printStackTrace(); - session.getTransaction().rollback(); - } - return null; - } - }); + @SuppressWarnings("unchecked") + @CacheEvict(value = "topCache", allEntries = true) + public void addBanQuanVideo(final List<VideoBanQuanVideo> list) { + videoBanQuanDao.excute(new HibernateCallback() { + public Object doInHibernate(Session session) throws HibernateException { + try { + session.getTransaction().begin(); + for (int i = 0; i < list.size(); i++) { + List<VideoBanQuanVideo> bl = session + .createQuery("from VideoBanQuanVideo v where v.detailSystem.id=" + + list.get(i).getDetailSystem().getId() + " and v.info.id=" + + list.get(i).getInfo().getId()) + .list(); + if (bl == null || bl.size() == 0) { + session.persist(list.get(i)); + } + } + session.flush(); + session.getTransaction().commit(); + } catch (Exception e) { + e.printStackTrace(); + session.getTransaction().rollback(); + } + return null; + } + }); - } + } - @SuppressWarnings("unchecked") - public void addBanQuanKey(final List<VideoBanQuan> list) { - videoBanQuanDao.excute(new HibernateCallback() { - public Object doInHibernate(Session session) throws HibernateException { - try { - session.getTransaction().begin(); - for (int i = 0; i < list.size(); i++) { - List<VideoBanQuan> bl = session - .createQuery("from VideoBanQuan v where v.detailSystem.id=" - + list.get(i).getDetailSystem().getId() + " and v.name=?") - .setParameter(0, list.get(i).getName()).list(); - if (bl == null || bl.size() == 0) { - session.persist(list.get(i)); - } - } - session.flush(); - session.getTransaction().commit(); - } catch (Exception e) { - e.printStackTrace(); - session.getTransaction().rollback(); - } - return null; - } - }); + @SuppressWarnings("unchecked") + public void addBanQuanKey(final List<VideoBanQuan> list) { + videoBanQuanDao.excute(new HibernateCallback() { + public Object doInHibernate(Session session) throws HibernateException { + try { + session.getTransaction().begin(); + for (int i = 0; i < list.size(); i++) { + List<VideoBanQuan> bl = session + .createQuery("from VideoBanQuan v where v.detailSystem.id=" + + list.get(i).getDetailSystem().getId() + " and v.name=?") + .setParameter(0, list.get(i).getName()).list(); + if (bl == null || bl.size() == 0) { + session.persist(list.get(i)); + } + } + session.flush(); + session.getTransaction().commit(); + } catch (Exception e) { + e.printStackTrace(); + session.getTransaction().rollback(); + } + return null; + } + }); - } + } - public VideoBanQuanVideo getBanQuanVideo(String id) { + public VideoBanQuanVideo getBanQuanVideo(String id) { - return videoBanQuanVideoDao.find(VideoBanQuanVideo.class, id); - } + return videoBanQuanVideoDao.find(VideoBanQuanVideo.class, id); + } - public VideoBanQuan getBanQuanKey(String id) { + public VideoBanQuan getBanQuanKey(String id) { - return videoBanQuanDao.find(VideoBanQuan.class, id); - } + return videoBanQuanDao.find(VideoBanQuan.class, id); + } - public void updateVideoBanQuanVideo(VideoBanQuanVideo video) { + public void updateVideoBanQuanVideo(VideoBanQuanVideo video) { - videoBanQuanVideoDao.update(video); - } + videoBanQuanVideoDao.update(video); + } - public void updateVideoBanQuan(VideoBanQuan video) { + public void updateVideoBanQuan(VideoBanQuan video) { - videoBanQuanDao.update(video); - } + videoBanQuanDao.update(video); + } - public void deleteBanQuanVideo(final List<VideoBanQuanVideo> list) { - videoBanQuanDao.excute(new HibernateCallback() { - public Object doInHibernate(Session session) throws HibernateException { - try { - session.getTransaction().begin(); - for (int i = 0; i < list.size(); i++) { - session.delete(list.get(i)); - } - session.flush(); - session.getTransaction().commit(); - } catch (Exception e) { - e.printStackTrace(); - session.getTransaction().rollback(); - } - return null; - } - }); + public void deleteBanQuanVideo(final List<VideoBanQuanVideo> list) { + videoBanQuanDao.excute(new HibernateCallback() { + public Object doInHibernate(Session session) throws HibernateException { + try { + session.getTransaction().begin(); + for (int i = 0; i < list.size(); i++) { + session.delete(list.get(i)); + } + session.flush(); + session.getTransaction().commit(); + } catch (Exception e) { + e.printStackTrace(); + session.getTransaction().rollback(); + } + return null; + } + }); - } + } - public void deleteBanQuanKey(final List<VideoBanQuan> list) { - videoBanQuanDao.excute(new HibernateCallback() { - public Object doInHibernate(Session session) throws HibernateException { - try { - session.getTransaction().begin(); - for (int i = 0; i < list.size(); i++) { - session.delete(list.get(i)); - } - session.flush(); - session.getTransaction().commit(); - } catch (Exception e) { - e.printStackTrace(); - session.getTransaction().rollback(); - } - return null; - } - }); + public void deleteBanQuanKey(final List<VideoBanQuan> list) { + videoBanQuanDao.excute(new HibernateCallback() { + public Object doInHibernate(Session session) throws HibernateException { + try { + session.getTransaction().begin(); + for (int i = 0; i < list.size(); i++) { + session.delete(list.get(i)); + } + session.flush(); + session.getTransaction().commit(); + } catch (Exception e) { + e.printStackTrace(); + session.getTransaction().rollback(); + } + return null; + } + }); - } + } - public void deleteBanQuanKeyByKey(final String key) { - videoBanQuanDao.excute(new HibernateCallback() { - public Object doInHibernate(Session session) throws HibernateException { - try { - session.getTransaction().begin(); - session.createQuery("delete from VideoBanQuan vb where vb.name=?").setParameter(0, key) - .executeUpdate(); - session.flush(); - session.getTransaction().commit(); - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - }); + public void deleteBanQuanKeyByKey(final String key) { + videoBanQuanDao.excute(new HibernateCallback() { + public Object doInHibernate(Session session) throws HibernateException { + try { + session.getTransaction().begin(); + session.createQuery("delete from VideoBanQuan vb where vb.name=?").setParameter(0, key) + .executeUpdate(); + session.flush(); + session.getTransaction().commit(); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + }); - } + } - @CacheEvict(value = "topCache", allEntries = true) - public void deleteBanQuanVideoByVID(final String videoid) { - videoBanQuanDao.excute(new HibernateCallback() { - public Object doInHibernate(Session session) throws HibernateException { - try { - session.getTransaction().begin(); - session.createQuery("delete from VideoBanQuanVideo vb where vb.info.id=?").setParameter(0, videoid) - .executeUpdate(); - session.flush(); - session.getTransaction().commit(); - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - }); + @CacheEvict(value = "topCache", allEntries = true) + public void deleteBanQuanVideoByVID(final String videoid) { + videoBanQuanDao.excute(new HibernateCallback() { + public Object doInHibernate(Session session) throws HibernateException { + try { + session.getTransaction().begin(); + session.createQuery("delete from VideoBanQuanVideo vb where vb.info.id=?").setParameter(0, videoid) + .executeUpdate(); + session.flush(); + session.getTransaction().commit(); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + }); - } + } - public List<VideoBanQuanVideo> getBanQuanVideoList(int page, String key, int detailSystemId) { - String sql = ""; - if (detailSystemId == 0) - sql = "from VideoBanQuanVideo vb where vb.name like ?"; - else - sql = "from VideoBanQuanVideo vb where vb.name like ? and vb.detailSystem.id=" + detailSystemId; + public List<VideoBanQuanVideo> getBanQuanVideoList(int page, String key, int detailSystemId) { + String sql = ""; + if (detailSystemId == 0) + sql = "from VideoBanQuanVideo vb where vb.name like ?"; + else + sql = "from VideoBanQuanVideo vb where vb.name like ? and vb.detailSystem.id=" + detailSystemId; - return videoBanQuanVideoDao.list(sql, (page - 1) * Constant.pageCount, Constant.pageCount, - new String[] { "%" + key + "%" }); - } + return videoBanQuanVideoDao.list(sql, (page - 1) * Constant.pageCount, Constant.pageCount, + new String[]{"%" + key + "%"}); + } - public long getBanQuanVideoPage(String key, int detailSystemId) { - String sql = ""; - if (detailSystemId == 0) { - sql = "select count(*) from VideoBanQuanVideo v where v.name like ?"; - } else { - sql = "select count(*) from VideoBanQuanVideo v where v.name like ? and v.detailSystem.id=" - + detailSystemId; - } + public long getBanQuanVideoPage(String key, int detailSystemId) { + String sql = ""; + if (detailSystemId == 0) { + sql = "select count(*) from VideoBanQuanVideo v where v.name like ?"; + } else { + sql = "select count(*) from VideoBanQuanVideo v where v.name like ? and v.detailSystem.id=" + + detailSystemId; + } - long count = videoBanQuanVideoDao.getCount(sql, new String[] { "%" + key + "%" }); + long count = videoBanQuanVideoDao.getCount(sql, new String[]{"%" + key + "%"}); - return count % Constant.pageCount == 0 ? count / Constant.pageCount : count / Constant.pageCount + 1; - } + return count % Constant.pageCount == 0 ? count / Constant.pageCount : count / Constant.pageCount + 1; + } - public List<VideoBanQuan> getBanQuanKeyList(int page, String key, int detailSystemId) { - String sql = ""; - if (detailSystemId == 0) - sql = "from VideoBanQuan vb where vb.name like ?"; - else - sql = "from VideoBanQuan vb where vb.name like ? and vb.detailSystem.id=" + detailSystemId; + public List<VideoBanQuan> getBanQuanKeyList(int page, String key, int detailSystemId) { + String sql = ""; + if (detailSystemId == 0) + sql = "from VideoBanQuan vb where vb.name like ?"; + else + sql = "from VideoBanQuan vb where vb.name like ? and vb.detailSystem.id=" + detailSystemId; - return videoBanQuanDao.list(sql, (page - 1) * Constant.pageCount, Constant.pageCount, - new String[] { "%" + key + "%" }); - } + return videoBanQuanDao.list(sql, (page - 1) * Constant.pageCount, Constant.pageCount, + new String[]{"%" + key + "%"}); + } - public List<String> getBanQuanKeyListAll(int detailSystemId) { - String sql = ""; - if (detailSystemId == 0) - sql = "from VideoBanQuan vb"; - else - sql = "from VideoBanQuan vb where vb.detailSystem.id=" + detailSystemId; + public List<String> getBanQuanKeyListAll(int detailSystemId) { + String sql = ""; + if (detailSystemId == 0) + sql = "from VideoBanQuan vb"; + else + sql = "from VideoBanQuan vb where vb.detailSystem.id=" + detailSystemId; - List<VideoBanQuan> bList = videoBanQuanDao.list(sql); - List<String> keyList = new ArrayList<>(); - if (bList != null) - for (VideoBanQuan b : bList) - keyList.add(b.getName()); - return keyList; - } + List<VideoBanQuan> bList = videoBanQuanDao.list(sql); + List<String> keyList = new ArrayList<>(); + if (bList != null) + for (VideoBanQuan b : bList) + keyList.add(b.getName()); + return keyList; + } - public long getBanQuanKeyPage(String key, int detailSystemId) { - String sql = ""; - if (detailSystemId == 0) { - sql = "select count(*) from VideoBanQuan v where v.name like ?"; - } else { - sql = "select count(*) from VideoBanQuan v where v.name like ? and v.detailSystem.id=" + detailSystemId; - } + public long getBanQuanKeyPage(String key, int detailSystemId) { + String sql = ""; + if (detailSystemId == 0) { + sql = "select count(*) from VideoBanQuan v where v.name like ?"; + } else { + sql = "select count(*) from VideoBanQuan v where v.name like ? and v.detailSystem.id=" + detailSystemId; + } - long count = videoBanQuanVideoDao.getCount(sql, new String[] { "%" + key + "%" }); + long count = videoBanQuanVideoDao.getCount(sql, new String[]{"%" + key + "%"}); - return count % Constant.pageCount == 0 ? count / Constant.pageCount : count / Constant.pageCount + 1; - } + return count % Constant.pageCount == 0 ? count / Constant.pageCount : count / Constant.pageCount + 1; + } - // 杩囨护鐗堟潈瑙嗛 + // 杩囨护鐗堟潈瑙嗛 - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Cacheable(value = "userCache", key = "'getBanQuanVideo'+'-'+#cacheMD5+'-'+#detailSystemId") - public List<VideoInfo> getBanQuanVideo(final List<VideoInfo> list, final String detailSystemId, String cacheMD5) { - if (list == null || list.size() == 0) - return list; - List<VideoInfo> newList = (List<VideoInfo>) videoBanQuanDao.excute(new HibernateCallback<List<VideoInfo>>() { - public List<VideoInfo> doInHibernate(Session session) throws HibernateException { - String sql = ""; - for (VideoInfo vi : list) { - sql += " (SELECT v.`id`,bv.`videoid`,bv.`detailsystemid`,bv.`show` FROM wk_video_video v LEFT JOIN wk_video_banquan_video bv ON bv.`videoid`=v.`id` WHERE v.`id`=" - + vi.getId() + ") UNION ALL"; - } - if (sql.endsWith("UNION ALL")) - sql = sql.substring(0, sql.length() - 9); + @SuppressWarnings({"rawtypes", "unchecked"}) + @Cacheable(value = "userCache", key = "'getBanQuanVideo'+'-'+#cacheMD5+'-'+#detailSystemId") + public List<VideoInfo> getBanQuanVideo(final List<VideoInfo> list, final String detailSystemId, String cacheMD5) { + if (list == null || list.size() == 0) + return list; + List<VideoInfo> newList = (List<VideoInfo>) videoBanQuanDao.excute(new HibernateCallback<List<VideoInfo>>() { + public List<VideoInfo> doInHibernate(Session session) throws HibernateException { + String sql = ""; + for (VideoInfo vi : list) { + if (NumberUtil.isNumeric(vi.getId())) + sql += " (SELECT v.`id`,bv.`videoid`,bv.`detailsystemid`,bv.`show` FROM wk_video_video v LEFT JOIN wk_video_banquan_video bv ON bv.`videoid`=v.`id` WHERE v.`id`=" + + vi.getId() + ") UNION ALL"; + } + if (sql.endsWith("UNION ALL")) + sql = sql.substring(0, sql.length() - 9); - try { - List rlist = session.createSQLQuery(sql).list(); - for (int i = 0; i < rlist.size(); i++) { - Object[] objs = (Object[]) rlist.get(i); - if (!StringUtil.isNullOrEmpty(objs[1] + "") && "1".equalsIgnoreCase(objs[3] + "") - && detailSystemId.equalsIgnoreCase(objs[2] + "")) { - // 鏄増鏉冭棰� - // if (list.size() > i) - // list.get(i).setShow("0"); - // 20171009 update - for (VideoInfo vi : list) { - if (vi.getId().equals(objs[1] + "")) { - vi.setShow("0"); - } - } + try { + List rlist = session.createSQLQuery(sql).list(); + for (int i = 0; i < rlist.size(); i++) { + Object[] objs = (Object[]) rlist.get(i); + if (!StringUtil.isNullOrEmpty(objs[1] + "") && "1".equalsIgnoreCase(objs[3] + "") + && detailSystemId.equalsIgnoreCase(objs[2] + "")) { + // 鏄増鏉冭棰� + // if (list.size() > i) + // list.get(i).setShow("0"); + // 20171009 update + for (VideoInfo vi : list) { + if (vi.getId().equals(objs[1] + "")) { + vi.setShow("0"); + } + } - } - // else { - // if (list.size() > i) - // list.get(i).setShow("1"); - // } - } + } + // else { + // if (list.size() > i) + // list.get(i).setShow("1"); + // } + } - } catch (Exception e) { - e.printStackTrace(); - } - return list; - } - }); + } catch (Exception e) { + e.printStackTrace(); + } + return list; + } + }); - for (int i = 0; i < newList.size(); i++) { - if ("0".equalsIgnoreCase(newList.get(i).getShow())) { - newList.remove(i); - i--; - } - } - return newList; - } + for (int i = 0; i < newList.size(); i++) { + if ("0".equalsIgnoreCase(newList.get(i).getShow())) { + newList.remove(i); + i--; + } + } + return newList; + } - @SuppressWarnings("rawtypes") - public List<HomeVideo> getBanQuanHomeVideo(final List<HomeVideo> list, final String detailSystemId) { + @SuppressWarnings("rawtypes") + public List<HomeVideo> getBanQuanHomeVideo(final List<HomeVideo> list, final String detailSystemId) { - videoBanQuanDao.excute(new HibernateCallback<List<HomeVideo>>() { - public List<HomeVideo> doInHibernate(Session session) throws HibernateException { - String sql = ""; - for (HomeVideo hv : list) { - sql += " (SELECT v.`id`,bv.`videoid`,bv.`detailsystemid`,bv.`show` FROM wk_video_video v LEFT JOIN wk_video_banquan_video bv ON bv.`videoid`=v.`id` WHERE v.`id`=" - + hv.getVideo().getId() + ") UNION ALL"; - } - if (sql.endsWith("UNION ALL")) - sql = sql.substring(0, sql.length() - 9); - try { - List rlist = session.createSQLQuery(sql).list(); - for (int i = 0; i < rlist.size(); i++) { - Object[] objs = (Object[]) rlist.get(i); - if (!StringUtil.isNullOrEmpty(objs[1] + "") && "1".equalsIgnoreCase(objs[2] + "") - && detailSystemId.equalsIgnoreCase(objs[3] + "")) { - // 鏄増鏉冭棰� - // list.get(i).getVideo().setShow("0"); - // 20171009 update - for (HomeVideo hv : list) { - if (hv.getVideo().getId().equals(objs[1] + "")) { - hv.getVideo().setShow("0"); - } - } - } - // else - // list.get(i).getVideo().setShow("1"); - } + videoBanQuanDao.excute(new HibernateCallback<List<HomeVideo>>() { + public List<HomeVideo> doInHibernate(Session session) throws HibernateException { + String sql = ""; + for (HomeVideo hv : list) { + sql += " (SELECT v.`id`,bv.`videoid`,bv.`detailsystemid`,bv.`show` FROM wk_video_video v LEFT JOIN wk_video_banquan_video bv ON bv.`videoid`=v.`id` WHERE v.`id`=" + + hv.getVideo().getId() + ") UNION ALL"; + } + if (sql.endsWith("UNION ALL")) + sql = sql.substring(0, sql.length() - 9); + try { + List rlist = session.createSQLQuery(sql).list(); + for (int i = 0; i < rlist.size(); i++) { + Object[] objs = (Object[]) rlist.get(i); + if (!StringUtil.isNullOrEmpty(objs[1] + "") && "1".equalsIgnoreCase(objs[2] + "") + && detailSystemId.equalsIgnoreCase(objs[3] + "")) { + // 鏄増鏉冭棰� + // list.get(i).getVideo().setShow("0"); + // 20171009 update + for (HomeVideo hv : list) { + if (hv.getVideo().getId().equals(objs[1] + "")) { + hv.getVideo().setShow("0"); + } + } + } + // else + // list.get(i).getVideo().setShow("1"); + } - } catch (Exception e) { - e.printStackTrace(); - } + } catch (Exception e) { + e.printStackTrace(); + } - return list; - } - }); + return list; + } + }); - for (int i = 0; i < list.size(); i++) { - if (list.get(i).getVideo().getShow().equalsIgnoreCase("0")) { - list.remove(i); - i--; - } - } - return list; - } + for (int i = 0; i < list.size(); i++) { + if (list.get(i).getVideo().getShow().equalsIgnoreCase("0")) { + list.remove(i); + i--; + } + } + return list; + } - /** - * 绠$悊椤甸潰鎿嶄綔 - */ + /** + * 绠$悊椤甸潰鎿嶄綔 + */ - @SuppressWarnings("unchecked") - public List<BanquanKeyAdmin> getBanquanKeyAdmin(final String key, final int detailSystem, final int page) { + @SuppressWarnings("unchecked") + public List<BanquanKeyAdmin> getBanquanKeyAdmin(final String key, final int detailSystem, final int page) { - return (List<BanquanKeyAdmin>) videoBanQuanDao.excute(new HibernateCallback<List<BanquanKeyAdmin>>() { - public List<BanquanKeyAdmin> doInHibernate(Session session) throws HibernateException { - List<BanquanKeyAdmin> banquanList = new ArrayList<>(); - try { - List<DetailSystem> detailSystemList = session.createQuery("from DetailSystem").list(); - String where = ""; - if (detailSystem > 0) - where = "where vb.detailSystem.id=" + detailSystem + " and"; - else - where = "where"; + return (List<BanquanKeyAdmin>) videoBanQuanDao.excute(new HibernateCallback<List<BanquanKeyAdmin>>() { + public List<BanquanKeyAdmin> doInHibernate(Session session) throws HibernateException { + List<BanquanKeyAdmin> banquanList = new ArrayList<>(); + try { + List<DetailSystem> detailSystemList = session.createQuery("from DetailSystem").list(); + String where = ""; + if (detailSystem > 0) + where = "where vb.detailSystem.id=" + detailSystem + " and"; + else + where = "where"; - List<VideoBanQuan> list = session - .createQuery("from VideoBanQuan vb " + where - + " vb.name like ? group by vb.name order by vb.createtime desc") - .setParameter(0, "%" + key + "%").setFirstResult((page - 1) * Constant.pageCount) - .setMaxResults(Constant.pageCount).list(); - for (VideoBanQuan vb : list) { - List<DetailSystem> detailSystemS = session - .createQuery("select vb.detailSystem from VideoBanQuan vb where vb.name=?") - .setParameter(0, vb.getName()).list(); + List<VideoBanQuan> list = session + .createQuery("from VideoBanQuan vb " + where + + " vb.name like ? group by vb.name order by vb.createtime desc") + .setParameter(0, "%" + key + "%").setFirstResult((page - 1) * Constant.pageCount) + .setMaxResults(Constant.pageCount).list(); + for (VideoBanQuan vb : list) { + List<DetailSystem> detailSystemS = session + .createQuery("select vb.detailSystem from VideoBanQuan vb where vb.name=?") + .setParameter(0, vb.getName()).list(); - List<DetailSystemSelect> dssList = new ArrayList<>(); + List<DetailSystemSelect> dssList = new ArrayList<>(); - for (DetailSystem ds : detailSystemList) { - DetailSystemSelect dss = new DetailSystemSelect(); - dss.setDetailSystem(ds); - dss.setSelected(false); - dssList.add(dss); - } + for (DetailSystem ds : detailSystemList) { + DetailSystemSelect dss = new DetailSystemSelect(); + dss.setDetailSystem(ds); + dss.setSelected(false); + dssList.add(dss); + } - // 璁剧疆宸茬粡瀛樺湪鐨� - for (DetailSystem ds : detailSystemS) { + // 璁剧疆宸茬粡瀛樺湪鐨� + for (DetailSystem ds : detailSystemS) { - for (DetailSystemSelect dss : dssList) { - if (dss.getDetailSystem().getId().equalsIgnoreCase(ds.getId())) { - dss.setSelected(true); - break; - } - } - } - banquanList.add(new BanquanKeyAdmin(vb, dssList)); - } + for (DetailSystemSelect dss : dssList) { + if (dss.getDetailSystem().getId().equalsIgnoreCase(ds.getId())) { + dss.setSelected(true); + break; + } + } + } + banquanList.add(new BanquanKeyAdmin(vb, dssList)); + } - } catch (Exception e) { - e.printStackTrace(); - } - return banquanList; - } - }); + } catch (Exception e) { + e.printStackTrace(); + } + return banquanList; + } + }); - } + } - public long getBanquanKeyAdminCount(String key, int detailSystem) { - String where = ""; - if (detailSystem > 0) - where = "where vb.detailsystem=" + detailSystem + " and"; - else - where = "where"; + public long getBanquanKeyAdminCount(String key, int detailSystem) { + String where = ""; + if (detailSystem > 0) + where = "where vb.detailsystem=" + detailSystem + " and"; + else + where = "where"; - return videoBanQuanVideoDao.getCountSQL("select count(*) from (select count(*) from wk_video_banquan vb " - + where + " vb.name like '%" + key + "%' group by vb.name ) s"); - } + return videoBanQuanVideoDao.getCountSQL("select count(*) from (select count(*) from wk_video_banquan vb " + + where + " vb.name like '%" + key + "%' group by vb.name ) s"); + } - @SuppressWarnings("rawtypes") - public void addBanQuanKeyAdmin(final String key, final String detailSystemId) { - videoBanQuanDao.excute(new HibernateCallback() { - public Object doInHibernate(Session session) throws HibernateException { - try { - List list = session.createQuery("from VideoBanQuan vb where vb.name=? and vb.detailSystem.id=?") - .setParameter(0, key).setParameter(0, detailSystemId).list(); - session.getTransaction().begin(); - if (list == null || list.size() == 0) { - VideoBanQuan vb = new VideoBanQuan(); - vb.setCreatetime(System.currentTimeMillis() + ""); - vb.setDetailSystem(new DetailSystem(detailSystemId)); - vb.setName(key); - vb.setShow(true); - vb.setVideoType(1); - vb.setVideoResource(new VideoResource("6")); - session.persist(vb); - } - session.flush(); - session.getTransaction().commit(); + @SuppressWarnings("rawtypes") + public void addBanQuanKeyAdmin(final String key, final String detailSystemId) { + videoBanQuanDao.excute(new HibernateCallback() { + public Object doInHibernate(Session session) throws HibernateException { + try { + List list = session.createQuery("from VideoBanQuan vb where vb.name=? and vb.detailSystem.id=?") + .setParameter(0, key).setParameter(0, detailSystemId).list(); + session.getTransaction().begin(); + if (list == null || list.size() == 0) { + VideoBanQuan vb = new VideoBanQuan(); + vb.setCreatetime(System.currentTimeMillis() + ""); + vb.setDetailSystem(new DetailSystem(detailSystemId)); + vb.setName(key); + vb.setShow(true); + vb.setVideoType(1); + vb.setVideoResource(new VideoResource("6")); + session.persist(vb); + } + session.flush(); + session.getTransaction().commit(); - } catch (Exception e) { - e.printStackTrace(); - session.getTransaction().rollback(); - } + } catch (Exception e) { + e.printStackTrace(); + session.getTransaction().rollback(); + } - return null; - } - }); + return null; + } + }); - } + } - @SuppressWarnings({ "unchecked", "rawtypes" }) - public void deleteBanQuanKeyAdmin(final String key, final String detailSystemId) { - videoBanQuanDao.excute(new HibernateCallback() { - public Object doInHibernate(Session session) throws HibernateException { - try { - session.getTransaction().begin(); - List<VideoBanQuan> list = session - .createQuery("from VideoBanQuan vb where vb.name=? and vb.detailSystem.id=?") - .setParameter(0, key).setParameter(1, detailSystemId).list(); - if (list != null && list.size() > 0) { - for (VideoBanQuan vb : list) - session.delete(vb); - } - session.flush(); - session.getTransaction().commit(); + @SuppressWarnings({"unchecked", "rawtypes"}) + public void deleteBanQuanKeyAdmin(final String key, final String detailSystemId) { + videoBanQuanDao.excute(new HibernateCallback() { + public Object doInHibernate(Session session) throws HibernateException { + try { + session.getTransaction().begin(); + List<VideoBanQuan> list = session + .createQuery("from VideoBanQuan vb where vb.name=? and vb.detailSystem.id=?") + .setParameter(0, key).setParameter(1, detailSystemId).list(); + if (list != null && list.size() > 0) { + for (VideoBanQuan vb : list) + session.delete(vb); + } + session.flush(); + session.getTransaction().commit(); - } catch (Exception e) { - e.printStackTrace(); - session.getTransaction().rollback(); - } - return null; - } - }); + } catch (Exception e) { + e.printStackTrace(); + session.getTransaction().rollback(); + } + return null; + } + }); - } + } - @SuppressWarnings("unchecked") - public List<BanquanVideoAdmin> getBanquanVideoAdmin(final String key, final int detailSystem, final int page) { + @SuppressWarnings("unchecked") + public List<BanquanVideoAdmin> getBanquanVideoAdmin(final String key, final int detailSystem, final int page) { - return (List<BanquanVideoAdmin>) videoBanQuanDao.excute(new HibernateCallback<List<BanquanVideoAdmin>>() { - public List<BanquanVideoAdmin> doInHibernate(Session session) throws HibernateException { - List<BanquanVideoAdmin> banquanList = new ArrayList<>(); - try { - List<DetailSystem> detailSystemList = session.createQuery("from DetailSystem").list(); - String where = ""; - if (detailSystem > 0) - where += " where vb.detailSystem.id= " + detailSystem + " and "; - else - where += " where "; + return (List<BanquanVideoAdmin>) videoBanQuanDao.excute(new HibernateCallback<List<BanquanVideoAdmin>>() { + public List<BanquanVideoAdmin> doInHibernate(Session session) throws HibernateException { + List<BanquanVideoAdmin> banquanList = new ArrayList<>(); + try { + List<DetailSystem> detailSystemList = session.createQuery("from DetailSystem").list(); + String where = ""; + if (detailSystem > 0) + where += " where vb.detailSystem.id= " + detailSystem + " and "; + else + where += " where "; - List<VideoBanQuanVideo> list = session - .createQuery("from VideoBanQuanVideo vb " + where - + " vb.info.name like ? group by vb.info.id order by vb.createtime desc") - .setParameter(0, "%" + key + "%").setFirstResult((page - 1) * Constant.pageCount) - .setMaxResults(Constant.pageCount).list(); - for (VideoBanQuanVideo vb : list) { - List<DetailSystem> detailSystemS = session - .createQuery("select vb.detailSystem from VideoBanQuanVideo vb where vb.info.id=?") - .setParameter(0, vb.getInfo().getId()).list(); + List<VideoBanQuanVideo> list = session + .createQuery("from VideoBanQuanVideo vb " + where + + " vb.info.name like ? group by vb.info.id order by vb.createtime desc") + .setParameter(0, "%" + key + "%").setFirstResult((page - 1) * Constant.pageCount) + .setMaxResults(Constant.pageCount).list(); + for (VideoBanQuanVideo vb : list) { + List<DetailSystem> detailSystemS = session + .createQuery("select vb.detailSystem from VideoBanQuanVideo vb where vb.info.id=?") + .setParameter(0, vb.getInfo().getId()).list(); - List<DetailSystemSelect> dssList = new ArrayList<>(); + List<DetailSystemSelect> dssList = new ArrayList<>(); - for (DetailSystem ds : detailSystemList) { - DetailSystemSelect dss = new DetailSystemSelect(); - dss.setDetailSystem(ds); - dss.setSelected(false); - dssList.add(dss); - } + for (DetailSystem ds : detailSystemList) { + DetailSystemSelect dss = new DetailSystemSelect(); + dss.setDetailSystem(ds); + dss.setSelected(false); + dssList.add(dss); + } - // 璁剧疆宸茬粡瀛樺湪鐨� - for (DetailSystem ds : detailSystemS) { + // 璁剧疆宸茬粡瀛樺湪鐨� + for (DetailSystem ds : detailSystemS) { - for (DetailSystemSelect dss : dssList) { - if (dss.getDetailSystem().getId().equalsIgnoreCase(ds.getId())) { - dss.setSelected(true); - break; - } - } - } - banquanList.add(new BanquanVideoAdmin(vb, dssList)); - } + for (DetailSystemSelect dss : dssList) { + if (dss.getDetailSystem().getId().equalsIgnoreCase(ds.getId())) { + dss.setSelected(true); + break; + } + } + } + banquanList.add(new BanquanVideoAdmin(vb, dssList)); + } - } catch (Exception e) { - e.printStackTrace(); - } - return banquanList; - } - }); + } catch (Exception e) { + e.printStackTrace(); + } + return banquanList; + } + }); - } + } - public long getBanquanVideoAdminCount(String key, int detailSystem) { + public long getBanquanVideoAdminCount(String key, int detailSystem) { - String where = ""; - if (detailSystem > 0) - where += " where bv.detailsystemid= " + detailSystem + " and "; - else - where += " where "; + String where = ""; + if (detailSystem > 0) + where += " where bv.detailsystemid= " + detailSystem + " and "; + else + where += " where "; - return videoBanQuanVideoDao.getCountSQL( - "select count(*) from (select count(*) from wk_video_banquan_video bv left join wk_video_video v on v.id=bv.videoid " - + where + " v.name like '%" + key + "%' group by bv.videoid) s"); - } + return videoBanQuanVideoDao.getCountSQL( + "select count(*) from (select count(*) from wk_video_banquan_video bv left join wk_video_video v on v.id=bv.videoid " + + where + " v.name like '%" + key + "%' group by bv.videoid) s"); + } - @SuppressWarnings("rawtypes") - public void addBanQuanVideoAdmin(final String videoid, final String detailSystemId) { - videoBanQuanDao.excute(new HibernateCallback() { - public Object doInHibernate(Session session) throws HibernateException { - try { - List list = session - .createQuery("from VideoBanQuanVideo vb where vb.info.id=? and vb.detailSystem.id=?") - .setParameter(0, videoid).setParameter(1, detailSystemId).list(); - session.getTransaction().begin(); - if (list == null || list.size() == 0) { - VideoBanQuanVideo vb = new VideoBanQuanVideo(); - vb.setCreatetime(System.currentTimeMillis() + ""); - vb.setDetailSystem(new DetailSystem(detailSystemId)); - vb.setInfo(new VideoInfo(videoid)); - vb.setName(((VideoInfo) session.get(VideoInfo.class, videoid)).getName()); - vb.setShow(true); - session.persist(vb); - } - session.flush(); - session.getTransaction().commit(); + @SuppressWarnings("rawtypes") + public void addBanQuanVideoAdmin(final String videoid, final String detailSystemId) { + videoBanQuanDao.excute(new HibernateCallback() { + public Object doInHibernate(Session session) throws HibernateException { + try { + List list = session + .createQuery("from VideoBanQuanVideo vb where vb.info.id=? and vb.detailSystem.id=?") + .setParameter(0, videoid).setParameter(1, detailSystemId).list(); + session.getTransaction().begin(); + if (list == null || list.size() == 0) { + VideoBanQuanVideo vb = new VideoBanQuanVideo(); + vb.setCreatetime(System.currentTimeMillis() + ""); + vb.setDetailSystem(new DetailSystem(detailSystemId)); + vb.setInfo(new VideoInfo(videoid)); + vb.setName(((VideoInfo) session.get(VideoInfo.class, videoid)).getName()); + vb.setShow(true); + session.persist(vb); + } + session.flush(); + session.getTransaction().commit(); - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - }); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + }); - } + } - @SuppressWarnings("unchecked") - public void deleteBanQuanVideoAdmin(final String videoid, final String detailSystemId) { - videoBanQuanDao.excute(new HibernateCallback() { - public Object doInHibernate(Session session) throws HibernateException { - try { - session.getTransaction().begin(); - List<VideoBanQuanVideo> list = session - .createQuery("from VideoBanQuanVideo vb where vb.info.id=? and vb.detailSystem.id=?") - .setParameter(0, videoid).setParameter(1, detailSystemId).list(); - if (list != null && list.size() > 0) { - for (VideoBanQuanVideo vb : list) - session.delete(vb); - } - session.flush(); - session.getTransaction().commit(); - } catch (Exception e) { - e.printStackTrace(); - session.getTransaction().rollback(); - } - return null; - } - }); + @SuppressWarnings("unchecked") + public void deleteBanQuanVideoAdmin(final String videoid, final String detailSystemId) { + videoBanQuanDao.excute(new HibernateCallback() { + public Object doInHibernate(Session session) throws HibernateException { + try { + session.getTransaction().begin(); + List<VideoBanQuanVideo> list = session + .createQuery("from VideoBanQuanVideo vb where vb.info.id=? and vb.detailSystem.id=?") + .setParameter(0, videoid).setParameter(1, detailSystemId).list(); + if (list != null && list.size() > 0) { + for (VideoBanQuanVideo vb : list) + session.delete(vb); + } + session.flush(); + session.getTransaction().commit(); + } catch (Exception e) { + e.printStackTrace(); + session.getTransaction().rollback(); + } + return null; + } + }); - } + } - public boolean isNeedWebPlay(String detailSystemId, String videoid) { - return webVideoDao.getCount("select count(*) from WebVideo web where web.detailSystem.id=? and web.info.id=?", - new Serializable[] { detailSystemId, videoid }) > 0; - } + public boolean isNeedWebPlay(String detailSystemId, String videoid) { + return webVideoDao.getCount("select count(*) from WebVideo web where web.detailSystem.id=? and web.info.id=?", + new Serializable[]{detailSystemId, videoid}) > 0; + } } -- Gitblit v1.8.0