From 0a18a8cb0a7a57bf1f82df425251334c57f8c39a Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期六, 23 一月 2021 15:40:37 +0800 Subject: [PATCH] 新增手机号/qq/微信绑定 --- src/main/java/com/yeshi/buwan/service/imp/ClassService.java | 1315 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 659 insertions(+), 656 deletions(-) diff --git a/src/main/java/com/yeshi/buwan/service/imp/ClassService.java b/src/main/java/com/yeshi/buwan/service/imp/ClassService.java index ac1d5d5..4c94e05 100644 --- a/src/main/java/com/yeshi/buwan/service/imp/ClassService.java +++ b/src/main/java/com/yeshi/buwan/service/imp/ClassService.java @@ -6,6 +6,7 @@ import javax.annotation.Resource; +import com.yeshi.buwan.service.inter.VideoResourceMapExtraInfoService; import org.hibernate.CacheMode; import org.hibernate.HibernateException; import org.hibernate.Session; @@ -29,753 +30,755 @@ @Service public class ClassService { - @Resource - private VideoTypeDao videoTypeDao; - @Resource - private VideoInfoDao videoInfoDao; - @Resource - private SuperVideoTypeDao superVideoTypeDao; + @Resource + private VideoTypeDao videoTypeDao; + @Resource + private VideoInfoDao videoInfoDao; + @Resource + private SuperVideoTypeDao superVideoTypeDao; + @Resource + private VideoResourceMapExtraInfoService videoResourceMapExtraInfoService; - public List<VideoType> getTypeList() { - List<VideoType> list = videoTypeDao.list("from VideoType v where v.show='1' and v.parent=null"); - return list; - } + public List<VideoType> getTypeList() { + List<VideoType> list = videoTypeDao.list("from VideoType v where v.show='1' and v.parent=null"); + return list; + } - public VideoType getTypeById(String id) { + public VideoType getTypeById(String id) { - return videoTypeDao.find(VideoType.class, id); - } + return videoTypeDao.find(VideoType.class, id); + } - public VideoType getTypeById(long id) { + public VideoType getTypeById(long id) { - return videoTypeDao.find(VideoType.class, id); - } + return videoTypeDao.find(VideoType.class, id); + } - @Cacheable(value = "classCache", key = "'getFirstTypeList'+'-'+#parentId") - public List<VideoType> getFirstTypeList(String parentId) { - if (StringUtil.isNullOrEmpty(parentId) || parentId.equalsIgnoreCase("0")) - return getTypeList(); + @Cacheable(value = "classCache", key = "'getFirstTypeList'+'-'+#parentId") + public List<VideoType> getFirstTypeList(String parentId) { + if (StringUtil.isNullOrEmpty(parentId) || parentId.equalsIgnoreCase("0")) + return getTypeList(); - List<VideoType> list = videoTypeDao - .list("from VideoType v where v.show='1' and v.parent.id=" + parentId + " order by v.orderby desc"); - return list; - } + List<VideoType> list = videoTypeDao + .list("from VideoType v where v.show='1' and v.parent.id=" + parentId + " order by v.orderby desc"); + return list; + } - public List<VideoType> getAllTypeList() { + public List<VideoType> getAllTypeList() { - List<VideoType> list = videoTypeDao.list("from VideoType v order by v.orderby desc"); - return list; - } + List<VideoType> list = videoTypeDao.list("from VideoType v order by v.orderby desc"); + return list; + } - public List<VideoType> getNextTypeList(String pid) { + public List<VideoType> getNextTypeList(String pid) { - if (StringUtil.isNullOrEmpty(pid)) { - List<VideoType> list = videoTypeDao - .list("from VideoType v where v.show='1' and v.parent=null order by v.orderby desc"); - return list; - } - if (Integer.parseInt(pid) > 0) { - List<VideoType> list = videoTypeDao.list( - (new StringBuilder("from VideoType v where v.show='1' and v.parent.id=")).append(pid).toString() - + " order by v.orderby desc"); - return list; - } else { - List<VideoType> list = videoTypeDao - .list("from VideoType v where v.show='1' and v.parent=null order by v.orderby desc"); - return list; - } - } + if (StringUtil.isNullOrEmpty(pid)) { + List<VideoType> list = videoTypeDao + .list("from VideoType v where v.show='1' and v.parent=null order by v.orderby desc"); + return list; + } + if (Integer.parseInt(pid) > 0) { + List<VideoType> list = videoTypeDao.list( + (new StringBuilder("from VideoType v where v.show='1' and v.parent.id=")).append(pid).toString() + + " order by v.orderby desc"); + return list; + } else { + List<VideoType> list = videoTypeDao + .list("from VideoType v where v.show='1' and v.parent=null order by v.orderby desc"); + return list; + } + } - @SuppressWarnings("unchecked") - public void deleteVideoType(final String id) { - videoTypeDao.excute(new HibernateCallback() { - public Object doInHibernate(Session session) throws HibernateException { - try { - session.getTransaction().begin(); - List<SuperVideoType> list = session.createQuery("from SuperVideoType sv where sv.type.id=?") - .setParameter(0, Long.parseLong(id)).list(); - for (SuperVideoType sv : list) - session.delete(sv); - session.delete(new VideoType(Long.parseLong(id))); - session.flush(); - session.getTransaction().commit(); - } catch (Exception e) { - e.printStackTrace(); - session.getTransaction().rollback(); - } - return null; - } - }); + @SuppressWarnings("unchecked") + public void deleteVideoType(final String id) { + videoTypeDao.excute(new HibernateCallback() { + public Object doInHibernate(Session session) throws HibernateException { + try { + session.getTransaction().begin(); + List<SuperVideoType> list = session.createQuery("from SuperVideoType sv where sv.type.id=?") + .setParameter(0, Long.parseLong(id)).list(); + for (SuperVideoType sv : list) + session.delete(sv); + session.delete(new VideoType(Long.parseLong(id))); + session.flush(); + session.getTransaction().commit(); + } catch (Exception e) { + e.printStackTrace(); + session.getTransaction().rollback(); + } + return null; + } + }); - } + } - public VideoType getType(long id) { + public VideoType getType(long id) { - return videoTypeDao.find(VideoType.class, Long.valueOf(id)); - } + return videoTypeDao.find(VideoType.class, Long.valueOf(id)); + } - public void createType(VideoType type) { + public void createType(VideoType type) { - videoTypeDao.create(type); - } + videoTypeDao.create(type); + } - public void updateType(VideoType type) { + public void updateType(VideoType type) { - videoTypeDao.update(type); - } + videoTypeDao.update(type); + } - public long getTypeVideoCount(String type) { - String wheres = ""; - String sts[] = getChildrenType(Integer.parseInt(type)); - String as[]; - int j = (as = sts).length; - for (int i = 0; i < j; i++) { - String st = as[i]; - wheres = (new StringBuilder(String.valueOf(wheres))).append("or h.videoType.id=").append(Long.parseLong(st)) - .append(" ").toString(); - } + public long getTypeVideoCount(String type) { + String wheres = ""; + String sts[] = getChildrenType(Integer.parseInt(type)); + String as[]; + int j = (as = sts).length; + for (int i = 0; i < j; i++) { + String st = as[i]; + wheres = (new StringBuilder(String.valueOf(wheres))).append("or h.videoType.id=").append(Long.parseLong(st)) + .append(" ").toString(); + } - if (wheres.startsWith("or")) - wheres = wheres.substring(2, wheres.length()); - long count = videoInfoDao - .getCount("select count(*) from CategoryVideo as h where h.video.show='1' and (h.videoType.id=" + type - + " or h.videoType.parent.id=" + type + ")"); - return count; - } + if (wheres.startsWith("or")) + wheres = wheres.substring(2, wheres.length()); + long count = videoInfoDao + .getCount("select count(*) from CategoryVideo as h where h.video.show='1' and (h.videoType.id=" + type + + " or h.videoType.parent.id=" + type + ")"); + return count; + } - @SuppressWarnings("unchecked") - public String[] getChildrenType(final int type) { - return (String[]) videoTypeDao.excute(new HibernateCallback<String[]>() { - public String[] doInHibernate(Session session) throws HibernateException { - String sts[] = new String[] {}; - try { - List<String> list = session.createSQLQuery( - (new StringBuilder("select queryChildrenType(")).append(type).append(")").toString()) - .list(); - sts = list.get(0).toString().substring(2, list.get(0).toString().length()).split(","); - } catch (Exception e) { - e.printStackTrace(); - } + @SuppressWarnings("unchecked") + public String[] getChildrenType(final int type) { + return (String[]) videoTypeDao.excute(new HibernateCallback<String[]>() { + public String[] doInHibernate(Session session) throws HibernateException { + String sts[] = new String[]{}; + try { + List<String> list = session.createSQLQuery( + (new StringBuilder("select queryChildrenType(")).append(type).append(")").toString()) + .list(); + sts = list.get(0).toString().substring(2, list.get(0).toString().length()).split(","); + } catch (Exception e) { + e.printStackTrace(); + } - return sts; - } - }); + return sts; + } + }); - } + } - /** - * - * @param type - * @param page - * @param order - * 1-鏈�杩戞洿鏂� 2-鏈�鐑� 4-璇勮鏈�澶� - * @return - */ - public List<VideoInfo> getTypeVideoList(String type, int page, int order) { - String orderby = ""; - if (order == 1) { - orderby = " order by FROM_UNIXTIME(h.updatetime/1000) desc"; - } else if (order == 2) { - orderby = " order by h.latestWatchCount desc"; - } else if (order == 3) { - orderby = " order by h.commentCount desc"; - } - String wheres = ""; - if (StringUtil.isNullOrEmpty(type)) - return videoInfoDao.list("from VideoInfo as h where h.videoType.parent=null and h.show='1' ?", - (page - 1) * Constant.pageCount, Constant.pageCount, new String[] { orderby }); - String sts[] = getChildrenType(Integer.parseInt(type)); - String as[]; - int j = (as = sts).length; - for (int i = 0; i < j; i++) { - String st = as[i]; - wheres = (new StringBuilder(String.valueOf(wheres))).append("or h.videoType.id=").append(Long.parseLong(st)) - .append(" ").toString(); - } + /** + * @param type + * @param page + * @param order 1-鏈�杩戞洿鏂� 2-鏈�鐑� 4-璇勮鏈�澶� + * @return + */ + public List<VideoInfo> getTypeVideoList(String type, int page, int order) { + String orderby = ""; + if (order == 1) { + orderby = " order by FROM_UNIXTIME(h.updatetime/1000) desc"; + } else if (order == 2) { + orderby = " order by h.latestWatchCount desc"; + } else if (order == 3) { + orderby = " order by h.commentCount desc"; + } + String wheres = ""; + if (StringUtil.isNullOrEmpty(type)) + return videoInfoDao.list("from VideoInfo as h where h.videoType.parent=null and h.show='1' ?", + (page - 1) * Constant.pageCount, Constant.pageCount, new String[]{orderby}); + String sts[] = getChildrenType(Integer.parseInt(type)); + String as[]; + int j = (as = sts).length; + for (int i = 0; i < j; i++) { + String st = as[i]; + wheres = (new StringBuilder(String.valueOf(wheres))).append("or h.videoType.id=").append(Long.parseLong(st)) + .append(" ").toString(); + } - if (wheres.startsWith("or")) - wheres = wheres.substring(2, wheres.length()); - List<VideoInfo> list = videoInfoDao.list("from VideoInfo as h where h.show='1' and (" + wheres + ") " + orderby, - (page - 1) * Constant.pageCount, Constant.pageCount, new String[] {}); - return list; - } + if (wheres.startsWith("or")) + wheres = wheres.substring(2, wheres.length()); + List<VideoInfo> list = videoInfoDao.list("from VideoInfo as h where h.show='1' and (" + wheres + ") " + orderby, + (page - 1) * Constant.pageCount, Constant.pageCount, new String[]{}); + return list; + } - /** - * - * @param type - * @param ds - * @param page - * @param order - * @param resourceList - * @return - */ - @SuppressWarnings("unchecked") - @Cacheable(value = "longTimeCache", key = "'getTypeVideoList'+'-'+#type+'-'+#ds.id+'-'+#page+'-'+#pageCount+'-'+#order+'-'+#cachemd5") - public List<VideoInfo> getTypeVideoList(String type, DetailSystem ds, final int page, final int pageCount, - int order, List<Long> resourceList, String cachemd5) { - String resourceWhere = ""; - for (Long re : resourceList) { - resourceWhere += " rv.resourceid=" + re + " or"; - } + /** + * @param type + * @param ds + * @param page + * @param order + * @param resourceList + * @return + */ + @SuppressWarnings("unchecked") + @Cacheable(value = "longTimeCache", key = "'getTypeVideoList'+'-'+#type+'-'+#ds.id+'-'+#page+'-'+#pageCount+'-'+#order+'-'+#cachemd5") + public List<VideoInfo> getTypeVideoList(String type, DetailSystem ds, final int page, final int pageCount, + int order, List<Long> resourceList, String cachemd5) { + String resourceWhere = ""; + for (Long re : resourceList) { + resourceWhere += " rv.resourceid=" + re + " or"; + } - if (resourceWhere.endsWith("or")) - resourceWhere = resourceWhere.substring(0, resourceWhere.length() - 2); + if (resourceWhere.endsWith("or")) + resourceWhere = resourceWhere.substring(0, resourceWhere.length() - 2); - String orderby = ""; - if (order == 1) { - orderby = " order by FROM_UNIXTIME(v.updatetime/1000) desc"; - } else if (order == 2) { - orderby = " order by v.watchcount desc"; - } else if (order == 3) { - orderby = " order by v.commentcount desc"; - } + String orderby = ""; + if (order == 1) { + orderby = " order by FROM_UNIXTIME(v.updatetime/1000) desc"; + } else if (order == 2) { + orderby = " order by v.watchcount desc"; + } else if (order == 3) { + orderby = " order by v.commentcount desc"; + } - String wheres = ""; - if (StringUtil.isNullOrEmpty(type)) { - return getVideoInfoData(videoInfoDao.sqlList( - "select v.id,v.`name`,v.`tag`,v.`picture`,v.`hpicture`,v.`latest_hpicture`,v.watchcount,v.commentcount from wk_video_video v INNER JOIN (SELECT DISTINCT(v.id) FROM wk_category_video ca LEFT JOIN wk_video_video v ON v.id= ca.videoid LEFT JOIN wk_resource_video rv ON rv.`videoid`= v.`id` AND( ? ) WHERE v.show= 1 and ca.id is not null AND rv.`resourceid` IS NOT NULL ? ) a using(id)", - (page - 1) * pageCount, pageCount, new Serializable[] { resourceWhere, orderby, })); - } + String wheres = ""; + if (StringUtil.isNullOrEmpty(type)) { + return getVideoInfoData(videoInfoDao.sqlList( + "select v.id,v.`name`,v.`tag`,v.`picture`,v.`hpicture`,v.`latest_hpicture`,v.watchcount,v.commentcount from wk_video_video v INNER JOIN (SELECT DISTINCT(v.id) FROM wk_category_video ca LEFT JOIN wk_video_video v ON v.id= ca.videoid LEFT JOIN wk_resource_video rv ON rv.`videoid`= v.`id` AND( ? ) WHERE v.show= 1 and ca.id is not null AND rv.`resourceid` IS NOT NULL ? ) a using(id)", + (page - 1) * pageCount, pageCount, new Serializable[]{resourceWhere, orderby,}),resourceList); + } - List<VideoInfo> list = new ArrayList<VideoInfo>(); + List<VideoInfo> list = new ArrayList<VideoInfo>(); - long startTime = System.currentTimeMillis(); + long startTime = System.currentTimeMillis(); - final String typeNew = type; - final String resourceWhereNew = resourceWhere; - final String orderbyNew = orderby; - list = (List<VideoInfo>) videoTypeDao.excute(new HibernateCallback() { - public Object doInHibernate(Session session) throws HibernateException { - List<VideoInfo> list = new ArrayList<VideoInfo>(); - try { - session.setCacheMode(CacheMode.GET); - String sql = String.format( - "select v.id,v.`name`,v.`tag`,v.`picture`,v.`hpicture`,v.`latest_hpicture`,v.watchcount,v.commentcount from wk_video_video v INNER JOIN (SELECT DISTINCT(v.id) FROM wk_video_video v LEFT JOIN wk_category_video ca ON v.id=ca.videoid LEFT JOIN wk_video_type t ON t.`id`=ca.`videotypeid` AND (t.`id`=%s OR t.`pid`=%s) LEFT JOIN wk_resource_video rv ON rv.`videoid`=v.`id` AND (%s) WHERE v.show=1 AND ca.id>0 AND t.`id`>0 AND rv.`resourceid`>0 %s) a using(id)", - typeNew, typeNew, resourceWhereNew, orderbyNew); - System.out.println(sql); + final String typeNew = type; + final String resourceWhereNew = resourceWhere; + final String orderbyNew = orderby; + list = (List<VideoInfo>) videoTypeDao.excute(new HibernateCallback() { + public Object doInHibernate(Session session) throws HibernateException { + List<VideoInfo> list = new ArrayList<VideoInfo>(); + try { + session.setCacheMode(CacheMode.GET); + String sql = String.format( + "select v.id,v.`name`,v.`tag`,v.`picture`,v.`hpicture`,v.`latest_hpicture`,v.watchcount,v.commentcount from wk_video_video v INNER JOIN (SELECT DISTINCT(v.id) FROM wk_video_video v LEFT JOIN wk_category_video ca ON v.id=ca.videoid LEFT JOIN wk_video_type t ON t.`id`=ca.`videotypeid` AND (t.`id`=%s OR t.`pid`=%s) LEFT JOIN wk_resource_video rv ON rv.`videoid`=v.`id` AND (%s) WHERE v.show=1 AND ca.id>0 AND t.`id`>0 AND rv.`resourceid`>0 %s) a using(id)", + typeNew, typeNew, resourceWhereNew, orderbyNew); + System.out.println(sql); - list = session.createSQLQuery(sql).setFirstResult((page - 1) * pageCount).setCacheable(true) - .setMaxResults(pageCount).list(); - } catch (Exception e) { - e.printStackTrace(); - } - return list; - } - }); + list = session.createSQLQuery(sql).setFirstResult((page - 1) * pageCount).setCacheable(true) + .setMaxResults(pageCount).list(); + } catch (Exception e) { + e.printStackTrace(); + } + return list; + } + }); - System.out.println("鏌ヨSQL璐规椂:" + (System.currentTimeMillis() - startTime)); - return getVideoInfoData(list); - } + System.out.println("鏌ヨSQL璐规椂:" + (System.currentTimeMillis() - startTime)); + return getVideoInfoData(list,resourceList); + } - public List<VideoInfo> getVideoInfoData(List list) { - List<VideoInfo> dataList = new ArrayList<VideoInfo>(); - for (int i = 0; i < list.size(); i++) { - Object[] obj = (Object[]) list.get(i); - VideoInfo info = new VideoInfo(); - info.setId(obj[0] + ""); - info.setName(obj[1] + ""); - info.setTag(obj[2] + ""); - info.setPicture(obj[3] + ""); - info.setHpicture(obj[4] + ""); - info.setLatestHpicture(obj[5] + ""); - info.setWatchCount(obj[6] + ""); - info.setCommentCount(Integer.parseInt(obj[7] + "")); - if (obj.length > 8) { - String[] resourceIds = (obj[8] + "").split(","); - List<VideoResource> resourceList = new ArrayList<VideoResource>(); - for (String rid : resourceIds) - resourceList.add(new VideoResource(rid)); - info.setResourceList(resourceList); - } - if(obj.length > 9){ - info.setVpicture(obj[9]+""); - } - dataList.add(info); - } - return dataList; - } + public List<VideoInfo> getVideoInfoData(List list, List<Long> resourceIdList) { + List<VideoInfo> dataList = new ArrayList<VideoInfo>(); + for (int i = 0; i < list.size(); i++) { + Object[] obj = (Object[]) list.get(i); + VideoInfo info = new VideoInfo(); + info.setId(obj[0] + ""); + info.setName(obj[1] + ""); + info.setTag(obj[2] + ""); + info.setPicture(obj[3] + ""); + info.setHpicture(obj[4] + ""); + info.setLatestHpicture(obj[5] + ""); + info.setWatchCount(obj[6] + ""); + info.setCommentCount(Integer.parseInt(obj[7] + "")); + if (obj.length > 8) { + String[] resourceIds = (obj[8] + "").split(","); + List<VideoResource> resourceList = new ArrayList<VideoResource>(); + for (String rid : resourceIds) + resourceList.add(new VideoResource(rid)); + info.setResourceList(resourceList); + } + if (obj.length > 9) { + info.setVpicture(obj[9] + ""); + } + dataList.add(info); + } - @SuppressWarnings("unchecked") - public List<VideoInfo> getTypeVideoList(String type, String startYear, String endYear, DetailSystem ds, - final int page, int order) { - String orderby = ""; - if (order == 1) { - orderby = " order by v.watchcount desc, v.updatetime desc"; - } else if (order == 2) { - // orderby = " order by v.updatetime desc,v.watchcount desc"; - // 璞嗚眴绯� - // if (ds.getPackageName().contains("doudou")) - orderby = " order by FROM_UNIXTIME(v.createtime/1000) desc"; + dataList = videoResourceMapExtraInfoService.batchExtraInfo(dataList, resourceIdList); - } else if (order == 3) { - orderby = " order by v.orderby desc,v.watchcount desc, v.updatetime desc"; - } else if (order == 4) { - orderby = " order by v.score desc,v.updatetime desc"; - } + return dataList; + } - String yearWhere = ""; - if (!StringUtil.isNullOrEmpty(startYear) && !StringUtil.isNullOrEmpty(endYear)) { - yearWhere = " and (v.year>=" + startYear + " and v.year<=" + endYear + ") "; - } + @SuppressWarnings("unchecked") + public List<VideoInfo> getTypeVideoList(String type, String startYear, String endYear, DetailSystem ds, + final int page, int order) { + String orderby = ""; + if (order == 1) { + orderby = " order by v.watchcount desc, v.updatetime desc"; + } else if (order == 2) { + // orderby = " order by v.updatetime desc,v.watchcount desc"; + // 璞嗚眴绯� + // if (ds.getPackageName().contains("doudou")) + orderby = " order by FROM_UNIXTIME(v.createtime/1000) desc"; - String wheres = ""; - if (StringUtil.isNullOrEmpty(type)) { - final String yearWhereNew = yearWhere; - final String orderbyNew = orderby; - return (List<VideoInfo>) videoTypeDao.excute(new HibernateCallback() { - public Object doInHibernate(Session session) throws HibernateException { - try { - return session - .createSQLQuery( - "SELECT v.* FROM wk_category_video ca left join wk_video_video v on v.id=ca.videoid where v.show=1 " - + yearWhereNew + " group by v.id ?") - .addEntity(VideoInfo.class).setParameter(0, orderbyNew) - .setFirstResult((page - 1) * Constant.pageCount).setMaxResults(Constant.pageCount) - .list(); - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - }); + } else if (order == 3) { + orderby = " order by v.orderby desc,v.watchcount desc, v.updatetime desc"; + } else if (order == 4) { + orderby = " order by v.score desc,v.updatetime desc"; + } - } + String yearWhere = ""; + if (!StringUtil.isNullOrEmpty(startYear) && !StringUtil.isNullOrEmpty(endYear)) { + yearWhere = " and (v.year>=" + startYear + " and v.year<=" + endYear + ") "; + } - String sts[] = getChildrenType(Integer.parseInt(type)); - String as[]; - int j = (as = sts).length; - for (int i = 0; i < j; i++) { - String st = as[i]; - wheres = (new StringBuilder(String.valueOf(wheres))).append("or ca.videotypeid=").append(Long.parseLong(st)) - .append(" ").toString(); - } + String wheres = ""; + if (StringUtil.isNullOrEmpty(type)) { + final String yearWhereNew = yearWhere; + final String orderbyNew = orderby; + return (List<VideoInfo>) videoTypeDao.excute(new HibernateCallback() { + public Object doInHibernate(Session session) throws HibernateException { + try { + return session + .createSQLQuery( + "SELECT v.* FROM wk_category_video ca left join wk_video_video v on v.id=ca.videoid where v.show=1 " + + yearWhereNew + " group by v.id ?") + .addEntity(VideoInfo.class).setParameter(0, orderbyNew) + .setFirstResult((page - 1) * Constant.pageCount).setMaxResults(Constant.pageCount) + .list(); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + }); - if (wheres.startsWith("or")) - wheres = wheres.substring(2, wheres.length()); - List<VideoInfo> list = new ArrayList<VideoInfo>(); + } - final String wheresNew = wheres; - final String yearWhereNew = yearWhere; - final String orderbyNew = orderby; - list = (List<VideoInfo>) videoTypeDao.excute(new HibernateCallback<List<VideoInfo>>() { - public List<VideoInfo> doInHibernate(Session session) throws HibernateException { - List<VideoInfo> list = new ArrayList<VideoInfo>(); - try { - list = session - .createSQLQuery( - "select v.* from wk_category_video ca left join wk_video_video v on v.id=ca.videoid where v.show=1 and (" - + wheresNew + ") " + yearWhereNew + " group by v.id " + orderbyNew) - .addEntity(VideoInfo.class).setFirstResult((page - 1) * Constant.pageCount) - .setMaxResults(Constant.pageCount).list(); - } catch (Exception e) { - e.printStackTrace(); - } - return list; - } - }); + String sts[] = getChildrenType(Integer.parseInt(type)); + String as[]; + int j = (as = sts).length; + for (int i = 0; i < j; i++) { + String st = as[i]; + wheres = (new StringBuilder(String.valueOf(wheres))).append("or ca.videotypeid=").append(Long.parseLong(st)) + .append(" ").toString(); + } - return list; - } + if (wheres.startsWith("or")) + wheres = wheres.substring(2, wheres.length()); + List<VideoInfo> list = new ArrayList<VideoInfo>(); - private List<VideoInfo> parseVideoListAmin(List list) { - List<VideoInfo> resultList = new ArrayList<VideoInfo>(); - for (int i = 0; i < list.size(); i++) { - Object[] objs = (Object[]) list.get(i); - VideoInfo video = new VideoInfo(); - video.setId(objs[0] + ""); - video.setName(objs[1] + ""); - video.setPicture(objs[2] + ""); - video.setLatestHpicture(objs[3] + ""); - video.setHpicture(objs[4] + ""); - video.setCreatetime(Long.parseLong(objs[5] + "")); - video.setShow(objs[6] + ""); + final String wheresNew = wheres; + final String yearWhereNew = yearWhere; + final String orderbyNew = orderby; + list = (List<VideoInfo>) videoTypeDao.excute(new HibernateCallback<List<VideoInfo>>() { + public List<VideoInfo> doInHibernate(Session session) throws HibernateException { + List<VideoInfo> list = new ArrayList<VideoInfo>(); + try { + list = session + .createSQLQuery( + "select v.* from wk_category_video ca left join wk_video_video v on v.id=ca.videoid where v.show=1 and (" + + wheresNew + ") " + yearWhereNew + " group by v.id " + orderbyNew) + .addEntity(VideoInfo.class).setFirstResult((page - 1) * Constant.pageCount) + .setMaxResults(Constant.pageCount).list(); + } catch (Exception e) { + e.printStackTrace(); + } + return list; + } + }); + + return list; + } + + private List<VideoInfo> parseVideoListAmin(List list) { + List<VideoInfo> resultList = new ArrayList<VideoInfo>(); + for (int i = 0; i < list.size(); i++) { + Object[] objs = (Object[]) list.get(i); + VideoInfo video = new VideoInfo(); + video.setId(objs[0] + ""); + video.setName(objs[1] + ""); + video.setPicture(objs[2] + ""); + video.setLatestHpicture(objs[3] + ""); + video.setHpicture(objs[4] + ""); + video.setCreatetime(Long.parseLong(objs[5] + "")); + video.setShow(objs[6] + ""); + + boolean isEx = false; + for (VideoInfo info : resultList) { + if (info.getId().equalsIgnoreCase(video.getId())) { + isEx = true; + break; + } + } + if (!isEx) + resultList.add(video); + } + return resultList; + } + + public List<VideoInfo> getTypeVideoListAdmin(String type, int page, String key, int contenttype) { + String ctwhere = ""; + if (contenttype == 1) + ctwhere = " and v.`contenttype`=1 "; + else if (contenttype > 1) { + ctwhere = " and v.`contenttype`>1 "; + } + String sql = ""; + if (StringUtil.isNullOrEmpty(type)) + sql = String.format( + "SELECT v.`id`,v.name,v.`picture`,v.`latest_hpicture`,v.`hpicture`,v.`createtime`,v.`show` FROM wk_video_video v LEFT JOIN wk_category_video cv ON cv.`videoid`=v.`id` LEFT JOIN wk_video_type ty ON ty.`id`=cv.`videotypeid` WHERE v.`name` LIKE %s %s ORDER BY v.`createtime` DESC", + "'" + key + "%'", ctwhere); + else { + sql = String.format( + "SELECT v.`id`,v.name,v.`picture`,v.`latest_hpicture`,v.`hpicture`,v.`createtime`,v.`show` FROM wk_video_video v LEFT JOIN wk_category_video cv ON cv.`videoid`=v.`id` LEFT JOIN wk_video_type ty ON ty.`id`=cv.`videotypeid` WHERE (ty.`id`=%s OR ty.`pid`=%s) AND v.`name` LIKE %s %s ORDER BY v.`createtime` DESC", + type, type, "'" + key + "%'", ctwhere); + } - boolean isEx = false; - for (VideoInfo info : resultList) { - if (info.getId().equalsIgnoreCase(video.getId())) { - isEx = true; - break; - } - } - if (!isEx) - resultList.add(video); - } - return resultList; - } + List result = videoInfoDao.sqlList(sql, (page - 1) * Constant.pageCount, Constant.pageCount, null); - public List<VideoInfo> getTypeVideoListAdmin(String type, int page, String key, int contenttype) { - String ctwhere = ""; - if (contenttype == 1) - ctwhere = " and v.`contenttype`=1 "; - else if (contenttype > 1) { - ctwhere = " and v.`contenttype`>1 "; - } - String sql = ""; - if (StringUtil.isNullOrEmpty(type)) - sql = String.format( - "SELECT v.`id`,v.name,v.`picture`,v.`latest_hpicture`,v.`hpicture`,v.`createtime`,v.`show` FROM wk_video_video v LEFT JOIN wk_category_video cv ON cv.`videoid`=v.`id` LEFT JOIN wk_video_type ty ON ty.`id`=cv.`videotypeid` WHERE v.`name` LIKE %s %s ORDER BY v.`createtime` DESC", - "'" + key + "%'", ctwhere); - else { - sql = String.format( - "SELECT v.`id`,v.name,v.`picture`,v.`latest_hpicture`,v.`hpicture`,v.`createtime`,v.`show` FROM wk_video_video v LEFT JOIN wk_category_video cv ON cv.`videoid`=v.`id` LEFT JOIN wk_video_type ty ON ty.`id`=cv.`videotypeid` WHERE (ty.`id`=%s OR ty.`pid`=%s) AND v.`name` LIKE %s %s ORDER BY v.`createtime` DESC", - type, type, "'" + key + "%'", ctwhere); - } + List<VideoInfo> list = parseVideoListAmin(result); + return list; + } - List result = videoInfoDao.sqlList(sql, (page - 1) * Constant.pageCount, Constant.pageCount, null); + public long getTypeVideoListAdminCount(String type, String key, int contenttype) { - List<VideoInfo> list = parseVideoListAmin(result); - return list; - } + String wheres = ""; + String ctwhere = ""; + if (contenttype == 1) + ctwhere = " and v.`contenttype`=1 "; + else if (contenttype > 1) { + ctwhere = " and v.`contenttype`>1 "; + } - public long getTypeVideoListAdminCount(String type, String key, int contenttype) { + String sql = ""; + if (StringUtil.isNullOrEmpty(type)) + sql = String.format( + "SELECT count(v.`id`) FROM wk_video_video v LEFT JOIN wk_category_video cv ON cv.`videoid`=v.`id` LEFT JOIN wk_video_type ty ON ty.`id`=cv.`videotypeid` WHERE v.`name` LIKE %s %s", + "'" + key + "%'", ctwhere); + else { + sql = String.format( + "SELECT count(v.`id`) FROM wk_video_video v LEFT JOIN wk_category_video cv ON cv.`videoid`=v.`id` LEFT JOIN wk_video_type ty ON ty.`id`=cv.`videotypeid` WHERE (ty.`id`=%s OR ty.`pid`=%s) AND v.`name` LIKE %s %s", + type, type, "'" + key + "%'", ctwhere); + } - String wheres = ""; - String ctwhere = ""; - if (contenttype == 1) - ctwhere = " and v.`contenttype`=1 "; - else if (contenttype > 1) { - ctwhere = " and v.`contenttype`>1 "; - } + return videoInfoDao.getCountSQL(sql); + } - String sql = ""; - if (StringUtil.isNullOrEmpty(type)) - sql = String.format( - "SELECT count(v.`id`) FROM wk_video_video v LEFT JOIN wk_category_video cv ON cv.`videoid`=v.`id` LEFT JOIN wk_video_type ty ON ty.`id`=cv.`videotypeid` WHERE v.`name` LIKE %s %s", - "'" + key + "%'", ctwhere); - else { - sql = String.format( - "SELECT count(v.`id`) FROM wk_video_video v LEFT JOIN wk_category_video cv ON cv.`videoid`=v.`id` LEFT JOIN wk_video_type ty ON ty.`id`=cv.`videotypeid` WHERE (ty.`id`=%s OR ty.`pid`=%s) AND v.`name` LIKE %s %s", - type, type, "'" + key + "%'", ctwhere); - } + public long getTypeVideoListAdminPage(String type, String key, int contenttype) { + long count = getTypeVideoListAdminCount(type, key, contenttype); + return count % (long) Constant.pageCount != 0L ? count / (long) Constant.pageCount + 1L + : count / (long) Constant.pageCount; + } - return videoInfoDao.getCountSQL(sql); - } + public VideoType getRootVideoType(VideoType ty) { - public long getTypeVideoListAdminPage(String type, String key, int contenttype) { - long count = getTypeVideoListAdminCount(type, key, contenttype); - return count % (long) Constant.pageCount != 0L ? count / (long) Constant.pageCount + 1L - : count / (long) Constant.pageCount; - } + ty = videoTypeDao.find(VideoType.class, ty.getId()); + while (ty.getParent() != null) + ty = ty.getParent(); + return ty; + } - public VideoType getRootVideoType(VideoType ty) { + @SuppressWarnings("unchecked") + public void deleteHotTypeAdmin(final String hotTypeId) { + videoTypeDao.excute(new HibernateCallback() { + public Object doInHibernate(Session session) throws HibernateException { + try { + session.getTransaction().begin(); + List<SuperHotType> list = session.createQuery("from SuperHotType sh where sh.hotType.id=?") + .setParameter(0, hotTypeId).list(); + if (list != null && list.size() > 0) { + for (SuperHotType st : list) { + session.delete(st); + } + } + session.flush(); + session.getTransaction().commit(); + } catch (Exception e) { + e.printStackTrace(); + session.getTransaction().rollback(); + } + return null; + } + }); - ty = videoTypeDao.find(VideoType.class, ty.getId()); - while (ty.getParent() != null) - ty = ty.getParent(); - return ty; - } + } - @SuppressWarnings("unchecked") - public void deleteHotTypeAdmin(final String hotTypeId) { - videoTypeDao.excute(new HibernateCallback() { - public Object doInHibernate(Session session) throws HibernateException { - try { - session.getTransaction().begin(); - List<SuperHotType> list = session.createQuery("from SuperHotType sh where sh.hotType.id=?") - .setParameter(0, hotTypeId).list(); - if (list != null && list.size() > 0) { - for (SuperHotType st : list) { - session.delete(st); - } - } - session.flush(); - session.getTransaction().commit(); - } catch (Exception e) { - e.printStackTrace(); - session.getTransaction().rollback(); - } - return null; - } - }); + @SuppressWarnings("unchecked") + public void deleteVideoTypeAdmin(final String videoTypeId) { + videoTypeDao.excute(new HibernateCallback() { + public Object doInHibernate(Session session) throws HibernateException { + try { + List<SuperVideoType> list = session.createQuery("from SuperVideoType sh where sh.type.id=?") + .setParameter(0, videoTypeId).list(); + session.getTransaction().begin(); + if (list != null && list.size() > 0) { + for (SuperVideoType st : list) { + session.delete(st); + } + } + session.flush(); + session.getTransaction().commit(); + } catch (Exception e) { + e.printStackTrace(); + session.getTransaction().rollback(); + } + return null; + } + }); - } + } - @SuppressWarnings("unchecked") - public void deleteVideoTypeAdmin(final String videoTypeId) { - videoTypeDao.excute(new HibernateCallback() { - public Object doInHibernate(Session session) throws HibernateException { - try { - List<SuperVideoType> list = session.createQuery("from SuperVideoType sh where sh.type.id=?") - .setParameter(0, videoTypeId).list(); - session.getTransaction().begin(); - if (list != null && list.size() > 0) { - for (SuperVideoType st : list) { - session.delete(st); - } - } - session.flush(); - session.getTransaction().commit(); - } catch (Exception e) { - e.printStackTrace(); - session.getTransaction().rollback(); - } - return null; - } - }); + @SuppressWarnings("unchecked") + public void deleteVideoTypeAdmin(final String videtype, final String detailSystem) { + videoTypeDao.excute(new HibernateCallback() { + public Object doInHibernate(Session session) throws HibernateException { + try { + List<SuperVideoType> list = session + .createQuery("from SuperVideoType sh where sh.type.id=? and sh.detailSystem.id=?") + .setParameter(0, Long.parseLong(videtype)).setParameter(1, detailSystem).list(); + session.getTransaction().begin(); + if (list != null && list.size() > 0) { + for (SuperVideoType st : list) { + session.delete(st); + } + } + session.flush(); + session.getTransaction().commit(); + } catch (Exception e) { + e.printStackTrace(); + session.getTransaction().rollback(); + } + return null; + } + }); - } + } - @SuppressWarnings("unchecked") - public void deleteVideoTypeAdmin(final String videtype, final String detailSystem) { - videoTypeDao.excute(new HibernateCallback() { - public Object doInHibernate(Session session) throws HibernateException { - try { - List<SuperVideoType> list = session - .createQuery("from SuperVideoType sh where sh.type.id=? and sh.detailSystem.id=?") - .setParameter(0, Long.parseLong(videtype)).setParameter(1, detailSystem).list(); - session.getTransaction().begin(); - if (list != null && list.size() > 0) { - for (SuperVideoType st : list) { - session.delete(st); - } - } - session.flush(); - session.getTransaction().commit(); - } catch (Exception e) { - e.printStackTrace(); - session.getTransaction().rollback(); - } - return null; - } - }); + @SuppressWarnings("unchecked") + public void deleteHotTypeAdmin(final String hotTypeId, final String detailSystem) { + videoTypeDao.excute(new HibernateCallback() { + public Object doInHibernate(Session session) throws HibernateException { + try { + List<SuperHotType> list = session + .createQuery("from SuperHotType sh where sh.hotType.id=? and sh.detailSystem.id=?") + .setParameter(0, hotTypeId).setParameter(1, detailSystem).list(); + session.getTransaction().begin(); + if (list != null && list.size() > 0) { + for (SuperHotType st : list) { + session.delete(st); + } + } + session.flush(); + session.getTransaction().commit(); + } catch (Exception e) { + e.printStackTrace(); + session.getTransaction().rollback(); + } + return null; + } + }); - } + } - @SuppressWarnings("unchecked") - public void deleteHotTypeAdmin(final String hotTypeId, final String detailSystem) { - videoTypeDao.excute(new HibernateCallback() { - public Object doInHibernate(Session session) throws HibernateException { - try { - List<SuperHotType> list = session - .createQuery("from SuperHotType sh where sh.hotType.id=? and sh.detailSystem.id=?") - .setParameter(0, hotTypeId).setParameter(1, detailSystem).list(); - session.getTransaction().begin(); - if (list != null && list.size() > 0) { - for (SuperHotType st : list) { - session.delete(st); - } - } - session.flush(); - session.getTransaction().commit(); - } catch (Exception e) { - e.printStackTrace(); - session.getTransaction().rollback(); - } - return null; - } - }); + /** + * 棣栭〉澶у垎绫�--鍚庡彴缂栬緫浣跨敤 + * + * @param detailSystem + * @param page + * @return + */ - } + @SuppressWarnings("unchecked") + public List<com.yeshi.buwan.domain.web.VideoTypeAdmin> getVideoTypeAdmin(final int detailSystem, final int pid, + final int page) { + return (List<com.yeshi.buwan.domain.web.VideoTypeAdmin>) videoTypeDao + .excute(new HibernateCallback<List<com.yeshi.buwan.domain.web.VideoTypeAdmin>>() { + public List<com.yeshi.buwan.domain.web.VideoTypeAdmin> doInHibernate(Session session) + throws HibernateException { + List<com.yeshi.buwan.domain.web.VideoTypeAdmin> hotTypeList = new ArrayList<com.yeshi.buwan.domain.web.VideoTypeAdmin>(); + try { + List<DetailSystem> detailSystemList = session.createQuery("from DetailSystem").list(); + String where = ""; - /** - * 棣栭〉澶у垎绫�--鍚庡彴缂栬緫浣跨敤 - * - * @param detailSystem - * @param page - * @return - */ + List<VideoType> list = null; + if (detailSystem > 0) { + where += " where vb.detailSystem.id= " + detailSystem; - @SuppressWarnings("unchecked") - public List<com.yeshi.buwan.domain.web.VideoTypeAdmin> getVideoTypeAdmin(final int detailSystem, final int pid, - final int page) { - return (List<com.yeshi.buwan.domain.web.VideoTypeAdmin>) videoTypeDao - .excute(new HibernateCallback<List<com.yeshi.buwan.domain.web.VideoTypeAdmin>>() { - public List<com.yeshi.buwan.domain.web.VideoTypeAdmin> doInHibernate(Session session) - throws HibernateException { - List<com.yeshi.buwan.domain.web.VideoTypeAdmin> hotTypeList = new ArrayList<com.yeshi.buwan.domain.web.VideoTypeAdmin>(); - try { - List<DetailSystem> detailSystemList = session.createQuery("from DetailSystem").list(); - String where = ""; + if (pid > 0) - List<VideoType> list = null; - if (detailSystem > 0) { - where += " where vb.detailSystem.id= " + detailSystem; + list = session + .createQuery("select vb.type from SuperVideoType vb " + where + + " and vb.type.parent!=null and vb.type.parent.id=" + pid + + " group by vb.type.id order by vb.createtime desc") + .setFirstResult((page - 1) * Constant.pageCount) + .setMaxResults(Constant.pageCount).list(); + else + list = session + .createQuery("select vb.type from SuperVideoType vb " + where + + " and vb.type.parent=null group by vb.type.id order by vb.createtime desc") + .setFirstResult((page - 1) * Constant.pageCount) + .setMaxResults(Constant.pageCount).list(); + } else { + if (pid > 0) + list = session + .createQuery("from VideoType vb where vb.parent!=null and vb.parent.id=" + + pid + " order by vb.createtime desc") + .setFirstResult((page - 1) * Constant.pageCount) + .setMaxResults(Constant.pageCount).list(); + else + list = session + .createQuery( + "from VideoType vb where vb.parent=null order by vb.createtime desc") + .setFirstResult((page - 1) * Constant.pageCount) + .setMaxResults(Constant.pageCount).list(); + } + for (VideoType vb : list) { + List<DetailSystem> detailSystemS = session + .createQuery("select vb.detailSystem from SuperVideoType vb where vb.type.id=?") + .setParameter(0, vb.getId()).list(); - if (pid > 0) + List<DetailSystemSelect> dssList = new ArrayList<DetailSystemSelect>(); - list = session - .createQuery("select vb.type from SuperVideoType vb " + where - + " and vb.type.parent!=null and vb.type.parent.id=" + pid - + " group by vb.type.id order by vb.createtime desc") - .setFirstResult((page - 1) * Constant.pageCount) - .setMaxResults(Constant.pageCount).list(); - else - list = session - .createQuery("select vb.type from SuperVideoType vb " + where - + " and vb.type.parent=null group by vb.type.id order by vb.createtime desc") - .setFirstResult((page - 1) * Constant.pageCount) - .setMaxResults(Constant.pageCount).list(); - } else { - if (pid > 0) - list = session - .createQuery("from VideoType vb where vb.parent!=null and vb.parent.id=" - + pid + " order by vb.createtime desc") - .setFirstResult((page - 1) * Constant.pageCount) - .setMaxResults(Constant.pageCount).list(); - else - list = session - .createQuery( - "from VideoType vb where vb.parent=null order by vb.createtime desc") - .setFirstResult((page - 1) * Constant.pageCount) - .setMaxResults(Constant.pageCount).list(); - } - for (VideoType vb : list) { - List<DetailSystem> detailSystemS = session - .createQuery("select vb.detailSystem from SuperVideoType vb where vb.type.id=?") - .setParameter(0, vb.getId()).list(); + for (DetailSystem ds : detailSystemList) { + DetailSystemSelect dss = new DetailSystemSelect(); + dss.setDetailSystem(ds); + dss.setSelected(false); + dssList.add(dss); + } - List<DetailSystemSelect> dssList = new ArrayList<DetailSystemSelect>(); + // 璁剧疆宸茬粡瀛樺湪鐨� + for (DetailSystem ds : detailSystemS) { - for (DetailSystem ds : detailSystemList) { - DetailSystemSelect dss = new DetailSystemSelect(); - dss.setDetailSystem(ds); - dss.setSelected(false); - dssList.add(dss); - } + for (DetailSystemSelect dss : dssList) { + if (dss.getDetailSystem().getId().equalsIgnoreCase(ds.getId())) { + dss.setSelected(true); + break; + } + } + } - // 璁剧疆宸茬粡瀛樺湪鐨� - for (DetailSystem ds : detailSystemS) { + hotTypeList.add(new com.yeshi.buwan.domain.web.VideoTypeAdmin(vb, dssList)); + } - for (DetailSystemSelect dss : dssList) { - if (dss.getDetailSystem().getId().equalsIgnoreCase(ds.getId())) { - dss.setSelected(true); - break; - } - } - } + } catch (Exception e) { + e.printStackTrace(); + } + return hotTypeList; + } + }); - hotTypeList.add(new com.yeshi.buwan.domain.web.VideoTypeAdmin(vb, dssList)); - } + } - } catch (Exception e) { - e.printStackTrace(); - } - return hotTypeList; - } - }); + /** + * 鑾峰彇鐑棬鍒嗙被鏁伴噺 + * + * @param detailSystem + * @return + */ + public long getVideoTypeAdminCount(int detailSystem, int pid) { - } + String where = ""; + if (detailSystem > 0) { - /** - * 鑾峰彇鐑棬鍒嗙被鏁伴噺 - * - * @param detailSystem - * @return - */ - public long getVideoTypeAdminCount(int detailSystem, int pid) { + where += " where bv.detailsystem= " + detailSystem; + if (pid > 0) + return videoTypeDao.getCountSQL( + "select count(*) from (select count(*) from wk_video_super_class bv left join wk_video_type v on v.id=bv.classid " + + where + " and v.pid=" + pid + " group by bv.hottypeid) s"); + else + return videoTypeDao.getCountSQL( + "select count(*) from (select count(*) from wk_video_super_class bv left join wk_video_type v on v.id=bv.classid " + + where + " and v.pid IS NULL group by bv.hottypeid) s"); + } else { + if (pid > 0) + return videoTypeDao + .getCount("select count(*) from VideoType vt where vt.parent!=null and vt.parent.id=" + pid); + else + return videoTypeDao.getCount("select count(*) from VideoType vt where vt.parent=null"); + } + } - String where = ""; - if (detailSystem > 0) { + public void updateVideoTypes(final String videoid, final List<VideoType> typeList) { + videoTypeDao.excute(new HibernateCallback() { + public Object doInHibernate(Session session) throws HibernateException { + try { + session.createQuery("delete from CategoryVideo cv where cv.video.id=?").setParameter(0, videoid) + .executeUpdate(); + session.getTransaction().begin(); + for (VideoType vt : typeList) { + CategoryVideo cv = new CategoryVideo(); + cv.setVideo(new VideoInfo(videoid)); + cv.setVideoType(vt); + session.persist(cv); + } + session.flush(); + session.getTransaction().commit(); + } catch (Exception e) { + e.printStackTrace(); + session.getTransaction().rollback(); + } + return null; + } + }); - where += " where bv.detailsystem= " + detailSystem; - if (pid > 0) - return videoTypeDao.getCountSQL( - "select count(*) from (select count(*) from wk_video_super_class bv left join wk_video_type v on v.id=bv.classid " - + where + " and v.pid=" + pid + " group by bv.hottypeid) s"); - else - return videoTypeDao.getCountSQL( - "select count(*) from (select count(*) from wk_video_super_class bv left join wk_video_type v on v.id=bv.classid " - + where + " and v.pid IS NULL group by bv.hottypeid) s"); - } else { - if (pid > 0) - return videoTypeDao - .getCount("select count(*) from VideoType vt where vt.parent!=null and vt.parent.id=" + pid); - else - return videoTypeDao.getCount("select count(*) from VideoType vt where vt.parent=null"); - } - } + } - public void updateVideoTypes(final String videoid, final List<VideoType> typeList) { - videoTypeDao.excute(new HibernateCallback() { - public Object doInHibernate(Session session) throws HibernateException { - try { - session.createQuery("delete from CategoryVideo cv where cv.video.id=?").setParameter(0, videoid) - .executeUpdate(); - session.getTransaction().begin(); - for (VideoType vt : typeList) { - CategoryVideo cv = new CategoryVideo(); - cv.setVideo(new VideoInfo(videoid)); - cv.setVideoType(vt); - session.persist(cv); - } - session.flush(); - session.getTransaction().commit(); - } catch (Exception e) { - e.printStackTrace(); - session.getTransaction().rollback(); - } - return null; - } - }); + /** + * 鑾峰彇鏌愪釜瑙嗛鐨勫垎绫� + * + * @param vid + * @return + */ + @Cacheable(value = "homeCache", key = "'getVideoTypeList'+'-'+#vid") + public List<VideoType> getVideoTypeList(String vid) { + return videoTypeDao.list("select cv.videoType from CategoryVideo cv where cv.video.id=?", new String[]{vid}); + } - } + /** + * 鏄剧ず瑙嗛澶у垎绫诲尯 + */ - /** - * 鑾峰彇鏌愪釜瑙嗛鐨勫垎绫� - * - * @param vid - * @return - */ - @Cacheable(value = "homeCache", key = "'getVideoTypeList'+'-'+#vid") - public List<VideoType> getVideoTypeList(String vid) { - return videoTypeDao.list("select cv.videoType from CategoryVideo cv where cv.video.id=?", new String[] { vid }); - } + @Cacheable(value = "classCache", key = "'getSuperVideoTypeList'+'-'+#detailSystem") + public List<SuperVideoType> getSuperVideoTypeList(String detailSystem) { + return superVideoTypeDao.list( + "from SuperVideoType s where s.detailSystem.id=" + detailSystem + " order by s.type.orderby desc"); + } - /** - * 鏄剧ず瑙嗛澶у垎绫诲尯 - */ + @Cacheable(value = "classCache", key = "'getSuperVideoTypeTitleList'+'-'+#detailSystem") + public List<SuperVideoType> getSuperVideoTypeTitleList(String detailSystem) { + return superVideoTypeDao.list( + "from SuperVideoType s where s.detailSystem.id=" + detailSystem + " and s.type.showTitle='1' order by s.type.orderby desc"); + } - @Cacheable(value = "classCache", key = "'getSuperVideoTypeList'+'-'+#detailSystem") - public List<SuperVideoType> getSuperVideoTypeList(String detailSystem) { - return superVideoTypeDao.list( - "from SuperVideoType s where s.detailSystem.id=" + detailSystem + " order by s.type.orderby desc"); - } - - @Cacheable(value = "classCache", key = "'getSuperVideoTypeTitleList'+'-'+#detailSystem") - public List<SuperVideoType> getSuperVideoTypeTitleList(String detailSystem) { - return superVideoTypeDao.list( - "from SuperVideoType s where s.detailSystem.id=" + detailSystem + " and s.type.showTitle='1' order by s.type.orderby desc"); - } - - public void addSuperVideoType(SuperVideoType sv) { - List<SuperVideoType> list = superVideoTypeDao.list("from SuperVideoType sv where sv.type.id=" - + sv.getType().getId() + " and sv.detailSystem.id=" + sv.getDetailSystem().getId()); - if (list != null && list.size() > 0) - return; - superVideoTypeDao.create(sv); - } + public void addSuperVideoType(SuperVideoType sv) { + List<SuperVideoType> list = superVideoTypeDao.list("from SuperVideoType sv where sv.type.id=" + + sv.getType().getId() + " and sv.detailSystem.id=" + sv.getDetailSystem().getId()); + if (list != null && list.size() > 0) + return; + superVideoTypeDao.create(sv); + } - @SuppressWarnings("unchecked") - public void updateSuperVideoTypeList(final String detailSystemId, final List<SuperVideoType> typeList) { - videoTypeDao.excute(new HibernateCallback() { - public Object doInHibernate(Session session) throws HibernateException { - try { - List<SuperVideoType> list = session - .createQuery("from SuperVideoType sh where sh.detailSystem.id=" + detailSystemId).list(); - for (SuperVideoType ad : list) { - session.delete(ad); - } + @SuppressWarnings("unchecked") + public void updateSuperVideoTypeList(final String detailSystemId, final List<SuperVideoType> typeList) { + videoTypeDao.excute(new HibernateCallback() { + public Object doInHibernate(Session session) throws HibernateException { + try { + List<SuperVideoType> list = session + .createQuery("from SuperVideoType sh where sh.detailSystem.id=" + detailSystemId).list(); + for (SuperVideoType ad : list) { + session.delete(ad); + } - for (SuperVideoType videoType : typeList) { - session.persist(videoType); - } + for (SuperVideoType videoType : typeList) { + session.persist(videoType); + } - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - }); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + }); - } + } - public void deleteSuperVideoType(SuperVideoType videoType) { - superVideoTypeDao.delete(videoType); - } + public void deleteSuperVideoType(SuperVideoType videoType) { + superVideoTypeDao.delete(videoType); + } - public List<VideoType> getAllVideoType() { - return videoTypeDao.list("from VideoType vt where vt.parent = null"); - } + public List<VideoType> getAllVideoType() { + return videoTypeDao.list("from VideoType vt where vt.parent = null"); + } } -- Gitblit v1.8.0