Commit 75a0b865fd99f1dc8409c5e692206a2094f68ee4
1 parent
420805e8
Exists in
master
提交
Showing
3 changed files
with
66 additions
and
0 deletions
Show diff stats
src/HttpServer/logic/datadef.go
... | ... | @@ -57,6 +57,26 @@ type GetUserDataResp struct { |
57 | 57 | Data GetUserDataData `json:"data"` |
58 | 58 | } |
59 | 59 | |
60 | +type UserInfoData struct { | |
61 | + FromUserId int `json:"fromUserId"` | |
62 | + UserId int `json:"userId"` | |
63 | + Nickname string `json:"nickname"` | |
64 | + HeadImg string `json:"headImg"` | |
65 | + Score int `json:"score"` | |
66 | + FinishRate float32 `json:"finishRate"` | |
67 | + Cash float32 `json:"cash"` | |
68 | + InviteCode int `json:"inviteCode"` | |
69 | + Auth int `json:"auth"` | |
70 | + FriendCount int `json:"friendCount"` | |
71 | + FriendFriendCount int `json:"friendFriendCount"` | |
72 | +} | |
73 | + | |
74 | +type UserInfoResp struct { | |
75 | + Code int `json:"code"` | |
76 | + Message string `json:"message"` | |
77 | + Data UserInfoData `json:"data"` | |
78 | +} | |
79 | + | |
60 | 80 | type DataDesc struct { |
61 | 81 | Pos int `json:"pos"` |
62 | 82 | Catlv int `json:"cat_lv"` | ... | ... |
src/HttpServer/logic/httpserver.go
... | ... | @@ -137,6 +137,7 @@ func startServerHttpServe() { |
137 | 137 | http.HandleFunc("/api/gambling/chooseNum", ChooseNum) //选取号码 |
138 | 138 | http.HandleFunc("/api/gambling/autoChoose", AutoChoose) //自动选号码 |
139 | 139 | http.HandleFunc("/api/gambling/removeCat", RemoveCat) //清除猫 |
140 | + http.HandleFunc("/api/user/info", UserInfo) //个人信息 | |
140 | 141 | |
141 | 142 | /////---------------------------------------------------------------------old |
142 | 143 | //http.HandleFunc("/happycat/exchangetwoPos", ExchangePos) //交换位置 |
... | ... | @@ -1091,6 +1092,24 @@ func GetUserData(w http.ResponseWriter, r *http.Request) { |
1091 | 1092 | HandlerGetUserData(w, s, Uuid) |
1092 | 1093 | } |
1093 | 1094 | |
1095 | +func UserInfo(w http.ResponseWriter, r *http.Request) { | |
1096 | + Uuid := 0 | |
1097 | + if len(r.Header) > 0 { | |
1098 | + Uuid, _ = strconv.Atoi(r.Header.Get("uid")) | |
1099 | + } | |
1100 | + if Uuid == 0 { | |
1101 | + SetHeader(w) | |
1102 | + return | |
1103 | + } | |
1104 | + result, _ := ioutil.ReadAll(r.Body) | |
1105 | + r.Body.Close() | |
1106 | + | |
1107 | + s := string(result) | |
1108 | + logger.Info("UserInfo , body:%v,uuid=%v", s, Uuid) | |
1109 | + | |
1110 | + HandlerUserInfo(w, s, Uuid) | |
1111 | +} | |
1112 | + | |
1094 | 1113 | func TestaddCat(w http.ResponseWriter, r *http.Request) { |
1095 | 1114 | Uuid := 0 |
1096 | 1115 | if len(r.Header) > 0 { | ... | ... |
src/HttpServer/logic/logic.go
... | ... | @@ -230,6 +230,33 @@ func HandlerDoBuyCat(w http.ResponseWriter, data string, uuid int) { |
230 | 230 | fmt.Fprint(w, string(respstr)) |
231 | 231 | } |
232 | 232 | |
233 | +func HandlerUserInfo(w http.ResponseWriter, data string, uuid int) { | |
234 | + SetHeader(w) | |
235 | + var resp UserInfoResp | |
236 | + resp.Code = 0 | |
237 | + resp.Message = "success" | |
238 | + | |
239 | + for { | |
240 | + | |
241 | + uinfo, err := GetUserInfo(strconv.Itoa(uuid)) | |
242 | + if err != nil || uinfo == nil { | |
243 | + logger.Error("HandlerGetUserData getuserinfo failed=%v", err) | |
244 | + resp.Code = 1 | |
245 | + resp.Message = "get userinfo failed" | |
246 | + break | |
247 | + } | |
248 | + | |
249 | + resp.Data.UserId = uuid | |
250 | + resp.Data.HeadImg = uinfo.Head | |
251 | + resp.Data.Nickname = uinfo.NickName | |
252 | + | |
253 | + } | |
254 | + | |
255 | + //回包 | |
256 | + respstr, _ := json.Marshal(&resp) | |
257 | + fmt.Fprint(w, string(respstr)) | |
258 | +} | |
259 | + | |
233 | 260 | func HandlerGetUserData(w http.ResponseWriter, data string, uuid int) { |
234 | 261 | SetHeader(w) |
235 | 262 | var resp GetUserDataResp | ... | ... |