| | |
| | | |
| | | import com.yeshi.buwan.domain.*; |
| | | import com.yeshi.buwan.domain.Collection; |
| | | import com.yeshi.buwan.domain.solr.SolrAlbumVideo; |
| | | import com.yeshi.buwan.domain.system.DetailSystem; |
| | | 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.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.service.imp.*; |
| | | import com.yeshi.buwan.service.inter.juhe.InternetSearchVideoService; |
| | | import com.yeshi.buwan.service.manager.SolrAlbumVideoDataManager; |
| | | 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.log.LoggerUtil; |
| | | import com.yeshi.buwan.util.log.UserActiveLogFactory; |
| | | import com.yeshi.buwan.util.video.VideoCategoryConstant; |
| | | import com.yeshi.buwan.util.video.VideoConstant; |
| | | import com.yeshi.buwan.vo.AcceptData; |
| | | import com.yeshi.buwan.vo.video.VideoListResultVO; |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Controller; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | |
| | | @Controller |
| | | public class UserParser { |
| | | |
| | | @Resource |
| | | private SystemService systemService; |
| | | @Resource |
| | |
| | | private List<VideoDetailInfo> createSearchVideoDetailsVO(VideoInfo video) { |
| | | List<VideoDetailInfo> detailList = new ArrayList<>(); |
| | | if (video.getVideoType() != null && (Integer.parseInt(video.getVideoType().getId() + "") == VideoCategoryConstant.CATEGORY_DIANSHIJU || Integer.parseInt(video.getVideoType().getId() + "") == VideoCategoryConstant.CATEGORY_DONGMAN)) { |
| | | if (video.getVideocount()!=null&& video.getVideocount() <= 5) { |
| | | if (video.getVideocount() != null && video.getVideocount() <= 5) { |
| | | for (int i = 0; i < video.getVideocount(); i++) { |
| | | VideoDetailInfo detail = new VideoDetailInfo(); |
| | | detail.setTag((i + 1) + ""); |
| | |
| | | |
| | | // 搜索 |
| | | public void searchNew(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | | |
| | | |
| | | //type: 0-全部 1- |
| | | String key = request.getParameter("Key"); |
| | | String type = request.getParameter("Type"); |
| | |
| | | return; |
| | | } |
| | | |
| | | LoggerUtil.getUserActiveLogger().info(UserActiveLogFactory.createSearch(new BaseLog(acceptData, ""), key, type)); |
| | | |
| | | int pageIndex = StringUtil.getPage(page); |
| | | if (pageIndex <= 0) { |
| | | pageIndex = 1; |
| | | } |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion()); |
| | | |
| | | |
| | | String cacheMD5 = "0"; |
| | | if (resourceList != null && resourceList.size() > 0) |
| | | for (Long l : resourceList) |
| | | cacheMD5 += "#" + l; |
| | | cacheMD5 = StringUtil.Md5(cacheMD5); |
| | | |
| | | |
| | | VideoListResultVO videoListResultVO = searchService.searchNew(acceptData.getDetailSystem().getId(), request.getRemoteAddr(), |
| | | acceptData.getUid(), key, pageIndex, Integer.parseInt(type), |
| | |
| | | typeList.add(vt); |
| | | } |
| | | } |
| | | |
| | | vt = new VideoType(); |
| | | vt.setId(Constant.SEARCH_RESULT_TYPE_HIGH_DEFINITION); |
| | | vt.setName("高清"); |
| | | typeList.add(vt); |
| | | |
| | | |
| | | JSONArray array1 = new JSONArray(); |
| | | for (VideoType vt1 : typeList) |
| | | array1.add(StringUtil.outPutResultJson(vt1)); |
| | |
| | | } |
| | | |
| | | |
| | | @Resource |
| | | private InternetSearchVideoService internetSearchVideoService; |
| | | |
| | | private void guessLikeForInternetSearch(AcceptData acceptData, String videoId, PrintWriter out) { |
| | | InternetSearchVideo internetSearchVideo = internetSearchVideoService.selectByPrimaryKey(videoId); |
| | | if (internetSearchVideo != null) { |
| | | int rootType = internetSearchVideo.getRootType(); |
| | | SolrVideoSearchFilter filter = new SolrVideoSearchFilter(); |
| | | filter.setVideoType(rootType); |
| | | filter.setResourceIds(new String[]{PPTVUtil.RESOURCE_ID + ""}); |
| | | filter.setSortKey("watchcount"); |
| | | SolrResultDTO dto = solrDataManager.find(filter, 1, 20); |
| | | List<SolrAlbumVideo> solrAlbumVideoList = new ArrayList<>(); |
| | | solrAlbumVideoList.addAll(dto.getVideoList()); |
| | | List<VideoInfo> list = new ArrayList<>(); |
| | | for (int i = 0; i < 4; i++) { |
| | | if (solrAlbumVideoList.size() > 0) { |
| | | int p = (int) (Math.random() * solrAlbumVideoList.size()); |
| | | SolrAlbumVideo solrAlbumVideo = solrAlbumVideoList.get(p); |
| | | list.add(VideoInfoFactory.create(solrAlbumVideo)); |
| | | solrAlbumVideoList.remove(p); |
| | | } |
| | | } |
| | | |
| | | if (list.size() < 4) { |
| | | filter.setResourceIds(null); |
| | | dto = solrDataManager.find(filter, 1, 20); |
| | | solrAlbumVideoList.clear(); |
| | | solrAlbumVideoList.addAll(dto.getVideoList()); |
| | | for (int i = list.size(); i < 4; i++) { |
| | | if (solrAlbumVideoList.size() > 0) { |
| | | int p = (int) (Math.random() * solrAlbumVideoList.size()); |
| | | SolrAlbumVideo solrAlbumVideo = solrAlbumVideoList.get(p); |
| | | list.add(VideoInfoFactory.create(solrAlbumVideo)); |
| | | solrAlbumVideoList.remove(p); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.put("count", list.size() + ""); |
| | | JSONArray array = new JSONArray(); |
| | | |
| | | for (int i = 0; i < list.size(); i++) { |
| | | array.add(StringUtil.outPutResultJson(list.get(i))); |
| | | } |
| | | |
| | | 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; |
| | | } |
| | | |
| | | DetailSystem ds = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | private void getRelativeVideosForInternetSearch(AcceptData acceptData, String videoId, PrintWriter out) { |
| | | InternetSearchVideo internetSearchVideo = internetSearchVideoService.selectByPrimaryKey(videoId); |
| | | if (internetSearchVideo != null) { |
| | | SolrVideoSearchFilter filter = new SolrVideoSearchFilter(); |
| | | filter.setKey(internetSearchVideo.getName()); |
| | | filter.setFuzzy(true); |
| | | SolrResultDTO dto = solrDataManager.find(filter, 1, 20); |
| | | List<SolrAlbumVideo> solrAlbumVideoList = new ArrayList<>(); |
| | | solrAlbumVideoList.addAll(dto.getVideoList()); |
| | | List<VideoInfo> list = new ArrayList<>(); |
| | | for (int i = 0; i < 4; i++) { |
| | | if (i < solrAlbumVideoList.size()) { |
| | | SolrAlbumVideo solrAlbumVideo = solrAlbumVideoList.get(i); |
| | | list.add(VideoInfoFactory.create(solrAlbumVideo)); |
| | | } |
| | | } |
| | | |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.put("count", list.size() + ""); |
| | | JSONArray array = new JSONArray(); |
| | | |
| | | for (int i = 0; i < list.size(); i++) { |
| | | array.add(StringUtil.outPutResultJson(list.get(i))); |
| | | } |
| | | |
| | | object.put("data", array); |
| | | out.print(JsonUtil.loadTrueJson(object.toString())); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 相关视频 |
| | | * |
| | |
| | | return; |
| | | } |
| | | |
| | | if (!NumberUtil.isNumeric(videoId)) { |
| | | getRelativeVideosForInternetSearch(acceptData, videoId, out); |
| | | return; |
| | | } |
| | | |
| | | List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(acceptData.getDetailSystem(), acceptData.getVersion()); |
| | | |
| | | DetailSystem ds = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |