feat(card): 新增非会员卡片展示限制
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
# @Software : PyCharm
|
||||
# @Author : xingc
|
||||
# @Desc :
|
||||
from typing import Dict
|
||||
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
@@ -22,11 +24,21 @@ async def get_cache_card_by_number(db_session: AsyncSession, *, cert_number: str
|
||||
return card
|
||||
|
||||
|
||||
async def check_user_card_created_permission(db_session: AsyncSession, *, login_user: LoginUser) -> bool:
|
||||
async def check_user_card_created_permission(
|
||||
db_session: AsyncSession, *, login_user: LoginUser, other_conditions: Dict = None
|
||||
) -> bool:
|
||||
if other_conditions is None:
|
||||
other_conditions = {}
|
||||
|
||||
db_crud = CRUD(db_session, User)
|
||||
user = await db_crud.get(filters={'user_id': login_user.user_id})
|
||||
if user.is_vip():
|
||||
return True
|
||||
|
||||
total = await db_crud.total(model=UserCollection, filters={'user_id': login_user.user_id})
|
||||
total = await db_crud.total(
|
||||
model=UserCollection, filters={
|
||||
'user_id': login_user.user_id,
|
||||
**other_conditions
|
||||
}
|
||||
)
|
||||
return settings.USER_MAX_CREATED_CARD_NUM > total
|
||||
|
||||
Reference in New Issue
Block a user