admin
2021-09-24 f788607ff771a47bc60d6a86e00b3433c40f3d2c
src/main/java/com/yeshi/buwan/util/factory/SolrVideoFactory.java
@@ -1,9 +1,10 @@
package com.yeshi.buwan.util.factory;
import com.yeshi.buwan.domain.SolrVideo;
import com.yeshi.buwan.domain.VideoInfo;
import com.yeshi.buwan.domain.VideoResource;
import com.yeshi.buwan.util.VideoTypeUtil;
import com.yeshi.buwan.domain.VideoType;
import com.yeshi.buwan.domain.solr.SolrAlbumVideo;
import com.yeshi.buwan.domain.solr.SolrCommonVideo;
import org.yeshi.utils.StringUtil;
import java.util.ArrayList;
@@ -13,8 +14,55 @@
public class SolrVideoFactory {
    public static SolrVideo create(VideoInfo videoInfo, List<VideoResource> videoResources) {
        SolrVideo solrVideo = new SolrVideo();
    public static SolrAlbumVideo createAlbum(VideoInfo videoInfo, List<VideoResource> videoResources) {
        SolrAlbumVideo solrVideo = new SolrAlbumVideo();
        solrVideo.setMainactor(videoInfo.getMainActor());
        solrVideo.setShow(Integer.parseInt(videoInfo.getShow()));
        solrVideo.setLatestHpicture(videoInfo.getLatestHpicture());
        solrVideo.setDuration(videoInfo.getDuration());
        solrVideo.setScore(videoInfo.getScore());
        solrVideo.setVpicture(videoInfo.getVpicture());
        solrVideo.setLatestVpicture(videoInfo.getLatestVpicture());
        solrVideo.setId(videoInfo.getId());
        solrVideo.setTag(videoInfo.getTag());
        solrVideo.setHpicture(videoInfo.getHpicture());
        solrVideo.setArea(videoInfo.getArea());
        solrVideo.setCreatetime(videoInfo.getCreatetime() + "");
        solrVideo.setWatchcount(Integer.parseInt(videoInfo.getWatchCount()));
        solrVideo.setDirector(videoInfo.getDirector());
        solrVideo.setPicture(videoInfo.getPicture());
        solrVideo.setContenttype(videoInfo.getContentType());
        solrVideo.setSolrTime(new Date());
        solrVideo.setCommentcount(videoInfo.getCommentCount());
        solrVideo.setVideocount(videoInfo.getVideocount());
        solrVideo.setName(videoInfo.getName());
        solrVideo.setNameStr(videoInfo.getName());
        solrVideo.setUpdatetime(videoInfo.getUpdatetime());
        if (videoInfo.getUpdatetime() != null)
            solrVideo.setUpdateTime(Long.parseLong(videoInfo.getUpdatetime()));
        if (videoInfo.getVideoType() != null)
            solrVideo.setRootVideoType(videoInfo.getVideoType().getId());
        else
            solrVideo.setRootVideoType(0);
        solrVideo.setYear(videoInfo.getYear());
        if (videoResources != null && videoResources.size() > 0) {
            List<String> resourceIds = new ArrayList<>();
            for (VideoResource vr : videoResources) {
                resourceIds.add(vr.getId());
            }
            solrVideo.setResourceIds(StringUtil.concat(resourceIds, ","));
        }
        solrVideo.setFreeType(videoInfo.getFree());
        return solrVideo;
    }
    public static SolrCommonVideo createCommon(VideoInfo videoInfo, List<VideoType> typeList, List<VideoResource> videoResources) {
        SolrCommonVideo solrVideo = new SolrCommonVideo();
        solrVideo.setMainactor(videoInfo.getMainActor());
        solrVideo.setShow(Integer.parseInt(videoInfo.getShow()));
        solrVideo.setLatestHpicture(videoInfo.getLatestHpicture());
@@ -40,8 +88,20 @@
            solrVideo.setUpdateTime(Long.parseLong(videoInfo.getUpdatetime()));
        if (videoInfo.getVideoType() != null)
            solrVideo.setRootVideoType(videoInfo.getVideoType().getId());
        else
            solrVideo.setRootVideoType(0);
        if (typeList != null && typeList.size() > 0) {
            VideoType videoType = typeList.get(0);
            if (videoType.getParent() != null) {
                solrVideo.setRootVideoType(videoType.getParent().getId());
            } else {
                solrVideo.setRootVideoType(videoType.getId());
            }
            List<Long> ids = new ArrayList<>();
            for (VideoType cv : typeList) {
                ids.add(cv.getId());
            }
            solrVideo.setVideoTypes(StringUtil.concat(ids, ","));
        }
        solrVideo.setYear(videoInfo.getYear());
@@ -55,4 +115,6 @@
        return solrVideo;
    }
}