Browse Source

suhh-修改机器人权限接口

‘suhuihui’ 2 months ago
parent
commit
e80b9f52da
2 changed files with 6 additions and 7 deletions
  1. 2 3
      api/controllers/console/app/app.py
  2. 4 4
      api/services/app_service.py

+ 2 - 3
api/controllers/console/app/app.py

@@ -349,7 +349,7 @@ class AppPermissionApi(Resource):
     @account_initialization_required
     def get(self, app_model):
         app_service = AppService()
-        app_model = app_service.get_app(app_model)
+        app_model = app_service.get_app_by_id(app_model)
         if not app_model:
             raise NotFound("App not found.")
         read_permission_list = AppService.get_app_read_permission(app_model.id)
@@ -366,7 +366,7 @@ class AppPermissionApi(Resource):
     def post(self, app_model):
         # add app permission
         app_service = AppService()
-        app_model = app_service.get_app(app_model)
+        app_model = app_service.get_app_by_id(app_model)
 
         # 解析表单数据
         data = request.get_json()
@@ -374,7 +374,6 @@ class AppPermissionApi(Resource):
             raise NotFound("Invalid JSON")
 
         edit_auth = data.get("edit_auth")
-        print("edit_auth" + str(edit_auth))
         if edit_auth is None:
             return jsonify({"error": "Missing 'edit_auth' field"}), 400
 

+ 4 - 4
api/services/app_service.py

@@ -196,6 +196,7 @@ class AppService:
         app.api_rph = args.get("api_rph", 0)
         app.api_rpm = args.get("api_rpm", 0)
         app.created_by = account.id
+        app.dept_id =account.dept_id
         app.updated_by = account.id
 
         db.session.add(app)
@@ -218,8 +219,10 @@ class AppService:
         return app
 
     def get_app_by_id(self, app: App) -> App:
+
         return app
 
+
     def get_app(self, app: App) -> App:
         """
         Get App
@@ -247,7 +250,6 @@ class AppService:
                         provider_type=agent_tool_entity.provider_type,
                         identity_id=f"AGENT.{app.id}",
                     )
-
                     # get decrypted parameters
                     if agent_tool_entity.tool_parameters:
                         parameters = manager.decrypt_tool_parameters(agent_tool_entity.tool_parameters or {})
@@ -262,12 +264,10 @@ class AppService:
 
             # override agent mode
             model_config.agent_mode = json.dumps(agent_mode)
-
             class ModifiedApp(App):
                 """
                 Modified App class
                 """
-
                 def __init__(self, app):
                     self.__dict__.update(app.__dict__)
 
@@ -276,7 +276,6 @@ class AppService:
                     return model_config
 
             app = ModifiedApp(app)
-
         return app
 
     def update_app(self, app: App, args: dict) -> App:
@@ -449,6 +448,7 @@ class AppService:
         app.edit_auth = edit_auth
         app.updated_by = current_user.id
         app.updated_at = datetime.now(UTC).replace(tzinfo=None)
+
         db.session.commit()
 
         return app