fix(projects): 短剧项目 - 修复同名创建重试 (#691)

Co-authored-by: tanzui <305375675@.com>
This commit is contained in:
tanzuiandtanzui authored and GitHub committed 2026-10-06 09:24:11 +08:00
1 parent 6ce9960216
commit ea51df2b58
14 files changed
+350 -18

No files matched your search

+7
View File
@@ -4,6 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"net/http"
"strings"
"time"
@@ -254,6 +255,12 @@ func (s *Service) CreateProject(userID string, req CreateProjectRequest) (model.
}
project := model.Project{ID: newID(), UserID: userID, Name: name, Type: projectType, AspectRatio: aspectRatio, SourceType: sourceType, Description: strings.TrimSpace(req.Description), StylePresetID: stylePresetID, StyleProfileJSON: styleProfileJSON, DefaultImageModel: defaultImageModel, DefaultVideoModel: defaultVideoModel, Status: model.ProjectStatusActive, Revision: 1, CreatedAt: now, UpdatedAt: now}
if err := s.repo.CreateProject(&project); err != nil {
if errors.Is(err, repository.ErrProjectNameConflict) {
// 项目名称冲突需要明确返回 409,页面才能按已有逻辑换一个名称重试。
conflict := NewAppError(http.StatusConflict, "项目名称已存在")
conflict.Reason = ReasonProjectNameConflict
return model.Project{}, conflict
}
return model.Project{}, err
}
if _, err := s.createProjectWorkflow(project.ID, "", "project"); err != nil {