diff --git a/src/HttpServer/logic/datadef.go b/src/HttpServer/logic/datadef.go index 5f79193..e3956e1 100644 --- a/src/HttpServer/logic/datadef.go +++ b/src/HttpServer/logic/datadef.go @@ -57,6 +57,26 @@ type GetUserDataResp struct { Data GetUserDataData `json:"data"` } +type UserInfoData struct { + FromUserId int `json:"fromUserId"` + UserId int `json:"userId"` + Nickname string `json:"nickname"` + HeadImg string `json:"headImg"` + Score int `json:"score"` + FinishRate float32 `json:"finishRate"` + Cash float32 `json:"cash"` + InviteCode int `json:"inviteCode"` + Auth int `json:"auth"` + FriendCount int `json:"friendCount"` + FriendFriendCount int `json:"friendFriendCount"` +} + +type UserInfoResp struct { + Code int `json:"code"` + Message string `json:"message"` + Data UserInfoData `json:"data"` +} + type DataDesc struct { Pos int `json:"pos"` Catlv int `json:"cat_lv"` diff --git a/src/HttpServer/logic/httpserver.go b/src/HttpServer/logic/httpserver.go index 1deb744..ae7aa3c 100644 --- a/src/HttpServer/logic/httpserver.go +++ b/src/HttpServer/logic/httpserver.go @@ -137,6 +137,7 @@ func startServerHttpServe() { http.HandleFunc("/api/gambling/chooseNum", ChooseNum) //选取号码 http.HandleFunc("/api/gambling/autoChoose", AutoChoose) //自动选号码 http.HandleFunc("/api/gambling/removeCat", RemoveCat) //清除猫 + http.HandleFunc("/api/user/info", UserInfo) //个人信息 /////---------------------------------------------------------------------old //http.HandleFunc("/happycat/exchangetwoPos", ExchangePos) //交换位置 @@ -1091,6 +1092,24 @@ func GetUserData(w http.ResponseWriter, r *http.Request) { HandlerGetUserData(w, s, Uuid) } +func UserInfo(w http.ResponseWriter, r *http.Request) { + Uuid := 0 + if len(r.Header) > 0 { + Uuid, _ = strconv.Atoi(r.Header.Get("uid")) + } + if Uuid == 0 { + SetHeader(w) + return + } + result, _ := ioutil.ReadAll(r.Body) + r.Body.Close() + + s := string(result) + logger.Info("UserInfo , body:%v,uuid=%v", s, Uuid) + + HandlerUserInfo(w, s, Uuid) +} + func TestaddCat(w http.ResponseWriter, r *http.Request) { Uuid := 0 if len(r.Header) > 0 { diff --git a/src/HttpServer/logic/logic.go b/src/HttpServer/logic/logic.go index 6643f32..9b7eb86 100644 --- a/src/HttpServer/logic/logic.go +++ b/src/HttpServer/logic/logic.go @@ -230,6 +230,33 @@ func HandlerDoBuyCat(w http.ResponseWriter, data string, uuid int) { fmt.Fprint(w, string(respstr)) } +func HandlerUserInfo(w http.ResponseWriter, data string, uuid int) { + SetHeader(w) + var resp UserInfoResp + resp.Code = 0 + resp.Message = "success" + + for { + + uinfo, err := GetUserInfo(strconv.Itoa(uuid)) + if err != nil || uinfo == nil { + logger.Error("HandlerGetUserData getuserinfo failed=%v", err) + resp.Code = 1 + resp.Message = "get userinfo failed" + break + } + + resp.Data.UserId = uuid + resp.Data.HeadImg = uinfo.Head + resp.Data.Nickname = uinfo.NickName + + } + + //回包 + respstr, _ := json.Marshal(&resp) + fmt.Fprint(w, string(respstr)) +} + func HandlerGetUserData(w http.ResponseWriter, data string, uuid int) { SetHeader(w) var resp GetUserDataResp -- libgit2 0.21.0