第五版_完整
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from api import statistics_api, stu_score_api, cls_mgmt_api, employ_api,stu_api, teacher_api # 导入 users 子路由
|
||||
from api import statistics_api, stu_score_api, cls_mgmt_api, employ_api,stu_api, teacher_api
|
||||
|
||||
# 1. 创建数据库表(如果表不存在)
|
||||
# Base.metadata.create_all 会扫描所有继承 Base 的模型,生成对应的 CREATE TABLE 语句
|
||||
@@ -13,9 +13,11 @@ from api import statistics_api, stu_score_api, cls_mgmt_api, employ_api,stu_api,
|
||||
|
||||
# 2. 创建 FastAPI 实例
|
||||
app = FastAPI(
|
||||
title="FastAPI + SQLAlchemy 分层架构(MySQL)",
|
||||
description="用户管理示例,演示分层架构和 MySQL 集成",
|
||||
version="1.0.0"
|
||||
title="码力全开: 学生管理系统",
|
||||
description="本项目旨在开发一个基于 FastAPI 的学生管理系统,"
|
||||
"提供学生基本信息管理、考核成绩管理、就业管理和统计分析四大核心功能模块。"
|
||||
"系统将采用 RESTful API 设计,支持前后端分离架构。<br>",
|
||||
version="0.141.1"
|
||||
)
|
||||
|
||||
# 3. 添加跨域中间件(允许前端跨域请求)
|
||||
@@ -29,11 +31,11 @@ app.add_middleware(
|
||||
|
||||
# 4. 注册子路由
|
||||
|
||||
app.include_router(statistics_api.router, prefix="/api/stats", tags=["统计分析"])
|
||||
app.include_router(statistics_api.router, prefix="/api/stats", tags=["统计分析模块(动态查询与综合能力锻炼)"])
|
||||
|
||||
app.include_router(stu_score_api.router, prefix="/api/score", tags=["学生成绩管理"])
|
||||
app.include_router(stu_score_api.router, prefix="/api/score", tags=["学生成绩管理模块"])
|
||||
|
||||
app.include_router(cls_mgmt_api.router, prefix="/api/classes", tags=["班级管理"])
|
||||
app.include_router(cls_mgmt_api.router, prefix="/api/classes", tags=["班级管理模块"])
|
||||
|
||||
app.include_router(employ_api.router,prefix="/api/employ",tags=["学生就业管理模块"])
|
||||
|
||||
@@ -43,7 +45,7 @@ app.include_router(stu_api.router, prefix="/api/student", tags=["学生信息管
|
||||
# 5. 根路径
|
||||
@app.get("/")
|
||||
async def root():
|
||||
return {"message": "欢迎访问 FastAPI + SQLAlchemy 分层示例!请访问 /docs 查看 API 文档。"}
|
||||
return {"message": "欢迎访问 码力全开: 学生管理系统 分层示例!请访问 /docs 查看 API 文档。"}
|
||||
|
||||
# 6. 如果直接运行此文件,启动 uvicorn 服务器
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user