This commit is contained in:
jxxghp 2024-04-23 10:02:15 +08:00
parent 0cbe8f5cdc
commit 3002bf4dd2
2 changed files with 5 additions and 3 deletions

View File

@ -184,6 +184,7 @@ def read_user_by_id(
) )
return user return user
@router.get("/config/{key}", summary="查询用户配置", response_model=schemas.Response) @router.get("/config/{key}", summary="查询用户配置", response_model=schemas.Response)
def get_config(key: str, def get_config(key: str,
current_user: User = Depends(get_current_active_user)): current_user: User = Depends(get_current_active_user)):
@ -195,6 +196,7 @@ def get_config(key: str,
"value": value "value": value
}) })
@router.post("/config/{key}", summary="更新用户配置", response_model=schemas.Response) @router.post("/config/{key}", summary="更新用户配置", response_model=schemas.Response)
def set_config(key: str, value: Union[list, dict, bool, int, str] = None, def set_config(key: str, value: Union[list, dict, bool, int, str] = None,
current_user: User = Depends(get_current_active_user)): current_user: User = Depends(get_current_active_user)):

View File

@ -1,5 +1,5 @@
import json import json
from typing import Any, Union, Dict from typing import Any, Union, Dict, Optional
from app.db import DbOper from app.db import DbOper
from app.db.models.userconfig import UserConfig from app.db.models.userconfig import UserConfig
@ -76,7 +76,7 @@ class UserConfigOper(DbOper, metaclass=Singleton):
user_cache[key] = value user_cache[key] = value
self.__USERCONF = cache self.__USERCONF = cache
def __get_config_caches(self, username: str) -> Dict[str, Any]: def __get_config_caches(self, username: str) -> Optional[Dict[str, Any]]:
""" """
获取配置缓存 获取配置缓存
""" """