fix: 完成商务迁移复核与接口优化并清理历史资料

This commit is contained in:
Yvan
2026-11-04 14:45:02 +08:00
parent 5a96be6a79
commit 297e80827d
176 changed files with 6803 additions and 6002 deletions
+4 -1
View File
@@ -125,6 +125,9 @@ func (r *mediaRepo) UpdateMediaName(ctx context.Context, id uint, name string) e
// not-found error instead of silently succeeding with RowsAffected=0.
var po mediaPO
if err := r.data.DB().WithContext(ctx).Where("id = ?", id).First(&po).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return system.ErrMediaNotFound
}
return err
}
return r.data.DB().WithContext(ctx).Model(&po).Update("name", name).Error
@@ -147,7 +150,7 @@ func (r *mediaRepo) CreateMediaBatch(ctx context.Context, items []*system.MediaF
func (r *mediaRepo) SaveCategory(ctx context.Context, v *system.AttachmentCategory) error {
db := r.data.DB().WithContext(ctx)
var count int64
query := db.Model(&categoryPO{}).Where("name = ? AND pid = ?", v.Name, v.ParentID)
query := db.Model(&categoryPO{}).Where("name = ? AND pid = ? AND id <> ?", v.Name, v.ParentID, v.ID)
if err := query.Count(&count).Error; err != nil {
return err
}