Files
2025-11-22 21:29:00 +08:00

57 lines
1.3 KiB
Python

"""
基因资源 API
"""
from typing import List, Optional
from fastapi import APIRouter, Query, HTTPException
router = APIRouter()
@router.get("/")
async def get_genes(
skip: int = Query(0, ge=0),
limit: int = Query(20, ge=1, le=100),
function_type: Optional[str] = None,
search: Optional[str] = None,
):
"""
获取基因列表
- **skip**: 跳过记录数
- **limit**: 返回记录数
- **function_type**: 功能类型 (抗逆/促生/杀虫/抗病/其他)
- **search**: 搜索关键词
"""
# TODO: 实现数据库查询
return {
"total": 0,
"items": [],
"skip": skip,
"limit": limit
}
@router.get("/{gene_id}")
async def get_gene_detail(gene_id: str):
"""
获取基因详情
"""
# TODO: 从数据库查询基因详细信息
raise HTTPException(status_code=404, detail="Gene not found")
@router.get("/functions/categories")
async def get_gene_functions():
"""
获取基因功能分类
"""
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},
]
}