| | |
| | | package com.yeshi.buwan.service.imp.juhe; |
| | | |
| | | import com.yeshi.buwan.dao.juhe.youku.YouKuSearchVideoMapDao; |
| | | import com.yeshi.buwan.dao.juhe.youku.YouKuShowDetailDao; |
| | | import com.yeshi.buwan.dao.juhe.youku.YouKuVideoDao; |
| | | import com.yeshi.buwan.domain.VideoDetailInfo; |
| | | import com.yeshi.buwan.domain.video.InternetSearchVideo; |
| | | import com.yeshi.buwan.service.inter.juhe.InternetSearchVideoService; |
| | | import com.yeshi.buwan.service.inter.juhe.YouKuService; |
| | | import com.yeshi.buwan.youku.entity.YouKuShowDetail; |
| | | import com.yeshi.buwan.youku.entity.YouKuVideo; |
| | | import com.yeshi.buwan.util.factory.InternetSearchVideoFactory; |
| | | import com.yeshi.buwan.videos.youku.YouKuUtil; |
| | | import com.yeshi.buwan.videos.youku.entity.YouKuSearchVideoMap; |
| | | import com.yeshi.buwan.videos.youku.entity.YouKuShowDetail; |
| | | import com.yeshi.buwan.videos.youku.entity.YouKuVideo; |
| | | import org.springframework.data.domain.Sort; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | |
| | | public class YouKuServiceImpl implements YouKuService { |
| | | |
| | | @Resource |
| | | private YouKuSearchVideoMapDao youKuSearchVideoMapDao; |
| | | |
| | | @Resource |
| | | private YouKuShowDetailDao youKuShowDetailDao; |
| | | @Resource |
| | | private YouKuVideoDao youKuVideoDao; |
| | | @Resource |
| | | private InternetSearchVideoService internetSearchVideoService; |
| | | |
| | | @Override |
| | | public void save(YouKuShowDetail detail) { |
| | | public void save(YouKuShowDetail detail) throws Exception { |
| | | if (detail.getUpdateTime() == null) |
| | | detail.setUpdateTime(new Date()); |
| | | youKuShowDetailDao.save(detail); |
| | |
| | | return detail; |
| | | } |
| | | |
| | | @Override |
| | | public YouKuShowDetail getSimpleShowDetail(String showId) { |
| | | YouKuShowDetail detail = youKuShowDetailDao.get(showId); |
| | | return detail; |
| | | } |
| | | |
| | | @Override |
| | | public List<YouKuVideo> getVideoList(String showId, int page, int pageSize) { |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria.where("showId").is(showId)); |
| | | query.with(new Sort(new Sort.Order(Sort.Direction.ASC, "show_videoseq"))); |
| | | query.skip((page - 1) * pageSize); |
| | | query.limit(pageSize); |
| | | List<YouKuVideo> videoList = youKuVideoDao.findList(query); |
| | | return videoList; |
| | | } |
| | | |
| | | @Override |
| | | public YouKuVideo getVideoDetail(String id) { |
| | | return youKuVideoDao.get(id); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public long count(String category) { |
| | |
| | | query.skip((page - 1) * pageSize); |
| | | return youKuShowDetailDao.findList(query); |
| | | } |
| | | |
| | | @Override |
| | | public List<VideoDetailInfo> getVideoDetailList(String videoid, int page, int pageSize) { |
| | | YouKuSearchVideoMap map = youKuSearchVideoMapDao.selectByVideoId(videoid); |
| | | if (map == null) |
| | | return null; |
| | | return YouKuUtil.convertToDetail(getVideoList(map.getShowId(), page, pageSize)); |
| | | } |
| | | |
| | | @Override |
| | | public YouKuSearchVideoMap selectByVideoId(String videoId) { |
| | | YouKuSearchVideoMap map = youKuSearchVideoMapDao.selectByVideoId(videoId); |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public void addToInternetSearch(YouKuShowDetail showDetail) throws Exception { |
| | | save(showDetail); |
| | | InternetSearchVideo video = InternetSearchVideoFactory.create(showDetail); |
| | | if (internetSearchVideoService.save(video) == null) { |
| | | return; |
| | | } |
| | | YouKuSearchVideoMap map = new YouKuSearchVideoMap(); |
| | | map.setShowId(showDetail.getId()); |
| | | map.setVideoId(video.getId()); |
| | | map.setCreateTime(new Date()); |
| | | youKuSearchVideoMapDao.save(map); |
| | | } |
| | | } |