From ad3ac53da1c3a11a96ae62d790aa61a81b9eab91 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期六, 20 三月 2021 18:47:23 +0800 Subject: [PATCH] 完善APP首页顶部标签栏兼容,初步处理推送 --- src/main/java/com/yeshi/buwan/service/imp/juhe/Iqiyi2ServiceImpl.java | 125 +++++++++++++++++++++++++++++++++-------- 1 files changed, 100 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/yeshi/buwan/service/imp/juhe/Iqiyi2ServiceImpl.java b/src/main/java/com/yeshi/buwan/service/imp/juhe/Iqiyi2ServiceImpl.java index cd873b2..475da62 100644 --- a/src/main/java/com/yeshi/buwan/service/imp/juhe/Iqiyi2ServiceImpl.java +++ b/src/main/java/com/yeshi/buwan/service/imp/juhe/Iqiyi2ServiceImpl.java @@ -6,32 +6,36 @@ import com.yeshi.buwan.dao.video.AlbumVideoMapDao; import com.yeshi.buwan.domain.*; import com.yeshi.buwan.domain.entity.PlayUrl; +import com.yeshi.buwan.domain.system.SystemConfig; import com.yeshi.buwan.domain.video.AlbumVideoMap; import com.yeshi.buwan.iqiyi.IqiYiNewAPI; import com.yeshi.buwan.iqiyi.entity.IqiyiAlbum2; import com.yeshi.buwan.iqiyi.entity.VideoIqiyi2; import com.yeshi.buwan.iqiyi.util.IqiyiUtil; import com.yeshi.buwan.iqiyi.util.IqiyiUtil2; -import com.yeshi.buwan.service.imp.CategoryVideoService; -import com.yeshi.buwan.service.imp.ResourceVideoService; -import com.yeshi.buwan.service.imp.VideoInfoService; -import com.yeshi.buwan.service.imp.VideoResourceService; +import com.yeshi.buwan.query.Iqiyi2AlbumQuery; +import com.yeshi.buwan.service.imp.*; import com.yeshi.buwan.service.inter.juhe.Iqiyi2Service; +import com.yeshi.buwan.service.inter.system.SystemConfigService; +import com.yeshi.buwan.util.StringUtil; import com.yeshi.buwan.util.TimeUtil; +import com.yeshi.buwan.util.log.VideoLogFactory; import com.yeshi.buwan.util.mq.CMQManager; import com.yeshi.buwan.util.video.VideoConstant; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.io.Serializable; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.List; +import java.util.*; import java.util.regex.Pattern; @Service public class Iqiyi2ServiceImpl implements Iqiyi2Service { + + private final Logger logger = LoggerFactory.getLogger("videoUpdate"); + @Resource private VideoIqiyi2Dao videoIqiyi2Dao; @@ -56,7 +60,10 @@ @Resource private VideoResourceService videoResourceService; - public List<VideoDetailInfo> getVideoDetailList(String videoId) { + @Resource + private SystemConfigService systemConfigService; + + public List<VideoDetailInfo> getVideoDetailList(String videoId, int page, int pageSize) { //鏌ヨ涓撹緫 VideoIqiyi2 videoIqiyi2 = videoIqiyi2Dao.selectByVideoId(Long.parseLong(videoId)); if (videoIqiyi2 == null) @@ -67,7 +74,12 @@ if (album.getFeatureAlbumId() > 0) {//鍗曡棰� album2List.add(album); } else {//涓撹緫 - List<IqiyiAlbum2> list = iqiyiAlbum2Dao.listByAid(album.getId(), 0, 1000); + //鍒ゆ柇period瀛楁鏄惁涓虹┖ + int sort = album.isSourceAlbum() ? IqiyiAlbum2.SORT_PERIOD : IqiyiAlbum2.SORT_ORDER; + Iqiyi2AlbumQuery query = new Iqiyi2AlbumQuery(); + query.setFeatureAlbumId(album.getId()); + query.setContentType(1); + List<IqiyiAlbum2> list = iqiyiAlbum2Dao.listByAid(query, sort, (page - 1) * pageSize, pageSize); if (list != null) album2List.addAll(list); } @@ -99,11 +111,29 @@ iqiyiAlbum2Dao.save(album); } + public boolean isUnNormalUpdateVideoName(String name) { + SystemConfig config = systemConfigService.getConfigByKeyCache("iqiyi_update_video_name"); + if (config != null) { + String[] sts = config.getValue().split(","); + List<String> list = new ArrayList<>(); + for (String st : sts) { + list.add(st.trim()); + } + return list.contains(name.trim()); + } + return false; + } + @Override public void addToVideoInfo(IqiyiAlbum2 album) { if (album.getFeatureAlbumId() > 0L && album.getChannelId() != IqiYiNewAPI.TYPE_DIANYING) { return; } + + if (StringUtil.isNullOrEmpty(album.getName())) { + return; + } + //鍙紦瀛樻湁鏁堢殑 if (album.getEffect() == 0) @@ -119,11 +149,18 @@ return; } - //鏍囬涓彧鑳藉寘鍚腑鑻辨枃涓庢暟瀛� - String regx = "^[(\\u4e00-\\u9fa5)( )a-zA-Z0-9]+$"; - if (!Pattern.matches(regx, album.getName())) { - return; + + if (album.getChannelId() != 1 && !isUnNormalUpdateVideoName(album.getName())) { + //鏍囬涓彧鑳藉寘鍚腑鑻辨枃涓庢暟瀛� + String regx = "^[(\\u4e00-\\u9fa5)(锛�)( )a-zA-Z0-9]+$"; + if (!Pattern.matches(regx, album.getName())) { + return; + } } + + //杩囨护鏌愪簺鐭墖涓庡奖璇� + if (album.getName().contains("銆�") && !isUnNormalUpdateVideoName(album.getName())) + return; //绌虹數瑙嗗墽鎴栬�呮槸绌哄姩婕垯杩斿洖 if (album.getChannelId() == 2 || album.getChannelId() == 4) { @@ -131,6 +168,7 @@ return; } + logger.info(VideoLogFactory.createAddToVideoLog(album)); VideoInfo newVideoInfo = convertAlbumToVideoInfo(album); VideoIqiyi2 videoIqiyi2 = videoIqiyi2Dao.selectByIqiyiId(album.getId()); @@ -139,7 +177,7 @@ if (videoInfo == null) return; newVideoInfo.setId(videoInfo.getId()); - if (!newVideoInfo.getTag().equalsIgnoreCase(videoInfo.getTag())) { + if (!newVideoInfo.getTag().equalsIgnoreCase(videoInfo.getTag()) || newVideoInfo.getVideocount() != videoInfo.getVideocount()) { newVideoInfo.setCreatetime(videoInfo.getCreatetime()); //鏇存柊淇℃伅tag淇℃伅 videoInfo.setLatestHpicture(newVideoInfo.getLatestHpicture()); @@ -151,11 +189,12 @@ videoInfo.setVpicture(newVideoInfo.getVpicture()); videoInfo.setShow(newVideoInfo.getShow()); videoInfo.setVideoType(newVideoInfo.getVideoType()); + videoInfo.setUpdatetime(newVideoInfo.getUpdatetime()); videoInfoDao.update(videoInfo); } } else {//瑙嗛涓嶅瓨鍦� //鍒ゆ柇2涓棰戝疄浣撴槸鍚︿负鍚屼竴瑙嗛 - VideoInfo oldVideo = videoInfoService.getExistSameVideo(newVideoInfo); + VideoInfo oldVideo = videoInfoService.getExistSameVideoWithTime(newVideoInfo); if (oldVideo == null) { //娣诲姞瑙嗛 Serializable id = videoInfoDao.save(newVideoInfo); @@ -172,11 +211,13 @@ oldVideo.setVpicture(newVideoInfo.getVpicture()); oldVideo.setShow(newVideoInfo.getShow()); oldVideo.setVideoType(newVideoInfo.getVideoType()); + oldVideo.setUpdatetime(newVideoInfo.getUpdatetime()); videoInfoDao.update(oldVideo); } //鍔犲叆涓撹緫瑙嗛鏄犲皠 AlbumVideoMap map = new AlbumVideoMap(); + map.setId(newVideoInfo.getId()); map.setCreateTime(new Date()); map.setVideoId(newVideoInfo.getId()); map.setRootVideoType(newVideoInfo.getVideoType().getId()); @@ -218,11 +259,20 @@ @Override public int getShowType(String videoid) { - VideoInfo videoInfo = videoInfoDao.find(VideoInfo.class, videoid); - if (videoInfo.getVideoType() != null && (videoInfo.getVideoType().getId() == VideoConstant.VIDEO_CATEGORY_DIANSHIJU || videoInfo.getVideoType().getId() == VideoConstant.VIDEO_CATEGORY_DONGMAN)) - return 2; - else - return 1; + VideoIqiyi2 iqiyi2 = videoIqiyi2Dao.selectByVideoId(Long.parseLong(videoid)); + if (iqiyi2 != null) { + IqiyiAlbum2 album2 = iqiyiAlbum2Dao.get(iqiyi2.getIqiyiId()); + if (album2 != null) { + if (album2.getChannelId() == 4 || album2.getChannelId() == 2) { + if (album2.isSourceAlbum()) { + return 1; + } else + return 2; + } + } + } + + return 1; } @Override @@ -287,11 +337,11 @@ video.setLatestVpicture(IqiyiUtil.getVPicture(album2.getImageUrl())); } } + long videoCount = iqiyiAlbum2Dao.countVideoByAid(album.getId()); + if (videoCount == 0L) + videoCount = 1; - if (album.getTvQipuIds() != null && album.getTvQipuIds().size() > 0) - video.setVideocount(album.getTvQipuIds().size()); - else - video.setVideocount(1); + video.setVideocount((int) videoCount); video.setUpdatetime(System.currentTimeMillis() + ""); @@ -303,4 +353,29 @@ public IqiyiAlbum2 selectAlbumById(Long id) { return iqiyiAlbum2Dao.get(id); } + + @Override + public long countById(Long id) { + return iqiyiAlbum2Dao.countById(id); + } + + @Override + public void deleteByAid(long id) { + long count = iqiyiAlbum2Dao.countById(id); + if (count > 0) { + iqiyiAlbum2Dao.delete(id); + } + VideoIqiyi2 bean = videoIqiyi2Dao.selectByIqiyiId(id); + if (bean != null) { + videoIqiyi2Dao.delete(bean.getVideoId()); + //鍒犻櫎璧勬簮 + resourceVideoService.delete(bean.getVideoId() + "", IqiyiUtil2.RESOURCE_ID + ""); + } + + } + + @Override + public List<IqiyiAlbum2> listByIds(List<Long> idsList) { + return iqiyiAlbum2Dao.listByIds(idsList); + } } -- Gitblit v1.8.0