admin
2021-03-20 ad3ac53da1c3a11a96ae62d790aa61a81b9eab91
src/main/java/com/yeshi/buwan/service/imp/IntersectionService.java
@@ -16,133 +16,118 @@
@Service
public class IntersectionService {
   @Resource
   private VideoIntersectionDao videoIntersectionDao;
   @Resource
   private VideoIntersectionVideoDao videoIntersectionVideoDao;
    @Resource
    private VideoIntersectionDao videoIntersectionDao;
    @Resource
    private VideoIntersectionVideoDao videoIntersectionVideoDao;
   public VideoIntersectionVideoDao getVideoIntersectionVideoDao() {
      return videoIntersectionVideoDao;
   }
   public void setVideoIntersectionVideoDao(VideoIntersectionVideoDao videoIntersectionVideoDao) {
      this.videoIntersectionVideoDao = videoIntersectionVideoDao;
   }
    // 添加合集
    public void addIntersection(VideoIntersection section) {
        videoIntersectionDao.create(section);
    }
   public VideoIntersectionDao getVideoIntersectionDao() {
      return videoIntersectionDao;
   }
    public void updateIntersection(VideoIntersection section) {
        videoIntersectionDao.update(section);
    }
   public void setVideoIntersectionDao(VideoIntersectionDao videoIntersectionDao) {
      this.videoIntersectionDao = videoIntersectionDao;
   }
    public void deleteIntersection(VideoIntersection section) {
        videoIntersectionDao.delete(section);
    }
   // 添加合集
   public void addIntersection(VideoIntersection section) {
      videoIntersectionDao.create(section);
   }
    public void deleteIntersectionVideo(VideoIntersectionVideo section) {
        videoIntersectionVideoDao.delete(section);
    }
   public void updateIntersection(VideoIntersection section) {
      videoIntersectionDao.update(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 void deleteIntersection(VideoIntersection section) {
      videoIntersectionDao.delete(section);
   }
    public List<VideoIntersection> getIntersectionList() {
        return videoIntersectionDao.list("from VideoIntersection");
    }
   public void deleteIntersectionVideo(VideoIntersectionVideo section) {
      videoIntersectionVideoDao.delete(section);
   }
    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 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 long getIntersectionListCount(String key) {
        return videoIntersectionDao.getCount("select count(*)  from VideoIntersection vi where vi.name like ? ",
                new String[]{"%" + key + "%"});
    }
   public List<VideoIntersection> getIntersectionList() {
      return videoIntersectionDao.list("from VideoIntersection");
   }
    public List<VideoIntersection> getIntersectionListByPage(int page) {
        return videoIntersectionDao.list("from VideoIntersection", Constant.pageCount * (page - 1), Constant.pageCount,
                new String[]{});
    }
   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 getIntersectionListPage() {
        return videoIntersectionDao.getCount("select count(*)  from VideoIntersection");
    }
   public long getIntersectionListCount(String key) {
      return videoIntersectionDao.getCount("select count(*)  from VideoIntersection vi where vi.name like ? ",
            new String[] { "%" + key + "%" });
   }
    public VideoIntersection getIntersectionById(String id) {
        return videoIntersectionDao.find(VideoIntersection.class, id);
    }
   public List<VideoIntersection> getIntersectionListByPage(int page) {
      return videoIntersectionDao.list("from VideoIntersection", Constant.pageCount * (page - 1), Constant.pageCount,
            new String[] {});
   }
    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 long getIntersectionListPage() {
      return videoIntersectionDao.getCount("select count(*)  from VideoIntersection");
   }
    public VideoIntersectionVideo getIntersectionVideoById(String id) {
        return videoIntersectionVideoDao.find(VideoIntersectionVideo.class, id);
    }
   public VideoIntersection getIntersectionById(String id) {
      return videoIntersectionDao.find(VideoIntersection.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 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 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 VideoIntersectionVideo getIntersectionVideoById(String id) {
      return videoIntersectionVideoDao.find(VideoIntersectionVideo.class, id);
   }
    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<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 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 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 + "%" });
   }
    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 + "%"});
    }
}