github.com/chanxuehong/wechat@v0.0.0-20230222024006-36f0325263cd/mp/datacube/reqeust.go (about) 1 package datacube 2 3 import ( 4 "time" 5 ) 6 7 // 获取统计数据通用的请求结构. 8 type Request struct { 9 // 获取数据的起始日期, YYYY-MM-DD 格式; 10 // begin_date 和 end_date 的差值需小于"最大时间跨度"(比如最大时间跨度为1时, 11 // begin_date 和 end_date 的差值只能为0, 才能小于1), 否则会报错. 12 BeginDate string `json:"begin_date,omitempty"` 13 14 // 获取数据的结束日期, YYYY-MM-DD 格式; 15 // end_date 允许设置的最大值为昨日. 16 EndDate string `json:"end_date,omitempty"` 17 } 18 19 // NewRequest 创建一个 Request. 20 // 21 // 请注意 BeginDate, EndDate 的 Location. 22 func NewRequest(BeginDate, EndDate time.Time) *Request { 23 return &Request{ 24 BeginDate: BeginDate.Format("2006-01-02"), 25 EndDate: EndDate.Format("2006-01-02"), 26 } 27 }