| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- package http
- import (
- "encoding/json"
- "fmt"
- "io/ioutil"
- "net/http"
- "net/url"
- "strings"
- "video_course/global"
- "video_course/model"
- "video_course/utils"
- )
- type HeartRateServer struct {
- }
- //查询用户身体数据
- func (h HeartRateServer) VipUserQueryByUserMd5(userMd5 string) (rtnCode int, rtn *model.UserBodyInfo) {
- api := strings.Join([]string{global.Project.HeartrateUrl, "v1/OutService/GetUserBodyInfoByUserMd5"}, "/")
- resp, err := http.PostForm(api, url.Values{
- "userMd5": {userMd5},
- })
- if err != nil {
- panic(err)
- }
- defer resp.Body.Close()
- body, err := ioutil.ReadAll(resp.Body)
- if err != nil {
- err = fmt.Errorf("response:[%s], err:\n%w", string(body), err)
- panic(err)
- }
- var responseBase struct {
- Code int
- Memo string
- Rs map[string]interface{}
- }
- err = json.Unmarshal(body, &responseBase)
- if err != nil {
- err = fmt.Errorf("response:[%s], err:\n%w", string(body), err)
- panic(err)
- }
- rtnCode = responseBase.Code
- if rtnCode == 0 {
- rtn = &model.UserBodyInfo{
- UserName: utils.MapToString(responseBase.Rs, "Name"),
- Birthday: utils.MapToTime(responseBase.Rs, "Birthday"),
- Height: utils.MapToInt32(responseBase.Rs, "Height"),
- Weight: utils.MapToInt32(responseBase.Rs, "Weight"),
- Sex: utils.MapToInt32(responseBase.Rs, "Sex"),
- StaticHr: utils.MapToInt32(responseBase.Rs, "StaticHr"),
- UserMd5: utils.MapToString(responseBase.Rs, "UserMd5"),
- Head: utils.MapToString(responseBase.Rs, "Head"),
- }
- }
- return
- }
|