Private
Public Access
algunos refactors y arregle el tema de que no se eliminaban los
subgrupos
This commit is contained in:
1 parent
ab88be0ba5
commit
df2412f29a
25 files changed
+415
-261
No files matched your search
@@ -148,16 +148,24 @@ func (r *repositorioGrupo) AgregarSubGrupo(padreID, hijoID uint) error {
|
||||
}
|
||||
|
||||
func (r *repositorioGrupo) QuitarSubGrupo(padreID, hijoID uint) error {
|
||||
// var padre models_seguridad.Grupo
|
||||
// if err := r.db.Preload("Grupos").First(&padre, padreID).Error; err != nil {
|
||||
// return err
|
||||
// }
|
||||
|
||||
var padre models_seguridad.Grupo
|
||||
if err := r.db.Preload("Grupos").First(&padre, padreID).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
var nuevos []models_seguridad.Grupo
|
||||
for _, g := range padre.Grupos {
|
||||
if g.ID != hijoID {
|
||||
nuevos = append(nuevos, g)
|
||||
}
|
||||
}
|
||||
padre.Grupos = nuevos
|
||||
return r.db.Save(&padre).Error
|
||||
|
||||
return r.db.Model(&padre).Association("Grupos").Delete(&models_seguridad.Grupo{ID: hijoID})
|
||||
|
||||
// var nuevos []models_seguridad.Grupo
|
||||
// for _, g := range padre.Grupos {
|
||||
// if g.ID != hijoID {
|
||||
// nuevos = append(nuevos, g)
|
||||
// }
|
||||
// }
|
||||
// padre.Grupos = nuevos
|
||||
// return r.db.Save(&padre).Error
|
||||
}
|
||||
Reference in new issue
Block a user