feat(content): 列表卡片与后台返回收藏点赞评论数
This commit is contained in:
1 parent
f90336963b
commit
256821b824
13 files changed
+324
-50
No files matched your search
+9
-4
@@ -144,15 +144,17 @@ public class AppCatalogService {
|
||||
|
||||
/** 整屏卡片共用一次剧集查询,取每部剧的首个可播免费集作为预览。 */
|
||||
private List<AppDramaCardVO> cards(List<Drama> dramas, Map<Long, String> categoryNames) {
|
||||
Map<Long, DramaEpisode> previews = episodeService.firstPlayableByDramas(
|
||||
dramas.stream().map(Drama::getId).toList());
|
||||
List<Long> ids = dramas.stream().map(Drama::getId).toList();
|
||||
Map<Long, DramaEpisode> previews = episodeService.firstPlayableByDramas(ids);
|
||||
Map<Long, Long> commentCounts = commentService.countByDramas(ids);
|
||||
return dramas.stream()
|
||||
.map(drama -> toCard(drama, categoryNames, previews.get(drama.getId())))
|
||||
.map(drama -> toCard(
|
||||
drama, categoryNames, previews.get(drama.getId()), commentCounts))
|
||||
.toList();
|
||||
}
|
||||
|
||||
private AppDramaCardVO toCard(Drama drama, Map<Long, String> categoryNames,
|
||||
DramaEpisode preview) {
|
||||
DramaEpisode preview, Map<Long, Long> commentCounts) {
|
||||
AppDramaCardVO card = new AppDramaCardVO();
|
||||
card.setId(drama.getId());
|
||||
card.setTitle(drama.getTitle());
|
||||
@@ -163,6 +165,9 @@ public class AppCatalogService {
|
||||
card.setTotalEpisodes(drama.getTotalEpisodes());
|
||||
card.setIsHot(drama.getIsHot() != null && drama.getIsHot() == 1);
|
||||
card.setViewCount(drama.getViewCount());
|
||||
card.setLikeCount(drama.getLikeCount());
|
||||
card.setFavoriteCount(drama.getFavoriteCount());
|
||||
card.setCommentCount(commentCounts.getOrDefault(drama.getId(), 0L));
|
||||
card.setLanguage(drama.getLanguage());
|
||||
card.setPreview(preview == null ? null : toEpisode(preview));
|
||||
return card;
|
||||
|
||||
@@ -18,6 +18,12 @@ public class AppDramaCardVO {
|
||||
private Integer totalEpisodes;
|
||||
private Boolean isHot;
|
||||
private Long viewCount;
|
||||
/** 短剧累计点赞数:drama.like_count */
|
||||
private Long likeCount;
|
||||
/** 短剧累计收藏数:drama.favorite_count */
|
||||
private Long favoriteCount;
|
||||
/** 该剧未删除评论数:content_comment 按 drama_id 统计 */
|
||||
private Long commentCount;
|
||||
/** 语种,供客户端按语言筛选(如 zh-CN / id)。 */
|
||||
@Schema(description = "短剧语种,如 zh-CN / id")
|
||||
private String language;
|
||||
|
||||
Reference in new issue
Block a user