prs_server/crud/crud_interview_tables.py
2022-08-31 14:18:29 +08:00

37 lines
1.4 KiB
Python

from motor.motor_asyncio import AsyncIOMotorDatabase
import schemas
from crud.base import CRUDBase
__all__ = 'api_interview_tables',
class ApiInterviewTables(CRUDBase):
# 获取分组所有报表
async def get_mode_tables(self, db: AsyncIOMotorDatabase, data_in: schemas.FindTables):
where = data_in.where
where.update({'mode_id': data_in.mode_id})
return await self.find_many(db, where, {'_id': 0})
# 插入一条全新的分组
async def insert_tables(self, db: AsyncIOMotorDatabase, data_in: schemas.InsertTables):
data = {k: v for k, v in data_in.dict().items() if k != 'table_data'}
insert_data = data_in.table_data
insert_data.update(data)
return await self.insert_one(db, insert_data)
# 更新一条报表信息
async def update_tables(self, db: AsyncIOMotorDatabase, data_in: schemas.UpdateTables):
return await self.update_one(db, {'table_id': data_in.table_id}, {'$set': data_in.update_data})
# 查询报表信息
async def get_tables(self, db: AsyncIOMotorDatabase, where):
return await self.find_many(db, where, {'_id': 0})
# 获取一条报表信息
async def get_one_table(self, db: AsyncIOMotorDatabase, table_id):
return await self.find_one(db, {'table_id': table_id}, {'_id': 0})
api_interview_tables = ApiInterviewTables('interview_tables')