package controller import ( "bigdata_archives/app/e" "bigdata_archives/configs" "bytes" "encoding/json" "github.com/gin-gonic/gin" "io" "net/http" ) type RequestData struct { AppId string `json:"appId"` Secret string `json:"secret"` } type T struct { Success bool `json:"success"` Message string `json:"message"` Code int `json:"code"` Result struct { QzCount int `json:"qzCount"` QsCount int `json:"qsCount"` JsCount int `json:"jsCount"` DzdaCount int `json:"dzdaCount"` YjCount int `json:"yjCount"` CqqsCount int `json:"cqqsCount"` CqjsCount int `json:"cqjsCount"` QueryCount int `json:"queryCount"` FileCount int `json:"fileCount"` ZkList []struct { Name string `json:"name"` Num int `json:"num"` } `json:"zkList"` CkList []struct { Name string `json:"name"` Num int `json:"num"` } `json:"ckList"` DrkList []struct { Name string `json:"name"` Num int `json:"num"` } `json:"drkList"` DckList []struct { Name string `json:"name"` Num int `json:"num"` } `json:"dckList"` ZkNum int `json:"zkNum"` CkNum int `json:"ckNum"` DrkNum int `json:"drkNum"` DckNum int `json:"dckNum"` } `json:"result"` Timestamp int64 `json:"timestamp"` } func Archives(c *gin.Context) { // 创建要发送的数据 data := &RequestData{ AppId: "1686846386279535435", Secret: "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDvv8hgUuIzp7WdTS5zHQPt9bOytMNRY+s1MBCbLp6C2sz9kg+agQ/cMqztYgwjlYqETyUTiu/uuF0y71VHtfazip6eYI++EHqBCNgmgGBkdyV5EyiSBC+RsJ0tX+oCFFtIIlYzIwgserkZyVKrSF61OieQj+C2rqbJBZq5svXlwIDAQAB", } marshal, err2 := json.Marshal(data) if err2 != nil { e.ResponseWithMsg(c, e.ERROR, "json序列化失败") return } resp, err := http.Post(configs.Config.GetString("archives.arc"), "application/json", bytes.NewReader(marshal)) if err != nil { e.ResponseWithMsg(c, e.ERROR, "请求接口失败") return } defer resp.Body.Close() all, _ := io.ReadAll(resp.Body) var datas T json.Unmarshal(all, &datas) if datas.Code == 200 { e.ResponseSuccess(c, datas.Result) return } else { e.ResponseWithMsg(c, e.ERROR, "请求接口失败") return } }