merge: 合并 K89.1 预览集查询顺序修复
This commit is contained in:
commit
6252a07b5d
2 files changed
+15
-9
No files matched your search
+2
-2
@@ -107,7 +107,7 @@ public class AppCatalogService {
|
|||||||
Drama drama = dramaService.getPublished(dramaId);
|
Drama drama = dramaService.getPublished(dramaId);
|
||||||
List<DramaEpisode> episodes = episodeService.listPublishedByDrama(dramaId);
|
List<DramaEpisode> episodes = episodeService.listPublishedByDrama(dramaId);
|
||||||
Map<Long, Long> episodeCommentCounts = commentService.countByEpisodes(
|
Map<Long, Long> episodeCommentCounts = commentService.countByEpisodes(
|
||||||
episodes.stream().map(DramaEpisode::getId).toList());
|
episodes.stream().map(DramaEpisode::getId).sorted().toList());
|
||||||
String categoryName = categoryNameMap().getOrDefault(drama.getCategoryId(), "");
|
String categoryName = categoryNameMap().getOrDefault(drama.getCategoryId(), "");
|
||||||
|
|
||||||
AppDramaDetailVO detail = new AppDramaDetailVO();
|
AppDramaDetailVO detail = new AppDramaDetailVO();
|
||||||
@@ -173,7 +173,7 @@ public class AppCatalogService {
|
|||||||
List<Long> ids = dramas.stream().map(Drama::getId).toList();
|
List<Long> ids = dramas.stream().map(Drama::getId).toList();
|
||||||
Map<Long, DramaEpisode> previews = episodeService.firstPlayableByDramas(ids);
|
Map<Long, DramaEpisode> previews = episodeService.firstPlayableByDramas(ids);
|
||||||
Map<Long, Long> commentCounts = commentService.countByEpisodes(
|
Map<Long, Long> commentCounts = commentService.countByEpisodes(
|
||||||
previews.values().stream().map(DramaEpisode::getId).toList());
|
previews.values().stream().map(DramaEpisode::getId).sorted().toList());
|
||||||
return dramas.stream()
|
return dramas.stream()
|
||||||
.map(drama -> toCard(
|
.map(drama -> toCard(
|
||||||
drama, categoryNames, previews.get(drama.getId()), commentCounts))
|
drama, categoryNames, previews.get(drama.getId()), commentCounts))
|
||||||
|
|||||||
+13
-7
@@ -15,6 +15,7 @@ import com.fruitshorts.media.service.PlaybackSigner;
|
|||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -56,12 +57,15 @@ class AppCatalogServiceTest {
|
|||||||
drama.setLikeCount(3200L);
|
drama.setLikeCount(3200L);
|
||||||
drama.setFavoriteCount(1800L);
|
drama.setFavoriteCount(1800L);
|
||||||
drama.setViewCount(12400L);
|
drama.setViewCount(12400L);
|
||||||
DramaEpisode episode = episode(11L, 42L, 55L);
|
DramaEpisode firstEpisode = episode(11L, 42L, 55L);
|
||||||
|
DramaEpisode secondEpisode = episode(22L, 42L, 66L);
|
||||||
given(dramaService.getPublished(42L)).willReturn(drama);
|
given(dramaService.getPublished(42L)).willReturn(drama);
|
||||||
given(episodeService.listPublishedByDrama(42L)).willReturn(List.of(episode));
|
given(episodeService.listPublishedByDrama(42L))
|
||||||
|
.willReturn(List.of(secondEpisode, firstEpisode));
|
||||||
given(dramaCategoryService.listBasic()).willReturn(List.of());
|
given(dramaCategoryService.listBasic()).willReturn(List.of());
|
||||||
given(commentService.countByDrama(42L)).willReturn(96L);
|
given(commentService.countByDrama(42L)).willReturn(96L);
|
||||||
given(commentService.countByEpisodes(List.of(11L))).willReturn(Map.of(11L, 2L));
|
given(commentService.countByEpisodes(List.of(11L, 22L)))
|
||||||
|
.willReturn(Map.of(11L, 2L, 22L, 4L));
|
||||||
|
|
||||||
AppDramaDetailVO detail = catalogService.dramaDetail(42L);
|
AppDramaDetailVO detail = catalogService.dramaDetail(42L);
|
||||||
|
|
||||||
@@ -69,8 +73,8 @@ class AppCatalogServiceTest {
|
|||||||
assertThat(detail.getLikeCount()).isEqualTo(3200L);
|
assertThat(detail.getLikeCount()).isEqualTo(3200L);
|
||||||
assertThat(detail.getFavoriteCount()).isEqualTo(1800L);
|
assertThat(detail.getFavoriteCount()).isEqualTo(1800L);
|
||||||
assertThat(detail.getCommentCount()).isEqualTo(96L);
|
assertThat(detail.getCommentCount()).isEqualTo(96L);
|
||||||
assertThat(detail.getEpisodes().get(0).getLikeCount()).isEqualTo(55L);
|
assertThat(detail.getEpisodes().get(0).getLikeCount()).isEqualTo(66L);
|
||||||
assertThat(detail.getEpisodes().get(0).getCommentCount()).isEqualTo(2L);
|
assertThat(detail.getEpisodes().get(0).getCommentCount()).isEqualTo(4L);
|
||||||
verify(commentService).countByDrama(42L);
|
verify(commentService).countByDrama(42L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,8 +94,10 @@ class AppCatalogServiceTest {
|
|||||||
second.setFavoriteCount(80L);
|
second.setFavoriteCount(80L);
|
||||||
DramaEpisode firstEpisode = episode(11L, 1L, 320L);
|
DramaEpisode firstEpisode = episode(11L, 1L, 320L);
|
||||||
DramaEpisode secondEpisode = episode(22L, 2L, 120L);
|
DramaEpisode secondEpisode = episode(22L, 2L, 120L);
|
||||||
given(episodeService.firstPlayableByDramas(List.of(1L, 2L)))
|
Map<Long, DramaEpisode> previews = new LinkedHashMap<>();
|
||||||
.willReturn(Map.of(1L, firstEpisode, 2L, secondEpisode));
|
previews.put(2L, secondEpisode);
|
||||||
|
previews.put(1L, firstEpisode);
|
||||||
|
given(episodeService.firstPlayableByDramas(List.of(1L, 2L))).willReturn(previews);
|
||||||
given(dramaCategoryService.listBasic()).willReturn(List.of());
|
given(dramaCategoryService.listBasic()).willReturn(List.of());
|
||||||
given(commentService.countByEpisodes(List.of(11L, 22L)))
|
given(commentService.countByEpisodes(List.of(11L, 22L)))
|
||||||
.willReturn(Map.of(11L, 9L));
|
.willReturn(Map.of(11L, 9L));
|
||||||
|
|||||||
Reference in new issue
Block a user