from fastapi import APIRouter, Depends, HTTPException, Query, Form from app.common.response import ApiResult from app.common.schema import ApiResultSchema from app.case.case01 import _username, _password, _list_data router = APIRouter() @router.post("/login", name="用户登录", description=""" #### 测试数据 - username: `zhangsan` - pwssword: `123456` """, response_model=ApiResultSchema) async def login( username: str = Form(..., title="用户名", description="用户名"), password: str = Form(..., title="密码", description="密码"), ): if username != _username: return ApiResult.error_msg("用户名不存在") if password != _password: return ApiResult.error_msg("密码不正确") return ApiResult.success() @router.get("/list", name="小说列表", description="", response_model=ApiResultSchema) async def list(): return ApiResult.success_data(_list_data)