Files
usernode/internal/api/stats.go
T

31 lines
716 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 仪表盘统计接口(admin):GET /admin/statsPLAN §8 仪表盘数据)。
package api
import (
"net/http"
"github.com/gin-gonic/gin"
"ws_usernode/internal/service"
)
// StatsHandler 仪表盘统计。
type StatsHandler struct {
userSvc *service.UserService
}
// NewStatsHandler 创建统计 handler。
func NewStatsHandler(userSvc *service.UserService) *StatsHandler {
return &StatsHandler{userSvc: userSvc}
}
// Stats GET /admin/stats —— 用户状态分布、近期待过期、待审批数。
func (h *StatsHandler) Stats(c *gin.Context) {
st, err := h.userSvc.Stats(c.Request.Context())
if err != nil {
fail(c, http.StatusInternalServerError, err.Error())
return
}
ok(c, st)
}