fix: update app_shares.is_active to false when deleting shared app

This commit is contained in:
wxy
2026-04-01 17:41:28 +08:00
parent 0470a71d03
commit 924d10ac5b

View File

@@ -13,7 +13,7 @@ import uuid
from typing import Annotated, Any, Dict, List, Optional, Tuple from typing import Annotated, Any, Dict, List, Optional, Tuple
from fastapi import Depends 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 sqlalchemy.orm import Session
from app.core.error_codes import BizCode from app.core.error_codes import BizCode
@@ -759,14 +759,11 @@ class AppService:
app.is_active = False app.is_active = False
# 更新 app_shares 表中该应用的所有共享记录为失效状态 # 更新 app_shares 表中该应用的所有共享记录为失效状态
from app.models import AppShare stmt = sa_update(AppShare).where(
from sqlalchemy import update as sa_update AppShare.source_app_id == app_id,
self.db.execute( AppShare.is_active.is_(True)
sa_update(AppShare).where( ).values(is_active=False)
AppShare.source_app_id == app_id, self.db.execute(stmt)
AppShare.is_active.is_(True)
).values(is_active=False)
)
self.db.commit() self.db.commit()