// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
|
// Jad home page: http://www.kpdus.com/jad.html
|
// Decompiler options: packimports(3)
|
// Source File Name: StarService.java
|
|
package com.yeshi.buwan.service.imp;
|
|
import java.io.Serializable;
|
import java.util.ArrayList;
|
import java.util.List;
|
|
import javax.annotation.Resource;
|
|
import com.yeshi.buwan.service.inter.VideoResourceMapExtraInfoService;
|
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.HotStarDao;
|
import com.yeshi.buwan.dao.SuperHotStarDao;
|
import com.yeshi.buwan.dao.VideoInfoDao;
|
import com.yeshi.buwan.domain.DetailSystem;
|
import com.yeshi.buwan.domain.HotStar;
|
import com.yeshi.buwan.domain.SuperHotStar;
|
import com.yeshi.buwan.domain.VideoInfo;
|
import com.yeshi.buwan.domain.web.DetailSystemSelect;
|
import com.yeshi.buwan.domain.web.HotStarAdmin;
|
import com.yeshi.buwan.util.Constant;
|
import com.yeshi.buwan.util.SolrUtil;
|
import com.yeshi.buwan.util.StringUtil;
|
|
@Service
|
public class StarService {
|
@Resource
|
private HotStarDao hotStarDao;
|
@Resource
|
private VideoInfoDao videoInfoDao;
|
@Resource
|
private SuperHotStarDao superHotStarDao;
|
|
@Resource
|
private DetailSystemDao detailSystemDao;
|
|
@Resource
|
private VideoResourceMapExtraInfoService videoResourceMapExtraInfoService;
|
|
public StarService() {
|
|
}
|
|
@Cacheable(value = "classCache", key = "'getHotStarList'+'-'+#page+'-'+#pageCount")
|
public List<HotStar> getHotStarList(int page, int pageCount) {
|
|
List<HotStar> list = hotStarDao.list("from HotStar h order by h.orderby desc,h.createtime desc",
|
(page - 1) * pageCount, pageCount, new String[]{});
|
return list;
|
}
|
|
public List<HotStar> getHotStarList(String detailSystem, int page) {
|
List<HotStar> list = hotStarDao.list(
|
"select h.hotStar from SuperHotStar h where h.detailSystem.id=? order by h.hotStar.orderby desc,h.hotStar.createtime desc",
|
(page - 1) * Constant.pageCount, Constant.pageCount, new String[]{detailSystem});
|
return list;
|
}
|
|
@Cacheable(value = "classCache", key = "'getHotStarDetail'+'-'+#id")
|
public HotStar getHotStarDetail(String id) {
|
|
return hotStarDao.find(HotStar.class, id);
|
}
|
|
public long getHotStarCount() {
|
|
return hotStarDao.getCount("select count(*) from HotStar");
|
}
|
|
public long getHotStarCount(String detailSystem) {
|
|
return hotStarDao.getCount("select count(*) from SuperHotStar s where s.detailSystem.id=?",
|
new String[]{detailSystem});
|
}
|
|
public List<VideoInfo> getHotStarVideo(String starId, int page) {
|
|
List<VideoInfo> list = videoInfoDao.list(
|
"select h.video from HotStarVideo as h LEFT JOIN h.video as v where h.video.show='1' and v.id=h.video.id and h.star.id=? order by h.video.updatetime desc",
|
(page - 1) * Constant.pageCount, Constant.pageCount, new String[]{starId});
|
return list;
|
}
|
|
public long getHotStarVideoCount(String starId) {
|
|
long count = hotStarDao.getCount(
|
"select count(*) from HotStarVideo as h where h.video.show='1' and h.star.id=?",
|
new String[]{starId});
|
return count;
|
}
|
|
public List<HotStar> getStarList() {
|
return hotStarDao.list("from HotStar h order by h.orderby DESC");
|
}
|
|
public HotStar getStar(String id) {
|
if (!StringUtil.isNullOrEmpty(id)) {
|
return (HotStar) hotStarDao.find(HotStar.class, id);
|
} else {
|
return null;
|
}
|
}
|
|
public HotStar addStar(HotStar star) {
|
if (star != null) {
|
hotStarDao.save(star);
|
List<HotStar> list = hotStarDao.list("from HotStar h where h.createtime=? and h.name=?",
|
new String[]{star.getCreatetime(), star.getName()});
|
if (list != null && list.size() > 0)
|
return (HotStar) list.get(0);
|
}
|
return null;
|
}
|
|
public HotStar updateStar(HotStar star) {
|
if (star != null) {
|
hotStarDao.update(star);
|
List<HotStar> list = hotStarDao.list("from HotStar h where h.createtime=? and h.name=?",
|
new String[]{star.getCreatetime(), star.getName()});
|
if (list != null && list.size() > 0)
|
return (HotStar) list.get(0);
|
}
|
return null;
|
}
|
|
public void deleteStar(final HotStar star) {
|
if (star != null) {
|
hotStarDao.excute(new HibernateCallback() {
|
public Object doInHibernate(Session session) throws HibernateException {
|
try {
|
@SuppressWarnings("unchecked")
|
List<SuperHotStar> list = session.createQuery("from SuperHotStar sh where sh.hotStar.id=?")
|
.setParameter(0, star.getId()).list();
|
session.getTransaction().begin();
|
for (SuperHotStar sh : list) {
|
session.delete(sh);
|
}
|
session.createQuery("delete from HotStar hs where hs.id=?").setParameter(0, star.getId())
|
.executeUpdate();
|
session.flush();
|
session.getTransaction().commit();
|
} catch (Exception e) {
|
e.printStackTrace();
|
session.getTransaction().rollback();
|
}
|
return null;
|
}
|
});
|
|
}
|
}
|
|
@SuppressWarnings("unchecked")
|
@Cacheable(value = "classCache", key = "'getStarVideo'+'-'+#detailSystemId+'-'+#starId+'-'+#pageIndex+'-'+#cachemd5")
|
public List<VideoInfo> getStarVideo(String detailSystemId, String starId, int pageIndex, List<Long> resourceList,
|
String cachemd5) {
|
String resourceWhere = "";
|
for (Long rid : resourceList)
|
resourceWhere += String.format(" rv.`resourceid`=%d or", rid);
|
if (resourceWhere.endsWith("or"))
|
resourceWhere = resourceWhere.substring(0, resourceWhere.length() - 2);
|
|
List<VideoInfo> list = null;
|
Session session = hotStarDao.getSession();
|
try {
|
HotStar star = (HotStar) session.get(HotStar.class, starId);
|
String sql = String.format(
|
"SELECT v.* FROM wk_video_video v LEFT JOIN wk_resource_video rv ON rv.`videoid`=v.`id` AND (%s) WHERE v.`contenttype`=1 AND v.`show`=1 AND v.`mainactor` LIKE '%s' AND rv.`videoid` IS NOT NULL and v.area is not null and v.area !='' GROUP BY v.`id` ORDER BY FROM_UNIXTIME(v.`updatetime`/1000) DESC",
|
resourceWhere, "%" + star.getName() + "%");
|
list = session.createSQLQuery(sql).addEntity(VideoInfo.class)
|
.setFirstResult((pageIndex - 1) * Constant.pageCount).setMaxResults(Constant.pageCount).list();
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
|
list = videoResourceMapExtraInfoService.batchExtraInfo(list, resourceList);
|
return list;
|
}
|
|
@Cacheable(value = "classCache", key = "'getStarVideo'+'-'+#detailSystemId+'-'+#starId+'-'+#pageIndex+'-'+#cachemd5")
|
public List<VideoInfo> getStarVideo(String detailSystemId, String starId, int pageIndex, String cachemd5) {
|
HotStar star = hotStarDao.find(HotStar.class, starId);
|
return SolrUtil.searchStarVideos(star.getName(), pageIndex);
|
}
|
|
@Cacheable(value = "classCache", key = "'getStarVideoCount'+'-'+#detailSystemId+'-'+#starId")
|
public long getStarVideoCount(String detailSystemId, String starId) {
|
long count = 0;
|
try {
|
HotStar star = (HotStar) hotStarDao.find(HotStar.class, starId);
|
count = hotStarDao.getCount(
|
"select count(*) from CategoryVideo cv where cv.video.mainActor like ? and cv.video.contentType=1 and cv.video.area is not null and cv.video.area!=''",
|
new Serializable[]{"%" + star.getName() + "%"});
|
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return count;
|
}
|
|
public long getStarVideoPage(String detailSystemId, String starId) {
|
long count = getStarVideoCount(detailSystemId, starId);
|
return count % (long) Constant.pageCount != 0L ? count / (long) Constant.pageCount + 1L
|
: count / (long) Constant.pageCount;
|
}
|
|
@SuppressWarnings("unchecked")
|
public List<HotStarAdmin> getHotStarAdmin(String key, String systemId, int detailSystem, int page) {
|
key = StringUtil.isNullOrEmpty(key) ? "" : key;
|
List<HotStarAdmin> zhiBoClassList = new ArrayList<>();
|
|
try {
|
List<DetailSystem> detailSystemList = detailSystemDao.list("from DetailSystem ds where ds.system.id=" + systemId);
|
String sql = "";
|
if (detailSystem > 0)
|
sql = "select sh.hotStar from SuperHotStar sh where sh.detailSystem.id=" + detailSystem
|
+ " and sh.hotStar.name like ? order by sh.hotStar.orderby desc";
|
else
|
sql = "from HotStar zb where zb.name like ? and zb.system.id=" + systemId + " order by zb.orderby desc";
|
|
List<HotStar> list = hotStarDao.list(sql, (page - 1) * Constant.pageCount, Constant.pageCount,
|
new Serializable[]{"%" + key + "%"});
|
for (HotStar vb : list) {
|
List<DetailSystem> detailSystemS = detailSystemDao
|
.list("select vb.detailSystem from SuperHotStar vb where vb.hotStar.id=" + vb.getId());
|
|
List<DetailSystemSelect> dssList = new ArrayList<>();
|
|
for (DetailSystem ds : detailSystemList) {
|
DetailSystemSelect dss = new DetailSystemSelect();
|
dss.setDetailSystem(ds);
|
dss.setSelected(false);
|
dssList.add(dss);
|
}
|
|
for (DetailSystem ds : detailSystemS) {
|
for (DetailSystemSelect dss : dssList) {
|
if (dss.getDetailSystem().getId().equalsIgnoreCase(ds.getId())) {
|
dss.setSelected(true);
|
break;
|
}
|
}
|
}
|
SuperHotStar sz = new SuperHotStar();
|
sz.setDetailSystem(null);
|
sz.setHotStar(vb);
|
zhiBoClassList.add(new HotStarAdmin(sz, dssList));
|
}
|
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return zhiBoClassList;
|
}
|
|
public long getHotStarAdminCount(String key, String systemId, int detailSystem) {
|
key = StringUtil.isNullOrEmpty(key) ? "" : key;
|
|
String sql = "";
|
if (detailSystem > 0)
|
sql = "select count(*) from (select count(*) from wk_video_super_hotstar zb left join wk_video_hotstar c on c.id=zb.hotstarid where zb.detailsystemid="
|
+ detailSystem + " and c.name like '%" + key + "%' group by zb.hotstarid) s";
|
else
|
sql = "select count(*) from (select count(*) from wk_video_hotstar zb left join wk_video_hotstar c on c.id=zb.id where c.name like '%"
|
+ key + "%' and zb.system=" + systemId + " group by zb.id) s";
|
|
return hotStarDao.getCountSQL(sql);
|
}
|
|
@SuppressWarnings("unchecked")
|
public void deleteHotStarAdmin(final String classId, final String detailSystemId) {
|
hotStarDao.excute(new HibernateCallback() {
|
public Object doInHibernate(Session session) throws HibernateException {
|
try {
|
|
List<SuperHotStar> list = session
|
.createQuery("from SuperHotStar vb where vb.hotStar.id=? and vb.detailSystem.id=?")
|
.setParameter(0, classId).setParameter(1, detailSystemId).list();
|
if (list != null && list.size() > 0) {
|
session.getTransaction().begin();
|
for (SuperHotStar vb : list)
|
session.delete(vb);
|
session.flush();
|
session.getTransaction().commit();
|
}
|
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
});
|
|
}
|
|
/**
|
* 明星
|
*/
|
|
public List<HotStar> getHotStarList(String detailSystem) {
|
|
return hotStarDao.list("select hs.hotStar FROM SuperHotStar hs where hs.detailSystem.id=" + detailSystem
|
+ " order by hs.hotStar.orderby desc");
|
}
|
|
public List<SuperHotStar> getSuperHotStarList(String detailSystem) {
|
return superHotStarDao.list(
|
"FROM SuperHotStar hs where hs.detailSystem.id=" + detailSystem + " order by hs.hotStar.orderby desc");
|
}
|
|
public void addSuperHotStar(SuperHotStar sv) {
|
List<SuperHotStar> list = superHotStarDao.list("from SuperHotStar sv where sv.hotStar.id="
|
+ sv.getHotStar().getId() + " and sv.detailSystem.id=" + sv.getDetailSystem().getId());
|
if (list != null && list.size() > 0)
|
return;
|
superHotStarDao.create(sv);
|
}
|
|
public void updateSuperHotStar(SuperHotStar hotSearch) {
|
superHotStarDao.update(hotSearch);
|
}
|
|
public void deleteSuperHotStar(SuperHotStar hotSearch) {
|
superHotStarDao.delete(hotSearch);
|
}
|
|
@SuppressWarnings("unchecked")
|
public void updateSuperHotStarList(final String detailSystemId, final List<SuperHotStar> typeList) {
|
hotStarDao.excute(new HibernateCallback() {
|
public Object doInHibernate(Session session) throws HibernateException {
|
try {
|
List<SuperHotStar> list = session
|
.createQuery("from SuperHotStar sh where sh.detailSystem.id=" + detailSystemId).list();
|
session.getTransaction().begin();
|
for (SuperHotStar ad : list) {
|
session.delete(ad);
|
}
|
|
for (SuperHotStar videoType : typeList) {
|
session.persist(videoType);
|
}
|
session.flush();
|
session.getTransaction().commit();
|
} catch (Exception e) {
|
e.printStackTrace();
|
session.getTransaction().rollback();
|
}
|
return null;
|
}
|
});
|
|
}
|
|
@Cacheable(value = "foundCache", key = "'getHotStarOnMain'+'-'+#detailSystemId")
|
public List<HotStar> getHotStarOnMain(String detailSystemId) {
|
return hotStarDao.list("select hs.hotStar FROM SuperHotStar hs where hs.detailSystem.id=" + detailSystemId
|
+ " order by hs.hotStar.orderby desc", 0, 3, null);
|
}
|
|
}
|