| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import com.yeshi.buwan.dao.VideoResourceMapExtraInfoDao; |
| | | import com.yeshi.buwan.dao.juhe.iqiyi.VideoIqiyiDao; |
| | | import com.yeshi.buwan.domain.VideoResource; |
| | | import com.yeshi.buwan.domain.VideoResourceMapExtraInfo; |
| | | import com.yeshi.buwan.dto.mq.VideoExtraInfoChangeMQMsg; |
| | | import com.yeshi.buwan.iqiyi.entity.VideoIqiyi; |
| | | import com.yeshi.buwan.util.mq.CMQManager; |
| | | import org.hibernate.HibernateException; |
| | | import org.hibernate.Query; |
| | | import org.hibernate.Session; |
| | |
| | | import com.yeshi.buwan.dao.ResourceVideoDao; |
| | | import com.yeshi.buwan.domain.ResourceVideo; |
| | | import com.yeshi.buwan.domain.VideoInfo; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | @Service |
| | | public class ResourceVideoService { |
| | | |
| | | @Autowired |
| | | private ResourceVideoDao resourceVideoDao; |
| | | |
| | | @Resource |
| | | private VideoResourceMapExtraInfoDao videoResourceMapExtraInfoDao; |
| | | |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | public List<ResourceVideo> getResourceList(final List<VideoInfo> list) { |
| | |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取资源列表 |
| | | * |
| | | * @param videoId |
| | | * @return |
| | | */ |
| | | public List<ResourceVideo> getResourceList(String videoId) { |
| | | List<VideoInfo> videoInfoList = new ArrayList<>(); |
| | | videoInfoList.add(new VideoInfo(videoId)); |
| | | return getResourceList(videoInfoList); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据视频ID与ResourceId查询 |
| | | * |
| | | * @param videoId |
| | | * @param sourceId |
| | | * @return |
| | | */ |
| | | |
| | | public long countByVideoIdAndResourceId(String videoId, long sourceId) { |
| | | return resourceVideoDao.countByVideoIdAndResourceId(videoId, sourceId + ""); |
| | | } |
| | | |
| | | public void save(ResourceVideo resourceVideo) { |
| | | resourceVideoDao.save(resourceVideo); |
| | | } |
| | |
| | | public void addVideoResource(String videoId, String resourceId) { |
| | | ResourceVideo rv = resourceVideoDao.selectByVideoIdAndResourceId(videoId, resourceId); |
| | | if (rv == null) { |
| | | System.out.println(videoId + ":" + resourceId); |
| | | rv = new ResourceVideo(); |
| | | rv.setResource(new VideoResource(resourceId + "")); |
| | | rv.setVideo(new VideoInfo(videoId + "")); |
| | | resourceVideoDao.save(rv); |
| | | CMQManager.getInstance().addVideoExtraInfoChanged(new VideoExtraInfoChangeMQMsg(VideoExtraInfoChangeMQMsg.TYPE_RESOURCE, videoId, VideoExtraInfoChangeMQMsg.ACTION_ADD)); |
| | | } |
| | | } |
| | | |
| | | @Transactional |
| | | public void delete(String videoId, String resourceId) { |
| | | ResourceVideo resourceVideo = resourceVideoDao.selectByVideoIdAndResourceId(videoId, resourceId + ""); |
| | | if (resourceVideo != null) { |
| | | resourceVideoDao.delete(resourceVideo); |
| | | CMQManager.getInstance().addVideoExtraInfoChanged(new VideoExtraInfoChangeMQMsg(VideoExtraInfoChangeMQMsg.TYPE_RESOURCE, videoId, VideoExtraInfoChangeMQMsg.ACTION_DELETE)); |
| | | } |
| | | |
| | | VideoResourceMapExtraInfo extraInfo = new VideoResourceMapExtraInfo(videoId, Long.parseLong(resourceId)); |
| | | extraInfo = videoResourceMapExtraInfoDao.find(VideoResourceMapExtraInfo.class, extraInfo.getId()); |
| | | if (extraInfo != null) { |
| | | videoResourceMapExtraInfoDao.delete(extraInfo); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |