修复:装填前复核仓库权限
This commit is contained in:
@@ -8,16 +8,22 @@ class AccessDao:
|
||||
"""仓库与客户现场数据权限数据库操作层。"""
|
||||
|
||||
@classmethod
|
||||
async def user_has_warehouse(cls, db: AsyncSession, user_id: int, warehouse_id: int) -> bool:
|
||||
async def user_has_warehouse(
|
||||
cls,
|
||||
db: AsyncSession,
|
||||
user_id: int,
|
||||
warehouse_id: int,
|
||||
*,
|
||||
for_update: bool = False,
|
||||
) -> bool:
|
||||
"""判断用户是否关联指定仓库。"""
|
||||
mapped_user_id = (
|
||||
await db.execute(
|
||||
select(BizUserWarehouse.user_id).where(
|
||||
BizUserWarehouse.user_id == user_id,
|
||||
BizUserWarehouse.warehouse_id == warehouse_id,
|
||||
)
|
||||
)
|
||||
).scalar_one_or_none()
|
||||
statement = select(BizUserWarehouse.user_id).where(
|
||||
BizUserWarehouse.user_id == user_id,
|
||||
BizUserWarehouse.warehouse_id == warehouse_id,
|
||||
)
|
||||
if for_update:
|
||||
statement = statement.with_for_update()
|
||||
mapped_user_id = (await db.execute(statement)).scalar_one_or_none()
|
||||
|
||||
return mapped_user_id is not None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user