diff --git a/api/app/controllers/app_controller.py b/api/app/controllers/app_controller.py index f30b959d..2300f148 100644 --- a/api/app/controllers/app_controller.py +++ b/api/app/controllers/app_controller.py @@ -48,6 +48,7 @@ def list_apps( include_shared: bool = True, page: int = 1, pagesize: int = 10, + ids: Optional[str] = None, db: Session = Depends(get_db), current_user=Depends(get_current_user), ): @@ -55,8 +56,19 @@ def list_apps( - 默认包含本工作空间的应用和分享给本工作空间的应用 - 设置 include_shared=false 可以只查看本工作空间的应用 + - 当提供 ids 参数时,按逗号分割获取指定应用,不分页 """ workspace_id = current_user.current_workspace_id + service = app_service.AppService(db) + + # 当 ids 存在且不为 None 时,根据 ids 获取应用 + if ids is not None: + app_ids = [id.strip() for id in ids.split(',') if id.strip()] + items_orm = app_service.get_apps_by_ids(db, app_ids, workspace_id) + items = [service._convert_to_schema(app, workspace_id) for app in items_orm] + return success(data=items) + + # 正常分页查询 items_orm, total = app_service.list_apps( db, workspace_id=workspace_id, @@ -69,8 +81,6 @@ def list_apps( pagesize=pagesize, ) - # 使用 AppService 的转换方法来设置 is_shared 字段 - service = app_service.AppService(db) items = [service._convert_to_schema(app, workspace_id) for app in items_orm] meta = PageMeta(page=page, pagesize=pagesize, total=total, hasnext=(page * pagesize) < total) return success(data=PageData(page=meta, items=items)) diff --git a/api/app/controllers/home_page_controller.py b/api/app/controllers/home_page_controller.py index f1a5310d..77db9d8f 100644 --- a/api/app/controllers/home_page_controller.py +++ b/api/app/controllers/home_page_controller.py @@ -31,5 +31,8 @@ def get_workspace_list( @router.get("/version", response_model=ApiResponse) def get_system_version(): - """获取系统版本号""" - return success(data={"version": settings.SYSTEM_VERSION}, msg="系统版本获取成功") \ No newline at end of file + """获取系统版本号+说明""" + return success(data={ + "version": settings.SYSTEM_VERSION, + "introduction": settings.SYSTEM_INTRODUCTION + }, msg="系统版本获取成功") \ No newline at end of file diff --git a/api/app/core/config.py b/api/app/core/config.py index b02b94a5..d9b9cea8 100644 --- a/api/app/core/config.py +++ b/api/app/core/config.py @@ -166,7 +166,8 @@ class Settings: ENABLE_TOOL_MANAGEMENT: bool = os.getenv("ENABLE_TOOL_MANAGEMENT", "true").lower() == "true" # official environment system version - SYSTEM_VERSION: str = os.getenv("SYSTEM_VERSION", "v1.0.0") + SYSTEM_VERSION: str = os.getenv("SYSTEM_VERSION", "v0.2.0") + SYSTEM_INTRODUCTION: str = os.getenv("SYSTEM_INTRODUCTION", "") def get_memory_output_path(self, filename: str = "") -> str: """ diff --git a/api/app/services/app_service.py b/api/app/services/app_service.py index b97bf874..6d5204f8 100644 --- a/api/app/services/app_service.py +++ b/api/app/services/app_service.py @@ -812,6 +812,37 @@ class AppService: ) return items, int(total) + def get_apps_by_ids( + self, + app_ids: List[str], + workspace_id: uuid.UUID + ) -> List[App]: + """根据ID列表获取应用 + + Args: + app_ids: 应用ID列表 + workspace_id: 工作空间ID(用于权限验证) + + Returns: + List[App]: 应用列表 + """ + if not app_ids: + return [] + + # 转换字符串ID为UUID + try: + uuid_ids = [uuid.UUID(app_id) for app_id in app_ids] + except ValueError: + return [] + + # 查询本工作空间的应用 + 分享给本工作空间的应用 + stmt = select(App).where( + App.id.in_(uuid_ids), + App.workspace_id == workspace_id + ) + + return list(self.db.scalars(stmt).all()) + # ==================== Agent 配置管理 ==================== def update_agent_config( @@ -2068,6 +2099,16 @@ def list_apps( ) +def get_apps_by_ids( + db: Session, + app_ids: List[str], + workspace_id: uuid.UUID +) -> List[App]: + """根据ID列表获取应用(向后兼容接口)""" + service = AppService(db) + return service.get_apps_by_ids(app_ids, workspace_id) + + # ==================== 向后兼容的函数接口 ==================== async def draft_run(