Private
Public Access
46 lines
934 B
Go
46 lines
934 B
Go
package logs
|
|
|
|
import (
|
|
"net/http"
|
|
dto_directors "repuestera_back/dto/Builders/Directors"
|
|
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(c).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
|
|
}
|
|
|
|
logsdto, err := dto_directors.NewLogTablaDirector().Listar(logs)
|
|
if err != nil {
|
|
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"logs": logsdto,
|
|
"maxlenght": cantpags,
|
|
})
|
|
}
|