|
@@ -0,0 +1,51 @@
|
|
|
+package models
|
|
|
+
|
|
|
+import (
|
|
|
+ "github.com/rdlucklib/rdluck_tools/orm"
|
|
|
+ "time"
|
|
|
+)
|
|
|
+
|
|
|
+// 谷歌出行指数
|
|
|
+type BaseFromChangesVisitorsCovid struct {
|
|
|
+ Id uint64 `orm:"column(id);pk"` //序号
|
|
|
+ Entity string `orm:"column(entity)"` //国家
|
|
|
+ Code string `orm:"column(code)"` //国家编码
|
|
|
+ EdbCode string `orm:"column(edb_code)"` //指标ID
|
|
|
+ Day time.Time `orm:"column(day)"` //统计的日期
|
|
|
+ RetailAndRecreation string `orm:"column(retail_and_recreation)"`
|
|
|
+ GroceryAndPharmacy string `orm:"column(grocery_and_pharmacy)"`
|
|
|
+ Residential string `orm:"column(residential)"`
|
|
|
+ TransitStations string `orm:"column(transit_stations)"`
|
|
|
+ Parks string `orm:"column(parks)"`
|
|
|
+ Workplaces string `orm:"column(workplaces)"`
|
|
|
+ Total string `orm:"column(total)"`
|
|
|
+ CreateTime time.Time `orm:"auto_now_add;column(create_time)"` //创建时间
|
|
|
+ ModifyTime time.Time `orm:"auto_now_add;column(modify_time)"` //修改时间
|
|
|
+}
|
|
|
+
|
|
|
+// AddBaseFromChangesVisitorsCovidMulti 批量添加谷歌出行记录
|
|
|
+func AddBaseFromChangesVisitorsCovidMulti(list []*BaseFromChangesVisitorsCovid) (err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ o.Using("data")
|
|
|
+ _, err = o.InsertMulti(1000, list)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// GetLatestBaseFromChangesVisitorsCovid 查询最新的日期
|
|
|
+func GetLatestBaseFromChangesVisitorsCovid() (item *BaseFromChangesVisitorsCovid, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ o.Using("data")
|
|
|
+ sql := `SELECT * FROM base_from_changes_visitors_covid order by day desc, id desc limit 1`
|
|
|
+ err = o.Raw(sql).QueryRow(&item)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+// GetBaseFromChangesVisitorsCovidByEntityDay 查询国家和统计日期查询记录是否存在
|
|
|
+func GetBaseFromChangesVisitorsCovidByEntityDay(entity, day string) (item *BaseFromChangesVisitorsCovid, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ o.Using("data")
|
|
|
+ sql := `SELECT * FROM base_from_changes_visitors_covid where entity=? and day=? limit 1`
|
|
|
+ err = o.Raw(sql, entity, day).QueryRow(&item)
|
|
|
+ return
|
|
|
+}
|