feat(dramas): 新增剧集搜索、推荐接口与管理筛选功能
1. 为后台剧集列表添加标题和推荐状态筛选参数 2. 新增前台推荐剧集列表接口和前置搜索接口 3. 添加可选布尔值解析工具方法 4. 新增对应接口的端到端测试用例
This commit is contained in:
@@ -28,10 +28,12 @@ export class DramasController {
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(AdminJwtAuthGuard, PermissionsGuard)
|
||||
@RequirePermissions("drama:read")
|
||||
listAdminDramas(@Query("page") page?: string, @Query("pageSize") pageSize?: string) {
|
||||
listAdminDramas(@Query("page") page?: string, @Query("pageSize") pageSize?: string, @Query("title") title?: string, @Query("isRecommended") isRecommended?: string) {
|
||||
return this.dramasService.listAdminDramas({
|
||||
page: Number(page) || 1,
|
||||
pageSize: Number(pageSize) || 20,
|
||||
title,
|
||||
isRecommended: this.parseOptionalBoolean(isRecommended),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -111,11 +113,27 @@ export class DramasController {
|
||||
}
|
||||
|
||||
@Get("/api/app/v1/dramas")
|
||||
listPublishedDramas(@Query("page") page?: string, @Query("pageSize") pageSize?: string, @Query("title") title?: string) {
|
||||
listPublishedDramas(@Query("page") page?: string, @Query("pageSize") pageSize?: string) {
|
||||
return this.dramasService.listPublishedDramas({
|
||||
page: Number(page) || 1,
|
||||
pageSize: Number(pageSize) || 10,
|
||||
title,
|
||||
});
|
||||
}
|
||||
|
||||
@Get("/api/app/v1/dramas/recommended")
|
||||
listRecommendedDramas(@Query("page") page?: string, @Query("pageSize") pageSize?: string) {
|
||||
return this.dramasService.listRecommendedDramas({
|
||||
page: Number(page) || 1,
|
||||
pageSize: Number(pageSize) || 10,
|
||||
});
|
||||
}
|
||||
|
||||
@Get("/api/app/v1/dramas/presearch")
|
||||
presearchVideos(@Query("keyword") keyword?: string, @Query("page") page?: string, @Query("pageSize") pageSize?: string) {
|
||||
return this.dramasService.presearchVideos({
|
||||
page: Number(page) || 1,
|
||||
pageSize: Number(pageSize) || 10,
|
||||
keyword,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -131,4 +149,14 @@ export class DramasController {
|
||||
getPublishedDrama(@Param("id") id: string) {
|
||||
return this.dramasService.getPublishedDramaOrThrow(Number(id));
|
||||
}
|
||||
|
||||
private parseOptionalBoolean(value?: string) {
|
||||
if (value === "true") {
|
||||
return true;
|
||||
}
|
||||
if (value === "false") {
|
||||
return false;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user