|
|
|
|
|
|
|
|
# See the License for the specific language governing permissions and |
|
|
# See the License for the specific language governing permissions and |
|
|
# limitations under the License. |
|
|
# limitations under the License. |
|
|
# |
|
|
# |
|
|
|
|
|
import hashlib |
|
|
from datetime import datetime |
|
|
from datetime import datetime |
|
|
|
|
|
|
|
|
import peewee |
|
|
import peewee |
|
|
|
|
|
|
|
|
from api.db.services.common_service import CommonService |
|
|
from api.db.services.common_service import CommonService |
|
|
from api.utils import get_uuid, current_timestamp, datetime_format |
|
|
from api.utils import get_uuid, current_timestamp, datetime_format |
|
|
from api.db import StatusEnum |
|
|
from api.db import StatusEnum |
|
|
|
|
|
from rag.settings import MINIO |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class UserService(CommonService): |
|
|
class UserService(CommonService): |
|
|
|
|
|
|
|
|
else: |
|
|
else: |
|
|
return None |
|
|
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 |
|
|
@classmethod |
|
|
@DB.connection_context() |
|
|
@DB.connection_context() |
|
|
def save(cls, **kwargs): |
|
|
def save(cls, **kwargs): |