From 19533a17aa55fafc70d0a385928e785cb50e1ebc Mon Sep 17 00:00:00 2001
From: admin <2780501319@qq.com>
Date: 星期五, 30 七月 2021 02:05:14 +0800
Subject: [PATCH] 爱奇艺视频更新

---
 src/main/java/com/yeshi/buwan/service/imp/SpecialService.java |  469 +++++++++++++++++++++++++++-------------------------------
 1 files changed, 219 insertions(+), 250 deletions(-)

diff --git a/src/main/java/com/yeshi/buwan/service/imp/SpecialService.java b/src/main/java/com/yeshi/buwan/service/imp/SpecialService.java
index dba271f..ec3d31a 100644
--- a/src/main/java/com/yeshi/buwan/service/imp/SpecialService.java
+++ b/src/main/java/com/yeshi/buwan/service/imp/SpecialService.java
@@ -12,12 +12,12 @@
 import org.springframework.orm.hibernate4.HibernateCallback;
 import org.springframework.stereotype.Service;
 
-import com.yeshi.buwan.dao.DetailSystemDao;
+import com.yeshi.buwan.dao.system.DetailSystemDao;
 import com.yeshi.buwan.dao.SpecialDao;
 import com.yeshi.buwan.dao.SpecialVideoDao;
 import com.yeshi.buwan.dao.SuperSpecialDao;
 import com.yeshi.buwan.dao.VideoInfoDao;
-import com.yeshi.buwan.domain.DetailSystem;
+import com.yeshi.buwan.domain.system.DetailSystem;
 import com.yeshi.buwan.domain.VideoInfo;
 import com.yeshi.buwan.domain.special.Special;
 import com.yeshi.buwan.domain.special.SpecialVideo;
@@ -30,294 +30,263 @@
 
 @Service
 public class SpecialService {
-	@Resource
-	private SpecialDao specialDao;
-	@Resource
-	private SpecialVideoDao specialVideoDao;
-	@Resource
-	private VideoInfoDao videoInfoDao;
-	@Resource
-	private SuperSpecialDao superSpecialDao;
-	@Resource
-	private DetailSystemDao detailSystemDao;
+    @Resource
+    private SpecialDao specialDao;
+    @Resource
+    private SpecialVideoDao specialVideoDao;
+    @Resource
+    private VideoInfoDao videoInfoDao;
+    @Resource
+    private SuperSpecialDao superSpecialDao;
+    @Resource
+    private DetailSystemDao detailSystemDao;
 
-	public SuperSpecialDao getSuperSpecialDao() {
-		return superSpecialDao;
-	}
 
-	public void setSuperSpecialDao(SuperSpecialDao superSpecialDao) {
-		this.superSpecialDao = superSpecialDao;
-	}
+    @Cacheable(value = "classCache", key = "'getSpecialList'+'-'+#detailSystemId+'-'+#page")
+    public List<Special> getSpecialList(String detailSystemId, int page) {
+        return specialDao.list(
+                "select ss.special from SuperSpecial ss where ss.detailSystem.id=? and ss.special.show=1 order by ss.special.orderby desc",
+                (page - 1) * Constant.pageCount, Constant.pageCount, new String[]{detailSystemId});
+    }
 
-	public VideoInfoDao getVideoInfoDao() {
-		return videoInfoDao;
-	}
+    public List<Special> getSpecialList(String detailSystemId) {
+        return specialDao.list(
+                "select ss.special from SuperSpecial ss where ss.detailSystem.id=? order by ss.special.orderby desc",
+                new String[]{detailSystemId});
+    }
 
-	public void setVideoInfoDao(VideoInfoDao videoInfoDao) {
-		this.videoInfoDao = videoInfoDao;
-	}
+    public List<Special> getSpecialList() {
+        return specialDao.list("from Special");
+    }
 
-	public SpecialVideoDao getSpecialVideoDao() {
-		return specialVideoDao;
-	}
+    @Cacheable(value = "classCache", key = "'getSpecialCount'+'-'+#detailSystemId")
+    public long getSpecialCount(String detailSystemId) {
+        return specialDao.getCount("select count(*)  from SuperSpecial ss where ss.detailSystem.id=?",
+                new String[]{detailSystemId});
+    }
 
-	public void setSpecialVideoDao(SpecialVideoDao specialVideoDao) {
-		this.specialVideoDao = specialVideoDao;
-	}
+    @Cacheable(value = "classCache", key = "'getSpecial'+'-'+#id")
+    public Special getSpecial(String id) {
+        return specialDao.find(Special.class, id);
+    }
 
-	public SpecialDao getSpecialDao() {
-		return specialDao;
-	}
+    public void addSpecial(Special special) {
+        specialDao.save(special);
+    }
 
-	public void setSpecialDao(SpecialDao specialDao) {
-		this.specialDao = specialDao;
-	}
+    @SuppressWarnings("rawtypes")
+    public void deleteSpecial(final Special special) {
+        if (special != null) {
+            specialDao.excute(new HibernateCallback() {
+                public Object doInHibernate(Session session) throws HibernateException {
+                    try {
+                        @SuppressWarnings("unchecked")
+                        List<SuperSpecial> list = session.createQuery("from SuperSpecial sh where sh.special.id=?")
+                                .setParameter(0, special.getId()).list();
+                        session.getTransaction().begin();
+                        for (SuperSpecial sh : list)
+                            session.delete(sh);
+                        session.delete(special);
+                        session.flush();
+                        session.getTransaction().commit();
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                        session.getTransaction().rollback();
+                    }
+                    return null;
+                }
+            });
 
-	@Cacheable(value = "classCache",key="'getSpecialList'+'-'+#detailSystemId+'-'+#page")
-	public List<Special> getSpecialList(String detailSystemId, int page) {
-		return specialDao.list(
-				"select ss.special from SuperSpecial ss where ss.detailSystem.id=? and ss.special.show=1 order by ss.special.orderby desc",
-				(page - 1) * Constant.pageCount, Constant.pageCount, new String[] { detailSystemId });
-	}
+        }
+    }
 
-	public List<Special> getSpecialList(String detailSystemId) {
-		return specialDao.list(
-				"select ss.special from SuperSpecial ss where ss.detailSystem.id=? order by ss.special.orderby desc",
-				new String[] { detailSystemId });
-	}
+    public void updateSpecial(Special special) {
+        specialDao.update(special);
+    }
 
-	public List<Special> getSpecialList() {
-		return specialDao.list("from Special");
-	}
+    public void addSpecialVideo(SpecialVideo sv) {
+        specialVideoDao.create(sv);
+    }
 
-	@Cacheable(value = "classCache",key="'getSpecialCount'+'-'+#detailSystemId")
-	public long getSpecialCount(String detailSystemId) {
-		return specialDao.getCount("select count(*)  from SuperSpecial ss where ss.detailSystem.id=?",
-				new String[] { detailSystemId });
-	}
+    @Cacheable(value = "classCache", key = "'getSpecialVideoList'+'-'+#specialId")
+    public List<VideoInfo> getSpecialVideoList(String specialId) {
+        return videoInfoDao.list(
+                "select sv.video from SpecialVideo sv where sv.special.id=? and sv.video.show=1 order by sv.orderby desc",
+                new String[]{specialId});
+    }
 
-	@Cacheable(value = "classCache",key="'getSpecial'+'-'+#id")
-	public Special getSpecial(String id) {
-		return specialDao.find(Special.class, id);
-	}
+    public void deleteSpecialVideo(String specialVideoId) {
+        specialVideoDao.delete(new SpecialVideo(specialVideoId));
+    }
 
-	public void addSpecial(Special special) {
-		specialDao.save(special);
-	}
+    public long getSpecialVideoListCount(String specialId) {
 
-	@SuppressWarnings("rawtypes")
-	public void deleteSpecial(final Special special) {
-		if (special != null) {
-			specialDao.excute(new HibernateCallback() {
-				public Object doInHibernate(Session session) throws HibernateException {
-					try {
-						@SuppressWarnings("unchecked")
-						List<SuperSpecial> list = session.createQuery("from SuperSpecial sh where sh.special.id=?")
-								.setParameter(0, special.getId()).list();
-						session.getTransaction().begin();
-						for (SuperSpecial sh : list)
-							session.delete(sh);
-						session.delete(special);
-						session.flush();
-						session.getTransaction().commit();
-					} catch (Exception e) {
-						e.printStackTrace();
-						session.getTransaction().rollback();
-					}
-					return null;
-				}
-			});
+        return videoInfoDao.getCount("select sv.video from SpecialVideo sv where sv.special.id=?",
+                new String[]{specialId});
+    }
 
-		}
-	}
+    public List<SpecialVideo> getSpecialVideoList(String specialId, String key) {
+        return specialVideoDao.list("from SpecialVideo sv where sv.special.id=? and sv.video.name like ?",
+                new String[]{specialId, "%" + key + "%"});
+    }
 
-	public void updateSpecial(Special special) {
-		specialDao.update(special);
-	}
+    public List<SpecialVideo> getSpecialVideoList(String specialId, PageEntity pg, String key) {
+        return specialVideoDao.list("from SpecialVideo sv where sv.special.id=? and sv.video.name like ?", ((pg.getPageIndex() - 1) * pg.getPageSize()), pg.getPageSize(),
+                new String[]{specialId, "%" + key + "%"});
+    }
 
-	public void addSpecialVideo(SpecialVideo sv) {
-		specialVideoDao.create(sv);
-	}
+    public long getSpecialVideoListCount(String specialId, String key) {
+        return specialVideoDao.getCount(
+                "select count(*)  from SpecialVideo sv where sv.special.id=? and sv.video.name like ?",
+                new String[]{specialId, "%" + key + "%"});
+    }
 
-	@Cacheable(value = "classCache",key="'getSpecialVideoList'+'-'+#specialId")
-	public List<VideoInfo> getSpecialVideoList(String specialId) {
-		return videoInfoDao.list(
-				"select sv.video from SpecialVideo sv where sv.special.id=? and sv.video.show=1 order by sv.orderby desc",
-				new String[] { specialId });
-	}
+    @SuppressWarnings("unchecked")
+    public List<SpecialAdmin> getSpecialAdmin(String key, String systemId, int detailSystem, int page) {
+        key = StringUtil.isNullOrEmpty(key) ? "" : key;
+        List<SpecialAdmin> zhiBoClassList = new ArrayList<>();
 
-	public void deleteSpecialVideo(String specialVideoId) {
-		specialVideoDao.delete(new SpecialVideo(specialVideoId));
-	}
+        try {
+            List<DetailSystem> detailSystemList = detailSystemDao.list("from DetailSystem ds where ds.system.id=" + systemId);
+            String sql = "";
+            if (detailSystem > 0)
+                sql = "select sh.special from SuperSpecial sh where sh.special.name like ? and  sh.detailSystem.id="
+                        + detailSystem + " order by  sh.special.orderby desc";
+            else
+                sql = "from Special zb where zb.name like ? and zb.system.id=" + systemId + " order by zb.orderby desc";
 
-	public long getSpecialVideoListCount(String specialId) {
+            List<Special> list = specialDao.list(sql, (page - 1) * Constant.pageCount, Constant.pageCount,
+                    new Serializable[]{"%" + key + "%"});
+            for (Special vb : list) {
+                List<DetailSystem> detailSystemS = detailSystemDao
+                        .list("select vb.detailSystem from SuperSpecial vb where vb.special.id=" + vb.getId());
 
-		return videoInfoDao.getCount("select sv.video from SpecialVideo sv where sv.special.id=?",
-				new String[] { specialId });
-	}
+                List<DetailSystemSelect> dssList = new ArrayList<>();
 
-	public List<SpecialVideo> getSpecialVideoList(String specialId, String key) {
-		return specialVideoDao.list("from SpecialVideo sv where sv.special.id=? and sv.video.name like ?",
-				new String[] { specialId, "%" + key + "%" });
-	}
-	
-	public List<SpecialVideo> getSpecialVideoList(String specialId,PageEntity pg, String key) {
-		return specialVideoDao.list("from SpecialVideo sv where sv.special.id=? and sv.video.name like ?",((pg.getPageIndex()-1)*pg.getPageSize()),pg.getPageSize(),
-				new String[] { specialId, "%" + key + "%" });
-	}
+                for (DetailSystem ds : detailSystemList) {
+                    DetailSystemSelect dss = new DetailSystemSelect();
+                    dss.setDetailSystem(ds);
+                    dss.setSelected(false);
+                    dssList.add(dss);
+                }
 
-	public long getSpecialVideoListCount(String specialId, String key) {
-		return specialVideoDao.getCount(
-				"select count(*)  from SpecialVideo sv where sv.special.id=? and sv.video.name like ?",
-				new String[] { specialId, "%" + key + "%" });
-	}
+                for (DetailSystem ds : detailSystemS) {
+                    for (DetailSystemSelect dss : dssList) {
+                        if (dss.getDetailSystem().getId().equalsIgnoreCase(ds.getId())) {
+                            dss.setSelected(true);
+                            break;
+                        }
+                    }
+                }
+                SuperSpecial sz = new SuperSpecial();
+                sz.setDetailSystem(null);
+                sz.setSpecial(vb);
+                zhiBoClassList.add(new SpecialAdmin(sz, dssList));
+            }
 
-	@SuppressWarnings("unchecked")
-	public List<SpecialAdmin> getSpecialAdmin(String key, int detailSystem, int page) {
-		key = StringUtil.isNullOrEmpty(key) ? "" : key;
-		List<SpecialAdmin> zhiBoClassList = new ArrayList<>();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return zhiBoClassList;
+    }
 
-		try {
-			List<DetailSystem> detailSystemList = detailSystemDao.list("from DetailSystem");
-			String sql = "";
-			if (detailSystem > 0)
-				sql = "select sh.special from SuperSpecial sh where sh.special.name like ? and  sh.detailSystem.id="
-						+ detailSystem + " order by  sh.special.orderby desc";
-			else
-				sql = "from Special zb where zb.name like ? order by zb.orderby desc";
+    public long getSpecialAdminCount(String key, String systemId, int detailSystem) {
+        key = StringUtil.isNullOrEmpty(key) ? "" : key;
 
-			List<Special> list = specialDao.list(sql, (page - 1) * Constant.pageCount, Constant.pageCount,
-					new Serializable[] { "%" + key + "%" });
-			for (Special vb : list) {
-				List<DetailSystem> detailSystemS = detailSystemDao
-						.list("select vb.detailSystem from SuperSpecial vb where vb.special.id=" + vb.getId());
+        String sql = "";
+        if (detailSystem > 0)
+            sql = "select count(*) from  (select count(*) from wk_video_super_special zb left join wk_video_special c on c.id=zb.specialid where zb.detailsystemid="
+                    + detailSystem + " and c.name like '%" + key + "%' group by zb.specialid) s";
+        else
+            sql = "select count(*) from  (select count(*) from wk_video_super_special zb left join wk_video_special c on c.id=zb.specialid where c.system=" + systemId + " and c.name like '%"
+                    + key + "%'  group by zb.specialid) s";
 
-				List<DetailSystemSelect> dssList = new ArrayList<>();
+        return specialVideoDao.getCountSQL(sql);
+    }
 
-				for (DetailSystem ds : detailSystemList) {
-					DetailSystemSelect dss = new DetailSystemSelect();
-					dss.setDetailSystem(ds);
-					dss.setSelected(false);
-					dssList.add(dss);
-				}
+    @SuppressWarnings("unchecked")
+    public void deleteSpecialAdmin(final String classId, final String detailSystemId) {
+        specialDao.excute(new HibernateCallback() {
+            public Object doInHibernate(Session session) throws HibernateException {
+                try {
 
-				for (DetailSystem ds : detailSystemS) {
-					for (DetailSystemSelect dss : dssList) {
-						if (dss.getDetailSystem().getId().equalsIgnoreCase(ds.getId())) {
-							dss.setSelected(true);
-							break;
-						}
-					}
-				}
-				SuperSpecial sz = new SuperSpecial();
-				sz.setDetailSystem(null);
-				sz.setSpecial(vb);
-				zhiBoClassList.add(new SpecialAdmin(sz, dssList));
-			}
+                    List<SuperSpecial> list = session
+                            .createQuery("from SuperSpecial vb where vb.special.id=? and vb.detailSystem.id=?")
+                            .setParameter(0, classId).setParameter(1, detailSystemId).list();
+                    session.getTransaction().begin();
+                    if (list != null && list.size() > 0) {
+                        for (SuperSpecial vb : list)
+                            session.delete(vb);
+                    }
+                    session.flush();
+                    session.getTransaction().commit();
 
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		return zhiBoClassList;
-	}
+                } catch (Exception e) {
+                    e.printStackTrace();
+                    session.getTransaction().rollback();
+                }
+                return null;
+            }
+        });
 
-	public long getSpecialAdminCount(String key, int detailSystem) {
-		key = StringUtil.isNullOrEmpty(key) ? "" : key;
+    }
 
-		String sql = "";
-		if (detailSystem > 0)
-			sql = "select count(*) from  (select count(*) from wk_video_super_special zb left join wk_video_special c on c.id=zb.specialid where zb.detailsystemid="
-					+ detailSystem + " and c.name like '%" + key + "%' group by zb.specialid) s";
-		else
-			sql = "select count(*) from  (select count(*) from wk_video_super_special zb left join wk_video_special c on c.id=zb.specialid where c.name like '%"
-					+ key + "%'  group by zb.specialid) s";
+    /**
+     * 涓撻
+     */
 
-		return specialVideoDao.getCountSQL(sql);
-	}
+    public List<SuperSpecial> getSuperSpecialList(String detailSystem) {
+        return superSpecialDao.list(
+                "FROM SuperSpecial hs where hs.detailSystem.id=" + detailSystem + " order by hs.Special.orderby desc");
+    }
 
-	@SuppressWarnings("unchecked")
-	public void deleteSpecialAdmin(final String classId, final String detailSystemId) {
-		specialDao.excute(new HibernateCallback() {
-			public Object doInHibernate(Session session) throws HibernateException {
-				try {
+    public void addSuperSpecial(SuperSpecial sv) {
+        List<SuperSpecial> list = superSpecialDao.list("from SuperSpecial sv where sv.special.id="
+                + sv.getSpecial().getId() + " and sv.detailSystem.id=" + sv.getDetailSystem().getId());
+        if (list != null && list.size() > 0)
+            return;
+        superSpecialDao.create(sv);
+    }
 
-					List<SuperSpecial> list = session
-							.createQuery("from SuperSpecial vb where vb.special.id=? and vb.detailSystem.id=?")
-							.setParameter(0, classId).setParameter(1, detailSystemId).list();
-					session.getTransaction().begin();
-					if (list != null && list.size() > 0) {
-						for (SuperSpecial vb : list)
-							session.delete(vb);
-					}
-					session.flush();
-					session.getTransaction().commit();
+    public void updateSuperSpecial(SuperSpecial hotSearch) {
+        superSpecialDao.update(hotSearch);
+    }
 
-				} catch (Exception e) {
-					e.printStackTrace();
-					session.getTransaction().rollback();
-				}
-				return null;
-			}
-		});
+    public void deleteSuperSpecial(SuperSpecial hotSearch) {
+        superSpecialDao.delete(hotSearch);
+    }
 
-	}
+    @SuppressWarnings({"unchecked", "rawtypes"})
+    public void updateSuperSpecialList(final String detailSystemId, final List<SuperSpecial> typeList) {
+        specialDao.excute(new HibernateCallback() {
+            public Object doInHibernate(Session session) throws HibernateException {
+                try {
+                    List<SuperSpecial> list = session
+                            .createQuery("from SuperSpecial sh where sh.detailSystem.id=" + detailSystemId).list();
+                    session.getTransaction().begin();
+                    for (SuperSpecial ad : list) {
+                        session.delete(ad);
+                    }
 
-	/**
-	 * 涓撻
-	 */
+                    for (SuperSpecial videoType : typeList) {
+                        session.persist(videoType);
+                    }
+                    session.flush();
+                    session.getTransaction().commit();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                    session.getTransaction().rollback();
+                }
+                return null;
+            }
+        });
 
-	public List<SuperSpecial> getSuperSpecialList(String detailSystem) {
-		return superSpecialDao.list(
-				"FROM SuperSpecial hs where hs.detailSystem.id=" + detailSystem + " order by hs.Special.orderby desc");
-	}
+    }
 
-	public void addSuperSpecial(SuperSpecial sv) {
-		List<SuperSpecial> list = superSpecialDao.list("from SuperSpecial sv where sv.special.id="
-				+ sv.getSpecial().getId() + " and sv.detailSystem.id=" + sv.getDetailSystem().getId());
-		if (list != null && list.size() > 0)
-			return;
-		superSpecialDao.create(sv);
-	}
-
-	public void updateSuperSpecial(SuperSpecial hotSearch) {
-		superSpecialDao.update(hotSearch);
-	}
-
-	public void deleteSuperSpecial(SuperSpecial hotSearch) {
-		superSpecialDao.delete(hotSearch);
-	}
-
-	@SuppressWarnings({ "unchecked", "rawtypes" })
-	public void updateSuperSpecialList(final String detailSystemId, final List<SuperSpecial> typeList) {
-		specialDao.excute(new HibernateCallback() {
-			public Object doInHibernate(Session session) throws HibernateException {
-				try {
-					List<SuperSpecial> list = session
-							.createQuery("from SuperSpecial sh where sh.detailSystem.id=" + detailSystemId).list();
-					session.getTransaction().begin();
-					for (SuperSpecial ad : list) {
-						session.delete(ad);
-					}
-
-					for (SuperSpecial videoType : typeList) {
-						session.persist(videoType);
-					}
-					session.flush();
-					session.getTransaction().commit();
-				} catch (Exception e) {
-					e.printStackTrace();
-					session.getTransaction().rollback();
-				}
-				return null;
-			}
-		});
-
-	}
-
-	@Cacheable(value = "foundCache",key="'getSpecialOnMain'+'-'+#detailSystem")
-	public List<Special> getSpecialOnMain(String detailSystem) {
-		return specialDao.list("SELECT hs.special FROM SuperSpecial hs where hs.detailSystem.id=" + detailSystem
-				+ " and  hs.special.show=1 and  hs.special.showonmain=1 order by hs.special.orderby desc");
-	}
+    @Cacheable(value = "foundCache", key = "'getSpecialOnMain'+'-'+#detailSystem")
+    public List<Special> getSpecialOnMain(String detailSystem) {
+        return specialDao.list("SELECT hs.special FROM SuperSpecial hs where hs.detailSystem.id=" + detailSystem
+                + " and  hs.special.show=1 and  hs.special.showonmain=1 order by hs.special.orderby desc");
+    }
 
 }

--
Gitblit v1.8.0