__init__.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. from fastapi import APIRouter
  4. from schemas.app.resource import ResourceUrlDetail, CollectDetail
  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
  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. __all__ = [router]