Private
Public Access
lo que es back esta correjido
This commit is contained in:
1 parent
6ed8805e21
commit
9205fea8d8
23 files changed
+486
No files matched your search
@@ -0,0 +1,24 @@
|
||||
package stock
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
r "repuestera_back/repositorios"
|
||||
)
|
||||
|
||||
func ObtenerStockPorID(c *gin.Context) {
|
||||
uid, err := strconv.ParseUint(c.Param("id"), 10, 64)
|
||||
if err != nil || uid == 0 {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "id inválido"})
|
||||
return
|
||||
}
|
||||
stock, err := r.ObtenerRepositorios(c).Stock.ObtenerPorID(uint(uid))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusNotFound, gin.H{"error": "stock no encontrado"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, stock)
|
||||
}
|
||||
Reference in new issue
Block a user