Commit bc55f3e1d8820aada99b33dea51769dbfcba6a6b

Authored by 陆恒
1 parent dd4d741e
Exists in master

提交

src/HttpServer/logic/datadef.go
@@ -136,6 +136,23 @@ type UserInfoResp struct { @@ -136,6 +136,23 @@ type UserInfoResp struct {
136 Data UserInfoData `json:"data"` 136 Data UserInfoData `json:"data"`
137 } 137 }
138 138
  139 +type UpdateSocialInfoReq struct {
  140 + Qq string `json:"qq"`
  141 + Weixin string `json:"weixin"`
  142 + HeadImg string `json:"headImg"`
  143 + Nickname string `json:"nickname"`
  144 + Auth int `json:"auth"`
  145 +}
  146 +
  147 +type UpdateSocialInfoData struct {
  148 +}
  149 +
  150 +type UpdateSocialInfoResp struct {
  151 + Code int `json:"code"`
  152 + Message string `json:"message"`
  153 + Data UpdateSocialInfoData `json:"data"`
  154 +}
  155 +
139 type GetrandredbagReq struct { 156 type GetrandredbagReq struct {
140 Optype int `json:"optype"` 157 Optype int `json:"optype"`
141 } 158 }
src/HttpServer/logic/httpserver.go
@@ -151,6 +151,7 @@ func startServerHttpServe() { @@ -151,6 +151,7 @@ func startServerHttpServe() {
151 http.HandleFunc("/api/gambling/removeCat", RemoveCat) //清除猫 151 http.HandleFunc("/api/gambling/removeCat", RemoveCat) //清除猫
152 http.HandleFunc("/api/user/info", UserInfo) //个人信息 152 http.HandleFunc("/api/user/info", UserInfo) //个人信息
153 http.HandleFunc("/api/ad/add", AddAd) //看广告 153 http.HandleFunc("/api/ad/add", AddAd) //看广告
  154 + http.HandleFunc("/api/ad/updateSocialInfo", UpdateSocialInfo) //更新社交信息
154 //新增的接口 155 //新增的接口
155 http.HandleFunc("/api/happycat/getrandredbag", Getrandredbag) //领取随机红包 156 http.HandleFunc("/api/happycat/getrandredbag", Getrandredbag) //领取随机红包
156 http.HandleFunc("/api/happycat/generatebox", Generatebox) //请求刷出空格礼包 157 http.HandleFunc("/api/happycat/generatebox", Generatebox) //请求刷出空格礼包
@@ -1117,6 +1118,24 @@ func GetUserData(w http.ResponseWriter, r *http.Request) { @@ -1117,6 +1118,24 @@ func GetUserData(w http.ResponseWriter, r *http.Request) {
1117 HandlerGetUserData(w, s, Uuid) 1118 HandlerGetUserData(w, s, Uuid)
1118 } 1119 }
1119 1120
  1121 +func UpdateSocialInfo(w http.ResponseWriter, r *http.Request) {
  1122 + Uuid := 0
  1123 + if len(r.Header) > 0 {
  1124 + Uuid, _ = strconv.Atoi(r.Header.Get("uid"))
  1125 + }
  1126 + if Uuid == 0 {
  1127 + SetHeader(w)
  1128 + return
  1129 + }
  1130 + result, _ := ioutil.ReadAll(r.Body)
  1131 + r.Body.Close()
  1132 +
  1133 + s := string(result)
  1134 + logger.Info("UpdateSocialInfo , body:%v,uuid=%v", s, Uuid)
  1135 +
  1136 + HandlerUpdateSocialInfo(w, s, Uuid)
  1137 +}
  1138 +
1120 func UserInfo(w http.ResponseWriter, r *http.Request) { 1139 func UserInfo(w http.ResponseWriter, r *http.Request) {
1121 Uuid := 0 1140 Uuid := 0
1122 if len(r.Header) > 0 { 1141 if len(r.Header) > 0 {
src/HttpServer/logic/logic.go
@@ -1056,6 +1056,42 @@ func HandlerGetrandredbag(w http.ResponseWriter, data string, uuid int) { @@ -1056,6 +1056,42 @@ func HandlerGetrandredbag(w http.ResponseWriter, data string, uuid int) {
1056 fmt.Fprint(w, string(respstr)) 1056 fmt.Fprint(w, string(respstr))
1057 } 1057 }
1058 1058
  1059 +func HandlerUpdateSocialInfo(w http.ResponseWriter, data string, uuid int) {
  1060 + SetHeader(w)
  1061 + var resp UpdateSocialInfoResp
  1062 + resp.Code = 0
  1063 + resp.Message = "success"
  1064 + var rdata UpdateSocialInfoReq
  1065 +
  1066 + err := json.Unmarshal([]byte(data), &rdata)
  1067 + for {
  1068 +
  1069 + if err != nil {
  1070 + logger.Error("HandlerUpdateSocialInfo json unmarshal failed=%v", err)
  1071 + resp.Code = 1
  1072 + resp.Message = "json failed"
  1073 + break
  1074 + }
  1075 + uinfo, err := GetUserInfo(strconv.Itoa(uuid))
  1076 + if err != nil || uinfo == nil {
  1077 + logger.Error("HandlerUpdateSocialInfo getuserinfo failed=%v", err)
  1078 + resp.Code = 1
  1079 + resp.Message = "get userinfo failed"
  1080 + break
  1081 + }
  1082 +
  1083 + uinfo.NickName = rdata.Nickname
  1084 + uinfo.Head = rdata.HeadImg
  1085 +
  1086 + SaveUserInfo(uinfo, strconv.Itoa(uuid))
  1087 + break
  1088 + }
  1089 +
  1090 + //回包
  1091 + respstr, _ := json.Marshal(&resp)
  1092 + fmt.Fprint(w, string(respstr))
  1093 +}
  1094 +
1059 func HandlerUserInfo(w http.ResponseWriter, data string, uuid int) { 1095 func HandlerUserInfo(w http.ResponseWriter, data string, uuid int) {
1060 SetHeader(w) 1096 SetHeader(w)
1061 var resp UserInfoResp 1097 var resp UserInfoResp