修正若干拼写错误,增强相关逻辑

This commit is contained in:
2026-03-07 17:50:35 +08:00
parent 8f40572a38
commit b38dde1b70
3 changed files with 20 additions and 13 deletions

View File

@ -91,7 +91,10 @@ def create_startup(): # pragma: no cover
@driver.on_shutdown @driver.on_shutdown
async def _(): async def _():
await db.close_all_connections() try:
await db.close_all_connections()
except Exception:
pass
DepPermManager = Annotated[PermManager, Depends(perm_manager)] DepPermManager = Annotated[PermManager, Depends(perm_manager)]

View File

@ -121,7 +121,7 @@ class PermRepo:
async def get_entity_id_batch( async def get_entity_id_batch(
self, entities: list[PermEntity] self, entities: list[PermEntity]
) -> dict[PermEntity, int]: ) -> dict[PermEntity, int]:
"""批量获取 Entity 的 eneity_id """批量获取 Entity 的 entity_id
Args: Args:
entities: PermEntity 列表 entities: PermEntity 列表
@ -130,11 +130,15 @@ class PermRepo:
字典,键为 PermEntity值为对应的 ID 字典,键为 PermEntity值为对应的 ID
""" """
for entity in entities: # for entity in entities:
await self.conn.execute( # await self.conn.execute(
s("create_entity.sql"), # s("create_entity.sql"),
(entity.platform, entity.entity_type, entity.external_id), # (entity.platform, entity.entity_type, entity.external_id),
) # )
await self.conn.executemany(
s("create_entity.sql"),
[(e.platform, e.entity_type, e.external_id) for e in entities],
)
await self.conn.commit() await self.conn.commit()
val_placeholders = ", ".join(["(?, ?, ?)"] * len(entities)) val_placeholders = ", ".join(["(?, ?, ?)"] * len(entities))
params = [] params = []

View File

@ -58,7 +58,7 @@ def make_formatter(parent: PermEntity):
@cmd.assign("list") @cmd.assign("list")
async def list_permisison( async def list_permission(
pm: DepPermManager, pm: DepPermManager,
ec: _DepEntityChain, ec: _DepEntityChain,
event: Event, event: Event,
@ -71,7 +71,7 @@ async def list_permisison(
@cmd.assign("get") @cmd.assign("get")
async def get_permisison( async def get_permission(
pm: DepPermManager, pm: DepPermManager,
ec: _DepEntityChain, ec: _DepEntityChain,
perm: str, perm: str,
@ -96,7 +96,7 @@ async def get_permisison(
@cmd.assign("set") @cmd.assign("set")
async def set_permisison( async def set_permission(
pm: DepPermManager, pm: DepPermManager,
ec: _DepEntityChain, ec: _DepEntityChain,
perm: str, perm: str,
@ -105,8 +105,8 @@ async def set_permisison(
): ):
if any(i == val.lower() for i in ("y", "yes", "allow", "true", "t")): if any(i == val.lower() for i in ("y", "yes", "allow", "true", "t")):
await pm.update_permission(ec[0], perm, True) await pm.update_permission(ec[0], perm, True)
if any(i == val.lower() for i in ("n", "no", "deny", "false", "f")): elif any(i == val.lower() for i in ("n", "no", "deny", "false", "f")):
await pm.update_permission(ec[0], perm, False) await pm.update_permission(ec[0], perm, False)
if any(i == val.lower() for i in ("null", "none")): elif any(i == val.lower() for i in ("null", "none")):
await pm.update_permission(ec[0], perm, None) await pm.update_permission(ec[0], perm, None)
await get_permisison(pm, ec, perm, event) await get_permission(pm, ec, perm, event)