Private
Public Access
26 lines
510 B
Go
26 lines
510 B
Go
package repuestos
|
|
|
|
import (
|
|
"net/http"
|
|
"strconv"
|
|
|
|
r "repuestera_back/repositorios"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func ObtenerRepuesto(c *gin.Context){
|
|
id, err := strconv.ParseUint(c.Param("id"), 10, 64)
|
|
if err != nil {
|
|
c.JSON(http.StatusBadRequest, gin.H{"error": "ID invalido"})
|
|
return
|
|
}
|
|
|
|
repuesto, err := r.ObtenerRepositorios().Repuesto.ObtenerPorID(uint(id))
|
|
if err != nil {
|
|
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
|
return
|
|
}
|
|
c.JSON(http.StatusOK, repuesto)
|
|
}
|