__init__.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. from fastapi import APIRouter
  4. from schemas.app.resource import ResourceUrlDetail, CollectDetail, CollectedResourceList
  5. from schemas.resource import CategoryList, ResourceList
  6. from .category import get_categories
  7. from .resource import get_resources, download_resource, collect_resource, preview_resource, get_collected_resource
  8. router = APIRouter(prefix="/resource", tags=["资源管理-教师学生端"])
  9. router.add_api_route("/categories",
  10. get_categories,
  11. methods=["get"],
  12. response_model=CategoryList,
  13. response_model_exclude_none=True,
  14. summary="资源分类列表")
  15. router.add_api_route("/items",
  16. get_resources,
  17. methods=["get"],
  18. response_model=ResourceList,
  19. response_model_exclude_none=True,
  20. summary="资源列表")
  21. router.add_api_route("/items/{rid}",
  22. download_resource,
  23. methods=["get"],
  24. response_model=ResourceUrlDetail,
  25. response_model_exclude_none=True,
  26. summary="下载资源")
  27. router.add_api_route("/items/{rid}",
  28. collect_resource,
  29. methods=["post"],
  30. response_model=CollectDetail,
  31. response_model_exclude_none=True,
  32. summary="收藏资源")
  33. router.add_api_route("/items/{rid}/preview",
  34. preview_resource,
  35. methods=["get"],
  36. response_model=ResourceUrlDetail,
  37. response_model_exclude_none=True,
  38. summary="预览资源")
  39. router.add_api_route("/collected",
  40. get_collected_resource,
  41. methods=["get"],
  42. response_model=CollectedResourceList,
  43. response_model_exclude_none=True,
  44. summary="个人收藏资源列表")
  45. __all__ = [router]