Private
Public Access
39 lines
704 B
Go
39 lines
704 B
Go
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,
|
|
})
|
|
}
|