feat(card): 会员功能验证
This commit is contained in:
@@ -99,6 +99,9 @@ class User(BaseModel, DateModel):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f'{self.user_id}'
|
return f'{self.user_id}'
|
||||||
|
|
||||||
|
def is_vip(self) -> bool:
|
||||||
|
return self.vip_expire_date >= datetime.now().date()
|
||||||
|
|
||||||
|
|
||||||
class UserFollows(BaseModel, DateModel):
|
class UserFollows(BaseModel, DateModel):
|
||||||
__tablename__ = 'system_user_followers'
|
__tablename__ = 'system_user_followers'
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ from config import settings
|
|||||||
from core.base import schema as base_schema
|
from core.base import schema as base_schema
|
||||||
from core.db.crud import CRUD
|
from core.db.crud import CRUD
|
||||||
from core.db.engine import get_async_session, get_cache
|
from core.db.engine import get_async_session, get_cache
|
||||||
from core.db.models import Card, SearchCardCache, UserCollection
|
from core.db.models import Card, SearchCardCache, UserCollection, User
|
||||||
from core.routers.auth.schema import LoginUser
|
from core.routers.auth.schema import LoginUser
|
||||||
from core.routers.auth.services import get_current_user_form_http
|
from core.routers.auth.services import get_current_user_form_http
|
||||||
from core.utils.helper import generate_keyname, check_picture_for_empty
|
from core.utils.helper import generate_keyname, check_picture_for_empty
|
||||||
@@ -267,6 +267,10 @@ async def update_card_price_info(
|
|||||||
db_session: AsyncSession = Depends(get_async_session),
|
db_session: AsyncSession = Depends(get_async_session),
|
||||||
):
|
):
|
||||||
db_crud = CRUD(db_session, UserCollection)
|
db_crud = CRUD(db_session, UserCollection)
|
||||||
|
user = await db_crud.get(model=User, filters={'user_id': login_user.user_id})
|
||||||
|
if user.is_vip() is False:
|
||||||
|
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail='会员未开通或者已过期')
|
||||||
|
|
||||||
result = await db_crud.update(
|
result = await db_crud.update(
|
||||||
data=payload.dict(exclude_none=True),
|
data=payload.dict(exclude_none=True),
|
||||||
filters={'card_id': card_id, 'user_id': login_user.user_id}
|
filters={'card_id': card_id, 'user_id': login_user.user_id}
|
||||||
|
|||||||
@@ -62,8 +62,9 @@ class SearchCardOut(Card):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class CardVisitOut(Card, UpdateCard):
|
class CardVisitOut(Card):
|
||||||
source: PlatformSourceType
|
source: PlatformSourceType
|
||||||
|
display_price: Optional[condecimal(max_digits=10, decimal_places=2)] = None
|
||||||
|
|
||||||
|
|
||||||
class CardOut(CardVisitOut):
|
class CardOut(CardVisitOut):
|
||||||
@@ -71,7 +72,6 @@ class CardOut(CardVisitOut):
|
|||||||
card_id: Optional[int] = None
|
card_id: Optional[int] = None
|
||||||
card_year: str | None
|
card_year: str | None
|
||||||
purchase_price: Optional[condecimal(max_digits=10, decimal_places=2)] = None
|
purchase_price: Optional[condecimal(max_digits=10, decimal_places=2)] = None
|
||||||
display_price: Optional[condecimal(max_digits=10, decimal_places=2)] = None
|
|
||||||
displayed: Optional[bool] = False
|
displayed: Optional[bool] = False
|
||||||
diy_source: Optional[str] = None
|
diy_source: Optional[str] = None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user