package almacen import ( "net/http" "strconv" r "repuestera_back/repositorios" "github.com/gin-gonic/gin" "gorm.io/gorm" ) func AltaAlmacen(c *gin.Context) { id, err := strconv.ParseUint(c.Param("id"), 10, 64) if err != nil || id < 1 { c.JSON(http.StatusBadRequest, gin.H{"error": "ID inválido"}) return } repo := r.ObtenerRepositorios(c).Almacen almacen, err := repo.ObtenerPorID(uint(id)) if err != nil { c.JSON(http.StatusNotFound, gin.H{"error": "Almacén no encontrado"}) return } if !almacen.DeletedAt.Valid { c.JSON(http.StatusBadRequest, gin.H{"error": "El almacén no está eliminado"}) return } almacen.DeletedAt = gorm.DeletedAt{} if err := repo.Alta(almacen, *almacen, c.GetUint("userID")); err != nil { c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return } c.Status(http.StatusOK) }