feat(app): 推荐流支持分类过滤

This commit is contained in:
Zhou Weidong committed 2026-10-21 18:23:57 +08:00
1 parent 0e8fb1582d
commit 8f35160b56
12 files changed
+255 -24

No files matched your search

@@ -41,13 +41,14 @@ public class AppCatalogController {
return Result.ok(appCatalogService.discoverFeed());
}
@Operation(summary = "推荐流:支持内容类型多选与游标翻页")
@Operation(summary = "推荐流:支持内容类型、分类过滤与游标翻页")
@GetMapping("/feed")
public Result<CursorResult<AppDramaCardVO>> feed(
@RequestParam(required = false) String types,
@RequestParam(required = false) Long categoryId,
@RequestParam(required = false) Long cursor,
@RequestParam(required = false) Integer size) {
return Result.ok(appCatalogService.feed(types, cursor, size));
return Result.ok(appCatalogService.feed(types, categoryId, cursor, size));
}
@Operation(summary = "分类列表")
@@ -74,7 +74,8 @@ public class AppCatalogService {
.toList();
}
public CursorResult<AppDramaCardVO> feed(String types, Long cursor, Integer size) {
public CursorResult<AppDramaCardVO> feed(
String types, Long categoryId, Long cursor, Integer size) {
int pageSize = size == null ? DEFAULT_FEED_SIZE : Math.max(1, Math.min(size, MAX_FEED_SIZE));
List<String> dramaTypes = types == null
? List.of()
@@ -82,7 +83,8 @@ public class AppCatalogService {
.map(String::trim)
.filter(type -> !type.isEmpty())
.toList();
List<Drama> rows = dramaService.listPublishedFeed(dramaTypes, cursor, pageSize + 1);
List<Drama> rows = dramaService.listPublishedFeed(
dramaTypes, categoryId, cursor, pageSize + 1);
if (rows.isEmpty()) {
return CursorResult.empty();
}