feat(app): 全部短剧改为请求体分页

This commit is contained in:
Zhou Weidong committed 2026-10-24 16:53:26 +08:00
1 parent ebc5f890fd
commit 2367a5d12b
15 files changed
+322 -61

No files matched your search

@@ -17,15 +17,18 @@ import com.fruitshorts.playback.service.PlaybackService;
import com.fruitshorts.interaction.service.CommentService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import java.util.List;
import java.util.Map;
import static org.hamcrest.Matchers.nullValue;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@@ -58,7 +61,7 @@ class AppCatalogControllerContractTest {
banner.setLinkValue("12");
AppDramaCardVO card = new AppDramaCardVO();
card.setId(12L);
card.setTitle("命运的相遇");
card.setTitleLocales(Map.of("zh", "命运的相遇"));
card.setViewCount(12400L);
card.setLikeCount(3200L);
card.setFavoriteCount(1800L);
@@ -94,7 +97,7 @@ class AppCatalogControllerContractTest {
void should_return_typed_cursor_feed() throws Exception {
AppDramaCardVO card = new AppDramaCardVO();
card.setId(12L);
card.setTitle("漫剧卡片");
card.setTitleLocales(Map.of("zh", "漫剧卡片"));
card.setDramaType("ANIME");
given(catalogService.feed("ANIME", 7L, null, 20))
.willReturn(new CursorResult<>(List.of(card), 12L, true));
@@ -122,14 +125,14 @@ class AppCatalogControllerContractTest {
.andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(0))
.andExpect(jsonPath("$.data[0].id").value(3))
.andExpect(jsonPath("$.data[0].name").value("都市"));
.andExpect(jsonPath("$.data[0].locales.zh").value("都市"));
}
@Test
void should_bind_path_variable_when_drama_detail_is_requested() throws Exception {
AppDramaDetailVO detail = new AppDramaDetailVO();
detail.setId(42L);
detail.setTitle("命运的相遇");
detail.setTitleLocales(Map.of("zh", "命运的相遇"));
detail.setViewCount(12400L);
detail.setLikeCount(3200L);
detail.setFavoriteCount(1800L);
@@ -142,7 +145,7 @@ class AppCatalogControllerContractTest {
.andExpect(jsonPath("$.code").value(0))
.andExpect(jsonPath("$.data.id").value("42"))
.andExpect(jsonPath("$.data.id").isString())
.andExpect(jsonPath("$.data.title").value("命运的相遇"))
.andExpect(jsonPath("$.data.titleLocales.zh").value("命运的相遇"))
.andExpect(jsonPath("$.data.viewCount").value("12400"))
.andExpect(jsonPath("$.data.likeCount").value("3200"))
.andExpect(jsonPath("$.data.favoriteCount").value("1800"))
@@ -161,4 +164,23 @@ class AppCatalogControllerContractTest {
.andExpect(jsonPath("$.code").value(ErrorCode.DATA_NOT_FOUND.getCode()))
.andExpect(jsonPath("$.data").value(nullValue()));
}
@Test
void should_bind_filter_ids_from_body_when_drama_page_is_posted() throws Exception {
AppDramaCardVO card = new AppDramaCardVO();
card.setId(9L);
card.setTitleLocales(Map.of("zh", "重生"));
given(catalogService.libraryDramas(List.of(2L), List.of(3L), List.of(4L), 1, 20))
.willReturn(new com.fruitshorts.common.pojo.PageResult<>(1L, List.of(card)));
catalogMvc.perform(post("/app/dramas/page")
.contentType(MediaType.APPLICATION_JSON)
.content("{\"pageIndex\":1,\"pageSize\":20,"
+ "\"categoryIds\":[\"2\"],\"classificationIds\":[\"3\"],\"tagIds\":[\"4\"]}"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.code").value(0))
.andExpect(jsonPath("$.data.total").value("1"))
.andExpect(jsonPath("$.data.list[0].titleLocales.zh").value("重生"));
verify(catalogService).libraryDramas(List.of(2L), List.of(3L), List.of(4L), 1, 20);
}
}
@@ -7,6 +7,7 @@ import com.fruitshorts.common.pojo.CursorResult;
import com.fruitshorts.content.dal.entity.Drama;
import com.fruitshorts.content.dal.entity.DramaEpisode;
import com.fruitshorts.content.service.BannerService;
import com.fruitshorts.content.service.ContentTagService;
import com.fruitshorts.content.service.DramaCategoryService;
import com.fruitshorts.content.service.DramaClassificationService;
import com.fruitshorts.content.service.DramaPlaylistCategoryService;
@@ -54,7 +55,7 @@ class AppCatalogServiceTest {
given(thumbnailUrlResolver.resolveAll(any())).willReturn(Map.of());
commentService = mock(CommentService.class);
catalogService = new AppCatalogService(dramaService, episodeService, bannerService,
dramaCategoryService, dramaClassificationService, dramaPlaylistCategoryService,
dramaCategoryService, mock(ContentTagService.class), dramaClassificationService, dramaPlaylistCategoryService,
playbackSigner, commentService, thumbnailUrlResolver);
}
@@ -43,6 +43,8 @@ class DramaServiceFavoriteCountTest {
mock(DramaEpisodeMapper.class),
mock(DramaReviewRecordMapper.class),
mock(DramaCategoryService.class),
mock(com.fruitshorts.content.dal.mapper.ContentTagMapper.class),
mock(com.fruitshorts.content.service.ContentTagService.class),
mock(EpisodePriceSync.class));
given(dramaMapper.update(isNull(), any())).willReturn(1);
ArgumentCaptor<Wrapper<Drama>> captor = ArgumentCaptor.forClass(Wrapper.class);
@@ -47,6 +47,8 @@ class DramaServiceFeedTest {
mock(DramaEpisodeMapper.class),
mock(DramaReviewRecordMapper.class),
mock(DramaCategoryService.class),
mock(com.fruitshorts.content.dal.mapper.ContentTagMapper.class),
mock(com.fruitshorts.content.service.ContentTagService.class),
mock(EpisodePriceSync.class));
}
@@ -48,6 +48,8 @@ class DramaServiceK88Test {
mock(DramaEpisodeMapper.class),
mock(DramaReviewRecordMapper.class),
mock(DramaCategoryService.class),
mock(com.fruitshorts.content.dal.mapper.ContentTagMapper.class),
mock(com.fruitshorts.content.service.ContentTagService.class),
mock(EpisodePriceSync.class));
}
@@ -56,6 +56,8 @@ class DramaServiceMultiTagTest {
mock(DramaEpisodeMapper.class),
mock(DramaReviewRecordMapper.class),
categoryService,
mock(com.fruitshorts.content.dal.mapper.ContentTagMapper.class),
mock(com.fruitshorts.content.service.ContentTagService.class),
mock(EpisodePriceSync.class));
}