Commit 78e3cfdb1d3d701aed84fa93e9040bd285b9aadc
1 parent
bcfe0403
Exists in
master
and in
4 other branches
增加微转发阅读量接口
Showing
3 changed files
with
71 additions
and
0 deletions
Show diff stats
src/HttpServer/logic/datadef.go
| ... | ... | @@ -243,6 +243,19 @@ type UsersignResp struct { |
| 243 | 243 | Data UsersignData `json:"data"` |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | +type ReadNumUploadReq struct { | |
| 247 | + Uid int `json:"uid"` | |
| 248 | + Readnum int `json:"readnum"` | |
| 249 | + Gameid string `json:"gameid"` | |
| 250 | + Channel string `json:"channel"` | |
| 251 | +} | |
| 252 | + | |
| 253 | +type ReadNumUploadResp struct { | |
| 254 | + Code int `json:"code"` | |
| 255 | + Message string `json:"message"` | |
| 256 | + Timestamp int `json:"timestamp"` | |
| 257 | +} | |
| 258 | + | |
| 246 | 259 | //********************************************************************************************************** |
| 247 | 260 | |
| 248 | 261 | type TaskListDesc struct { |
| ... | ... | @@ -318,6 +331,7 @@ type UserData struct { |
| 318 | 331 | LeftFreeRB int //剩余免费红包次数 |
| 319 | 332 | UpLvCostTime int //上一个等级升级时间 |
| 320 | 333 | UpLvCostTimeSec int //上一个等级升级的时间点时刻 |
| 334 | + ReadNum int //玩家微转发阅读量 | |
| 321 | 335 | WithDraw WithDrawInfo //提现记录信息 |
| 322 | 336 | Task TaskInfo //玩家任务完成相关信息 |
| 323 | 337 | Achieve AchieveMentInfo //玩家成就完成相关数据 | ... | ... |
src/HttpServer/logic/httpserver.go
| ... | ... | @@ -61,6 +61,8 @@ func startServerHttpServe() { |
| 61 | 61 | http.HandleFunc("/eliminatestar/getnewlevelreward", Getnewlevelreward) //领取任务或者成就奖励 |
| 62 | 62 | http.HandleFunc("/eliminatestar/querysigndata", Querysigndata) //获取签到数据 |
| 63 | 63 | http.HandleFunc("/eliminatestar/usersign", Usersign) //玩家签到 |
| 64 | + // | |
| 65 | + http.HandleFunc("/eliminatestar/readNumUpload", ReadNumUpload) //阅读量上报 | |
| 64 | 66 | |
| 65 | 67 | err := http.ListenAndServe(conf.GetServerHttpAddrConf(), nil) |
| 66 | 68 | CheckErr(err) |
| ... | ... | @@ -95,6 +97,27 @@ func ClearData(w http.ResponseWriter, r *http.Request) { |
| 95 | 97 | fmt.Fprint(w, "success!") |
| 96 | 98 | } |
| 97 | 99 | |
| 100 | +func ReadNumUpload(w http.ResponseWriter, r *http.Request) { | |
| 101 | + | |
| 102 | + /*Uuid := 0 | |
| 103 | + if len(r.Header) > 0 { | |
| 104 | + Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) | |
| 105 | + } | |
| 106 | + | |
| 107 | + if Uuid == 0 { | |
| 108 | + SetHeader(w) | |
| 109 | + //logger.Error("Uuid is nil!") | |
| 110 | + return | |
| 111 | + }*/ | |
| 112 | + result, _ := ioutil.ReadAll(r.Body) | |
| 113 | + r.Body.Close() | |
| 114 | + | |
| 115 | + s := string(result) | |
| 116 | + logger.Info("ReadNumUpload , body:%v,uuid=%v", s) | |
| 117 | + | |
| 118 | + HandlerReadNumUpload(w, s) | |
| 119 | +} | |
| 120 | + | |
| 98 | 121 | func Usersign(w http.ResponseWriter, r *http.Request) { |
| 99 | 122 | |
| 100 | 123 | Uuid := 0 | ... | ... |
src/HttpServer/logic/logic.go
| ... | ... | @@ -348,6 +348,40 @@ func HandlerGetnewlevelreward(w http.ResponseWriter, data string, uuid int) { |
| 348 | 348 | |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | +func HandlerReadNumUpload(w http.ResponseWriter, data string) { | |
| 352 | + SetHeader(w) | |
| 353 | + var resp ReadNumUploadResp | |
| 354 | + resp.Code = 1 | |
| 355 | + resp.Message = "success" | |
| 356 | + var rdata ReadNumUploadReq | |
| 357 | + err := json.Unmarshal([]byte(data), &rdata) | |
| 358 | + for { | |
| 359 | + if err != nil { | |
| 360 | + logger.Info("json decode HandlerReadNumUpload data failed:%v,for:%v", err, data) | |
| 361 | + resp.Message = "json 解析错误" | |
| 362 | + resp.Code = ERROR_JSONUNMASH_ERROR | |
| 363 | + break | |
| 364 | + } | |
| 365 | + | |
| 366 | + //需要加上渠道才是唯一的玩家id,不同渠道视为不同数据 | |
| 367 | + uniqueuuid := strconv.Itoa(rdata.Uid) + rdata.Channel | |
| 368 | + uinfo, err := GetUserInfo(uniqueuuid) | |
| 369 | + if err != nil || uinfo == nil { | |
| 370 | + logger.Error("redis failed err=%v", err) | |
| 371 | + resp.Message = "uid错误,无法查询到玩家信息" | |
| 372 | + resp.Code = ERROR_SRV_ERROR | |
| 373 | + break | |
| 374 | + } | |
| 375 | + | |
| 376 | + uinfo.ReadNum += rdata.Readnum | |
| 377 | + | |
| 378 | + break | |
| 379 | + } | |
| 380 | + //回包 | |
| 381 | + respstr, _ := json.Marshal(&resp) | |
| 382 | + fmt.Fprint(w, string(respstr)) | |
| 383 | +} | |
| 384 | + | |
| 351 | 385 | func HandlerUsersign(w http.ResponseWriter, data string, uuid int) { |
| 352 | 386 | SetHeader(w) |
| 353 | 387 | var resp UsersignResp | ... | ... |