57 lines
1.4 KiB
Python
57 lines
1.4 KiB
Python
"""
|
|
菌种资源 API
|
|
"""
|
|
from typing import List, Optional
|
|
from fastapi import APIRouter, Query, HTTPException
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/")
|
|
async def get_strains(
|
|
skip: int = Query(0, ge=0),
|
|
limit: int = Query(20, ge=1, le=100),
|
|
category: Optional[str] = None,
|
|
search: Optional[str] = None,
|
|
):
|
|
"""
|
|
获取菌种列表
|
|
|
|
- **skip**: 跳过记录数
|
|
- **limit**: 返回记录数
|
|
- **category**: 菌种分类 (抗逆/促生/杀虫/抗病/食药用)
|
|
- **search**: 搜索关键词
|
|
"""
|
|
# TODO: 实现数据库查询
|
|
return {
|
|
"total": 0,
|
|
"items": [],
|
|
"skip": skip,
|
|
"limit": limit
|
|
}
|
|
|
|
|
|
@router.get("/{strain_id}")
|
|
async def get_strain_detail(strain_id: str):
|
|
"""
|
|
获取菌种详情
|
|
"""
|
|
# TODO: 从数据库查询菌种详细信息
|
|
raise HTTPException(status_code=404, detail="Strain not found")
|
|
|
|
|
|
@router.get("/categories/tree")
|
|
async def get_strain_categories():
|
|
"""
|
|
获取菌种分类树
|
|
"""
|
|
return {
|
|
"categories": [
|
|
{"id": 1, "name": "抗逆微生物", "count": 0},
|
|
{"id": 2, "name": "促生微生物", "count": 0},
|
|
{"id": 3, "name": "杀虫微生物", "count": 0},
|
|
{"id": 4, "name": "抗病微生物", "count": 0},
|
|
{"id": 5, "name": "食药用微生物", "count": 0},
|
|
]
|
|
}
|