| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- package fwh_test
- import (
- "fwh-toolbox-server/domain"
- "net/url"
- "strconv"
- )
- type ShutdownListData struct {
- Current int `json:"current"` // 当前页
- Pages int `json:"pages"` // 总页数
- Size int `json:"size"` // 每页最大条数
- Total int64 `json:"total"` // 总条数
- Records []domain.ShutdownRecord `json:"records"` // 记录列表
- }
- // 查询Shutdown站点列表 one page
- func querySiteShutdownListOnePage(date string, country int, page int) (*domain.FwhResponseB[ShutdownListData], error) {
- // 构造 query 参数
- params := url.Values{}
- if country <= 0 {
- params.Add("countryId", "") // 0-ALL
- } else {
- params.Add("countryId", strconv.Itoa(country)) // 2-美国 3-澳大利亚 5-加拿大 6-新西兰 51-巴巴多斯
- }
- params.Add("date", date)
- params.Add("timeType", strconv.Itoa(1)) // 0-通讯时间;1-设备时间
- params.Add("pageSize", strconv.FormatUint(REQ_PAGE_SIZE, 10))
- params.Add("pageNum", strconv.Itoa(page))
- params.Add("land", "ZH_CN")
- response, err := FwhHttpGetUnmarshalB[ShutdownListData](getFullEnergyUrl("/api-inspect/fault/listShutdownGateway"), params)
- if err != nil {
- return nil, err
- }
- return response, nil
- }
- // 查询Shutdown站点列表
- func QuerySiteShutdownList(date string, country int) ([]domain.ShutdownRecord, error) {
- var total int64 = 0
- var page int = 0
- var records []domain.ShutdownRecord = []domain.ShutdownRecord{}
- for total == 0 || REQ_PAGE_SIZE*uint64(page) < uint64(total) {
- page++
- shutdownListRes, err := querySiteShutdownListOnePage(date, country, page)
- if err != nil {
- return nil, err
- }
- total = int64(shutdownListRes.Data.Total)
- records = append(records, shutdownListRes.Data.Records...)
- }
- return records, nil
- }
|