package data_manage

import (
	"eta/eta_api/controllers"
	"eta/eta_api/models"
	"eta/eta_api/models/data_manage"
)

// 谷歌出行数据
type BaseFromChangesVisitorsCovidController struct {
	controllers.BaseAuthController
}

// @Title 获取最新日期
// @Description 获取最新日期接口
// @Success 200
// @router /visitors_covid/last_date [get]
func (this *BaseFromChangesVisitorsCovidController) VisitorsCovidLastDate() {
	br := new(models.BaseResponse).Init()
	defer func() {
		this.Data["json"] = br
		this.ServeJSON()
	}()
	lastDate, err := data_manage.GetVisitorsCovidLastDate()
	if err != nil {
		br.Msg = "获取最新日期失败"
		br.ErrMsg = "获取最新日期失败,Err:" + err.Error()
		return
	}
	br.Ret = 200
	br.Success = true
	br.Msg = "获取成功"
	br.Data = lastDate
}

// @Title 获取最新日期
// @Description 获取最新日期接口
// @Param   Day   query   string  false       "日期"
// @Success 200
// @router /visitors_covid/list [get]
func (this *BaseFromChangesVisitorsCovidController) VisitorsCovidList() {
	br := new(models.BaseResponse).Init()
	defer func() {
		this.Data["json"] = br
		this.ServeJSON()
	}()
	day := this.GetString("Day")
	list, err := data_manage.GetVisitorsCovidList(day)
	if err != nil {
		br.Msg = "获取数据失败"
		br.ErrMsg = "获取数据失败,Err:" + err.Error()
		return
	}
	br.Ret = 200
	br.Success = true
	br.Msg = "获取成功"
	br.Data = list
}
