from motor.motor_asyncio import AsyncIOMotorDatabase import schemas from crud.base import CRUDBase __all__ = 'api_module', class Api_module(CRUDBase): # 获取权限模板信息 async def get_api_module(self, db: AsyncIOMotorDatabase): return await self.find_many(db) # 获取一个用户的权限信息 async def get_quanxian(self, db: AsyncIOMotorDatabase, data_in: schemas.Url_quanxian): return await self.find_one(db, {'user_id': data_in.user_id}) # 插入一条全新的用户权限信息 async def insert_quanxian(self, db: AsyncIOMotorDatabase, data_in: schemas.Url_module): return await self.insert_one(db, data_in.dict()) # 更新一条用户权限信息 async def updata_quanxian_module(self, db: AsyncIOMotorDatabase, data_in: schemas.Url_module): return await self.update_one(db, {'auth_id': data_in.auth_id, 'path_name': data_in.path_name}, {'$set': {'api_list': data_in.api_list, 'api_name': data_in.api_name, 'state': data_in.state}}) #获取一条权限模板信息 async def get_one_module(self, db: AsyncIOMotorDatabase, data_in: schemas.Add_module): return await self.find_one(db, {'auth_id': data_in.auth_id}) #更新一条权限模板状态 async def update_one_module(self, db: AsyncIOMotorDatabase, res): return await self.update_one(db, {'_id':res['_id']}, { '$set': {'state':res['state']}}) api_module = Api_module('api_module')