From ad3ac53da1c3a11a96ae62d790aa61a81b9eab91 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期六, 20 三月 2021 18:47:23 +0800
Subject: [PATCH] 完善APP首页顶部标签栏兼容,初步处理推送
---
src/main/java/com/yeshi/buwan/service/imp/HomeTypeService.java | 997 +++++++++++++++++++++++++++++-----------------------------
1 files changed, 501 insertions(+), 496 deletions(-)
diff --git a/src/main/java/com/yeshi/buwan/service/imp/HomeTypeService.java b/src/main/java/com/yeshi/buwan/service/imp/HomeTypeService.java
index 146fceb..c2d4f95 100644
--- a/src/main/java/com/yeshi/buwan/service/imp/HomeTypeService.java
+++ b/src/main/java/com/yeshi/buwan/service/imp/HomeTypeService.java
@@ -1,30 +1,21 @@
package com.yeshi.buwan.service.imp;
import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
+import java.util.*;
import javax.annotation.Resource;
+import com.yeshi.buwan.dao.*;
+import com.yeshi.buwan.dao.system.DetailSystemDao;
+import com.yeshi.buwan.domain.*;
+import com.yeshi.buwan.domain.system.DetailSystem;
+import com.yeshi.buwan.service.inter.video.VideoInfoExtraService;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.orm.hibernate4.HibernateCallback;
import org.springframework.stereotype.Service;
-import com.yeshi.buwan.dao.DetailSystemDao;
-import com.yeshi.buwan.dao.HomeTypeDao;
-import com.yeshi.buwan.dao.HomeVideoDao;
-import com.yeshi.buwan.dao.SuperHomeTypeDao;
-import com.yeshi.buwan.dao.VideoInfoDao;
-import com.yeshi.buwan.domain.DetailSystem;
-import com.yeshi.buwan.domain.HomeType;
-import com.yeshi.buwan.domain.HomeVideo;
-import com.yeshi.buwan.domain.SuperHomeType;
-import com.yeshi.buwan.domain.VideoInfo;
import com.yeshi.buwan.domain.web.DetailSystemSelect;
import com.yeshi.buwan.domain.web.HomeTypeAdmin;
import com.yeshi.buwan.util.Constant;
@@ -32,567 +23,581 @@
@Service
public class HomeTypeService {
- @Resource
- private HomeTypeDao homeTypeDao;
- @Resource
- private HomeVideoDao homeVideoDao;
- @Resource
- private VideoInfoDao videoInfoDao;
- @Resource
- private SuperHomeTypeDao superHomeTypeDao;
- @Resource
- private DetailSystemDao detailSystemDao;
+ @Resource
+ private HomeTypeDao homeTypeDao;
+ @Resource
+ private HomeVideoDao homeVideoDao;
+ @Resource
+ private VideoInfoDao videoInfoDao;
+ @Resource
+ private SuperHomeTypeDao superHomeTypeDao;
+ @Resource
+ private DetailSystemDao detailSystemDao;
- public List<HomeType> getHomeType() {
- List<HomeType> list = homeTypeDao.list("from HomeType h order by h.orderby desc");
+ @Resource
+ private VideoInfoExtraService videoInfoExtraService;
- return getHomeType(list);
- }
+ public List<HomeType> getHomeTypeDetailList() {
+ List<HomeType> list = homeTypeDao.list("from HomeType h order by h.orderby desc");
- @SuppressWarnings("unchecked")
- @Cacheable(value = "homeCache", key = "'getHomeType'+'-'+#detailSystem+'-'+#cacheMd5+'-'+#maxNumber+'-'+#vtid")
- public List<HomeType> getHomeType(final String detailSystem, final List<Long> resourceIds, String cacheMd5,
- final int maxNumber, final long vtid) {
- return (List<HomeType>) homeTypeDao.excute(new HibernateCallback<List<HomeType>>() {
- public List<HomeType> doInHibernate(Session session) throws HibernateException {
+ return getHomeType(list);
+ }
- return (List<HomeType>) homeTypeDao.excute(new HibernateCallback<List<HomeType>>() {
- public List<HomeType> doInHibernate(Session session) throws HibernateException {
- try {
- String resourceWhere = "";
- for (Long rid : resourceIds)
- resourceWhere += String.format(" rv.`resourceid`=%d or", rid);
- if (resourceWhere.endsWith("or"))
- resourceWhere = resourceWhere.substring(0, resourceWhere.length() - 2);
+ public List<HomeType> getHomeTypeList(String systemId) {
+ List<HomeType> list = homeTypeDao.list("from HomeType h where h.system.id=? order by h.orderby desc", systemId);
+ return list;
+ }
- // List resultList = session
- // .createSQLQuery(
- // "SELECT ht.`id` as htid,ht.`name` as
- // htname,ht.`columns` as htcolumns
- // ,ht.`hasmore`,ht.`activity` ,ht.`params`
- // ,ht.`ioscontrol`,ht.number,hvideo.id as
- // hvid,hvideo.`videoid` AS
- // hvvideoid,hvideo.`picture`as hvpicture
- // ,hvideo.`tag` as hvtag, v.`id` as vid
- // ,v.`picture` as vpicture ,v.`name` as vname
- // ,v.`tag` as vtag ,v.`hpicture` as vhpicture
- // ,v.`latest_hpicture` as vlatest_hpicture
- // ,v.`watchcount` as
- // vwatchcount,v.commentcount,ht.icon as
- // hicon,ht.orderby FROM (SELECT hv.* FROM
- // `wk_resource_video` rv LEFT JOIN
- // `wk_video_homevideo` hv ON rv.`videoid`
- // =hv.`videoid` LEFT JOIN `wk_video_video` v ON
- // v.`id` =hv.`videoid` LEFT JOIN
- // `wk_video_banquan_video` bv ON
- // bv.`videoid`=hv.`videoid` AND
- // bv.`detailsystemid`="
- // + detailSystem + " AND bv.`show`=1 WHERE
- // (hv.`id`>0 AND v.`show` =1 AND ("
- // + resourceWhere
- // + " AND bv.`videoid` IS NULL) ) GROUP BY
- // (hv.`id`) ORDER BY v.`orderby` desc,v.createtime
- // DESC ) hvideo LEFT JOIN `wk_video_super_hometype`
- // sht ON sht.`hometypeid`=hvideo.hometype LEFT JOIN
- // `wk_video_hometype` ht ON sht.`hometypeid`
- // =ht.`id` LEFT JOIN wk_video_video v ON
- // v.`id`=hvideo.videoid WHERE sht.`detailsystemid`
- // =? ORDER BY hvideo.`orderby` DESC,v.orderby
- // desc,v.updatetime desc")
- // .setParameter(0,
- // Long.parseLong(detailSystem)).list();
- List resultList = session
- .createSQLQuery(
- "SELECT ht.`id` as htid,ht.`name` as htname,ht.`columns` as htcolumns ,ht.`hasmore`,ht.`activity` ,ht.`params` ,ht.`ioscontrol`,ht.number,hvideo.id as hvid,hvideo.`videoid` AS hvvideoid,hvideo.`picture`as hvpicture ,hvideo.`tag` as hvtag, v.`id` as vid ,v.`picture` as vpicture ,v.`name` as vname ,v.`tag` as vtag ,v.`hpicture` as vhpicture ,v.`latest_hpicture` as vlatest_hpicture ,v.`watchcount` as vwatchcount,v.commentcount,ht.icon as hicon,ht.orderby as htorder,hvideo.orderby as hvorder FROM (SELECT hv.* FROM `wk_resource_video` rv LEFT JOIN `wk_video_homevideo` hv ON rv.`videoid` =hv.`videoid` LEFT JOIN `wk_video_video` v ON v.`id` =hv.`videoid` LEFT JOIN `wk_video_banquan_video` bv ON bv.`videoid`=hv.`videoid` AND bv.`detailsystemid`="
- + detailSystem
- + " AND bv.`show`=1 LEFT JOIN `wk_video_hometype` ht ON ht.id=hv.hometype WHERE (hv.`id`>0 AND v.`show` =1 AND ht.vtid='"
- + vtid + "' AND (" + resourceWhere
- + " AND bv.`videoid` IS NULL) ) GROUP BY (hv.`id`) ORDER BY hv.`orderby` desc,v.createtime DESC ) hvideo LEFT JOIN `wk_video_super_hometype` sht ON sht.`hometypeid`=hvideo.hometype LEFT JOIN `wk_video_hometype` ht ON sht.`hometypeid` =ht.`id` LEFT JOIN wk_video_video v ON v.`id`=hvideo.videoid WHERE sht.`detailsystemid` =? ORDER BY hvideo.`orderby` DESC,v.orderby desc,v.updatetime desc")
- .setParameter(0, Long.parseLong(detailSystem)).list();
- List<HomeType> homeTypeList = new ArrayList<HomeType>();
- for (int i = 0; i < resultList.size(); i++) {
- Object[] obj = (Object[]) resultList.get(i);
- HomeType ht = new HomeType();
- ht.setId(obj[0] + "");
- ht.setName(obj[1] + "");
- ht.setColumns(Integer.parseInt(obj[2] + ""));
- ht.setHasMore(Boolean.parseBoolean(obj[3] + ""));
- ht.setActivity(obj[4] + "");
- ht.setParams(obj[5] + "");
- ht.setIosControl(obj[6] + "");
- ht.setNumber(Integer.parseInt(obj[7] + ""));
+ @SuppressWarnings("unchecked")
+ @Cacheable(value = "homeCache", key = "'getHomeType'+'-'+#detailSystem+'-'+#cacheMd5+'-'+#maxNumber+'-'+#dataKey")
+ public List<HomeType> getHomeType(final String detailSystem, final List<Long> resourceIds, String cacheMd5,
+ final int maxNumber, final String dataKey) {
+ List<HomeType> homeTypeList = (List<HomeType>) homeTypeDao.excute(new HibernateCallback<List<HomeType>>() {
+ public List<HomeType> doInHibernate(Session session) throws HibernateException {
- ht.setOrderby(obj[21] + "");
+ return (List<HomeType>) homeTypeDao.excute(new HibernateCallback<List<HomeType>>() {
+ public List<HomeType> doInHibernate(Session session) throws HibernateException {
+ try {
+ String resourceWhere = "";
+ for (Long rid : resourceIds)
+ resourceWhere += String.format(" rv.`resourceid`=%d or", rid);
+ if (resourceWhere.endsWith("or"))
+ resourceWhere = resourceWhere.substring(0, resourceWhere.length() - 2);
+ List resultList = session
+ .createSQLQuery(
+ "SELECT ht.`id` as htid,ht.`name` as htname,ht.`columns` as htcolumns ,ht.`hasmore`,ht.`activity` ,ht.`params` ,ht.`ioscontrol`,ht.number,hvideo.id as hvid,hvideo.`videoid` AS hvvideoid,hvideo.`picture`as hvpicture ,hvideo.`tag` as hvtag, v.`id` as vid ,v.`picture` as vpicture ,v.`name` as vname ,v.`tag` as vtag ,v.`hpicture` as vhpicture ,v.`latest_hpicture` as vlatest_hpicture ,v.`watchcount` as vwatchcount,v.commentcount,ht.icon as hicon,ht.orderby as htorder,hvideo.orderby as hvorder,need_ad FROM (SELECT hv.* FROM `wk_resource_video` rv LEFT JOIN `wk_video_homevideo` hv ON rv.`videoid` =hv.`videoid` LEFT JOIN `wk_video_video` v ON v.`id` =hv.`videoid` LEFT JOIN `wk_video_banquan_video` bv ON bv.`videoid`=hv.`videoid` AND bv.`detailsystemid`="
+ + detailSystem
+ + " AND bv.`show`=1 LEFT JOIN `wk_video_hometype` ht ON ht.id=hv.hometype WHERE (hv.`id`>0 AND v.`show` =1 AND ht.special_data_key='"
+ + dataKey + "' AND (" + resourceWhere
+ + " ) AND bv.`videoid` IS NULL ) GROUP BY (hv.`id`) ORDER BY hv.`orderby` desc,v.createtime DESC ) hvideo LEFT JOIN `wk_video_super_hometype` sht ON sht.`hometypeid`=hvideo.hometype LEFT JOIN `wk_video_hometype` ht ON sht.`hometypeid` =ht.`id` LEFT JOIN wk_video_video v ON v.`id`=hvideo.videoid WHERE sht.`detailsystemid` =" + detailSystem + " ORDER BY hvideo.`orderby` DESC,v.orderby desc,v.updatetime desc")
+ .list();
+ List<HomeType> homeTypeList = new ArrayList<>();
+ for (int i = 0; i < resultList.size(); i++) {
+ Object[] obj = (Object[]) resultList.get(i);
+ HomeType ht = new HomeType();
+ ht.setId(obj[0] + "");
+ ht.setName(obj[1] + "");
+ ht.setColumns(Integer.parseInt(obj[2] + ""));
+ ht.setHasMore(Boolean.parseBoolean(obj[3] + ""));
+ ht.setActivity(obj[4] + "");
+ ht.setParams(obj[5] + "");
+ ht.setIosControl(obj[6] + "");
+ ht.setNumber(Integer.parseInt(obj[7] + ""));
- HomeVideo hv = new HomeVideo();
- hv.setId(obj[8] + "");
- hv.setPicture(obj[10] + "");
- hv.setTag(obj[11] + "");
+ ht.setOrderby(obj[21] + "");
+ ht.setNeedAd(Boolean.parseBoolean(obj[23] + ""));
- VideoInfo video = new VideoInfo();
- video.setId(obj[12] + "");
- video.setPicture(obj[13] + "");
- video.setName(obj[14] + "");
- video.setTag(obj[15] + "");
- video.setHpicture(obj[16] + "");
- video.setLatestHpicture(obj[17] + "");
- video.setWatchCount(obj[18] + "");
- video.setCommentCount(Integer.parseInt(obj[19] + ""));
+ HomeVideo hv = new HomeVideo();
+ hv.setId(obj[8] + "");
+ hv.setPicture(obj[10] + "");
+ hv.setTag(obj[11] + "");
- ht.setIcon(obj[20] + "");
- hv.setVideo(video);
- hv.setOrderby(Integer.parseInt(obj[22] + ""));
- // System.out.println(ht.getName() + "--" +
- // hv.getVideo().getName());
+ VideoInfo video = new VideoInfo();
+ video.setId(obj[12] + "");
+ video.setPicture(obj[13] + "");
+ video.setName(obj[14] + "");
+ video.setTag(obj[15] + "");
+ video.setHpicture(obj[16] + "");
+ video.setLatestHpicture(obj[17] + "");
+ video.setWatchCount(obj[18] + "");
+ video.setCommentCount(obj[19] != null ? Integer.parseInt(obj[19] + "") : 0);
- // 鏇存敼鍥剧墖鏄剧ず
- if (!StringUtil.isNullOrEmpty(hv.getVideo().getLatestHpicture()))
- hv.getVideo().setPicture(hv.getVideo().getLatestHpicture());
- else
- hv.getVideo().setPicture(hv.getVideo().getHpicture());
+ ht.setIcon(obj[20] + "");
+ hv.setVideo(video);
+ hv.setOrderby(Integer.parseInt(obj[22] + ""));
+ // System.out.println(ht.getName() + "--" +
+ // hv.getVideo().getName());
- if (StringUtil.isNullOrEmpty(hv.getPicture()))
- hv.setPicture(hv.getVideo().getPicture());
+ // 鏇存敼鍥剧墖鏄剧ず
+ //濡傛灉涓虹珫鐗�
+ if (ht.getColumns() == 2) {
+ if (!StringUtil.isNullOrEmpty(hv.getVideo().getLatestHpicture()))
+ hv.getVideo().setPicture(hv.getVideo().getLatestHpicture());
+ else
+ hv.getVideo().setPicture(hv.getVideo().getHpicture());
+ } else {
+// hv.getVideo().setPicture(hv.getVideo().getVpicture());
+ }
- if (StringUtil.isNullOrEmpty(hv.getTag()))
- hv.setTag(hv.getVideo().getTag());
+ if (StringUtil.isNullOrEmpty(hv.getPicture()))
+ hv.setPicture(hv.getVideo().getPicture());
- int index = index(homeTypeList, ht);
- if (index > -1) {
- HomeType eHomeType = homeTypeList.get(index);
- int mn = eHomeType.getNumber();
- if (maxNumber > -1)// 鏍规嵁maxNumber鐨勬暟閲忔潵,閫傜敤浜庣綉椤�
- mn = maxNumber;
+ if (StringUtil.isNullOrEmpty(hv.getTag()))
+ hv.setTag(hv.getVideo().getTag());
- if (eHomeType.getHomeVideoList().size() < mn)// 鍔犲叆鎸囧畾鐨勬暟閲忕殑鏁版嵁
- {
- eHomeType.getHomeVideoList().add(hv);
- }
+ int index = index(homeTypeList, ht);
+ if (index > -1) {
+ HomeType eHomeType = homeTypeList.get(index);
+ int mn = eHomeType.getNumber();
+ if (maxNumber > -1)// 鏍规嵁maxNumber鐨勬暟閲忔潵,閫傜敤浜庣綉椤�
+ mn = maxNumber;
- } else {
- List<HomeVideo> videolist = new ArrayList<HomeVideo>();
- videolist.add(hv);
- ht.setHomeVideoList(videolist);
- homeTypeList.add(ht);
- }
- }
+ if (eHomeType.getHomeVideoList().size() < mn)// 鍔犲叆鎸囧畾鐨勬暟閲忕殑鏁版嵁
+ {
+ eHomeType.getHomeVideoList().add(hv);
+ }
- // for (HomeType homeType : homeTypeList) {
- // List<HomeVideo> list =
- // homeType.getHomeVideoList();
- // orderByVideo(list);
- // }
- orderByType(homeTypeList);
+ } else {
+ List<HomeVideo> videolist = new ArrayList<>();
+ videolist.add(hv);
+ ht.setHomeVideoList(videolist);
+ homeTypeList.add(ht);
+ }
+ }
- return homeTypeList;
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
+ // for (HomeType homeType : homeTypeList) {
+ // List<HomeVideo> list =
+ // homeType.getHomeVideoList();
+ // orderByVideo(list);
+ // }
+ orderByType(homeTypeList);
- });
+ return homeTypeList;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
- }
- });
- }
+ });
- private void orderByType(List<HomeType> homeTypeList) {
- Collections.sort(homeTypeList, new Comparator<HomeType>() {
- public int compare(HomeType o1, HomeType o2) {
- return Integer.parseInt(o2.getOrderby()) - Integer.parseInt(o1.getOrderby());
- }
- });
- }
+ }
+ });
+ List<VideoInfo> videoInfoList = new ArrayList<>();
+ for (HomeType ht : homeTypeList) {
+ if (ht.getHomeVideoList() != null)
+ for (HomeVideo hv : ht.getHomeVideoList()) {
+ if (hv.getVideo() != null)
+ videoInfoList.add(hv.getVideo());
+ }
+ }
- private int index(List<HomeType> list, HomeType ht) {
- if (list == null)
- return -1;
- for (int i = 0; i < list.size(); i++) {
- if (list.get(i).getId().equalsIgnoreCase(ht.getId()))
- return i;
- }
- return -1;
- }
+ videoInfoExtraService.batchExtra(videoInfoList, resourceIds);
+ return homeTypeList;
+ }
- public List<HomeType> getHomeType(String detailSystem) {
- List<HomeType> list = homeTypeDao.list("select h.homeType from SuperHomeType h where h.detailSystem.id="
- + detailSystem + " order by h.homeType.orderby desc");
- return getHomeType(list, detailSystem);
- }
+ private void orderByType(List<HomeType> homeTypeList) {
+ Collections.sort(homeTypeList, new Comparator<HomeType>() {
+ public int compare(HomeType o1, HomeType o2) {
+ return Integer.parseInt(o2.getOrderby()) - Integer.parseInt(o1.getOrderby());
+ }
+ });
+ }
- public HomeVideo getHomeVideoById(String homeVideoId) {
- return homeVideoDao.find(HomeVideo.class, homeVideoId);
- }
+ private int index(List<HomeType> list, HomeType ht) {
+ if (list == null)
+ return -1;
+ for (int i = 0; i < list.size(); i++) {
+ if (list.get(i).getId().equalsIgnoreCase(ht.getId()))
+ return i;
+ }
+ return -1;
+ }
- public HomeType getHomeTypeById(String id) {
+ public List<HomeType> getHomeType(String detailSystem) {
+ List<HomeType> list = homeTypeDao.list("select h.homeType from SuperHomeType h where h.detailSystem.id="
+ + detailSystem + " order by h.homeType.orderby desc");
+ return getHomeType(list, detailSystem);
+ }
- return homeTypeDao.find(HomeType.class, id);
- }
+ public HomeVideo getHomeVideoById(String homeVideoId) {
+ return homeVideoDao.find(HomeVideo.class, homeVideoId);
+ }
- public void deleteSuperHomeTypeByType(String homeType) {
- List<SuperHomeType> list = superHomeTypeDao.list("from SuperHomeType sh where sh.homeType.id=" + homeType);
- for (SuperHomeType sht : list) {
- superHomeTypeDao.delete(sht);
- }
- }
+ public HomeType getHomeTypeById(String id) {
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public void deleteHomeType(final String id) {
- homeTypeDao.excute(new HibernateCallback() {
- public Object doInHibernate(Session session) throws HibernateException {
- try {
- session.getTransaction().begin();
- List<SuperHomeType> spList = session.createQuery("from SuperHomeType sht where sht.homeType.id=?")
- .setParameter(0, id).list();
- for (SuperHomeType sp : spList)
- session.delete(sp);
+ return homeTypeDao.find(HomeType.class, id);
+ }
- List<HomeVideo> homeVideoList = session.createQuery("from HomeVideo hv where hv.type.id=?")
- .setParameter(0, id).list();
- for (HomeVideo sp : homeVideoList)
- session.delete(sp);
+ public void deleteSuperHomeTypeByType(String homeType) {
+ List<SuperHomeType> list = superHomeTypeDao.list("from SuperHomeType sh where sh.homeType.id=" + homeType);
+ for (SuperHomeType sht : list) {
+ superHomeTypeDao.delete(sht);
+ }
+ }
- session.delete(new HomeType(id));
- session.flush();
- session.getTransaction().commit();
- } catch (Exception e) {
- e.printStackTrace();
- }
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ public void deleteHomeType(final String id) {
+ homeTypeDao.excute(new HibernateCallback() {
+ public Object doInHibernate(Session session) throws HibernateException {
+ try {
+ session.getTransaction().begin();
+ List<SuperHomeType> spList = session.createQuery("from SuperHomeType sht where sht.homeType.id=?")
+ .setParameter(0, id).list();
+ for (SuperHomeType sp : spList)
+ session.delete(sp);
- return null;
- }
- });
+ List<HomeVideo> homeVideoList = session.createQuery("from HomeVideo hv where hv.type.id=?")
+ .setParameter(0, id).list();
+ for (HomeVideo sp : homeVideoList)
+ session.delete(sp);
- }
+ session.delete(session.get(HomeType.class, id));
+ session.flush();
+ session.getTransaction().commit();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
- public void updateHomeType(HomeType type) {
+ return null;
+ }
+ });
- homeTypeDao.update(type);
- }
+ }
- public void updateHomeVideo(HomeVideo type) {
+ public void updateHomeType(HomeType type) {
- homeVideoDao.update(type);
- }
+ homeTypeDao.update(type);
+ }
- public List<DetailSystemSelect> getDetailSystemSelectByType(String homeType) {
- List<DetailSystemSelect> li = new ArrayList<DetailSystemSelect>();
- List<DetailSystem> list = detailSystemDao
- .list("select sht.detailSystem from SuperHomeType sht where sht.homeType.id=" + homeType);
- List<DetailSystem> sdList = detailSystemDao.list("from DetailSystem");
- for (DetailSystem ds : sdList) {
- boolean contains = false;
- for (DetailSystem dsm : list) {
- if (dsm.getId().equalsIgnoreCase(ds.getId())) {
- contains = true;
- break;
- }
- }
- DetailSystemSelect dss = new DetailSystemSelect();
- dss.setSelected(contains ? true : false);
- dss.setDetailSystem(ds);
- li.add(dss);
- }
- return li;
- }
+ public void updateHomeVideo(HomeVideo type) {
- public void addHomeTypeVideo(HomeVideo video) {
+ homeVideoDao.update(type);
+ }
- long count = homeVideoDao.getCount("select count(*) from HomeVideo h where h.type.id=? and h.video.id=?",
- new String[] { video.getType().getId(), video.getVideo().getId() });
- if (count <= 0L)
- homeVideoDao.create(video);
- }
+ public List<DetailSystemSelect> getDetailSystemSelectByType(String homeType) {
+ List<DetailSystemSelect> li = new ArrayList<>();
+ List<DetailSystem> list = detailSystemDao
+ .list("select sht.detailSystem from SuperHomeType sht where sht.homeType.id=" + homeType);
+ List<DetailSystem> sdList = detailSystemDao.list("from DetailSystem");
+ for (DetailSystem ds : sdList) {
+ boolean contains = false;
+ for (DetailSystem dsm : list) {
+ if (dsm.getId().equalsIgnoreCase(ds.getId())) {
+ contains = true;
+ break;
+ }
+ }
+ DetailSystemSelect dss = new DetailSystemSelect();
+ dss.setSelected(contains ? true : false);
+ dss.setDetailSystem(ds);
+ li.add(dss);
+ }
+ return li;
+ }
- public void addHomeTypeVideo(List<HomeVideo> list) {
- HomeVideo info;
- for (Iterator<HomeVideo> iterator = list.iterator(); iterator.hasNext(); addHomeTypeVideo(info))
- info = (HomeVideo) iterator.next();
- }
+ public void addHomeTypeVideo(HomeVideo video) {
- public void deleteHomeVideo(HomeVideo video) {
+ long count = homeVideoDao.getCount("select count(*) from HomeVideo h where h.type.id=? and h.video.id=?",
+ new String[]{video.getType().getId(), video.getVideo().getId()});
+ if (count <= 0L)
+ homeVideoDao.create(video);
+ }
- homeVideoDao.delete(video);
- }
+ public void addHomeTypeVideo(List<HomeVideo> list) {
+ HomeVideo info;
+ for (Iterator<HomeVideo> iterator = list.iterator(); iterator.hasNext(); addHomeTypeVideo(info))
+ info = (HomeVideo) iterator.next();
+ }
+
+ public void deleteHomeVideo(HomeVideo video) {
+
+ homeVideoDao.delete(video);
+ }
+
+ public void deleteHomeTypeVideo(List<HomeVideo> list) {
+ HomeVideo video;
+ for (Iterator<HomeVideo> iterator = list.iterator(); iterator.hasNext(); deleteHomeVideo(video))
+ video = (HomeVideo) iterator.next();
+ }
+
+ public long getHomeVideoCount(String homeId) {
+
+ return homeVideoDao.getCount("from HomeVideo h where h.type.id=?", new String[]{homeId});
+ }
+
+ public long getHomeTypeVideoPage(String homeId) {
+ long count = getHomeVideoCount(homeId);
+ return count % (long) Constant.pageCount != 0L ? count / (long) Constant.pageCount + 1L
+ : count / (long) Constant.pageCount;
+ }
+
+ public List<HomeVideo> getHomeVideoList(String homeId, int page) {
- public void deleteHomeTypeVideo(List<HomeVideo> list) {
- HomeVideo video;
- for (Iterator<HomeVideo> iterator = list.iterator(); iterator.hasNext(); deleteHomeVideo(video))
- video = (HomeVideo) iterator.next();
- }
+ return homeVideoDao.list(
+ "from HomeVideo h where h.type.id=? order by h.video.orderby desc,h.video.watchCount desc,h.createtime desc",
+ (page - 1) * Constant.pageCount, Constant.pageCount, new String[]{homeId});
+ }
- public long getHomeVideoCount(String homeId) {
+ public List<HomeVideo> getHomeVideoList(String homeId, String key, int page) {
+ return homeVideoDao.list(
+ "from HomeVideo h where h.type.id=? and h.video.name like ? order by h.video.orderby desc,h.video.watchCount desc,h.createtime desc",
+ (page - 1) * Constant.pageCount, Constant.pageCount, new String[]{homeId, "%" + key + "%"});
+ }
- return homeVideoDao.getCount("from HomeVideo h where h.type.id=?", new String[] { homeId });
- }
+ public long getHomeVideoListCount(String homeId, String key) {
+ return homeVideoDao.getCount("select count(*) from HomeVideo h where h.type.id=? and h.video.name like ? ",
+ new String[]{homeId, "%" + key + "%"});
+ }
- public long getHomeTypeVideoPage(String homeId) {
- long count = getHomeVideoCount(homeId);
- return count % (long) Constant.pageCount != 0L ? count / (long) Constant.pageCount + 1L
- : count / (long) Constant.pageCount;
- }
+ public Serializable addHomeType(HomeType type) {
+ return homeTypeDao.save(type);
+ }
- public List<HomeVideo> getHomeVideoList(String homeId, int page) {
+ @SuppressWarnings("unchecked")
+ private List<HomeType> getHomeType(final List<HomeType> list) {
+ homeTypeDao.excute(new HibernateCallback<List<HomeType>>() {
+ public List<HomeType> doInHibernate(Session session) throws HibernateException {
+ try {
+ for (int i = 0; i < list.size(); i++) {
+ List<HomeVideo> videoList = session
+ .createQuery(
+ "select h from HomeVideo h where h.video.show='1' and hometype=:hometype order by h.video.orderby desc,h.video.watchCount desc,h.video.createtime desc")
+ .setParameter("hometype", ((HomeType) list.get(i)).getId()).setFirstResult(0)
+ .setMaxResults(list.get(i).getNumber()).list();
+ ((HomeType) list.get(i)).setHomeVideoList(videoList);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return list;
- return homeVideoDao.list(
- "from HomeVideo h where h.type.id=? order by h.video.orderby desc,h.video.watchCount desc,h.createtime desc",
- (page - 1) * Constant.pageCount, Constant.pageCount, new String[] { homeId });
- }
+ }
+ });
+ return list;
- public List<HomeVideo> getHomeVideoList(String homeId, String key, int page) {
- return homeVideoDao.list(
- "from HomeVideo h where h.type.id=? and h.video.name like ? order by h.video.orderby desc,h.video.watchCount desc,h.createtime desc",
- (page - 1) * Constant.pageCount, Constant.pageCount, new String[] { homeId, "%" + key + "%" });
- }
+ }
- public long getHomeVideoListCount(String homeId, String key) {
- return homeVideoDao.getCount("select count(*) from HomeVideo h where h.type.id=? and h.video.name like ? ",
- new String[] { homeId, "%" + key + "%" });
- }
+ @SuppressWarnings("unchecked")
+ private List<HomeType> getHomeType(final List<HomeType> list, final String detailSystem) {
+ return (List<HomeType>) homeTypeDao.excute(new HibernateCallback<List<HomeType>>() {
+ public List<HomeType> doInHibernate(Session session) throws HibernateException {
+ try {
+ for (int i = 0; i < list.size(); i++) {
+ List<HomeVideo> videoList = session
+ .createSQLQuery(
+ "SELECT h.* FROM wk_video_homevideo h LEFT JOIN wk_video_video v ON v.`id`=h.`videoid` LEFT JOIN wk_resource_video rv on rv.videoid= WHERE v.id=h.videoid AND v.show=1 AND h.`hometype`=? ORDER BY v.orderby DESC,v.`watchcount` DESC,h.createtime DESC")
+ .addEntity(HomeVideo.class).setParameter(0, detailSystem)
+ .setParameter(1, ((HomeType) list.get(i)).getId()).setFirstResult(0)
+ .setMaxResults(list.get(i).getNumber()).list();
+ for (HomeVideo hv : videoList) {
+ if (!StringUtil.isNullOrEmpty(hv.getVideo().getLatestHpicture()))
+ hv.getVideo().setPicture(hv.getVideo().getLatestHpicture());
+ else
+ hv.getVideo().setPicture(hv.getVideo().getHpicture());
+ }
- public Serializable addHomeType(HomeType type) {
- return homeTypeDao.save(type);
- }
+ ((HomeType) list.get(i)).setHomeVideoList(videoList);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return list;
+ }
+ });
- @SuppressWarnings("unchecked")
- private List<HomeType> getHomeType(final List<HomeType> list) {
- homeTypeDao.excute(new HibernateCallback<List<HomeType>>() {
- public List<HomeType> doInHibernate(Session session) throws HibernateException {
- try {
- for (int i = 0; i < list.size(); i++) {
- List<HomeVideo> videoList = session
- .createQuery(
- "select h from HomeVideo h LEFT JOIN h.video as v where v.id=h.video.id and h.video.show='1' and hometype=:hometype order by v.orderby desc,v.watchCount desc,h.createtime desc")
- .setParameter("hometype", ((HomeType) list.get(i)).getId()).setFirstResult(0)
- .setMaxResults(list.get(i).getNumber()).list();
- ((HomeType) list.get(i)).setHomeVideoList(videoList);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return list;
+ }
- }
- });
- return list;
+ @SuppressWarnings("unchecked")
+ public HomeType getHomeType(final HomeType ht, final String detailSystem) {
- }
+ return (HomeType) homeTypeDao.excute(new HibernateCallback<HomeType>() {
+ public HomeType doInHibernate(Session session) throws HibernateException {
+ try {
+ List<HomeVideo> videoList = session
+ .createSQLQuery(
+ "SELECT h.* FROM wk_video_homevideo h LEFT JOIN wk_video_video v ON v.`id`=h.`videoid` LEFT JOIN wk_video_banquan_video bv ON bv.`videoid`=v.`id` and bv.detailsystemid=? and bv.show=1 WHERE v.id=h.videoid AND v.show=1 AND h.`hometype`=? and (bv.videoid is null) ORDER BY v.orderby DESC,v.`watchcount` DESC,h.createtime DESC")
+ .addEntity(HomeVideo.class).setParameter(0, detailSystem)
+ .setParameter(1, ((HomeType) ht).getId()).setFirstResult(0).setMaxResults(ht.getNumber())
+ .list();
+ ((HomeType) ht).setHomeVideoList(videoList);
- @SuppressWarnings("unchecked")
- private List<HomeType> getHomeType(final List<HomeType> list, final String detailSystem) {
- return (List<HomeType>) homeTypeDao.excute(new HibernateCallback<List<HomeType>>() {
- public List<HomeType> doInHibernate(Session session) throws HibernateException {
- try {
- for (int i = 0; i < list.size(); i++) {
- List<HomeVideo> videoList = session
- .createSQLQuery(
- "SELECT h.* FROM wk_video_homevideo h LEFT JOIN wk_video_video v ON v.`id`=h.`videoid` LEFT JOIN wk_resource_video rv on rv.videoid= WHERE v.id=h.videoid AND v.show=1 AND h.`hometype`=? ORDER BY v.orderby DESC,v.`watchcount` DESC,h.createtime DESC")
- .addEntity(HomeVideo.class).setParameter(0, detailSystem)
- .setParameter(1, ((HomeType) list.get(i)).getId()).setFirstResult(0)
- .setMaxResults(list.get(i).getNumber()).list();
- for (HomeVideo hv : videoList) {
- if (!StringUtil.isNullOrEmpty(hv.getVideo().getLatestHpicture()))
- hv.getVideo().setPicture(hv.getVideo().getLatestHpicture());
- else
- hv.getVideo().setPicture(hv.getVideo().getHpicture());
- }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return ht;
+ }
+ });
- ((HomeType) list.get(i)).setHomeVideoList(videoList);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return list;
- }
- });
+ }
- }
+ @Cacheable(value = "homeCache", key = "'getVideoByTypes'+'-'+#homeType+'-'+#page+'-'+#ds.id")
+ public List<HomeVideo> getVideoByTypes(String homeType, int page, DetailSystem ds) {
+ List<HomeVideo> list = null;
+ String sql = "select h from HomeVideo h LEFT JOIN h.juhe as v where v.id=h.video.id and h.video.show='1' and h.type.id=? order by h.video.orderby desc,h.video.watchCount desc,h.createtime desc";
+ if (ds.getPackageName().contains("doudou"))
+ sql = "select h from HomeVideo h LEFT JOIN h.juhe as v where v.id=h.video.id and h.video.show='1' and h.type.id=? order by h.video.year desc, h.video.month desc,h.video.day desc,h.createtime desc";
+ list = homeVideoDao.list(sql, (page - 1) * Constant.pageCount, Constant.pageCount, new String[]{homeType});
+ return list;
+ }
- @SuppressWarnings("unchecked")
- public HomeType getHomeType(final HomeType ht, final String detailSystem) {
+ public List<VideoInfo> getIOSTestTypeVideo(String type, int page) {
+ return videoInfoDao.list(
+ "from VideoInfo v where v.videoType.id=" + type + " and v.show=1 order by createtime desc",
+ (page - 1) * Constant.pageCount, Constant.pageCount, new String[]{});
+ }
- return (HomeType) homeTypeDao.excute(new HibernateCallback<HomeType>() {
- public HomeType doInHibernate(Session session) throws HibernateException {
- try {
- List<HomeVideo> videoList = session
- .createSQLQuery(
- "SELECT h.* FROM wk_video_homevideo h LEFT JOIN wk_video_video v ON v.`id`=h.`videoid` LEFT JOIN wk_video_banquan_video bv ON bv.`videoid`=v.`id` and bv.detailsystemid=? and bv.show=1 WHERE v.id=h.videoid AND v.show=1 AND h.`hometype`=? and (bv.videoid is null) ORDER BY v.orderby DESC,v.`watchcount` DESC,h.createtime DESC")
- .addEntity(HomeVideo.class).setParameter(0, detailSystem)
- .setParameter(1, ((HomeType) ht).getId()).setFirstResult(0).setMaxResults(ht.getNumber())
- .list();
- ((HomeType) ht).setHomeVideoList(videoList);
+ public long getVideoCountByTypes(String homeType, int page) {
+ return homeVideoDao.getCount(
+ "select count(*) from HomeVideo h LEFT JOIN h.video as v where v.id=h.video.id and h.video.show='1' and h.type.id=?",
+ new String[]{homeType});
+ }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return ht;
- }
- });
+ /**
+ * 鍚庡彴鎿嶄綔
+ */
- }
+ @SuppressWarnings("unchecked")
+ public List<HomeTypeAdmin> getHomeTypeAdmin(final String key, final String systemId, final String dataKey, final int detailSystem, final int page) {
- @Cacheable(value = "homeCache", key = "'getVideoByTypes'+'-'+#homeType+'-'+#page+'-'+#ds.id")
- public List<HomeVideo> getVideoByTypes(String homeType, int page, DetailSystem ds) {
- List<HomeVideo> list = null;
- String sql = "select h from HomeVideo h LEFT JOIN h.video as v where v.id=h.video.id and h.video.show='1' and h.type.id=? order by h.video.orderby desc,h.video.watchCount desc,h.createtime desc";
- if (ds.getPackageName().contains("doudou"))
- sql = "select h from HomeVideo h LEFT JOIN h.video as v where v.id=h.video.id and h.video.show='1' and h.type.id=? order by h.video.year desc, h.video.month desc,h.video.day desc,h.createtime desc";
- list = homeVideoDao.list(sql, (page - 1) * Constant.pageCount, Constant.pageCount, new String[] { homeType });
- return list;
- }
+ return (List<HomeTypeAdmin>) homeTypeDao.excute(new HibernateCallback<List<HomeTypeAdmin>>() {
+ public List<HomeTypeAdmin> doInHibernate(Session session) throws HibernateException {
+ List<HomeTypeAdmin> zhiBoClassList = new ArrayList<>();
+ try {
+ List<DetailSystem> detailSystemList = session.createQuery("from DetailSystem ds where ds.system.id=" + systemId).list();
+ String sql = "";
+ List<String> andList = new ArrayList<>();
+ if (detailSystem > 0) {
+ andList.add("sh.homeType.name like ?");
+ andList.add("sh.detailSystem.id=" + detailSystem);
+ if (dataKey != null) {
+ andList.add("sh.homeType.specialDataKey='" + dataKey+"'");
+ }
+ sql = "select sh.homeType from SuperHomeType sh where " + org.yeshi.utils.StringUtil.concat(andList, " and ") + " order by sh.homeType.orderby desc";
+ } else {
+ andList.add("zb.name like ?");
+ andList.add("zb.system.id=" + systemId);
+ if (dataKey != null) {
+ andList.add("zb.specialDataKey='" + dataKey+"'");
+ }
+ sql = "from HomeType zb where " + org.yeshi.utils.StringUtil.concat(andList, " and ") + " order by zb.orderby desc";
+ }
+ List<HomeType> list = session.createQuery(sql).setParameter(0, "%" + key + "%")
+ .setFirstResult((page - 1) * Constant.pageCount).setMaxResults(Constant.pageCount).list();
+ for (HomeType vb : list) {
+ List<DetailSystem> detailSystemS = session
+ .createQuery("select vb.detailSystem from SuperHomeType vb where vb.homeType.id=?")
+ .setParameter(0, vb.getId()).list();
- public List<VideoInfo> getIOSTestTypeVideo(String type, int page) {
- return videoInfoDao.list(
- "from VideoInfo v where v.videoType.id=" + type + " and v.show=1 order by createtime desc",
- (page - 1) * Constant.pageCount, Constant.pageCount, new String[] {});
- }
+ List<DetailSystemSelect> dssList = new ArrayList<>();
- public long getVideoCountByTypes(String homeType, int page) {
- return homeVideoDao.getCount(
- "select count(*) from HomeVideo h LEFT JOIN h.video as v where v.id=h.video.id and h.video.show='1' and h.type.id=?",
- new String[] { homeType });
- }
+ for (DetailSystem ds : detailSystemList) {
+ DetailSystemSelect dss = new DetailSystemSelect();
+ dss.setDetailSystem(ds);
+ dss.setSelected(false);
+ dssList.add(dss);
+ }
- /**
- * 鍚庡彴鎿嶄綔
- */
+ // 璁剧疆宸茬粡瀛樺湪鐨�
+ for (DetailSystem ds : detailSystemS) {
+ for (DetailSystemSelect dss : dssList) {
+ if (dss.getDetailSystem().getId().equalsIgnoreCase(ds.getId())) {
+ dss.setSelected(true);
+ break;
+ }
+ }
+ }
+ SuperHomeType sz = new SuperHomeType();
+ sz.setDetailSystem(null);
+ sz.setHomeType(vb);
+ zhiBoClassList.add(new HomeTypeAdmin(sz, dssList));
+ }
- @SuppressWarnings("unchecked")
- public List<HomeTypeAdmin> getHomeTypeAdmin(final String key, final int detailSystem, final int page) {
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return zhiBoClassList;
+ }
+ });
- return (List<HomeTypeAdmin>) homeTypeDao.excute(new HibernateCallback<List<HomeTypeAdmin>>() {
- public List<HomeTypeAdmin> doInHibernate(Session session) throws HibernateException {
- List<HomeTypeAdmin> zhiBoClassList = new ArrayList<HomeTypeAdmin>();
- try {
- List<DetailSystem> detailSystemList = session.createQuery("from DetailSystem").list();
- String sql = "";
- if (detailSystem > 0)
- sql = "select sh.homeType from SuperHomeType sh where sh.homeType.name like ? and sh.detailSystem.id="
- + detailSystem + " order by sh.homeType.orderby desc";
- else
- sql = "from HomeType zb where zb.name like ? order by zb.orderby desc";
+ }
- List<HomeType> list = session.createQuery(sql).setParameter(0, "%" + key + "%")
- .setFirstResult((page - 1) * Constant.pageCount).setMaxResults(Constant.pageCount).list();
- for (HomeType vb : list) {
- List<DetailSystem> detailSystemS = session
- .createQuery("select vb.detailSystem from SuperHomeType vb where vb.homeType.id=?")
- .setParameter(0, vb.getId()).list();
+ public long getHomeTypeAdminCount(String key, String systemId, int detailSystem, final String dataKey) {
+ List<String> andList = new ArrayList<>();
- List<DetailSystemSelect> dssList = new ArrayList<DetailSystemSelect>();
- for (DetailSystem ds : detailSystemList) {
- DetailSystemSelect dss = new DetailSystemSelect();
- dss.setDetailSystem(ds);
- dss.setSelected(false);
- dssList.add(dss);
- }
+ String sql = "";
+ if (detailSystem > 0) {
+ andList.add("zb.detailsystemid=" + detailSystem);
+ andList.add("c.name like '%" + key + "%'");
+ if (dataKey != null) {
+ andList.add("c.special_data_key='" + dataKey + "'");
+ }
- // 璁剧疆宸茬粡瀛樺湪鐨�
- for (DetailSystem ds : detailSystemS) {
- for (DetailSystemSelect dss : dssList) {
- if (dss.getDetailSystem().getId().equalsIgnoreCase(ds.getId())) {
- dss.setSelected(true);
- break;
- }
- }
- }
- SuperHomeType sz = new SuperHomeType();
- sz.setDetailSystem(null);
- sz.setHomeType(vb);
- zhiBoClassList.add(new HomeTypeAdmin(sz, dssList));
- }
+ sql = "select count(*) from (select count(*) from wk_video_super_hometype zb left join wk_video_hometype c on c.id=zb.hometypeid where " + org.yeshi.utils.StringUtil.concat(andList, " and ") + " group by zb.hometypeid) s";
- } catch (Exception e) {
- e.printStackTrace();
- }
- return zhiBoClassList;
- }
- });
- }
+ } else {
- public long getHomeTypeAdminCount(String key, int detailSystem) {
- String sql = "";
- if (detailSystem > 0)
- sql = "select count(*) from (select count(*) from wk_video_super_hometype zb left join wk_video_hometype c on c.id=zb.hometypeid where zb.detailsystemid="
- + detailSystem + " and c.name like '%" + key + "%' group by zb.hometypeid) s";
- else
- sql = "select count(*) from (select count(*) from wk_video_super_hometype zb left join wk_video_hometype c on c.id=zb.hometypeid where c.name like '%"
- + key + "%' group by zb.hometypeid) s";
+ andList.add("c.name like '%" + key + "%'");
+ andList.add("c.system=" + systemId);
+ if (dataKey != null) {
+ andList.add("c.special_data_key='" + dataKey + "'");
+ }
- return homeTypeDao.getCountSQL(sql);
- }
+ sql = "select count(*) from (select count(*) from wk_video_super_hometype zb left join wk_video_hometype c on c.id=zb.hometypeid where " + org.yeshi.utils.StringUtil.concat(andList, " and ") + " group by zb.hometypeid) s";
+ }
+ return homeTypeDao.getCountSQL(sql);
+ }
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public void deleteHomeTypeAdmin(final String classId, final String detailSystemId) {
- homeTypeDao.excute(new HibernateCallback() {
- public Object doInHibernate(Session session) throws HibernateException {
- try {
- List<SuperHomeType> list = session
- .createQuery("from SuperHomeType vb where vb.homeType.id=? and vb.detailSystem.id=?")
- .setParameter(0, classId).setParameter(1, detailSystemId).list();
- session.getTransaction().begin();
- if (list != null && list.size() > 0) {
- for (SuperHomeType vb : list)
- session.delete(vb);
- }
- session.flush();
- session.getTransaction().commit();
- } catch (Exception e) {
- e.printStackTrace();
- session.getTransaction().rollback();
- }
- return null;
- }
- });
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ public void deleteHomeTypeAdmin(final String classId, final String detailSystemId) {
+ homeTypeDao.excute(new HibernateCallback() {
+ public Object doInHibernate(Session session) throws HibernateException {
+ try {
+ List<SuperHomeType> list = session
+ .createQuery("from SuperHomeType vb where vb.homeType.id=? and vb.detailSystem.id=?")
+ .setParameter(0, classId).setParameter(1, detailSystemId).list();
+ session.getTransaction().begin();
+ if (list != null && list.size() > 0) {
+ for (SuperHomeType vb : list)
+ session.delete(vb);
+ }
+ session.flush();
+ session.getTransaction().commit();
+ } catch (Exception e) {
+ e.printStackTrace();
+ session.getTransaction().rollback();
+ }
+ return null;
+ }
+ });
- }
+ }
- public List<HomeType> getSuperHomeTypeList(String detailSystemId) {
- return homeTypeDao.list("select sh.homeType from SuperHomeType sh where sh.detailSystem.id=" + detailSystemId);
- }
+ public List<HomeType> getSuperHomeTypeList(String detailSystemId) {
+ return homeTypeDao.list("select sh.homeType from SuperHomeType sh where sh.detailSystem.id=" + detailSystemId);
+ }
- // 鏇存柊骞垮憡鍒楄〃
- @SuppressWarnings("unchecked")
- public void updateSuperHomeTypeList(final String detailSystemId, final List<HomeType> typeList) {
- homeTypeDao.excute(new HibernateCallback() {
- public Object doInHibernate(Session session) throws HibernateException {
- try {
- List<SuperHomeType> list = session
- .createQuery("from SuperHomeType sh where sh.detailSystem.id=" + detailSystemId).list();
- session.getTransaction().begin();
- for (SuperHomeType ad : list) {
- session.delete(ad);
- }
+ // 鏇存柊骞垮憡鍒楄〃
+ @SuppressWarnings("unchecked")
+ public void updateSuperHomeTypeList(final String detailSystemId, final List<HomeType> typeList) {
+ homeTypeDao.excute(new HibernateCallback() {
+ public Object doInHibernate(Session session) throws HibernateException {
+ try {
+ List<SuperHomeType> list = session
+ .createQuery("from SuperHomeType sh where sh.detailSystem.id=" + detailSystemId).list();
+ session.getTransaction().begin();
+ for (SuperHomeType ad : list) {
+ session.delete(ad);
+ }
- for (HomeType homeType : typeList) {
- SuperHomeType shd = new SuperHomeType();
- shd.setCreatetime(System.currentTimeMillis() + "");
- shd.setDetailSystem(new DetailSystem(detailSystemId));
- shd.setHomeType(homeType);
- session.persist(shd);
- }
- session.flush();
- session.getTransaction().commit();
- } catch (Exception e) {
- e.printStackTrace();
- session.getTransaction().rollback();
- }
- return null;
- }
- });
+ for (HomeType homeType : typeList) {
+ SuperHomeType shd = new SuperHomeType();
+ shd.setCreatetime(System.currentTimeMillis() + "");
+ shd.setDetailSystem(new DetailSystem(detailSystemId));
+ shd.setHomeType(homeType);
+ session.persist(shd);
+ }
+ session.flush();
+ session.getTransaction().commit();
+ } catch (Exception e) {
+ e.printStackTrace();
+ session.getTransaction().rollback();
+ }
+ return null;
+ }
+ });
- }
+ }
- public void addSuperHomeType(SuperHomeType sv) {
- List<SuperHomeType> list = superHomeTypeDao.list(
- "from SuperHomeType sv where sv.homeType.id=? and sv.detailSystem.id=?",
- new String[] { sv.getHomeType().getId(), sv.getDetailSystem().getId() });
- if (list != null && list.size() > 0)
- return;
- superHomeTypeDao.create(sv);
- }
+ public void addSuperHomeType(SuperHomeType sv) {
+ List<SuperHomeType> list = superHomeTypeDao.list(
+ "from SuperHomeType sv where sv.homeType.id=? and sv.detailSystem.id=?",
+ new String[]{sv.getHomeType().getId(), sv.getDetailSystem().getId()});
+ if (list != null && list.size() > 0)
+ return;
+ superHomeTypeDao.create(sv);
+ }
}
--
Gitblit v1.8.0