feat: statistics: finish dev

This commit is contained in:
fallen-angle
2022-01-23 18:28:01 +08:00
parent 582807ae10
commit d844711191
29 changed files with 1670 additions and 51 deletions

59
handler/statistics.go Normal file
View 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)
}