素材云批量删除API
This commit is contained in:
@@ -9,6 +9,8 @@ from app.models.chat_generation_task import ChatGenerationTask
|
||||
from app.models.user import User
|
||||
from app.schemas.generation_ai import (
|
||||
GenerationAIEngineOptionsOut,
|
||||
GenerationAIHistoryBatchDeleteOut,
|
||||
GenerationAIHistoryBatchDeleteRequest,
|
||||
GenerationAIHistoryDayItemsOut,
|
||||
GenerationAIHistoryGroupedOut,
|
||||
GenerationAIRetryOut,
|
||||
@@ -31,6 +33,7 @@ from app.services.generation_billing_service import (
|
||||
charge_generation_media_by_params,
|
||||
get_next_credit_attempt_no,
|
||||
)
|
||||
from app.services.generation_history_delete_service import batch_delete_generation_history_items
|
||||
from app.services.generation_log_service import log_task_event
|
||||
from app.services.generation_refund_service import mark_chat_generation_task_failed_and_refund_once
|
||||
from app.services.resource_capacity_service import assert_user_resource_capacity_available
|
||||
@@ -332,6 +335,53 @@ async def list_history_grouped_days(
|
||||
)
|
||||
|
||||
|
||||
@router.delete(
|
||||
"/history/batch",
|
||||
response_model=GenerationAIHistoryBatchDeleteOut,
|
||||
summary="批量删除素材云历史记录",
|
||||
description=(
|
||||
"按 history_source 批量软删除素材云历史记录,单次最多30条。"
|
||||
"generation_record 和 chat_task 入参 ids 为对应记录ID,且只有生成完成后才能删除;"
|
||||
"hot_opening_replicate 入参 ids 为 module_project_id;"
|
||||
"shot_replicate 入参 ids 为 shot_segment_id。"
|
||||
"爆款开头复刻和拆镜复刻会联动软删 ModuleGenerationProject、ModuleGenerationStep、关联 ChatGenerationTask 和 generated_resources;"
|
||||
"拆镜复刻还会联动软删 ShotReplicateSegment。"
|
||||
"如果存在生成中、轮询中、下载中等任务,接口直接拦截,不做失败标记、不退款。"
|
||||
),
|
||||
responses={
|
||||
200: {
|
||||
"description": "批量软删除成功",
|
||||
},
|
||||
400: {
|
||||
"description": "参数错误,例如 history_source 不支持、ids 为空、超过30条或重复",
|
||||
},
|
||||
401: {
|
||||
"description": "未登录或 Token 无效",
|
||||
},
|
||||
404: {
|
||||
"description": "部分 ID 不存在、不属于当前用户或已删除",
|
||||
},
|
||||
409: {
|
||||
"description": "存在未完成或生成中的记录,当前不能删除",
|
||||
},
|
||||
},
|
||||
)
|
||||
async def batch_delete_history_items(
|
||||
req: GenerationAIHistoryBatchDeleteRequest = Body(
|
||||
...,
|
||||
description="素材云历史批量删除参数。不同 history_source 对应不同 ID 语义,详见字段说明",
|
||||
),
|
||||
current_user: User = Depends(get_current_user),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
return await batch_delete_generation_history_items(
|
||||
db=db,
|
||||
current_user=current_user,
|
||||
history_source=req.history_source,
|
||||
ids=req.ids,
|
||||
)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/history/{generated_date}",
|
||||
response_model=GenerationAIHistoryDayItemsOut,
|
||||
|
||||
Reference in New Issue
Block a user