From 4ebe7c447e964e1b3ead12abb1d95b75faf67426 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期六, 27 二月 2021 15:22:46 +0800
Subject: [PATCH] PPTV完善,兼容多个系统的框架搭建

---
 src/main/java/com/yeshi/buwan/service/imp/SystemService.java |  482 +++++++++++++++++++++++++++--------------------------
 1 files changed, 246 insertions(+), 236 deletions(-)

diff --git a/src/main/java/com/yeshi/buwan/service/imp/SystemService.java b/src/main/java/com/yeshi/buwan/service/imp/SystemService.java
index 2afeb63..51cebf9 100644
--- a/src/main/java/com/yeshi/buwan/service/imp/SystemService.java
+++ b/src/main/java/com/yeshi/buwan/service/imp/SystemService.java
@@ -40,289 +40,299 @@
 
 /**
  * 绯荤粺鍒嗙被鏈嶅姟
- * 
+ *
  * @author Administrator
- * 
  */
 @Service
 public class SystemService {
-	Logger log = Logger.getLogger(SystemService.class);
+    Logger log = Logger.getLogger(SystemService.class);
 
-	@Resource
-	private DetailSystemDao detailSystemDao;
-	@Resource
-	private SystemInfoDao systemInfoDao;
-	@Resource
-	private ClassService classService;
-	@Resource
-	private StarService starService;
-	@Resource
-	private SpecialService specialService;
+    @Resource
+    private DetailSystemDao detailSystemDao;
+    @Resource
+    private SystemInfoDao systemInfoDao;
+    @Resource
+    private ClassService classService;
+    @Resource
+    private StarService starService;
+    @Resource
+    private SpecialService specialService;
 
-	public ClassService getClassService() {
-		return classService;
-	}
+    public ClassService getClassService() {
+        return classService;
+    }
 
-	public void setClassService(ClassService classService) {
-		this.classService = classService;
-	}
+    public void setClassService(ClassService classService) {
+        this.classService = classService;
+    }
 
-	public StarService getStarService() {
-		return starService;
-	}
+    public StarService getStarService() {
+        return starService;
+    }
 
-	public void setStarService(StarService starService) {
-		this.starService = starService;
-	}
+    public void setStarService(StarService starService) {
+        this.starService = starService;
+    }
 
-	public SpecialService getSpecialService() {
-		return specialService;
-	}
+    public SpecialService getSpecialService() {
+        return specialService;
+    }
 
-	public void setSpecialService(SpecialService specialService) {
-		this.specialService = specialService;
-	}
+    public void setSpecialService(SpecialService specialService) {
+        this.specialService = specialService;
+    }
 
-	public SystemInfoDao getSystemInfoDao() {
-		return systemInfoDao;
-	}
+    public SystemInfoDao getSystemInfoDao() {
+        return systemInfoDao;
+    }
 
-	public void setSystemInfoDao(SystemInfoDao systemInfoDao) {
-		this.systemInfoDao = systemInfoDao;
-	}
+    public void setSystemInfoDao(SystemInfoDao systemInfoDao) {
+        this.systemInfoDao = systemInfoDao;
+    }
 
-	public DetailSystemDao getDetailSystemDao() {
-		return detailSystemDao;
-	}
+    public DetailSystemDao getDetailSystemDao() {
+        return detailSystemDao;
+    }
 
-	public void setDetailSystemDao(DetailSystemDao detailSystemDao) {
-		this.detailSystemDao = detailSystemDao;
-	}
+    public void setDetailSystemDao(DetailSystemDao detailSystemDao) {
+        this.detailSystemDao = detailSystemDao;
+    }
 
-	public List<DetailSystem> getDetailSystemList() {
-		List<DetailSystem> list = detailSystemDao.list("from DetailSystem");
-		return list;
-	}
+    public List<DetailSystem> getDetailSystemList() {
+        List<DetailSystem> list = detailSystemDao.list("from DetailSystem");
+        return list;
+    }
 
-	public List<DetailSystem> getDetailSystemList(String key, int pageIndex) {
-		List<DetailSystem> list = detailSystemDao.list(
-				"from DetailSystem ds where ds.appName like ? order by ds.createtime desc",
-				(pageIndex - 1) * Constant.pageCount, Constant.pageCount, new String[] { "%" + key + "%" });
-		return list;
-	}
+    public List<DetailSystem> getDetailSystemList(String key, int pageIndex) {
+        List<DetailSystem> list = detailSystemDao.list(
+                "from DetailSystem ds where ds.appName like ? order by ds.createtime desc",
+                (pageIndex - 1) * Constant.pageCount, Constant.pageCount, new String[]{"%" + key + "%"});
+        return list;
+    }
 
-	public long getDetailSystemListCount(String key) {
-		return detailSystemDao.getCount("select count(*)  from DetailSystem d where d.appName like ?",
-				new String[] { "%" + key + "%" });
-	}
+    public long getDetailSystemListCount(String key) {
+        return detailSystemDao.getCount("select count(*)  from DetailSystem d where d.appName like ?",
+                new String[]{"%" + key + "%"});
+    }
 
-	@Cacheable(value = "homeCache", key = "'getDetailSystemByPackage'+'-'+#packageName")
-	public DetailSystem getDetailSystemByPackage(String packageName) {
-		long startTime = System.currentTimeMillis();
-		log.info("getDetailSystemByPackage寮�濮嬭姹�");
-		List<DetailSystem> list = detailSystemDao.list("from DetailSystem d where d.packageName=?",
-				new String[] { packageName });
-		log.info("getDetailSystemByPackage璇锋眰瀹屾垚:" + (System.currentTimeMillis() - startTime));
-		if (list != null && list.size() > 0)
-			return list.get(0);
-		else
-			return null;
-	}
+    @Cacheable(value = "homeCache", key = "'getDetailSystemByPackage'+'-'+#packageName")
+    public DetailSystem getDetailSystemByPackage(String packageName) {
+        long startTime = System.currentTimeMillis();
+        log.info("getDetailSystemByPackage寮�濮嬭姹�");
+        List<DetailSystem> list = detailSystemDao.list("from DetailSystem d where d.packageName=?",
+                new String[]{packageName});
+        log.info("getDetailSystemByPackage璇锋眰瀹屾垚:" + (System.currentTimeMillis() - startTime));
+        if (list != null && list.size() > 0)
+            return list.get(0);
+        else
+            return null;
+    }
 
-	public DetailSystem getDetailSystemById(String id) {
-		return detailSystemDao.find(DetailSystem.class, id);
-	}
+    public DetailSystem getDetailSystemById(String id) {
+        return detailSystemDao.find(DetailSystem.class, id);
+    }
 
-	public void updateDetailSystem(DetailSystem system) {
-		detailSystemDao.update(system);
-	}
+    public void updateDetailSystem(DetailSystem system) {
+        detailSystemDao.update(system);
+    }
 
-	public boolean addDetailSystem(DetailSystem system) {
+    public boolean addDetailSystem(DetailSystem system) {
 
-		List<DetailSystem> list = detailSystemDao.list(
-				"from DetailSystem ds where ds.system.id=" + system.getSystem().getId()
-						+ " and ds.packageName=? and ds.platform=" + system.getPlatform(),
-				new String[] { system.getPackageName() });
-		if (list == null || list.size() == 0) {
-			detailSystemDao.create(system);
-			return true;
-		} else
-			return false;
-	}
+        List<DetailSystem> list = detailSystemDao.list(
+                "from DetailSystem ds where ds.system.id=" + system.getSystem().getId()
+                        + " and ds.packageName=? and ds.platform=" + system.getPlatform(),
+                new String[]{system.getPackageName()});
+        if (list == null || list.size() == 0) {
+            detailSystemDao.create(system);
+            return true;
+        } else
+            return false;
+    }
 
-	public List<SystemInfo> getSystemList() {
-		return systemInfoDao.list("from SystemInfo");
-	}
+    public List<SystemInfo> getSystemList() {
+        return systemInfoDao.list("from SystemInfo");
+    }
 
-	@SuppressWarnings("unchecked")
-	public void deleteDetailSystem(final String dsId) {
-		detailSystemDao.excute(new HibernateCallback() {
-			public Object doInHibernate(Session session) throws HibernateException {
-				try {
-					session.getTransaction().begin();
 
-					List<SuperHomeAd> shlist = session.createQuery("from SuperHomeAd sz where sz.detailSystem.id=?")
-							.setParameter(0, dsId).list();
-					for (SuperHomeAd sz : shlist)
-						session.delete(sz);
+    /**
+     * 鑾峰彇绯荤粺
+     *
+     * @param id
+     * @return
+     */
+    public SystemInfo getSystem(String id) {
+        return systemInfoDao.find(SystemInfo.class, id);
+    }
 
-					List<SuperHomeNotice> shnlist = session
-							.createQuery("from SuperHomeNotice sz where sz.detailSystem.id=?").setParameter(0, dsId)
-							.list();
-					for (SuperHomeNotice sz : shnlist)
-						session.delete(sz);
+    @SuppressWarnings("unchecked")
+    public void deleteDetailSystem(final String dsId) {
+        detailSystemDao.excute(new HibernateCallback() {
+            public Object doInHibernate(Session session) throws HibernateException {
+                try {
+                    session.getTransaction().begin();
 
-					List<SuperHomeType> shtlist = session
-							.createQuery("from SuperHomeType sz where sz.detailSystem.id=?").setParameter(0, dsId)
-							.list();
-					for (SuperHomeType sz : shtlist)
-						session.delete(sz);
+                    List<SuperHomeAd> shlist = session.createQuery("from SuperHomeAd sz where sz.detailSystem.id=?")
+                            .setParameter(0, dsId).list();
+                    for (SuperHomeAd sz : shlist)
+                        session.delete(sz);
 
-					List<SuperHotSearch> shslist = session
-							.createQuery("from SuperHotSearch sz where sz.detailSystem.id=?").setParameter(0, dsId)
-							.list();
-					for (SuperHotSearch sz : shslist)
-						session.delete(sz);
+                    List<SuperHomeNotice> shnlist = session
+                            .createQuery("from SuperHomeNotice sz where sz.detailSystem.id=?").setParameter(0, dsId)
+                            .list();
+                    for (SuperHomeNotice sz : shnlist)
+                        session.delete(sz);
 
-					List<SuperHotType> shotlist = session.createQuery("from SuperHotType sz where sz.detailSystem.id=?")
-							.setParameter(0, dsId).list();
-					for (SuperHotType sz : shotlist)
-						session.delete(sz);
+                    List<SuperHomeType> shtlist = session
+                            .createQuery("from SuperHomeType sz where sz.detailSystem.id=?").setParameter(0, dsId)
+                            .list();
+                    for (SuperHomeType sz : shtlist)
+                        session.delete(sz);
 
-					List<SuperRecommendAd> sralist = session
-							.createQuery("from SuperRecommendAd sz where sz.detailSystem.id=?").setParameter(0, dsId)
-							.list();
-					for (SuperRecommendAd sz : sralist)
-						session.delete(sz);
+                    List<SuperHotSearch> shslist = session
+                            .createQuery("from SuperHotSearch sz where sz.detailSystem.id=?").setParameter(0, dsId)
+                            .list();
+                    for (SuperHotSearch sz : shslist)
+                        session.delete(sz);
 
-					List<SuperUserBanner> sublist = session
-							.createQuery("from SuperUserBanner sz where sz.detailSystem.id=?").setParameter(0, dsId)
-							.list();
-					for (SuperUserBanner sz : sublist)
-						session.delete(sz);
+                    List<SuperHotType> shotlist = session.createQuery("from SuperHotType sz where sz.detailSystem.id=?")
+                            .setParameter(0, dsId).list();
+                    for (SuperHotType sz : shotlist)
+                        session.delete(sz);
 
-					List<SuperVideoType> svtlist = session
-							.createQuery("from SuperVideoType sz where sz.detailSystem.id=?").setParameter(0, dsId)
-							.list();
-					for (SuperVideoType sz : svtlist)
-						session.delete(sz);
+                    List<SuperRecommendAd> sralist = session
+                            .createQuery("from SuperRecommendAd sz where sz.detailSystem.id=?").setParameter(0, dsId)
+                            .list();
+                    for (SuperRecommendAd sz : sralist)
+                        session.delete(sz);
 
-					List<VideoBanQuan> vbqlist = session.createQuery("from VideoBanQuan sz where sz.detailSystem.id=?")
-							.setParameter(0, dsId).list();
-					for (VideoBanQuan sz : vbqlist)
-						session.delete(sz);
+                    List<SuperUserBanner> sublist = session
+                            .createQuery("from SuperUserBanner sz where sz.detailSystem.id=?").setParameter(0, dsId)
+                            .list();
+                    for (SuperUserBanner sz : sublist)
+                        session.delete(sz);
 
-					List<VideoBanQuanVideo> vbvlist = session
-							.createQuery("from VideoBanQuanVideo sz where sz.detailSystem.id=?").setParameter(0, dsId)
-							.list();
-					for (VideoBanQuanVideo sz : vbvlist)
-						session.delete(sz);
+                    List<SuperVideoType> svtlist = session
+                            .createQuery("from SuperVideoType sz where sz.detailSystem.id=?").setParameter(0, dsId)
+                            .list();
+                    for (SuperVideoType sz : svtlist)
+                        session.delete(sz);
 
-					List<ShareContent> sclist = session.createQuery("from ShareContent sz where sz.detailSystem.id=?")
-							.setParameter(0, dsId).list();
-					for (ShareContent sz : sclist)
-						session.delete(sz);
+                    List<VideoBanQuan> vbqlist = session.createQuery("from VideoBanQuan sz where sz.detailSystem.id=?")
+                            .setParameter(0, dsId).list();
+                    for (VideoBanQuan sz : vbqlist)
+                        session.delete(sz);
 
-					session.delete(new DetailSystem(dsId));
-					session.flush();
-					session.getTransaction().commit();
-				} catch (Exception e) {
-					e.printStackTrace();
-					session.getTransaction().rollback();
-				}
-				return null;
-			}
-		});
+                    List<VideoBanQuanVideo> vbvlist = session
+                            .createQuery("from VideoBanQuanVideo sz where sz.detailSystem.id=?").setParameter(0, dsId)
+                            .list();
+                    for (VideoBanQuanVideo sz : vbvlist)
+                        session.delete(sz);
 
-	}
+                    List<ShareContent> sclist = session.createQuery("from ShareContent sz where sz.detailSystem.id=?")
+                            .setParameter(0, dsId).list();
+                    for (ShareContent sz : sclist)
+                        session.delete(sz);
 
-	HomeAdService homeAdService;
-	HomeTypeService homeTypeService;
-	HotVideoTypeService hotVideoTypeService;
-	SearchService searchService;
-	UserBannerService userBannerService;
+                    session.delete(new DetailSystem(dsId));
+                    session.flush();
+                    session.getTransaction().commit();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                    session.getTransaction().rollback();
+                }
+                return null;
+            }
+        });
 
-	public void detailSystemClone(String fromid, String toId) {
-		// 棣栭〉Banner
-		List<HomeAd> homeAdlist = homeAdService.getHomeAdList(new DetailSystem(fromid));
-		for (HomeAd ad : homeAdlist) {
-			SuperHomeAd sa = new SuperHomeAd();
-			sa.setCreatetime(System.currentTimeMillis() + "");
-			sa.setDetailSystem(new DetailSystem(toId));
-			sa.setHomeAd(ad);
-			homeAdService.addSuperHomeAd(sa);
-		}
-		// 棣栭〉鏍忕洰
+    }
 
-		List<HomeType> homeTypelist = homeTypeService.getHomeType(fromid);
-		for (HomeType ht : homeTypelist) {
-			SuperHomeType sa = new SuperHomeType();
-			sa.setCreatetime(System.currentTimeMillis() + "");
-			sa.setDetailSystem(new DetailSystem(toId));
-			sa.setHomeType(ht);
-			homeTypeService.addSuperHomeType(sa);
-		}
+    HomeAdService homeAdService;
+    HomeTypeService homeTypeService;
+    HotVideoTypeService hotVideoTypeService;
+    SearchService searchService;
+    UserBannerService userBannerService;
 
-		// 瑙嗛澶у垎绫�
-		List<SuperVideoType> videoTypeList = classService.getSuperVideoTypeList(fromid);
-		for (SuperVideoType ht : videoTypeList) {
-			SuperVideoType sa = new SuperVideoType();
-			sa.setCreatetime(System.currentTimeMillis() + "");
-			sa.setDetailSystem(new DetailSystem(toId));
-			sa.setType(new VideoType(ht.getType().getId()));
-			classService.addSuperVideoType(sa);
-		}
+    public void detailSystemClone(String fromid, String toId) {
+        // 棣栭〉Banner
+        List<HomeAd> homeAdlist = homeAdService.getHomeAdList(new DetailSystem(fromid));
+        for (HomeAd ad : homeAdlist) {
+            SuperHomeAd sa = new SuperHomeAd();
+            sa.setCreatetime(System.currentTimeMillis() + "");
+            sa.setDetailSystem(new DetailSystem(toId));
+            sa.setHomeAd(ad);
+            homeAdService.addSuperHomeAd(sa);
+        }
+        // 棣栭〉鏍忕洰
 
-		// 鐑棬鍒嗙被
-		List<HotVideoType> hotVideoTypeList = hotVideoTypeService.getSuperHotTypeList(fromid);
-		for (HotVideoType ht : hotVideoTypeList) {
-			SuperHotType sa = new SuperHotType();
-			sa.setCreatetime(System.currentTimeMillis() + "");
-			sa.setDetailSystem(new DetailSystem(toId));
-			sa.setHotType(ht);
-			hotVideoTypeService.addSuperHotType(sa);
-		}
+        List<HomeType> homeTypelist = homeTypeService.getHomeType(fromid);
+        for (HomeType ht : homeTypelist) {
+            SuperHomeType sa = new SuperHomeType();
+            sa.setCreatetime(System.currentTimeMillis() + "");
+            sa.setDetailSystem(new DetailSystem(toId));
+            sa.setHomeType(ht);
+            homeTypeService.addSuperHomeType(sa);
+        }
 
-		// 涓撻
+        // 瑙嗛澶у垎绫�
+        List<SuperVideoType> videoTypeList = classService.getSuperVideoTypeList(fromid);
+        for (SuperVideoType ht : videoTypeList) {
+            SuperVideoType sa = new SuperVideoType();
+            sa.setCreatetime(System.currentTimeMillis() + "");
+            sa.setDetailSystem(new DetailSystem(toId));
+            sa.setType(new VideoType(ht.getType().getId()));
+            classService.addSuperVideoType(sa);
+        }
 
-		List<Special> specialList = specialService.getSpecialList(fromid);
-		for (Special special : specialList) {
-			SuperSpecial sa = new SuperSpecial();
-			sa.setDetailSystem(new DetailSystem(toId));
-			sa.setSpecial(new Special(special.getId()));
-			specialService.addSuperSpecial(sa);
-		}
+        // 鐑棬鍒嗙被
+        List<HotVideoType> hotVideoTypeList = hotVideoTypeService.getSuperHotTypeList(fromid);
+        for (HotVideoType ht : hotVideoTypeList) {
+            SuperHotType sa = new SuperHotType();
+            sa.setCreatetime(System.currentTimeMillis() + "");
+            sa.setDetailSystem(new DetailSystem(toId));
+            sa.setHotType(ht);
+            hotVideoTypeService.addSuperHotType(sa);
+        }
 
-		// 鏄庢槦
-		List<HotStar> hotStarList = starService.getHotStarList(fromid);
-		for (HotStar hs : hotStarList) {
-			SuperHotStar sa = new SuperHotStar();
-			sa.setDetailSystem(new DetailSystem(toId));
-			sa.setHotStar(new HotStar(hs.getId()));
-			sa.setCreatetime(System.currentTimeMillis() + "");
-			starService.addSuperHotStar(sa);
-		}
-		// 鐑棬鎼滅储
+        // 涓撻
 
-		List<HotSearch> hotSearchList = searchService.getHotSearchListByDS(fromid);
-		for (HotSearch hs : hotSearchList) {
-			SuperHotSearch sa = new SuperHotSearch();
-			sa.setDetailSystem(new DetailSystem(toId));
-			sa.setHotSearch(new HotSearch(hs.getId()));
-			sa.setCreatetime(System.currentTimeMillis() + "");
-			searchService.addSuperHotSearch(sa);
-		}
+        List<Special> specialList = specialService.getSpecialList(fromid);
+        for (Special special : specialList) {
+            SuperSpecial sa = new SuperSpecial();
+            sa.setDetailSystem(new DetailSystem(toId));
+            sa.setSpecial(new Special(special.getId()));
+            specialService.addSuperSpecial(sa);
+        }
 
-		// 鐢ㄦ埛Banner
-		List<UserBanner> userBannerList = userBannerService.getUserBannerList(fromid);
-		for (UserBanner ub : userBannerList) {
-			SuperUserBanner sa = new SuperUserBanner();
-			sa.setDetailSystem(new DetailSystem(toId));
-			sa.setUserBanner(new UserBanner(ub.getId()));
-			sa.setCreatetime(System.currentTimeMillis() + "");
-			userBannerService.addSuperUserBanner(sa);
-		}
+        // 鏄庢槦
+        List<HotStar> hotStarList = starService.getHotStarList(fromid);
+        for (HotStar hs : hotStarList) {
+            SuperHotStar sa = new SuperHotStar();
+            sa.setDetailSystem(new DetailSystem(toId));
+            sa.setHotStar(new HotStar(hs.getId()));
+            sa.setCreatetime(System.currentTimeMillis() + "");
+            starService.addSuperHotStar(sa);
+        }
+        // 鐑棬鎼滅储
 
-		// 鐩存挱
-	}
+        List<HotSearch> hotSearchList = searchService.getHotSearchListByDS(fromid);
+        for (HotSearch hs : hotSearchList) {
+            SuperHotSearch sa = new SuperHotSearch();
+            sa.setDetailSystem(new DetailSystem(toId));
+            sa.setHotSearch(new HotSearch(hs.getId()));
+            sa.setCreatetime(System.currentTimeMillis() + "");
+            searchService.addSuperHotSearch(sa);
+        }
+
+        // 鐢ㄦ埛Banner
+        List<UserBanner> userBannerList = userBannerService.getUserBannerList(fromid);
+        for (UserBanner ub : userBannerList) {
+            SuperUserBanner sa = new SuperUserBanner();
+            sa.setDetailSystem(new DetailSystem(toId));
+            sa.setUserBanner(new UserBanner(ub.getId()));
+            sa.setCreatetime(System.currentTimeMillis() + "");
+            userBannerService.addSuperUserBanner(sa);
+        }
+
+        // 鐩存挱
+    }
 }

--
Gitblit v1.8.0