From 86ef8b1a29c1471f4fd1aed2fedf14b0bcb8d44a Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Wed, 3 Jan 2024 14:18:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gzmiyuan/api.go | 9 ++++++++ gzmiyuan/getGzmiRealData.go | 41 +++++++++++++++++++++++++++++++++++++ gzmiyuan/gzmiyuan.go | 26 +++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 gzmiyuan/api.go create mode 100644 gzmiyuan/getGzmiRealData.go create mode 100644 gzmiyuan/gzmiyuan.go diff --git a/gzmiyuan/api.go b/gzmiyuan/api.go new file mode 100644 index 0000000..d36c35b --- /dev/null +++ b/gzmiyuan/api.go @@ -0,0 +1,9 @@ +package gzmiyuan + +import ( + zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils" +) + +func SendReq(urls string, params map[string]string) ([]byte, error) { + return zhios_third_party_utils.CurlPost(urls, zhios_third_party_utils.Serialize(params), map[string]string{"content-type": "application/json"}) +} diff --git a/gzmiyuan/getGzmiRealData.go b/gzmiyuan/getGzmiRealData.go new file mode 100644 index 0000000..badf1c0 --- /dev/null +++ b/gzmiyuan/getGzmiRealData.go @@ -0,0 +1,41 @@ +package gzmiyuan + +import ( + zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils" + "encoding/json" + "fmt" + "time" +) + +func GetGzmiRealData(pageSize, pageId, openType string) ([]GzmiRealNewsResponse, error) { + url := "https://api.gzmiyuan.com/api/business/sharerange/xianbao/findShareXianBaoByOpenType" + params := map[string]string{ + "page": pageId, + "rows": pageSize, + "openType": openType, + "version": fmt.Sprintf("%d", time.Now().UnixNano()/1e6), + } + fmt.Println(zhios_third_party_utils.Serialize(params)) + resp, err := SendReq(url, params) + zhios_third_party_utils.FilePutContents("miyuan", string(resp)) + if err != nil { + zhios_third_party_utils.FilePutContents("miyuan", err.Error()) + + return nil, err + } + + var responseData struct { + Msg string `json:"msg"` + Data []GzmiRealNewsResponse `json:"data"` + Code string `json:"code"` + } + + err = json.Unmarshal(resp, &responseData) + + if err != nil { + zhios_third_party_utils.FilePutContents("miyuan", err.Error()) + + return nil, err + } + return responseData.Data, nil +} diff --git a/gzmiyuan/gzmiyuan.go b/gzmiyuan/gzmiyuan.go new file mode 100644 index 0000000..0bff2d3 --- /dev/null +++ b/gzmiyuan/gzmiyuan.go @@ -0,0 +1,26 @@ +package gzmiyuan + +type GzmiRealNewsResponse struct { + Page int `json:"page"` + Rows int `json:"rows"` + Order interface{} `json:"order"` + Sort interface{} `json:"sort"` + Id int `json:"id"` + XianbaoId string `json:"xianbaoId"` + XianbaoContent string `json:"xianbaoContent"` + XianbaoImageUrl string `json:"xianbaoImageUrl"` + OpenType string `json:"openType"` + OpenName string `json:"openName"` + ItemIds string `json:"itemIds"` + Status int `json:"status"` + SourceFrom string `json:"sourceFrom"` + SourceXianbaoId interface{} `json:"sourceXianbaoId"` + ThirdCreateTime string `json:"thirdCreateTime"` + CreateTime string `json:"createTime"` + UpdateTime string `json:"updateTime"` + Version string `json:"version"` + IsConvert interface{} `json:"isConvert"` + IsExpireItem interface{} `json:"isExpireItem"` + IsExpireCoupon interface{} `json:"isExpireCoupon"` + ExtendJson string `json:"extendJson"` +}