admin
2021-03-29 ef37d60710c252e1d8473e8ce779696d497e857f
src/main/java/com/yeshi/buwan/controller/parser/HomeParser.java
@@ -18,6 +18,7 @@
import com.yeshi.buwan.domain.video.InternetSearchVideo;
import com.yeshi.buwan.domain.video.VideoWatchHistory;
import com.yeshi.buwan.dto.log.BaseLog;
import com.yeshi.buwan.mogotv.MogoTVUtil;
import com.yeshi.buwan.pptv.PPTVUtil;
import com.yeshi.buwan.pptv.entity.PPTVSeries;
import com.yeshi.buwan.service.imp.*;
@@ -26,6 +27,7 @@
import com.yeshi.buwan.service.inter.juhe.YouKuService;
import com.yeshi.buwan.service.inter.recommend.HomeRecommendSpecialService;
import com.yeshi.buwan.service.inter.video.VideoWatchHistoryService;
import com.yeshi.buwan.tencent.TencentVideoUtil;
import com.yeshi.buwan.util.*;
import com.yeshi.buwan.util.annotation.RequireUid;
import com.yeshi.buwan.util.factory.VideoInfoFactory;
@@ -53,6 +55,9 @@
@Controller
public class HomeParser {
    private Logger logger = LoggerFactory.getLogger(HomeParser.class);
    @Resource
    private SystemService systemService;
    @Resource
@@ -360,28 +365,59 @@
    @Resource
    private YouKuUtil youKuUtil;
    @Resource
    private MogoTVUtil mogoTVUtil;
    @Resource
    private TencentVideoUtil tencentVideoUtil;
    public void getVideoDetailForInternetSearch(AcceptData acceptData, String videoId, HttpServletRequest request, PrintWriter out) {
        String loginUid = request.getParameter("LoginUid");
        String from = request.getParameter("From");
        InternetSearchVideo internetSearchVideo = internetSearchVideoService.selectByPrimaryKey(videoId);
        String resourceId = request.getParameter("ResourceId");
        if (StringUtil.isNullOrEmpty(resourceId)) {
            resourceId = internetSearchVideo.getResourceIds().split(",")[0];
        }
        VideoInfo info = null;
        if (Integer.parseInt(resourceId) == YouKuUtil.RESOURCE_ID) {
            VideoInfo info = null;
            try {
                info = youKuUtil.getVideoInfo(internetSearchVideo);
            } catch (Exception e) {
                logger.error("全网搜视频详情出错:" + videoId);
                e.printStackTrace();
                out.print(JsonUtil.loadFalseAdmin(e.getMessage()));
                return;
            }
            JSONArray array = new JSONArray();
            JSONObject obj = new JSONObject();
            out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(Utils.convertVideo(info)), array.toString(),
                    obj.toString()));
        } else if (Integer.parseInt(resourceId) == MogoTVUtil.RESOURCE_ID) {
            try {
                info = mogoTVUtil.getVideoInfo(internetSearchVideo);
            } catch (Exception e) {
                logger.error("全网搜视频详情出错:" + videoId);
                out.print(JsonUtil.loadFalseAdmin(e.getMessage()));
                return;
            }
        } else if (Integer.parseInt(resourceId) == TencentVideoUtil.RESOURCE_ID) {
            try {
                info = tencentVideoUtil.getVideoInfo(internetSearchVideo);
            } catch (Exception e) {
                logger.error("全网搜视频详情出错:" + videoId);
                out.print(JsonUtil.loadFalseAdmin(e.getMessage()));
                return;
            }
        }
        LoggerUtil.getUserActiveLogger().info(UserActiveLogFactory.createVideoDetail(new BaseLog(acceptData, loginUid), videoId, info.getName(), from));
        info.setWatchCount("" + (int) (Math.random() * 1000));
        JSONArray array = new JSONArray();
        JSONObject obj = new JSONObject();
        out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(Utils.convertVideo(info)), array.toString(),
                obj.toString()));
    }
    @RequireUid