| | |
| | | import java.io.PrintWriter; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.google.common.base.Function; |
| | | import com.google.common.collect.Maps; |
| | | import com.google.gson.Gson; |
| | | import com.yeshi.buwan.domain.SolrVideo; |
| | | import com.yeshi.buwan.domain.solr.SolrAlbumVideo; |
| | | import com.yeshi.buwan.domain.video.VideoInfoExtra; |
| | | import com.yeshi.buwan.dto.search.SolrResultDTO; |
| | | import com.yeshi.buwan.dto.search.SolrVideoSearchFilter; |
| | | import com.yeshi.buwan.iqiyi.IqiYiNewAPI; |
| | | import com.yeshi.buwan.service.manager.SolrAlbumDataManager; |
| | | import com.yeshi.buwan.service.inter.video.VideoInfoExtraService; |
| | | import com.yeshi.buwan.service.manager.SolrAlbumVideoDataManager; |
| | | import com.yeshi.buwan.util.Constant; |
| | | import com.yeshi.buwan.vo.video.VideoAdminInfoVO; |
| | | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
| | |
| | | import com.yeshi.buwan.service.imp.VideoManager; |
| | | import com.yeshi.buwan.util.JsonUtil; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import com.yeshi.buwan.util.TimeUtil; |
| | | import com.yeshi.buwan.web.tag.PageEntity; |
| | | |
| | | import net.sf.json.JSONArray; |
| | |
| | | private ThreadPoolTaskExecutor taskExecutor; |
| | | |
| | | @Resource |
| | | private SolrAlbumDataManager solrAlbumDataManager; |
| | | private SolrAlbumVideoDataManager solrAlbumDataManager; |
| | | |
| | | @Resource |
| | | private VideoInfoExtraService videoInfoExtraService; |
| | | |
| | | @RequestMapping(value = "/changevideoshow", method = RequestMethod.POST) |
| | | public void changeVideoShow(String id, int show, PrintWriter out) { |
| | |
| | | } |
| | | |
| | | @RequestMapping(value = "/videolist", method = RequestMethod.POST) |
| | | public void videoList(int videotype, int page, String key, String type, String resourceIds, int contenttype, PrintWriter out) { |
| | | public void videoList(int videotype, int page, String key, String type, String resourceIds, int contenttype, String freeType, PrintWriter out) { |
| | | |
| | | if (StringUtil.isNullOrEmpty(type)) { |
| | | type = "name"; |
| | | } |
| | | |
| | | Integer freeTypeInt = null; |
| | | if (!StringUtil.isNullOrEmpty(freeType)) { |
| | | freeTypeInt = Integer.parseInt(freeType); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | filter.setSortKey("updateTime"); |
| | | |
| | | filter.setFreeType(freeTypeInt); |
| | | |
| | | SolrResultDTO dto = solrAlbumDataManager.find(filter, page, Constant.pageCount); |
| | | if (dto.getVideoList() != null) |
| | | for (SolrVideo videoInfo : dto.getVideoList()) |
| | | for (SolrAlbumVideo videoInfo : (List<SolrAlbumVideo>) dto.getVideoList()) |
| | | voList.add(VideoAdminInfoVO.create(videoInfo)); |
| | | count = dto.getTotalCount(); |
| | | } else { |
| | |
| | | for (VideoInfo videoInfo : list) |
| | | voList.add(VideoAdminInfoVO.create(videoInfo)); |
| | | } |
| | | |
| | | List<String> ids = new ArrayList<>(); |
| | | for (VideoAdminInfoVO a : voList) { |
| | | ids.add(a.getId()); |
| | | } |
| | | |
| | | List<VideoInfoExtra> extraList = videoInfoExtraService.listByIds(ids); |
| | | |
| | | Map<String, VideoInfoExtra> maps = Maps.uniqueIndex(extraList.iterator(), new Function<VideoInfoExtra, String>() { |
| | | @Override |
| | | public String apply(VideoInfoExtra extra) { |
| | | return extra.getId(); |
| | | } |
| | | }); |
| | | //过滤图片 |
| | | for (VideoAdminInfoVO a : voList) { |
| | | VideoInfoExtra extra = maps.get(a.getId()); |
| | | if (extra != null) { |
| | | if (!StringUtil.isNullOrEmpty(extra.gethPosterPicture())) |
| | | a.setPicture(extra.gethPosterPicture()); |
| | | } |
| | | } |
| | | |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.put("code", 0); |
| | | JSONObject data = new JSONObject(); |
| | |
| | | out.print(data); |
| | | } |
| | | |
| | | @RequestMapping("getVideoInfoExtra") |
| | | public void getVideoInfoExtra(String id, PrintWriter out) { |
| | | VideoInfoExtra extra = videoInfoExtraService.getById(id); |
| | | JSONObject object = new JSONObject(); |
| | | if (extra != null) { |
| | | object.put("code", 0); |
| | | object.put("data", new Gson().toJson(extra)); |
| | | } else { |
| | | object.put("code", 1); |
| | | object.put("msg", "无附加信息"); |
| | | } |
| | | out.print(object); |
| | | } |
| | | |
| | | @RequestMapping("updateVideoInfoExtra") |
| | | public void updateVideoInfoExtra(String id, String vPicture, String hPicture, PrintWriter out) { |
| | | VideoInfoExtra extra = new VideoInfoExtra(); |
| | | extra.setId(id); |
| | | if (StringUtil.isNullOrEmpty(vPicture)) { |
| | | vPicture = ""; |
| | | } |
| | | |
| | | extra.setvPosterPicture(vPicture); |
| | | |
| | | if (StringUtil.isNullOrEmpty(hPicture)) { |
| | | hPicture = ""; |
| | | } |
| | | |
| | | extra.sethPosterPicture(hPicture); |
| | | |
| | | videoInfoExtraService.save(extra); |
| | | |
| | | JSONObject object = new JSONObject(); |
| | | object.put("code", 0); |
| | | out.print(object); |
| | | } |
| | | |
| | | |
| | | } |