style: 后端代码black格式化
Deploy / Deploy Staging (push) Failing after 138h4m33s
CI/CD Pipeline / Frontend Lint (push) Failing after 138h4m39s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 138h4m39s
Deploy / Staging E2E Tests (push) Failing after 1796h40m0s
Deploy / Production Browser E2E (push) Failing after 1796h40m1s
Deploy / Build Production Runtime Images (push) Failing after 1796h40m6s
Deploy / Deploy Production (push) Failing after 1797h11m28s
Deploy / Deploy Staging (push) Failing after 138h4m33s
CI/CD Pipeline / Frontend Lint (push) Failing after 138h4m39s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 138h4m39s
Deploy / Staging E2E Tests (push) Failing after 1796h40m0s
Deploy / Production Browser E2E (push) Failing after 1796h40m1s
Deploy / Build Production Runtime Images (push) Failing after 1796h40m6s
Deploy / Deploy Production (push) Failing after 1797h11m28s
This commit is contained in:
@@ -153,11 +153,7 @@ class SQLAlchemyAssetRepository:
|
||||
query = query.filter(AssetModel.status == status)
|
||||
if classification_category is not None:
|
||||
# classification_result 是 JSON Text,用 LIKE 匹配 category 字段
|
||||
query = query.filter(
|
||||
AssetModel.classification_result.like(
|
||||
f'%"{classification_category}"%'
|
||||
)
|
||||
)
|
||||
query = query.filter(AssetModel.classification_result.like(f'%"{classification_category}"%'))
|
||||
query = query.order_by(AssetModel.quality_score.desc().nullslast())
|
||||
if limit > 0:
|
||||
query = query.limit(limit)
|
||||
@@ -166,10 +162,7 @@ class SQLAlchemyAssetRepository:
|
||||
# 内存中过滤 tags(tags 存在 metadata 中)
|
||||
if tags:
|
||||
tag_set = set(tags)
|
||||
candidates = [
|
||||
a for a in candidates
|
||||
if tag_set.issubset(set(a.metadata.get("tags", [])))
|
||||
]
|
||||
candidates = [a for a in candidates if tag_set.issubset(set(a.metadata.get("tags", [])))]
|
||||
return candidates
|
||||
|
||||
def _to_domain(self, model: AssetModel) -> Asset:
|
||||
|
||||
@@ -43,6 +43,7 @@ class SQLAlchemyBillingRepository:
|
||||
def update_subscription_on_payment(self, user_id: str, plan: str, expires_at: datetime) -> None:
|
||||
"""在支付成功后更新用户订阅状态(事务内调用)"""
|
||||
from packages.adapters.sqlalchemy_impl.models import UserModel
|
||||
|
||||
model = self.session.get(UserModel, user_id)
|
||||
if model:
|
||||
model.subscription_plan = plan
|
||||
|
||||
@@ -36,11 +36,7 @@ class SQLAlchemyEditPlanClipRepository:
|
||||
|
||||
def get(self, clip_id: str) -> Optional[EditPlanClip]:
|
||||
"""根据 ID 获取片段"""
|
||||
model = (
|
||||
self.session.query(EditPlanClipModel)
|
||||
.filter(EditPlanClipModel.id == clip_id)
|
||||
.first()
|
||||
)
|
||||
model = self.session.query(EditPlanClipModel).filter(EditPlanClipModel.id == clip_id).first()
|
||||
if model is None:
|
||||
return None
|
||||
return self._model_to_entity(model)
|
||||
@@ -68,11 +64,7 @@ class SQLAlchemyEditPlanClipRepository:
|
||||
|
||||
def update(self, clip: EditPlanClip) -> EditPlanClip:
|
||||
"""更新片段"""
|
||||
model = (
|
||||
self.session.query(EditPlanClipModel)
|
||||
.filter(EditPlanClipModel.id == clip.id)
|
||||
.first()
|
||||
)
|
||||
model = self.session.query(EditPlanClipModel).filter(EditPlanClipModel.id == clip.id).first()
|
||||
if model is None:
|
||||
raise ValueError(f"EditPlanClip {clip.id} not found")
|
||||
model.plan_id = clip.plan_id
|
||||
@@ -93,11 +85,7 @@ class SQLAlchemyEditPlanClipRepository:
|
||||
|
||||
def delete(self, clip_id: str) -> bool:
|
||||
"""删除片段"""
|
||||
model = (
|
||||
self.session.query(EditPlanClipModel)
|
||||
.filter(EditPlanClipModel.id == clip_id)
|
||||
.first()
|
||||
)
|
||||
model = self.session.query(EditPlanClipModel).filter(EditPlanClipModel.id == clip_id).first()
|
||||
if model is None:
|
||||
return False
|
||||
self.session.delete(model)
|
||||
@@ -106,11 +94,7 @@ class SQLAlchemyEditPlanClipRepository:
|
||||
|
||||
def delete_by_plan(self, plan_id: str) -> int:
|
||||
"""删除计划下所有片段,返回删除数量"""
|
||||
count = (
|
||||
self.session.query(EditPlanClipModel)
|
||||
.filter(EditPlanClipModel.plan_id == plan_id)
|
||||
.delete()
|
||||
)
|
||||
count = self.session.query(EditPlanClipModel).filter(EditPlanClipModel.plan_id == plan_id).delete()
|
||||
self.session.commit()
|
||||
return count
|
||||
|
||||
|
||||
@@ -51,11 +51,7 @@ class SQLAlchemyEditPlanRepository:
|
||||
|
||||
def get(self, plan_id: str) -> Optional[EditPlan]:
|
||||
"""根据 ID 获取计划"""
|
||||
model = (
|
||||
self.session.query(EditPlanModel)
|
||||
.filter(EditPlanModel.id == plan_id)
|
||||
.first()
|
||||
)
|
||||
model = self.session.query(EditPlanModel).filter(EditPlanModel.id == plan_id).first()
|
||||
if model is None:
|
||||
return None
|
||||
return self._model_to_entity(model)
|
||||
@@ -77,11 +73,7 @@ class SQLAlchemyEditPlanRepository:
|
||||
|
||||
def update(self, plan: EditPlan) -> EditPlan:
|
||||
"""更新计划"""
|
||||
model = (
|
||||
self.session.query(EditPlanModel)
|
||||
.filter(EditPlanModel.id == plan.id)
|
||||
.first()
|
||||
)
|
||||
model = self.session.query(EditPlanModel).filter(EditPlanModel.id == plan.id).first()
|
||||
if model is None:
|
||||
raise ValueError(f"EditPlan {plan.id} not found")
|
||||
model.template_id = plan.template_id
|
||||
@@ -96,11 +88,7 @@ class SQLAlchemyEditPlanRepository:
|
||||
|
||||
def delete(self, plan_id: str) -> bool:
|
||||
"""删除计划"""
|
||||
model = (
|
||||
self.session.query(EditPlanModel)
|
||||
.filter(EditPlanModel.id == plan_id)
|
||||
.first()
|
||||
)
|
||||
model = self.session.query(EditPlanModel).filter(EditPlanModel.id == plan_id).first()
|
||||
if model is None:
|
||||
return False
|
||||
self.session.delete(model)
|
||||
|
||||
@@ -59,11 +59,7 @@ class SQLAlchemyEditTemplateRepository:
|
||||
|
||||
def get(self, template_id: str) -> Optional[EditTemplate]:
|
||||
"""根据 ID 获取模板"""
|
||||
model = (
|
||||
self.session.query(EditTemplateModel)
|
||||
.filter(EditTemplateModel.id == template_id)
|
||||
.first()
|
||||
)
|
||||
model = self.session.query(EditTemplateModel).filter(EditTemplateModel.id == template_id).first()
|
||||
if model is None:
|
||||
return None
|
||||
return self._model_to_entity(model)
|
||||
@@ -87,11 +83,7 @@ class SQLAlchemyEditTemplateRepository:
|
||||
|
||||
def update(self, template: EditTemplate) -> EditTemplate:
|
||||
"""更新模板"""
|
||||
model = (
|
||||
self.session.query(EditTemplateModel)
|
||||
.filter(EditTemplateModel.id == template.id)
|
||||
.first()
|
||||
)
|
||||
model = self.session.query(EditTemplateModel).filter(EditTemplateModel.id == template.id).first()
|
||||
if model is None:
|
||||
raise ValueError(f"EditTemplate {template.id} not found")
|
||||
model.name = template.name
|
||||
@@ -108,11 +100,7 @@ class SQLAlchemyEditTemplateRepository:
|
||||
|
||||
def delete(self, template_id: str) -> bool:
|
||||
"""删除模板"""
|
||||
model = (
|
||||
self.session.query(EditTemplateModel)
|
||||
.filter(EditTemplateModel.id == template_id)
|
||||
.first()
|
||||
)
|
||||
model = self.session.query(EditTemplateModel).filter(EditTemplateModel.id == template_id).first()
|
||||
if model is None:
|
||||
return False
|
||||
self.session.delete(model)
|
||||
|
||||
@@ -125,9 +125,7 @@ class SQLAlchemyJobRepository:
|
||||
limit: int = 50,
|
||||
offset: int = 0,
|
||||
) -> list[Job]:
|
||||
query = self.session.query(JobModel).filter(
|
||||
JobModel.created_by_user_id == user_id
|
||||
)
|
||||
query = self.session.query(JobModel).filter(JobModel.created_by_user_id == user_id)
|
||||
if job_type is not None:
|
||||
jt = job_type.value if isinstance(job_type, JobType) else job_type
|
||||
query = query.filter(JobModel.job_type == jt)
|
||||
|
||||
@@ -408,6 +408,7 @@ class TemplateCategoryModel(Base):
|
||||
name = Column(String(100), nullable=False)
|
||||
created_at = Column(DateTime, nullable=False, default=lambda: datetime.now(timezone.utc))
|
||||
|
||||
|
||||
class JobModel(Base):
|
||||
"""Phase 8 任务 2.10 — 统一异步任务 ORM 模型。"""
|
||||
|
||||
@@ -461,8 +462,10 @@ class TTSJobModel(Base):
|
||||
created_at = Column(DateTime, nullable=False, default=lambda: datetime.now(timezone.utc))
|
||||
updated_at = Column(DateTime, nullable=False, default=lambda: datetime.now(timezone.utc))
|
||||
|
||||
|
||||
class BillingRecordModel(Base):
|
||||
"""账单记录"""
|
||||
|
||||
__tablename__ = "billing_records"
|
||||
|
||||
id = Column(String(36), primary_key=True)
|
||||
|
||||
@@ -40,11 +40,7 @@ class SQLAlchemyTemplateClipConfigRepository:
|
||||
|
||||
def get(self, config_id: str) -> Optional[TemplateClipConfig]:
|
||||
"""根据 ID 获取配置"""
|
||||
model = (
|
||||
self.session.query(TemplateClipConfigModel)
|
||||
.filter(TemplateClipConfigModel.id == config_id)
|
||||
.first()
|
||||
)
|
||||
model = self.session.query(TemplateClipConfigModel).filter(TemplateClipConfigModel.id == config_id).first()
|
||||
if model is None:
|
||||
return None
|
||||
return self._model_to_entity(model)
|
||||
@@ -70,11 +66,7 @@ class SQLAlchemyTemplateClipConfigRepository:
|
||||
|
||||
def update(self, config: TemplateClipConfig) -> TemplateClipConfig:
|
||||
"""更新配置"""
|
||||
model = (
|
||||
self.session.query(TemplateClipConfigModel)
|
||||
.filter(TemplateClipConfigModel.id == config.id)
|
||||
.first()
|
||||
)
|
||||
model = self.session.query(TemplateClipConfigModel).filter(TemplateClipConfigModel.id == config.id).first()
|
||||
if model is None:
|
||||
raise ValueError(f"TemplateClipConfig {config.id} not found")
|
||||
model.template_id = config.template_id
|
||||
@@ -93,11 +85,7 @@ class SQLAlchemyTemplateClipConfigRepository:
|
||||
|
||||
def delete(self, config_id: str) -> bool:
|
||||
"""删除配置"""
|
||||
model = (
|
||||
self.session.query(TemplateClipConfigModel)
|
||||
.filter(TemplateClipConfigModel.id == config_id)
|
||||
.first()
|
||||
)
|
||||
model = self.session.query(TemplateClipConfigModel).filter(TemplateClipConfigModel.id == config_id).first()
|
||||
if model is None:
|
||||
return False
|
||||
self.session.delete(model)
|
||||
@@ -132,9 +120,9 @@ class SQLAlchemyTemplateClipConfigRepository:
|
||||
max_duration=model.max_duration or 0.0,
|
||||
text_template=model.text_template or "",
|
||||
material_requirements=model.material_requirements or {},
|
||||
transition_effect=TransitionEffect(model.transition_effect)
|
||||
if model.transition_effect
|
||||
else TransitionEffect.CUT,
|
||||
transition_effect=(
|
||||
TransitionEffect(model.transition_effect) if model.transition_effect else TransitionEffect.CUT
|
||||
),
|
||||
config=model.config or {},
|
||||
created_at=model.created_at,
|
||||
updated_at=model.updated_at,
|
||||
|
||||
@@ -58,11 +58,7 @@ class SQLAlchemyTTSJobRepository:
|
||||
return self._model_to_entity(model)
|
||||
|
||||
def update(self, job: TTSJob) -> TTSJob:
|
||||
model = (
|
||||
self.session.query(TTSJobModel)
|
||||
.filter(TTSJobModel.id == job.id)
|
||||
.first()
|
||||
)
|
||||
model = self.session.query(TTSJobModel).filter(TTSJobModel.id == job.id).first()
|
||||
if model is None:
|
||||
raise ValueError(f"TTSJob {job.id} not found")
|
||||
model.input_text = job.input_text
|
||||
@@ -88,11 +84,7 @@ class SQLAlchemyTTSJobRepository:
|
||||
return self._model_to_entity(model)
|
||||
|
||||
def delete(self, job_id: str) -> bool:
|
||||
model = (
|
||||
self.session.query(TTSJobModel)
|
||||
.filter(TTSJobModel.id == job_id)
|
||||
.first()
|
||||
)
|
||||
model = self.session.query(TTSJobModel).filter(TTSJobModel.id == job_id).first()
|
||||
if model is None:
|
||||
return False
|
||||
model.status = "deleted"
|
||||
@@ -118,12 +110,9 @@ class SQLAlchemyTTSJobRepository:
|
||||
return [self._model_to_entity(m) for m in models]
|
||||
|
||||
def count_by_user(self, user_id: str, *, status: Optional[str] = None) -> int:
|
||||
query = (
|
||||
self.session.query(TTSJobModel)
|
||||
.filter(
|
||||
TTSJobModel.user_id == user_id,
|
||||
TTSJobModel.status != "deleted",
|
||||
)
|
||||
query = self.session.query(TTSJobModel).filter(
|
||||
TTSJobModel.user_id == user_id,
|
||||
TTSJobModel.status != "deleted",
|
||||
)
|
||||
if status:
|
||||
query = query.filter(TTSJobModel.status == status)
|
||||
|
||||
@@ -52,11 +52,7 @@ class SQLAlchemyVoiceCloneProfileRepository:
|
||||
return self._model_to_entity(model)
|
||||
|
||||
def update(self, profile: VoiceCloneProfile) -> VoiceCloneProfile:
|
||||
model = (
|
||||
self.session.query(VoiceCloneProfileModel)
|
||||
.filter(VoiceCloneProfileModel.id == profile.id)
|
||||
.first()
|
||||
)
|
||||
model = self.session.query(VoiceCloneProfileModel).filter(VoiceCloneProfileModel.id == profile.id).first()
|
||||
if model is None:
|
||||
raise ValueError(f"VoiceCloneProfile {profile.id} not found")
|
||||
model.name = profile.name
|
||||
@@ -76,11 +72,7 @@ class SQLAlchemyVoiceCloneProfileRepository:
|
||||
return self._model_to_entity(model)
|
||||
|
||||
def delete(self, profile_id: str) -> bool:
|
||||
model = (
|
||||
self.session.query(VoiceCloneProfileModel)
|
||||
.filter(VoiceCloneProfileModel.id == profile_id)
|
||||
.first()
|
||||
)
|
||||
model = self.session.query(VoiceCloneProfileModel).filter(VoiceCloneProfileModel.id == profile_id).first()
|
||||
if model is None:
|
||||
return False
|
||||
model.status = "deleted"
|
||||
@@ -106,12 +98,9 @@ class SQLAlchemyVoiceCloneProfileRepository:
|
||||
return [self._model_to_entity(m) for m in models]
|
||||
|
||||
def count_by_user(self, user_id: str, *, status: Optional[str] = None) -> int:
|
||||
query = (
|
||||
self.session.query(VoiceCloneProfileModel)
|
||||
.filter(
|
||||
VoiceCloneProfileModel.user_id == user_id,
|
||||
VoiceCloneProfileModel.status != "deleted",
|
||||
)
|
||||
query = self.session.query(VoiceCloneProfileModel).filter(
|
||||
VoiceCloneProfileModel.user_id == user_id,
|
||||
VoiceCloneProfileModel.status != "deleted",
|
||||
)
|
||||
if status:
|
||||
query = query.filter(VoiceCloneProfileModel.status == status)
|
||||
|
||||
@@ -111,12 +111,9 @@ class SQLAlchemyVoiceLibraryRepository:
|
||||
return True
|
||||
|
||||
def count_by_user(self, user_id: str, *, status: Optional[str] = None) -> int:
|
||||
query = (
|
||||
self.session.query(VoiceLibraryModel)
|
||||
.filter(
|
||||
VoiceLibraryModel.user_id == user_id,
|
||||
VoiceLibraryModel.status != "deleted",
|
||||
)
|
||||
query = self.session.query(VoiceLibraryModel).filter(
|
||||
VoiceLibraryModel.user_id == user_id,
|
||||
VoiceLibraryModel.status != "deleted",
|
||||
)
|
||||
if status:
|
||||
query = query.filter(VoiceLibraryModel.status == status)
|
||||
|
||||
Reference in New Issue
Block a user