package com.yeshi.buwan.util.factory;
|
|
import com.yeshi.buwan.domain.CategoryVideo;
|
import com.yeshi.buwan.domain.VideoType;
|
import com.yeshi.buwan.domain.solr.SolrAlbumVideo;
|
import com.yeshi.buwan.domain.VideoInfo;
|
import com.yeshi.buwan.domain.VideoResource;
|
import com.yeshi.buwan.domain.solr.SolrCommonVideo;
|
import org.yeshi.utils.StringUtil;
|
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.List;
|
|
public class SolrVideoFactory {
|
|
|
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());
|
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.setUpdatetime(videoInfo.getUpdatetime());
|
if (videoInfo.getUpdatetime() != null)
|
solrVideo.setUpdateTime(Long.parseLong(videoInfo.getUpdatetime()));
|
if (videoInfo.getVideoType() != null)
|
solrVideo.setRootVideoType(videoInfo.getVideoType().getId());
|
|
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());
|
|
if (videoResources != null && videoResources.size() > 0) {
|
List<String> resourceIds = new ArrayList<>();
|
for (VideoResource vr : videoResources) {
|
resourceIds.add(vr.getId());
|
}
|
solrVideo.setResourceIds(StringUtil.concat(resourceIds, ","));
|
}
|
|
return solrVideo;
|
}
|
|
|
}
|