
from fastapi import APIRouter, Depends, HTTPException
from pydantic import BaseModel
from sqlalchemy.orm import Session
from {{ base_package }}.shared.database import get_db

# 如果需要引用模型，请确保 basics_database 已生成并包含该模型
# from {{ base_package }}.features.basics_database.public import MyModel

router = APIRouter()

# --- 1. 数据模型 (Schemas) ---
class {{ slice_class_name }}Request(BaseModel):
    data: str

class {{ slice_class_name }}Response(BaseModel):
    message: str

# --- 2. 业务逻辑 (Logic) ---
def logic(req: {{ slice_class_name }}Request, db: Session):
    # TODO: 实现业务逻辑
    return {{ slice_class_name }}Response(message=f"Received {req.data}")

# --- 3. 路由接口 (Endpoint) ---
@router.{{ method | lower }}("/", response_model={{ slice_class_name }}Response)
async def endpoint(req: {{ slice_class_name }}Request, db: Session = Depends(get_db)):
    return logic(req, db)
