feat(catalog): 卡片下发完整简介不再截断
backend-ci / test (push) Canceled after 0s

This commit is contained in:
jianghaifeng authored and trae-solo-agent committed 2026-10-30 22:53:22 +08:00
1 parent 958de5ef22
commit afd8d00752
2 files changed
+20 -18

No files matched your search

@@ -34,7 +34,6 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Arrays;
@@ -350,7 +349,7 @@ public class AppCatalogService {
card.setTitleLocales(titles);
card.setCover(drama.getCoverUrl());
card.setCoverLandscape(drama.getHorizontalCoverUrl());
card.setSynopsisLocales(shortLocales(synopses));
card.setSynopsisLocales(synopses);
card.setTypes(types);
fillTag(card, drama, tags);
card.setTotalEpisodes(drama.getTotalEpisodes());
@@ -451,20 +450,4 @@ public class AppCatalogService {
return dramaCategoryService.localeMap();
}
/** 卡片只带一句简介,避免列表响应体过大 */
private Map<String, String> shortLocales(Map<String, String> locales) {
Map<String, String> result = new LinkedHashMap<>();
if (locales == null) {
return result;
}
locales.forEach((code, text) -> result.put(code, shortSynopsis(text)));
return result;
}
private String shortSynopsis(String synopsis) {
if (synopsis == null) {
return "";
}
return synopsis.length() <= 60 ? synopsis : synopsis.substring(0, 60);
}
}
@@ -130,6 +130,25 @@ class AppCatalogServiceTest {
verify(commentService, never()).countByDrama(any());
}
@Test
void should_keep_full_synopsis_on_card_when_text_exceeds_card_length() {
String longSynopsis = "一纸婚约,开启了甜蜜又心动的同居生活。"
+ "真相只有一个,而她亲手揭开迷雾。一场意外替嫁,让她成为冷面总裁的契约新娘。";
Drama drama = new Drama();
drama.setId(1L);
drama.setTitle("第一部");
drama.setSynopsis(longSynopsis);
given(episodeService.firstPlayableByDramas(List.of(1L))).willReturn(Map.of());
given(dramaCategoryService.listBasic()).willReturn(List.of());
given(commentService.countByEpisodes(List.of())).willReturn(Map.of());
List<AppDramaCardVO> cards = catalogService.toCards(List.of(drama));
assertThat(cards).hasSize(1);
assertThat(cards.get(0).getSynopsisLocales())
.containsEntry("zh", longSynopsis);
}
@Test
void should_filter_feed_by_drama_type_and_expose_it_on_card() {
Drama anime = drama(1L, "ANIME");