123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- from fastapi import APIRouter
- from schemas.resource import (PeriodList, SubjectList, WorkTypeList,
- CategoryList, CategoryDetail, ResourceList,
- ResourceDetail)
- from .category import (get_periods, get_subjects, get_work_types,
- get_categories, create_category, update_category,
- delete_category)
- from .resource import get_resources, create_resource, update_resource, delete_resource, get_resource
- router = APIRouter(prefix="/resource", tags=["资源管理"])
- # Category
- router.add_api_route("/periods",
- get_periods,
- response_model=PeriodList,
- response_model_exclude_none=True,
- summary="学段列表")
- router.add_api_route("/subjects",
- get_subjects,
- response_model=SubjectList,
- response_model_exclude_none=True,
- summary="学科列表")
- router.add_api_route("/worktypes",
- get_work_types,
- response_model=WorkTypeList,
- response_model_exclude_none=True,
- summary="作业资源分类列表")
- router.add_api_route("/categories",
- get_categories,
- methods=["get"],
- response_model=CategoryList,
- response_model_exclude_none=True,
- summary="资源分类列表")
- router.add_api_route("/categories",
- create_category,
- methods=["post"],
- response_model=CategoryDetail,
- response_model_exclude_none=True,
- summary="创建资源分类")
- router.add_api_route("/categories/{cid}",
- update_category,
- methods=["put"],
- response_model=CategoryDetail,
- response_model_exclude_none=True,
- summary="更新资源分类")
- router.add_api_route("/categories/{cid}",
- delete_category,
- methods=["delete"],
- response_model=CategoryDetail,
- response_model_exclude_none=True,
- summary="删除资源分类")
- # Resource
- router.add_api_route("/items",
- get_resources,
- methods=["get"],
- response_model=ResourceList,
- response_model_exclude_none=True,
- summary="资源列表")
- router.add_api_route("/items",
- create_resource,
- methods=["post"],
- response_model=ResourceDetail,
- response_model_exclude_none=True,
- summary="创建资源")
- router.add_api_route("/items/{rid}",
- get_resource,
- methods=["get"],
- response_model=ResourceDetail,
- response_model_exclude_none=True,
- summary="资源详情")
- router.add_api_route("/items/{rid}",
- update_resource,
- methods=["put"],
- response_model=ResourceDetail,
- response_model_exclude_none=True,
- summary="更新资源")
- router.add_api_route("/items/{rid}",
- delete_resource,
- methods=["delete"],
- response_model=ResourceDetail,
- response_model_exclude_none=True,
- summary="删除资源")
- __all__ = [router]
|