fix: 完成商务迁移复核与接口优化并清理历史资料
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user