MOD:首页优化

This commit is contained in:
leosam1024
2023-06-18 18:56:40 +08:00
parent acbb726074
commit e53fbb9e37
2 changed files with 16 additions and 15 deletions
@@ -19,12 +19,13 @@ public class VodResult {
@JsonProperty("class") @JsonProperty("class")
private List<VodClass> vodClassList; private List<VodClass> vodClassList;
public void init() { public VodResult init() {
this.code = 1; this.code = 1;
this.page = 1; this.page = 1;
this.pagecount = 1; this.pagecount = 1;
this.limit = 1; this.limit = 1;
this.total = 1; this.total = 1;
return this;
} }
public int getCode() { public int getCode() {
@@ -131,6 +131,7 @@ public class MvService {
} }
public VodResult searchVodHome(String type, int page) throws Exception { public VodResult searchVodHome(String type, int page) throws Exception {
// 防止分页请求
if (page > 1) { if (page > 1) {
return new VodResult(); return new VodResult();
} }
@@ -138,32 +139,31 @@ public class MvService {
StopWatch stopWatch = new StopWatch(); StopWatch stopWatch = new StopWatch();
stopWatch.start(); stopWatch.start();
VodResult vodResult = new VodResult(); VodResult vodResult = new VodResult().init();
vodResult.init();
vodResult.setList(new ArrayList<>()).getList();
// 分类 // 分类
if (StringUtils.isEmpty(type)) { if (StringUtils.isEmpty(type)) {
vodResult.setVodClassList(new ArrayList<>(homeConfigMap.size())); vodResult.setVodClassList(new ArrayList<>(homeConfigMap.size()));
Set<String> keySet = homeConfigMap.keySet(); Set<String> keySet = homeConfigMap.keySet();
for (String key : keySet) { for (String key : keySet) {
if (HOME_KEY.equalsIgnoreCase(key)) {
continue;
}
VodClass vodClass = new VodClass().setTypeId(key).setTypeName(key); VodClass vodClass = new VodClass().setTypeId(key).setTypeName(key);
if (HOME_KEY.equalsIgnoreCase(key)) {
vodClass.setTypeName("热门");
}
vodResult.getVodClassList().add(vodClass); vodResult.getVodClassList().add(vodClass);
} }
} }
// 首页mv推荐 // 首页mv推荐
String thisType = StringUtils.isNotEmpty(type) ? type : HOME_KEY; String thisType = StringUtils.isNotEmpty(type) ? type : HOME_KEY;
List<String> geshouList = homeConfigMap.getOrDefault(thisType, new ArrayList<>()); List<String> singerList = homeConfigMap.getOrDefault(thisType, new ArrayList<>());
for (String geshou : geshouList) { vodResult.setList(new ArrayList<>(singerList.size()));
for (String singer : singerList) {
Vod vod = new Vod(); Vod vod = new Vod();
vod.setVodId(geshou); vod.setVodId(singer);
vod.setVodName(geshou); vod.setVodName(singer);
vod.setVodPlayFrom("mv"); vod.setVodPlayFrom("mv");
vod.setVodPic(getVodPic(geshou)); vod.setVodPic(getVodPic(singer));
vodResult.getList().add(vod); vodResult.getList().add(vod);
} }
@@ -184,7 +184,7 @@ public class MvService {
vodPic = singerMap.get(split[0]); 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; return vodPic;
} }
@@ -207,7 +207,7 @@ public class MvService {
// 首页配置 // 首页配置
try { try {
String content = ClassPathReaderUtils.getContent("tvbox/home.json"); String content = ClassPathReaderUtils.getContent("tvbox/home.json");
Map<String, List<String>> map = new ObjectMapper().readValue(content, new TypeReference<HashMap<String, List<String>>>() { Map<String, List<String>> map = new ObjectMapper().readValue(content, new TypeReference<LinkedHashMap<String, List<String>>>() {
}); });
homeConfigMap.putAll(map); homeConfigMap.putAll(map);
logger.info("加载首页配置成功"); logger.info("加载首页配置成功");
@@ -217,7 +217,7 @@ public class MvService {
// 歌手详情配置 // 歌手详情配置
try { try {
String content = ClassPathReaderUtils.getContent("tvbox/singerPic.json"); String content = ClassPathReaderUtils.getContent("tvbox/singerPic.json");
Map<String, String> map = new ObjectMapper().readValue(content, new TypeReference<HashMap<String, String>>() { Map<String, String> map = new ObjectMapper().readValue(content, new TypeReference<LinkedHashMap<String, String>>() {
}); });
singerMap.putAll(map); singerMap.putAll(map);
logger.info("加载歌手头像成功"); logger.info("加载歌手头像成功");