| | |
| | | import com.yeshi.buwan.domain.*; |
| | | import com.yeshi.buwan.domain.Collection; |
| | | import com.yeshi.buwan.domain.solr.SolrAlbumVideo; |
| | | import com.yeshi.buwan.domain.solr.SolrShortVideo; |
| | | import com.yeshi.buwan.domain.system.DetailSystem; |
| | | import com.yeshi.buwan.domain.system.DetailSystemConfig; |
| | | import com.yeshi.buwan.domain.user.LoginUser; |
| | | import com.yeshi.buwan.domain.video.InternetSearchVideo; |
| | | import com.yeshi.buwan.dto.log.BaseLog; |
| | | import com.yeshi.buwan.dto.search.SolrResultDTO; |
| | | import com.yeshi.buwan.dto.search.SolrShortVideoSearchFilter; |
| | | import com.yeshi.buwan.dto.search.SolrVideoSearchFilter; |
| | | import com.yeshi.buwan.dto.user.LoginInfoDto; |
| | | import com.yeshi.buwan.exception.user.LoginUserException; |
| | | import com.yeshi.buwan.exception.user.RegisterUserException; |
| | | import com.yeshi.buwan.pptv.PPTVUtil; |
| | | import com.yeshi.buwan.videos.pptv.PPTVUtil; |
| | | import com.yeshi.buwan.service.imp.*; |
| | | import com.yeshi.buwan.service.inter.juhe.InternetSearchVideoService; |
| | | import com.yeshi.buwan.service.inter.system.SystemConfigService; |
| | | import com.yeshi.buwan.service.manager.SolrAlbumVideoDataManager; |
| | | import com.yeshi.buwan.service.manager.SolrInternetSearchVideoDataManager; |
| | | import com.yeshi.buwan.service.manager.search.SolrAlbumVideoDataManager; |
| | | import com.yeshi.buwan.service.manager.search.SolrInternetSearchVideoDataManager; |
| | | import com.yeshi.buwan.service.manager.search.SolrShortVideoDataManager; |
| | | import com.yeshi.buwan.util.*; |
| | | import com.yeshi.buwan.util.JuHe.VideoResourceUtil; |
| | | import com.yeshi.buwan.util.annotation.RequireUid; |
| | | import com.yeshi.buwan.util.email.MailSenderUtil; |
| | | import com.yeshi.buwan.util.factory.VideoInfoFactory; |
| | | import com.yeshi.buwan.util.factory.vo.UserInfoVOFactory; |
| | | import com.yeshi.buwan.util.log.LoggerUtil; |
| | | import com.yeshi.buwan.util.log.UserActiveLogFactory; |
| | | import com.yeshi.buwan.util.rank.IqiyiRankUtil; |
| | | import com.yeshi.buwan.util.video.VideoCategoryConstant; |
| | | import com.yeshi.buwan.util.video.VideoConstant; |
| | | import com.yeshi.buwan.util.video.VideoUtil; |
| | | import com.yeshi.buwan.vo.AcceptData; |
| | | import com.yeshi.buwan.vo.video.VideoListResultVO; |
| | | import net.sf.json.JSONArray; |
| | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Controller; |
| | | import redis.clients.jedis.Jedis; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpSession; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.PrintWriter; |
| | | import java.lang.reflect.Type; |
| | | import java.util.*; |
| | | |
| | | @Controller |
| | | public class UserParser { |
| | | |
| | | Logger searchKeyLogger = LoggerFactory.getLogger("searchKey"); |
| | | |
| | | |
| | | @Resource |
| | | private SystemService systemService; |
| | |
| | | private SolrAlbumVideoDataManager solrDataManager; |
| | | @Resource |
| | | private SolrInternetSearchVideoDataManager solrInternetSearchVideoDataManager; |
| | | |
| | | @Resource |
| | | private SolrShortVideoDataManager solrShortVideoDataManager; |
| | | |
| | | @Resource |
| | | private ConfigParser configParser; |
| | | @Resource |
| | | private SystemConfigService systemConfigService; |
| | | |
| | | @Resource |
| | | private RedisManager redisManager; |
| | | |
| | | public void getUid(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | | DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | |
| | | out.print(JsonUtil.loadFalseJson("获取uid失败")); |
| | | return; |
| | | } else { |
| | | Map<String, String> map = configService.getConfigAsMap(detailSystem, acceptData.getVersion()); |
| | | Map<String, String> map = configService.getConfigAsMap(acceptData.getChildDetailSystem(), acceptData.getVersion()); |
| | | ShareContent share = shareService.getShareContent(detailSystem.getId()); |
| | | JSONObject object = new JSONObject(); |
| | | object.put("Uid", uid); |
| | |
| | | object.put("data", array); |
| | | out.print(JsonUtil.loadTrueJson(object.toString())); |
| | | } else { |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(detailSystem, acceptData.getVersion(),acceptData.getChannel()); |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(detailSystem, acceptData.getVersion(), acceptData.getChannel()); |
| | | String cacheMD5 = "0"; |
| | | if (resourceList != null && resourceList.size() > 0) |
| | | for (Long l : resourceList) |
| | |
| | | return; |
| | | } |
| | | |
| | | final String id = StringUtil.Md5(String.format("%s#%s#%s#%s", acceptData.getDetailSystem().getId(), acceptData.getDevice(), key, type)); |
| | | ThreadUtil.run(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | String redisKey = "search-" + id; |
| | | Jedis jedis = redisManager.getJedis(); |
| | | try { |
| | | //重复请求过滤 |
| | | if (jedis.setnx(redisKey, "1") <= 0) { |
| | | return; |
| | | } |
| | | jedis.expire(redisKey, 120); |
| | | JSONObject searchData = new JSONObject(); |
| | | searchData.put("key", key); |
| | | searchData.put("type", type); |
| | | searchData.put("detailSystemId", acceptData.getDetailSystem().getId()); |
| | | searchData.put("device", acceptData.getDevice()); |
| | | searchData.put("createTime", System.currentTimeMillis()); |
| | | searchKeyLogger.info(new Gson().toJson(searchData)); |
| | | } finally { |
| | | jedis.close(); |
| | | } |
| | | } |
| | | }); |
| | | LoggerUtil.getUserActiveLogger().info(UserActiveLogFactory.createSearch(new BaseLog(acceptData, ""), key, type)); |
| | | |
| | | int pageIndex = StringUtil.getPage(page); |
| | |
| | | pageIndex = 1; |
| | | } |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion(),acceptData.getChannel()); |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion(), acceptData.getChannel()); |
| | | |
| | | |
| | | String cacheMD5 = "0"; |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | vt = new VideoType(); |
| | | vt.setId(Constant.SEARCH_RESULT_TYPE_HIGH_DEFINITION); |
| | | vt.setName("高清"); |
| | | typeList.add(vt); |
| | | //韩剧不返回高清 |
| | | if (!acceptData.getDetailSystem().getId().equalsIgnoreCase("48")) { |
| | | vt = new VideoType(); |
| | | vt.setId(Constant.SEARCH_RESULT_TYPE_HIGH_DEFINITION); |
| | | vt.setName("高清"); |
| | | typeList.add(vt); |
| | | } |
| | | |
| | | |
| | | JSONArray array1 = new JSONArray(); |
| | |
| | | int rootType = internetSearchVideo.getRootType(); |
| | | SolrVideoSearchFilter filter = new SolrVideoSearchFilter(); |
| | | filter.setVideoType(rootType); |
| | | filter.setResourceIds(new String[]{PPTVUtil.RESOURCE_ID + ""}); |
| | | filter.setResourceIds(Arrays.asList(new String[]{PPTVUtil.RESOURCE_ID + ""})); |
| | | filter.setSortKey("watchcount"); |
| | | SolrResultDTO dto = solrDataManager.find(filter, 1, 20); |
| | | List<SolrAlbumVideo> solrAlbumVideoList = new ArrayList<>(); |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | private void guessLikeForShortVideo(AcceptData acceptData, String videoId, PrintWriter out) { |
| | | SolrShortVideo solrShortVideo = solrShortVideoDataManager.findOne(videoId); |
| | | SolrShortVideoSearchFilter filter = new SolrShortVideoSearchFilter(); |
| | | filter.setRootVideoType(solrShortVideo.getRootVideoType()); |
| | | if (solrShortVideo.getArea() != null) { |
| | | filter.setAreas(Arrays.asList(solrShortVideo.getArea().split(","))); |
| | | } |
| | | |
| | | SolrResultDTO dto = solrShortVideoDataManager.find(filter, 1, 10); |
| | | |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.put("count", dto.getVideoList().size() + ""); |
| | | JSONArray array = new JSONArray(); |
| | | |
| | | for (int i = 0; i < dto.getVideoList().size(); i++) { |
| | | SolrShortVideo temp = (SolrShortVideo) dto.getVideoList().get(i); |
| | | if (temp.getId().equalsIgnoreCase(videoId)) |
| | | continue; |
| | | array.add(StringUtil.outPutResultJson(VideoInfoFactory.create(temp))); |
| | | } |
| | | if (array.size() % 2 != 0) { |
| | | array.remove(array.size() - 1); |
| | | } |
| | | |
| | | object.put("data", array); |
| | | out.print(JsonUtil.loadTrueJson(object.toString())); |
| | | } |
| | | |
| | | // 猜你喜欢 |
| | | public void guessLike(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | | |
| | | String videoId = request.getParameter("VideoId"); |
| | | if (!NumberUtil.isNumeric(videoId)) { |
| | | guessLikeForInternetSearch(acceptData, videoId, out); |
| | | return; |
| | | int fromtype = VideoUtil.getVideoFromType(videoId); |
| | | switch (fromtype) { |
| | | case HomeVideo.FROM_TYPE_INTERNET: |
| | | guessLikeForInternetSearch(acceptData, videoId, out); |
| | | return; |
| | | case HomeVideo.FROM_TYPE_SHORT: |
| | | guessLikeForShortVideo(acceptData, videoId, out); |
| | | return; |
| | | } |
| | | |
| | | DetailSystem ds = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion(),acceptData.getChannel()); |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion(), acceptData.getChannel()); |
| | | List<VideoInfo> list1 = StringUtil.isNullOrEmpty(videoId) |
| | | ? recommendService.guessLikeList(ds.getId(), 4, resourceList, CacheUtil.getMD5Long(resourceList)) |
| | | : recommendService.guessLikeList(ds.getId(), 4, videoId, resourceList, |
| | |
| | | |
| | | //新版热门搜索 |
| | | public void getHotSearchNew(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | | DetailSystemConfig config = configService.getConfigByKey("hot_search", acceptData.getDetailSystem(), acceptData.getVersion()); |
| | | DetailSystemConfig config = configService.getConfigByKey("hot_search", acceptData.getDetailSystem(), acceptData.getVersion()); |
| | | if (config == null) { |
| | | out.print(JsonUtil.loadFalseJson("无内容")); |
| | | return; |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | private void getRelativeVideosForShortVideo(AcceptData acceptData, String videoId, PrintWriter out) { |
| | | SolrShortVideo solrShortVideo = solrShortVideoDataManager.findOne(videoId); |
| | | SolrShortVideoSearchFilter filter = new SolrShortVideoSearchFilter(); |
| | | filter.setKey(solrShortVideo.getName()); |
| | | filter.setFuzzy(true); |
| | | |
| | | SolrResultDTO dto = solrShortVideoDataManager.find(filter, 1, 10); |
| | | |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.put("count", dto.getVideoList().size() + ""); |
| | | JSONArray array = new JSONArray(); |
| | | |
| | | for (int i = 0; i < dto.getVideoList().size(); i++) { |
| | | SolrShortVideo temp = (SolrShortVideo) dto.getVideoList().get(i); |
| | | if (temp.getId().equalsIgnoreCase(videoId)) |
| | | continue; |
| | | array.add(StringUtil.outPutResultJson(VideoInfoFactory.create(temp))); |
| | | } |
| | | if (array.size() % 2 != 0) { |
| | | array.remove(array.size() - 1); |
| | | } |
| | | |
| | | object.put("data", array); |
| | | out.print(JsonUtil.loadTrueJson(object.toString())); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 相关视频 |
| | | * |
| | |
| | | return; |
| | | } |
| | | |
| | | if (!NumberUtil.isNumeric(videoId)) { |
| | | getRelativeVideosForInternetSearch(acceptData, videoId, out); |
| | | return; |
| | | int fromtype = VideoUtil.getVideoFromType(videoId); |
| | | switch (fromtype) { |
| | | case HomeVideo.FROM_TYPE_INTERNET: |
| | | getRelativeVideosForInternetSearch(acceptData, videoId, out); |
| | | return; |
| | | case HomeVideo.FROM_TYPE_SHORT: |
| | | getRelativeVideosForShortVideo(acceptData, videoId, out); |
| | | return; |
| | | } |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion(),acceptData.getChannel()); |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion(), acceptData.getChannel()); |
| | | |
| | | DetailSystem ds = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | | List<VideoInfo> list = recommendService.getRelativeVideoList(ds.getId(), 4, videoId, resourceList, |
| | |
| | | return; |
| | | } |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion(),acceptData.getChannel()); |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion(), acceptData.getChannel()); |
| | | |
| | | DetailSystem ds = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | | List<VideoInfo> list1 = recommendService.peopleSee(ds.getId(), 4, videoId, resourceList, |
| | |
| | | |
| | | // 注册 --用户名,昵称,密码 |
| | | LoginUser user = userService.getLoginUser(loginUid); |
| | | if (user.getState() != null && user.getState() == LoginUser.STATE_UNREGISTER) { |
| | | out.print(JsonUtil.loadFalseJson("账户已注销")); |
| | | return; |
| | | } |
| | | //隐藏user中的email |
| | | user.setEmail(UserInfoVOFactory.getHiddenEmail(user.getEmail())); |
| | | if (user.getPortrait() != null && !user.getPortrait().startsWith("http")) |
| | | user.setPortrait("http://" + Constant.WEBSITE + "/BuWan" + user.getPortrait()); |
| | | out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(user))); |