zhaoqingang
2025-03-12 3b1bf7da6771bd1d6852d3dcc1f906d5ae5c95d1
app/service/service_token.py
@@ -1,8 +1,7 @@
from Log import logger
from app.config.config import settings
from app.config.const import BISHENG, RAGFLOW, DIFY
from app.models import UserModel, UserAppModel
from app.models.base_model import SessionLocal
from app.config.const import BISHENG, RAGFLOW, DIFY, chat_server
from app.models import UserModel, UserAppModel, UserTokenModel
from app.models.token_model import TokenModel
from app.service.auth import UserAppDao
from app.service.bisheng import BishengService
@@ -26,13 +25,14 @@
async def get_ragflow_token(db, user_id: int):
    # token = await UserAppDao(db).get_data_by_id(user_id, RAGFLOW)
    token = db.query(TokenModel).filter(TokenModel.user_id == user_id).first()
    token = db.query(UserTokenModel).filter(UserTokenModel.id == chat_server).first()
    if not token:
        token = await UserAppDao(db).get_data_by_id(user_id, RAGFLOW)
        if not token:
            return None
        return token.access_token
    else:
        return token.ragflow_token
        return token.access_token
async def get_dify_token(db, user_id: int):
@@ -118,4 +118,4 @@
            await ragflow_service.add_user_tenant(token, user.app_id,
                                                  u.email,
                                                  u.app_id)
    update_ragflow_user_tenant(sync_user.id)
    update_ragflow_user_tenant(user.app_id)