作者 陈志颖

fix:修改删除栏目设置

@@ -67,22 +67,26 @@ func (repository *ColumnSettingRepository) Save(columnSetting *domain.ColumnSett @@ -67,22 +67,26 @@ func (repository *ColumnSettingRepository) Save(columnSetting *domain.ColumnSett
67 func (repository *ColumnSettingRepository) Remove(columnSetting *domain.ColumnSetting, columnSettings []*domain.ColumnSetting) (*domain.ColumnSetting, []*domain.ColumnSetting, error) { 67 func (repository *ColumnSettingRepository) Remove(columnSetting *domain.ColumnSetting, columnSettings []*domain.ColumnSetting) (*domain.ColumnSetting, []*domain.ColumnSetting, error) {
68 tx := repository.transactionContext.PgTx 68 tx := repository.transactionContext.PgTx
69 69
70 - // 单个删除  
71 - columnSettingModel := new(models.ColumnSetting)  
72 - columnSettingModel.Id = columnSetting.Identify().(int64)  
73 - if _, err := tx.Model(columnSettingModel).WherePK().Delete(); err != nil {  
74 - return columnSetting, nil, err 70 + if columnSetting != nil {
  71 + // 单个删除
  72 + columnSettingModel := new(models.ColumnSetting)
  73 + columnSettingModel.Id = columnSetting.Identify().(int64)
  74 + if _, err := tx.Model(columnSettingModel).WherePK().Delete(); err != nil {
  75 + return columnSetting, nil, err
  76 + }
75 } 77 }
76 78
77 // 批量删除 79 // 批量删除
78 - var columnSettingModels []*models.ColumnSetting  
79 - for _, setting := range columnSettings {  
80 - columnSettingModels = append(columnSettingModels, &models.ColumnSetting{  
81 - Id: setting.Identify().(int64),  
82 - })  
83 - }  
84 - if _, err := tx.Model(columnSettingModels).WherePK().Delete(); err != nil {  
85 - return nil, columnSettings, err 80 + if len(columnSettings) > 0 {
  81 + var columnSettingModels []*models.ColumnSetting
  82 + for _, setting := range columnSettings {
  83 + columnSettingModels = append(columnSettingModels, &models.ColumnSetting{
  84 + Id: setting.Identify().(int64),
  85 + })
  86 + }
  87 + if _, err := tx.Model(columnSettingModels).WherePK().Delete(); err != nil {
  88 + return nil, columnSettings, err
  89 + }
86 } 90 }
87 return columnSetting, columnSettings, nil 91 return columnSetting, columnSettings, nil
88 } 92 }