From 873cc3e1a45f3ece9f26b48f655dde01cd2b02f9 Mon Sep 17 00:00:00 2001 From: tian <11429339@qq.com> Date: Sun, 26 Jul 2026 12:46:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20id=E5=92=8Coriginal=5Fname=E9=9A=90?= =?UTF-8?q?=E8=97=8F=E5=AD=97=E6=AE=B5=E5=88=86=E5=BC=80=E5=88=A4=E6=96=AD?= =?UTF-8?q?=EF=BC=8C=E9=81=BF=E5=85=8D=E7=A9=BAid=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/storage/assets_repo.go | 9 +++++++-- internal/web/ui/templates/assets.html | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/internal/storage/assets_repo.go b/internal/storage/assets_repo.go index 5997221..6f75603 100644 --- a/internal/storage/assets_repo.go +++ b/internal/storage/assets_repo.go @@ -120,8 +120,13 @@ func (r *AssetsRepo) SaveVideoSource(id int, name string, sourceType string, are } now := time.Now().Format(time.RFC3339) if id > 0 { - // Update existing by ID - _, err := r.db.Exec(` + // Check name uniqueness before update + var existingID int + err := r.db.QueryRow(`SELECT id FROM video_sources WHERE name = ? AND id != ?`, name, id).Scan(&existingID) + if err == nil { + return fmt.Errorf("视频源名称 %q 已存在", name) + } + _, err = r.db.Exec(` UPDATE video_sources SET name=?, source_type=?, area=?, description=?, body_json=?, updated_at=? WHERE id=?`, name, sourceType, area, description, bodyJSON, now, id) return err diff --git a/internal/web/ui/templates/assets.html b/internal/web/ui/templates/assets.html index 9389a2c..5f81df5 100644 --- a/internal/web/ui/templates/assets.html +++ b/internal/web/ui/templates/assets.html @@ -232,7 +232,8 @@ toggleIntegrationFields('{{.AssetIntegration.Type}}'); {{if .AssetVideoSource}}
- {{if .AssetVideoSource}}{{end}} + {{if .AssetVideoSource.ID}}{{end}} + {{if .AssetVideoSource.Name}}{{end}}