diff --git a/src/main/java/com/leosam/tvbox/mv/data/VodResult.java b/src/main/java/com/leosam/tvbox/mv/data/VodResult.java index 041feb1..a405139 100644 --- a/src/main/java/com/leosam/tvbox/mv/data/VodResult.java +++ b/src/main/java/com/leosam/tvbox/mv/data/VodResult.java @@ -19,12 +19,13 @@ public class VodResult { @JsonProperty("class") private List vodClassList; - public void init() { + public VodResult init() { this.code = 1; this.page = 1; this.pagecount = 1; this.limit = 1; this.total = 1; + return this; } public int getCode() { diff --git a/src/main/java/com/leosam/tvbox/mv/service/MvService.java b/src/main/java/com/leosam/tvbox/mv/service/MvService.java index 94b561f..8f00ec7 100644 --- a/src/main/java/com/leosam/tvbox/mv/service/MvService.java +++ b/src/main/java/com/leosam/tvbox/mv/service/MvService.java @@ -131,6 +131,7 @@ public class MvService { } public VodResult searchVodHome(String type, int page) throws Exception { + // 防止分页请求 if (page > 1) { return new VodResult(); } @@ -138,32 +139,31 @@ public class MvService { StopWatch stopWatch = new StopWatch(); stopWatch.start(); - VodResult vodResult = new VodResult(); - vodResult.init(); - vodResult.setList(new ArrayList<>()).getList(); + VodResult vodResult = new VodResult().init(); // 分类 if (StringUtils.isEmpty(type)) { vodResult.setVodClassList(new ArrayList<>(homeConfigMap.size())); Set keySet = homeConfigMap.keySet(); for (String key : keySet) { - if (HOME_KEY.equalsIgnoreCase(key)) { - continue; - } VodClass vodClass = new VodClass().setTypeId(key).setTypeName(key); + if (HOME_KEY.equalsIgnoreCase(key)) { + vodClass.setTypeName("热门"); + } vodResult.getVodClassList().add(vodClass); } } // 首页mv推荐 String thisType = StringUtils.isNotEmpty(type) ? type : HOME_KEY; - List geshouList = homeConfigMap.getOrDefault(thisType, new ArrayList<>()); - for (String geshou : geshouList) { + List singerList = homeConfigMap.getOrDefault(thisType, new ArrayList<>()); + vodResult.setList(new ArrayList<>(singerList.size())); + for (String singer : singerList) { Vod vod = new Vod(); - vod.setVodId(geshou); - vod.setVodName(geshou); + vod.setVodId(singer); + vod.setVodName(singer); vod.setVodPlayFrom("mv"); - vod.setVodPic(getVodPic(geshou)); + vod.setVodPic(getVodPic(singer)); vodResult.getList().add(vod); } @@ -184,7 +184,7 @@ public class MvService { vodPic = singerMap.get(split[0]); } } - vodPic = StringUtils.isEmpty(vodPic) ? "http://yanxuan.nosdn.127.net/b6fb987ce79f308949e44f5129a4b51c.jpeg" : vodPic; + vodPic = StringUtils.isNotEmpty(vodPic) ? vodPic : "http://yanxuan.nosdn.127.net/b6fb987ce79f308949e44f5129a4b51c.jpeg"; return vodPic; } @@ -207,7 +207,7 @@ public class MvService { // 首页配置 try { String content = ClassPathReaderUtils.getContent("tvbox/home.json"); - Map> map = new ObjectMapper().readValue(content, new TypeReference>>() { + Map> map = new ObjectMapper().readValue(content, new TypeReference>>() { }); homeConfigMap.putAll(map); logger.info("加载首页配置成功"); @@ -217,7 +217,7 @@ public class MvService { // 歌手详情配置 try { String content = ClassPathReaderUtils.getContent("tvbox/singerPic.json"); - Map map = new ObjectMapper().readValue(content, new TypeReference>() { + Map map = new ObjectMapper().readValue(content, new TypeReference>() { }); singerMap.putAll(map); logger.info("加载歌手头像成功");