|
|
@@ -108,6 +108,9 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
@Value("${video.min.score:0.6}")
|
|
|
private Double videoMinScore;
|
|
|
|
|
|
+ @Value("${video.title.search.max.count:500}")
|
|
|
+ private int videoTitleSearchMaxCount;
|
|
|
+
|
|
|
@Value("${small_page_url}")
|
|
|
private String GET_SMALL_PAGE_URL;
|
|
|
|
|
|
@@ -592,6 +595,10 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
@Override
|
|
|
public Page<VideoContentItemVO> getVideoContentList(VideoContentListParam param) {
|
|
|
ContentPlatformAccount user = LoginUserContext.getUser();
|
|
|
+ // 如果 title 有内容,调用 manager 平台接口搜索
|
|
|
+ if (StringUtils.hasText(param.getTitle())) {
|
|
|
+ return getVideoContentListByTitle(param);
|
|
|
+ }
|
|
|
Page<VideoContentItemVO> result = new Page<>(param.getPageNum(), param.getPageSize());
|
|
|
int offset = (param.getPageNum() - 1) * param.getPageSize();
|
|
|
String dt = planMapperExt.getVideoMaxDt();
|
|
|
@@ -613,6 +620,63 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 按标题通过 manager 平台接口查询视频列表,支持最大查询条数限制
|
|
|
+ */
|
|
|
+ private Page<VideoContentItemVO> getVideoContentListByTitle(VideoContentListParam param) {
|
|
|
+ Page<VideoContentItemVO> result = new Page<>(param.getPageNum(), param.getPageSize());
|
|
|
+ int pageSize = param.getPageSize() > 0 ? param.getPageSize() : 10;
|
|
|
+ int offset = (param.getPageNum() - 1) * pageSize;
|
|
|
+
|
|
|
+ // 查询前判断:如果请求的偏移量已超出最大条数限制,直接返回,不发起远程查询
|
|
|
+ if (offset >= videoTitleSearchMaxCount) {
|
|
|
+ result.setTotalSize(videoTitleSearchMaxCount);
|
|
|
+ result.setObjs(new ArrayList<>());
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject pageData = managerApiService.searchVideoByTitle(param.getTitle(), param.getPageNum(), pageSize);
|
|
|
+ if (pageData == null) {
|
|
|
+ result.setTotalSize(0);
|
|
|
+ result.setObjs(new ArrayList<>());
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ int totalSize = pageData.getIntValue("totalSize");
|
|
|
+ // 限制最大可查询条数
|
|
|
+ int effectiveTotalSize = Math.min(totalSize, videoTitleSearchMaxCount);
|
|
|
+ result.setTotalSize(effectiveTotalSize);
|
|
|
+
|
|
|
+ JSONArray objs = pageData.getJSONArray("objs");
|
|
|
+ result.setObjs(buildVideoContentItemVOFromRemote(objs));
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将 manager 接口返回的 objs 数据转换为 VideoContentItemVO 列表
|
|
|
+ */
|
|
|
+ private List<VideoContentItemVO> buildVideoContentItemVOFromRemote(JSONArray objs) {
|
|
|
+ if (objs == null || objs.isEmpty()) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ List<VideoContentItemVO> result = new ArrayList<>();
|
|
|
+ for (int i = 0; i < objs.size(); i++) {
|
|
|
+ JSONObject obj = objs.getJSONObject(i);
|
|
|
+ VideoContentItemVO item = new VideoContentItemVO();
|
|
|
+ item.setVideoId(obj.getLong("id"));
|
|
|
+ item.setTitle(obj.getString("title"));
|
|
|
+ item.setVideo(obj.getString("transedVideoPath"));
|
|
|
+ String cover = obj.getString("selfCoverImgPath");
|
|
|
+ if (cover.contains("?")) {
|
|
|
+ cover = cover.substring(0, cover.indexOf("?"));
|
|
|
+ }
|
|
|
+ cover += "?x-oss-process=image/resize,m_fill,w_600,h_480,limit_0/format,jpg/watermark,image_eXNoL3BpYy93YXRlcm1hcmtlci9pY29uX3BsYXlfd2hpdGUucG5nP3gtb3NzLXByb2Nlc3M9aW1hZ2UvcmVzaXplLHdfMTQ0,g_center";
|
|
|
+ item.setCover(cover);
|
|
|
+ result.add(item);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
private String getVideoContentListType(Integer type) {
|
|
|
switch (type) {
|
|
|
case 0:
|