#!/usr/bin/env python # -*- coding: utf-8 -*- from fastapi import APIRouter from schemas.app.resource import ResourceUrlDetail, CollectDetail from schemas.resource import CategoryList, ResourceList from .category import get_categories from .resource import get_resources, download_resource, collect_resource, preview_resource router = APIRouter(prefix="/resource", tags=["资源管理-客户端"]) router.add_api_route("/categories", get_categories, methods=["get"], response_model=CategoryList, response_model_exclude_none=True, summary="资源分类列表") router.add_api_route("/items", get_resources, methods=["get"], response_model=ResourceList, response_model_exclude_none=True, summary="资源列表") router.add_api_route("/items/{rid}", download_resource, methods=["get"], response_model=ResourceUrlDetail, response_model_exclude_none=True, summary="下载资源") router.add_api_route("/items/{rid}", collect_resource, methods=["post"], response_model=CollectDetail, response_model_exclude_none=True, summary="收藏资源") router.add_api_route("/items/{rid}/preview", preview_resource, methods=["get"], response_model=ResourceUrlDetail, response_model_exclude_none=True, summary="预览资源") __all__ = [router]