Private
Public Access
funcionalidad de logs andando
This commit is contained in:
1 parent
06ed4a518b
commit
aac88856ac
21 files changed
+627
-31
No files matched your search
@@ -0,0 +1,27 @@
|
||||
package logs
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
r "repuestera_back/repositorios"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func ObtenerLog(c *gin.Context) {
|
||||
pag, err := strconv.ParseUint(c.Param("p"), 10, 64)
|
||||
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
logs, err := r.ObtenerRepositorios().Logs.ObtenerPorPaginas(uint(pag))
|
||||
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, logs)
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package logs
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
r "repuestera_back/repositorios"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func ObtenerLogs(c *gin.Context) {
|
||||
pag, err := strconv.ParseUint(c.Param("p"), 10, 64)
|
||||
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
repo := r.ObtenerRepositorios().Logs
|
||||
|
||||
logs, err := repo.ObtenerPorPaginas(uint(pag))
|
||||
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
cantpags, err := repo.CantPaginas()
|
||||
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"logs": logs,
|
||||
"maxlenght": cantpags,
|
||||
})
|
||||
}
|
||||
@@ -46,7 +46,8 @@ func ActualizarRepuesto(c *gin.Context){
|
||||
return
|
||||
}
|
||||
|
||||
if err := r.ObtenerRepositorios().Repuesto.Actualizar(entity, &repuesto); err != nil {
|
||||
uid, _ := c.Get("userID")
|
||||
if err := r.ObtenerRepositorios().Repuesto.Actualizar(entity, &repuesto, uid.(uint)); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -32,7 +32,8 @@ func CrearRepuesto(c *gin.Context){
|
||||
ConMarca(marca.ID).
|
||||
Build()
|
||||
|
||||
if err := r.ObtenerRepositorios().Repuesto.Crear(&repuesto); err != nil {
|
||||
uid, _ := c.Get("userID")
|
||||
if err := r.ObtenerRepositorios().Repuesto.Crear(&repuesto, uid.(uint)); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -20,7 +20,9 @@ func EliminarRepuesto(c *gin.Context){
|
||||
return
|
||||
}
|
||||
|
||||
if err := r.ObtenerRepositorios().Repuesto.Eliminar(uint(id)); err != nil {
|
||||
|
||||
uid, _ := c.Get("userID")
|
||||
if err := r.ObtenerRepositorios().Repuesto.Eliminar(uint(id), uid.(uint)); err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err})
|
||||
return
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user