Add statistic api

This commit is contained in:
2025-10-02 21:34:35 +08:00
parent 17026a74c5
commit aac1992dba
5 changed files with 120 additions and 0 deletions

View File

@@ -61,10 +61,22 @@ func setServerConfig(c fiber.Ctx) error {
})
}
func getStatistics(c fiber.Ctx) error {
s, err := service.GetStatistic()
if err != nil {
return model.NewInternalServerError("Failed to get statistics")
}
return c.JSON(model.Response[*service.Statistic]{
Success: true,
Data: s,
})
}
func AddConfigRoutes(r fiber.Router) {
configGroup := r.Group("/config")
{
configGroup.Get("/", getServerConfig)
configGroup.Post("/", setServerConfig)
configGroup.Get("/statistics", getStatistics)
}
}