21 lines
446 B
Go
21 lines
446 B
Go
package handler
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
service "kra/internal/service/analytics"
|
|
"strconv"
|
|
)
|
|
|
|
type Analytics struct{ s *service.Service }
|
|
|
|
func NewAnalytics(s *service.Service) *Analytics { return &Analytics{s: s} }
|
|
func (h *Analytics) Dashboard(c *gin.Context) {
|
|
days, _ := strconv.Atoi(c.DefaultQuery("days", "1"))
|
|
v, e := h.s.Get(c.Request.Context(), days)
|
|
if e != nil {
|
|
businessFail(c, e)
|
|
return
|
|
}
|
|
OKWithData(c, v)
|
|
}
|