#!/usr/bin/env python # -*- coding: utf-8 -*- from fastapi import APIRouter from schemas.app.resource import ResourceUrlDetail, CollectDetail, CollectedResourceList from schemas.resource import CategoryList, ResourceList from .category import get_categories from .resource import get_resources, download_resource, collect_resource, preview_resource, get_collected_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="预览资源") router.add_api_route("/collected", get_collected_resource, methods=["get"], response_model=CollectedResourceList, response_model_exclude_none=True, summary="个人收藏资源列表") __all__ = [router]