33 lines
742 B
Go
33 lines
742 B
Go
package controllers
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"git.beifan.cn/trace-system/backend-go/services"
|
|
)
|
|
|
|
// DashboardController 控制台统计控制器
|
|
type DashboardController struct {
|
|
dashboardService services.DashboardService
|
|
}
|
|
|
|
// NewDashboardController 创建控制台统计控制器实例
|
|
func NewDashboardController() *DashboardController {
|
|
return &DashboardController{
|
|
dashboardService: services.DashboardService{},
|
|
}
|
|
}
|
|
|
|
// Stats 获取控制台统计
|
|
func (c *DashboardController) Stats(ctx *gin.Context) {
|
|
stats, err := c.dashboardService.GetStats()
|
|
if err != nil {
|
|
ErrorResponse(ctx, http.StatusInternalServerError, err.Error())
|
|
return
|
|
}
|
|
|
|
SuccessResponse(ctx, "获取统计数据成功", stats)
|
|
}
|