Private
Public Access
feat: logs para cuando le volves a dar el alta a un repuesto
This commit is contained in:
1 parent
c906dd4511
commit
6d123ea01d
13 files changed
+215
-7
No files matched your search
@@ -0,0 +1 @@
|
||||
package logs
|
||||
@@ -0,0 +1,30 @@
|
||||
package repuestos
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
r "repuestera_back/repositorios"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func AltaRepuestos(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
|
||||
}
|
||||
|
||||
if id < 1 {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "ID no puede ser menor que 1"})
|
||||
return
|
||||
}
|
||||
|
||||
uid := c.MustGet("userID").(uint)
|
||||
if _, err := r.ObtenerRepositorios().Repuesto.AltaRepuesto(uint(id), uint(uid)); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err})
|
||||
return
|
||||
}
|
||||
|
||||
c.Status(http.StatusOK)
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
r "repuestera_back/repositorios"
|
||||
)
|
||||
|
||||
func ObtenerRepuestos(c *gin.Context){
|
||||
func ObtenerRepuestos(c *gin.Context) {
|
||||
repuestos, err := r.ObtenerRepositorios().Repuesto.ObtenerTodos()
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
|
||||
Reference in new issue
Block a user