diff --git a/src/HttpServer/logic/datadef.go b/src/HttpServer/logic/datadef.go index 2ef82d9..530301a 100644 --- a/src/HttpServer/logic/datadef.go +++ b/src/HttpServer/logic/datadef.go @@ -136,6 +136,23 @@ type UserInfoResp struct { Data UserInfoData `json:"data"` } +type UpdateSocialInfoReq struct { + Qq string `json:"qq"` + Weixin string `json:"weixin"` + HeadImg string `json:"headImg"` + Nickname string `json:"nickname"` + Auth int `json:"auth"` +} + +type UpdateSocialInfoData struct { +} + +type UpdateSocialInfoResp struct { + Code int `json:"code"` + Message string `json:"message"` + Data UpdateSocialInfoData `json:"data"` +} + type GetrandredbagReq struct { Optype int `json:"optype"` } diff --git a/src/HttpServer/logic/httpserver.go b/src/HttpServer/logic/httpserver.go index 1e38970..328e659 100644 --- a/src/HttpServer/logic/httpserver.go +++ b/src/HttpServer/logic/httpserver.go @@ -151,6 +151,7 @@ func startServerHttpServe() { http.HandleFunc("/api/gambling/removeCat", RemoveCat) //清除猫 http.HandleFunc("/api/user/info", UserInfo) //个人信息 http.HandleFunc("/api/ad/add", AddAd) //看广告 + http.HandleFunc("/api/ad/updateSocialInfo", UpdateSocialInfo) //更新社交信息 //新增的接口 http.HandleFunc("/api/happycat/getrandredbag", Getrandredbag) //领取随机红包 http.HandleFunc("/api/happycat/generatebox", Generatebox) //请求刷出空格礼包 @@ -1117,6 +1118,24 @@ func GetUserData(w http.ResponseWriter, r *http.Request) { HandlerGetUserData(w, s, Uuid) } +func UpdateSocialInfo(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("UpdateSocialInfo , body:%v,uuid=%v", s, Uuid) + + HandlerUpdateSocialInfo(w, s, Uuid) +} + func UserInfo(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 25cb0bd..44666a2 100644 --- a/src/HttpServer/logic/logic.go +++ b/src/HttpServer/logic/logic.go @@ -1056,6 +1056,42 @@ func HandlerGetrandredbag(w http.ResponseWriter, data string, uuid int) { fmt.Fprint(w, string(respstr)) } +func HandlerUpdateSocialInfo(w http.ResponseWriter, data string, uuid int) { + SetHeader(w) + var resp UpdateSocialInfoResp + resp.Code = 0 + resp.Message = "success" + var rdata UpdateSocialInfoReq + + err := json.Unmarshal([]byte(data), &rdata) + for { + + if err != nil { + logger.Error("HandlerUpdateSocialInfo json unmarshal failed=%v", err) + resp.Code = 1 + resp.Message = "json failed" + break + } + uinfo, err := GetUserInfo(strconv.Itoa(uuid)) + if err != nil || uinfo == nil { + logger.Error("HandlerUpdateSocialInfo getuserinfo failed=%v", err) + resp.Code = 1 + resp.Message = "get userinfo failed" + break + } + + uinfo.NickName = rdata.Nickname + uinfo.Head = rdata.HeadImg + + SaveUserInfo(uinfo, strconv.Itoa(uuid)) + break + } + + //回包 + respstr, _ := json.Marshal(&resp) + fmt.Fprint(w, string(respstr)) +} + func HandlerUserInfo(w http.ResponseWriter, data string, uuid int) { SetHeader(w) var resp UserInfoResp -- libgit2 0.21.0