def create_app():
    app = Flask(__name__)

    # ... 配置代码 ...

    # 初始化数据库
    db.init_app(app)

    # 导入模型，确保所有模型在创建表之前被加载
    from app.models.user import User, Role
    from app.models.book import Book, Category
    from app.models.borrow import BorrowRecord
    from app.models.inventory import InventoryLog

    # 创建数据库表
    with app.app_context():
        db.create_all()

        # ... 其余代码 ...
