mirror of
https://github.com/fastapi-practices/fastapi-best-architecture.git
synced 2026-09-21 21:15:13 +00:00
Refactor foreign keys and relationships to pure logic (#901)
* Refactor foreign keys and relationships to pure logic * Revert of some changes * More revert * Update the user paginate * Update user create and update * Update dept select and delete * Rename the join query functions * Update select_join_serialize doc and README * Fix typo in README * Update the user delete * Update the user social * Update the dict plugin crud * Update the dict plugin version * Bump dependencies and pre-commits * Update the code generator plugin crud * Update the menu crud * Update the role crud * Update the data scope and rule crud * Restore get_paginated to get_select * Update the code generator plugin version * Add the py version in pre-commit * Remove the plugin include parameter config * Add more cache cleaning TODO * Rename get_with_relation to get_join * Add the user cache clear * Fix known compatibility issues * Update the version number to 1.11.0 * Fix lint * Optimize select_join_serialize logic * Delete cache cleanup comments * Update the oauth2 plugin version * Fix user-role table cleanup when user update
This commit is contained in:
@@ -22,7 +22,6 @@ from backend.common.exception.errors import TokenError
|
||||
from backend.core.conf import settings
|
||||
from backend.database.db import async_db_session
|
||||
from backend.database.redis import redis_client
|
||||
from backend.utils.serializers import select_as_dict
|
||||
from backend.utils.timezone import timezone
|
||||
|
||||
|
||||
@@ -246,7 +245,7 @@ async def get_current_user(db: AsyncSession, pk: int) -> User:
|
||||
"""
|
||||
from backend.app.admin.crud.crud_user import user_dao
|
||||
|
||||
user = await user_dao.get_with_relation(db, user_id=pk)
|
||||
user = await user_dao.get_join(db, user_id=pk)
|
||||
if not user:
|
||||
raise errors.TokenError(msg='Token 无效')
|
||||
if not user.status:
|
||||
@@ -297,7 +296,7 @@ async def jwt_authentication(token: str) -> GetUserInfoWithRelationDetail:
|
||||
if not cache_user:
|
||||
async with async_db_session() as db:
|
||||
current_user = await get_current_user(db, user_id)
|
||||
user = GetUserInfoWithRelationDetail(**select_as_dict(current_user))
|
||||
user = GetUserInfoWithRelationDetail.model_validate(current_user)
|
||||
await redis_client.setex(
|
||||
f'{settings.JWT_USER_REDIS_PREFIX}:{user_id}',
|
||||
settings.TOKEN_EXPIRE_SECONDS,
|
||||
|
||||
Reference in New Issue
Block a user