package data_manage

import "github.com/beego/beego/v2/client/orm"

func GetVisitorsCovidLastDate() (last_date string, err error) {
	o := orm.NewOrmUsingDB("data")
	sql := ` SELECT max(a.day) AS last_date FROM base_from_changes_visitors_covid AS a `
	err = o.Raw(sql).QueryRow(&last_date)
	return
}

type BaseFromChangesVisitorsCovid struct {
	Id                  int
	Entity              string `description:"国家"`
	Code                string `description:"国家编码"`
	EdbCode             string `description:"指标ID"`
	Day                 string `description:"统计的日期"`
	RetailAndRecreation string `description:"零售和娱乐场所"`
	GroceryAndPharmacy  string `description:"杂货店和药房"`
	Residential         string `description:"居家"`
	TransitStations     string `description:"公共交通车站"`
	Parks               string `description:"公园"`
	Workplaces          string `description:"工作场所"`
	Total               string `description:"总计"`
	CreateTime          string `description:"创建时间"`
	ModifyTime          string `description:"修改时间"`
}

func GetVisitorsCovidList(day string) (list []*BaseFromChangesVisitorsCovid, err error) {
	o := orm.NewOrmUsingDB("data")
	sql := ` SELECT * FROM base_from_changes_visitors_covid WHERE day=? `

	sql += ` ORDER BY entity ASC `
	_, err = o.Raw(sql, day).QueryRows(&list)
	return
}
