package com.yeshi.buwan.service.imp;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
import javax.annotation.Resource;
|
|
import org.springframework.stereotype.Service;
|
|
import com.yeshi.buwan.dao.VideoIntersectionDao;
|
import com.yeshi.buwan.dao.VideoIntersectionVideoDao;
|
import com.yeshi.buwan.domain.VideoInfo;
|
import com.yeshi.buwan.domain.VideoIntersection;
|
import com.yeshi.buwan.domain.VideoIntersectionVideo;
|
import com.yeshi.buwan.util.Constant;
|
|
@Service
|
public class IntersectionService {
|
@Resource
|
private VideoIntersectionDao videoIntersectionDao;
|
@Resource
|
private VideoIntersectionVideoDao videoIntersectionVideoDao;
|
|
public VideoIntersectionVideoDao getVideoIntersectionVideoDao() {
|
return videoIntersectionVideoDao;
|
}
|
|
public void setVideoIntersectionVideoDao(VideoIntersectionVideoDao videoIntersectionVideoDao) {
|
this.videoIntersectionVideoDao = videoIntersectionVideoDao;
|
}
|
|
public VideoIntersectionDao getVideoIntersectionDao() {
|
return videoIntersectionDao;
|
}
|
|
public void setVideoIntersectionDao(VideoIntersectionDao videoIntersectionDao) {
|
this.videoIntersectionDao = videoIntersectionDao;
|
}
|
|
// 添加合集
|
public void addIntersection(VideoIntersection section) {
|
videoIntersectionDao.create(section);
|
}
|
|
public void updateIntersection(VideoIntersection section) {
|
videoIntersectionDao.update(section);
|
}
|
|
public void deleteIntersection(VideoIntersection section) {
|
videoIntersectionDao.delete(section);
|
}
|
|
public void deleteIntersectionVideo(VideoIntersectionVideo section) {
|
videoIntersectionVideoDao.delete(section);
|
}
|
|
// 添加合集视频
|
public void addIntersectionVideo(VideoIntersectionVideo sectionVideo) {
|
List<VideoIntersectionVideo> list = videoIntersectionVideoDao.list(
|
"from VideoIntersectionVideo v where v.intersection.id=? and v.video.id=?",
|
new String[] { sectionVideo.getIntersection().getId(), sectionVideo.getVideo().getId() });
|
if (list == null || list.size() == 0)
|
videoIntersectionVideoDao.create(sectionVideo);
|
}
|
|
public List<VideoIntersection> getIntersectionList() {
|
return videoIntersectionDao.list("from VideoIntersection");
|
}
|
|
public List<VideoIntersection> getIntersectionList(String key, int pageIndex) {
|
return videoIntersectionDao.list("from VideoIntersection vi where vi.name like ? ",
|
(pageIndex - 1) * Constant.pageCount, Constant.pageCount, new String[] { "%" + key + "%" });
|
}
|
|
public long getIntersectionListCount(String key) {
|
return videoIntersectionDao.getCount("select count(*) from VideoIntersection vi where vi.name like ? ",
|
new String[] { "%" + key + "%" });
|
}
|
|
public List<VideoIntersection> getIntersectionListByPage(int page) {
|
return videoIntersectionDao.list("from VideoIntersection", Constant.pageCount * (page - 1), Constant.pageCount,
|
new String[] {});
|
}
|
|
public long getIntersectionListPage() {
|
return videoIntersectionDao.getCount("select count(*) from VideoIntersection");
|
}
|
|
public VideoIntersection getIntersectionById(String id) {
|
return videoIntersectionDao.find(VideoIntersection.class, id);
|
}
|
|
public List<VideoInfo> getIntersectionVideoList(String intersectionId) {
|
List<VideoInfo> videoList = new ArrayList<VideoInfo>();
|
List<VideoIntersectionVideo> list = videoIntersectionVideoDao.list(
|
"from VideoIntersectionVideo v where v.video.show=1 and v.intersection.id=?",
|
new String[] { intersectionId });
|
for (VideoIntersectionVideo vi : list)
|
if (vi.getVideo() != null)
|
videoList.add(vi.getVideo());
|
return videoList;
|
}
|
|
public VideoIntersectionVideo getIntersectionVideoById(String id) {
|
return videoIntersectionVideoDao.find(VideoIntersectionVideo.class, id);
|
}
|
|
public List<VideoInfo> getIntersectionVideoList(String intersectionId, String key, int pageIndex) {
|
List<VideoInfo> videoList = new ArrayList<VideoInfo>();
|
List<VideoIntersectionVideo> list = videoIntersectionVideoDao.list(
|
"from VideoIntersectionVideo v where v.video.show=1 and v.intersection.id=? and v.video.name like ?",
|
(pageIndex - 1) * Constant.pageCount, Constant.pageCount,
|
new String[] { intersectionId, "%" + key + "%" });
|
for (VideoIntersectionVideo vi : list)
|
if (vi.getVideo() != null)
|
videoList.add(vi.getVideo());
|
return videoList;
|
}
|
|
public long getIntersectionVideoListCount(String intersectionId, String key) {
|
return videoIntersectionVideoDao.getCount(
|
"select count(*) from VideoIntersectionVideo v where v.video.show=1 and v.intersection.id=? and v.video.name like ?",
|
new String[] { intersectionId, "%" + key + "%" });
|
}
|
|
public List<VideoIntersectionVideo> getIntersectionVideoListByInersection(String intersectionId) {
|
List<VideoIntersectionVideo> list = videoIntersectionVideoDao.list(
|
"from VideoIntersectionVideo v where v.video.show=1 and v.intersection.id=?",
|
new String[] { intersectionId });
|
return list;
|
}
|
|
public List<VideoIntersectionVideo> getIntersectionVideoListByInersection(String intersectionId, String key,
|
int pageIndex) {
|
List<VideoIntersectionVideo> list = videoIntersectionVideoDao.list(
|
"from VideoIntersectionVideo v where v.video.show=1 and v.intersection.id=? and v.video.name like ?",
|
(pageIndex - 1) * Constant.pageCount, Constant.pageCount,
|
new String[] { intersectionId, "%" + key + "%" });
|
return list;
|
}
|
|
public long getIntersectionVideoListByInersectionCount(String intersectionId, String key) {
|
return videoIntersectionVideoDao.getCount(
|
"select count(*) from VideoIntersectionVideo v where v.video.show=1 and v.intersection.id=? and v.video.name like ?",
|
new String[] { intersectionId, "%" + key + "%" });
|
}
|
|
}
|