Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

tenant_app.py 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #
  2. # Copyright 2024 The InfiniFlow Authors. All Rights Reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. from flask_login import current_user, login_required
  17. from api.utils.api_utils import server_error_response
  18. from api.db.services.user_service import TenantService, UserTenantService
  19. from api.utils.api_utils import get_json_result
  20. @manager.route("/list", methods=["GET"])
  21. @login_required
  22. def tenant_list():
  23. try:
  24. tenants = TenantService.get_by_user_id(current_user.id)
  25. return get_json_result(data=tenants)
  26. except Exception as e:
  27. return server_error_response(e)
  28. @manager.route("/<tenant_id>/user/list", methods=["GET"])
  29. @login_required
  30. def user_list(tenant_id):
  31. try:
  32. users = UserTenantService.get_by_tenant_id(tenant_id)
  33. return get_json_result(data=users)
  34. except Exception as e:
  35. return server_error_response(e)