From 0470a71d03dc0cc8fb7e6dc43a76c72b24d622d9 Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 1 Apr 2026 17:35:27 +0800 Subject: [PATCH 1/2] fix: update app_shares.is_active to false when deleting shared app --- api/app/services/app_service.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/api/app/services/app_service.py b/api/app/services/app_service.py index e1164206..841553e9 100644 --- a/api/app/services/app_service.py +++ b/api/app/services/app_service.py @@ -757,6 +757,17 @@ class AppService: # 逻辑删除应用 app.is_active = False + + # 更新 app_shares 表中该应用的所有共享记录为失效状态 + from app.models import AppShare + from sqlalchemy import update as sa_update + self.db.execute( + sa_update(AppShare).where( + AppShare.source_app_id == app_id, + AppShare.is_active.is_(True) + ).values(is_active=False) + ) + self.db.commit() logger.info( From 924d10ac5b112f394015c8fead334305c5d69f04 Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 1 Apr 2026 17:41:28 +0800 Subject: [PATCH 2/2] fix: update app_shares.is_active to false when deleting shared app --- api/app/services/app_service.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/api/app/services/app_service.py b/api/app/services/app_service.py index 841553e9..71bebbb0 100644 --- a/api/app/services/app_service.py +++ b/api/app/services/app_service.py @@ -13,7 +13,7 @@ import uuid from typing import Annotated, Any, Dict, List, Optional, Tuple from fastapi import Depends -from sqlalchemy import and_, delete, func, or_, select +from sqlalchemy import and_, delete, func, or_, select, update as sa_update from sqlalchemy.orm import Session from app.core.error_codes import BizCode @@ -759,14 +759,11 @@ class AppService: app.is_active = False # 更新 app_shares 表中该应用的所有共享记录为失效状态 - from app.models import AppShare - from sqlalchemy import update as sa_update - self.db.execute( - sa_update(AppShare).where( - AppShare.source_app_id == app_id, - AppShare.is_active.is_(True) - ).values(is_active=False) - ) + stmt = sa_update(AppShare).where( + AppShare.source_app_id == app_id, + AppShare.is_active.is_(True) + ).values(is_active=False) + self.db.execute(stmt) self.db.commit()