feat: statistics: finish dev
This commit is contained in:
59
handler/statistics.go
Normal file
59
handler/statistics.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
service "nCovTrack-Backend/service/statistics"
|
||||
"nCovTrack-Backend/utils"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// Get provience statistics
|
||||
// @Tags Statistics
|
||||
// @Prodeuce json
|
||||
// @Summary provience statistics
|
||||
// @Success 200 {object} models.GinResponse{data=[]models.AreaInfo}
|
||||
// @Router /statistics/provience/{sort} [get]
|
||||
// @Param sort path string false "data sorted by" Enums(today, total, now, default)
|
||||
func ProvienceDataHandler(c *gin.Context) {
|
||||
sort := c.Param("sort")
|
||||
data := service.GetAllProvienceData(sort)
|
||||
utils.Succ(c, data)
|
||||
}
|
||||
|
||||
// Get city statistics
|
||||
// @Tags Statistics
|
||||
// @Prodeuce json
|
||||
// @Summary city statistics
|
||||
// @Success 200 {object} models.GinResponse{data=[]models.AreaInfo}
|
||||
// @Router /statistics/city/{sort} [get]
|
||||
// @Param sort path string false "data sorted by" Enums(today, total, now, default)
|
||||
func CityDataHandler(c *gin.Context) {
|
||||
sort := c.Param("sort")
|
||||
data := service.GetAllCityData(sort)
|
||||
utils.Succ(c, data)
|
||||
}
|
||||
|
||||
// Get country statistics(only china currently)
|
||||
// @Tags Statistics
|
||||
// @Prodeuce json
|
||||
// @Summary country statistics
|
||||
// @Success 200 {object} models.GinResponse{data=[]models.AreaInfo}
|
||||
// @Router /statistics/country/child [get]
|
||||
// @Router /statistics/country [get]
|
||||
func CountryDataHandler(c *gin.Context) {
|
||||
child := strings.Contains(c.Request.URL.RequestURI(), "child")
|
||||
data := service.GetCountryData(child)
|
||||
utils.Succ(c, data)
|
||||
}
|
||||
|
||||
// Get china data
|
||||
// @Tags Statistics
|
||||
// @Prodeuce json
|
||||
// @Summary china data
|
||||
// @Success 200 {object} models.GinResponse{data=models.ChinaData}
|
||||
// @Router /statistics/china [get]
|
||||
func ChinaDataHandler(c *gin.Context) {
|
||||
data := service.GetChinaNCovStatistic()
|
||||
utils.Succ(c, data)
|
||||
}
|
||||
Reference in New Issue
Block a user