作者 陈志颖

fix:修改删除栏目设置

... ... @@ -67,22 +67,26 @@ func (repository *ColumnSettingRepository) Save(columnSetting *domain.ColumnSett
func (repository *ColumnSettingRepository) Remove(columnSetting *domain.ColumnSetting, columnSettings []*domain.ColumnSetting) (*domain.ColumnSetting, []*domain.ColumnSetting, error) {
tx := repository.transactionContext.PgTx
// 单个删除
columnSettingModel := new(models.ColumnSetting)
columnSettingModel.Id = columnSetting.Identify().(int64)
if _, err := tx.Model(columnSettingModel).WherePK().Delete(); err != nil {
return columnSetting, nil, err
if columnSetting != nil {
// 单个删除
columnSettingModel := new(models.ColumnSetting)
columnSettingModel.Id = columnSetting.Identify().(int64)
if _, err := tx.Model(columnSettingModel).WherePK().Delete(); err != nil {
return columnSetting, nil, err
}
}
// 批量删除
var columnSettingModels []*models.ColumnSetting
for _, setting := range columnSettings {
columnSettingModels = append(columnSettingModels, &models.ColumnSetting{
Id: setting.Identify().(int64),
})
}
if _, err := tx.Model(columnSettingModels).WherePK().Delete(); err != nil {
return nil, columnSettings, err
if len(columnSettings) > 0 {
var columnSettingModels []*models.ColumnSetting
for _, setting := range columnSettings {
columnSettingModels = append(columnSettingModels, &models.ColumnSetting{
Id: setting.Identify().(int64),
})
}
if _, err := tx.Model(columnSettingModels).WherePK().Delete(); err != nil {
return nil, columnSettings, err
}
}
return columnSetting, columnSettings, nil
}
... ...