ソースを参照

Unified user_service.py (#4606)

### What problem does this PR solve?

Unified user_service.py

### Type of change

- [x] Refactoring
tags/v0.16.0
Zhichang Yu 9ヶ月前
コミット
240e7d7c22
コミッターのメールアドレスに関連付けられたアカウントが存在しません
1個のファイルの変更8行の追加0行の削除
  1. 8
    0
      api/db/services/user_service.py

+ 8
- 0
api/db/services/user_service.py ファイルの表示

@@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import hashlib
from datetime import datetime

import peewee
@@ -24,6 +25,7 @@ from api.db.db_models import User, Tenant
from api.db.services.common_service import CommonService
from api.utils import get_uuid, current_timestamp, datetime_format
from api.db import StatusEnum
from rag.settings import MINIO


class UserService(CommonService):
@@ -48,6 +50,12 @@ class UserService(CommonService):
else:
return None

@classmethod
@DB.connection_context()
def user_gateway(cls, tenant_id):
hashobj = hashlib.sha256(tenant_id.encode("utf-8"))
return int(hashobj.hexdigest(), 16)%len(MINIO)

@classmethod
@DB.connection_context()
def save(cls, **kwargs):

読み込み中…
キャンセル
保存