完成项目训练模块的接口测试

This commit is contained in:
2025-04-22 10:11:44 +08:00
parent 7a9e571a96
commit 0033746fe1
11 changed files with 139 additions and 91 deletions

View File

@ -263,11 +263,17 @@ class DalBase:
await self.db.execute(insert(self.model), datas)
await self.db.flush()
async def create_model(self, data: Any) -> None:
"""
创建单个model
:param data: model
"""
self.db.add(data)
await self.db.flush()
async def create_models(self, datas: list[Any]) -> None:
"""
批量创建数据
SQLAlchemy 2.0 批量插入不支持 MySQL 返回值:
https://docs.sqlalchemy.org/en/20/orm/queryguide/dml.html#getting-new-objects-with-returning
:param datas: model数组
"""
self.db.add_all(datas)

View File

@ -7,7 +7,7 @@ from utils.websocket_server import room_manager
def websocket_config(app: FastAPI):
@app.websocket("/{room}")
@app.websocket("/ws/{room}")
async def websocket_room(websocket: WebSocket, room: str):
"""
websocket 房间管理