Commit eef4f8261b2127e61b8b48dcc8a9dbcd6a7ed0f5
1 parent
bf38495c
Exists in
master
提交接口
Showing
4 changed files
with
253 additions
and
21 deletions
Show diff stats
src/HttpServer/logic/datadef.go
| ... | ... | @@ -9,15 +9,13 @@ package logic |
| 9 | 9 | //"107":"签到罐" |
| 10 | 10 | |
| 11 | 11 | type UserLoginReq struct { |
| 12 | - | |
| 13 | 12 | } |
| 14 | 13 | |
| 15 | 14 | type UserLoginData struct { |
| 16 | - Isnew int `json:"isnew"` | |
| 17 | - Walletgold int `json:"walletgold"` | |
| 18 | - Guangold int `json:"guangold"` | |
| 19 | - PlayerData string `json:"playerData"` | |
| 20 | - | |
| 15 | + Isnew int `json:"isnew"` | |
| 16 | + Walletgold int `json:"walletgold"` | |
| 17 | + Guangold int `json:"guangold"` | |
| 18 | + PlayerData string `json:"playerData"` | |
| 21 | 19 | } |
| 22 | 20 | |
| 23 | 21 | type UserLoginResp struct { |
| ... | ... | @@ -26,6 +24,50 @@ type UserLoginResp struct { |
| 26 | 24 | Data UserLoginData `json:"data"` |
| 27 | 25 | } |
| 28 | 26 | |
| 27 | +type UploaduserbasicinfoReq struct { | |
| 28 | + Nickname string `json:"nickname"` | |
| 29 | + Headurl string `json:"headurl"` | |
| 30 | +} | |
| 31 | + | |
| 32 | +type UploaduserbasicinfoData struct { | |
| 33 | + Isnew int `json:"isnew"` | |
| 34 | + Walletgold int `json:"walletgold"` | |
| 35 | + Guangold int `json:"guangold"` | |
| 36 | + PlayerData string `json:"playerData"` | |
| 37 | +} | |
| 38 | + | |
| 39 | +type UploaduserbasicinfoResp struct { | |
| 40 | + Code int `json:"code"` | |
| 41 | + Message string `json:"message"` | |
| 42 | + Data UploaduserbasicinfoData `json:"data"` | |
| 43 | +} | |
| 44 | + | |
| 45 | +type UpdatedataReq struct { | |
| 46 | + PlayerData string `json:"playerData"` | |
| 47 | +} | |
| 48 | + | |
| 49 | +type UpdatedataData struct { | |
| 50 | +} | |
| 51 | + | |
| 52 | +type UpdatedataResp struct { | |
| 53 | + Code int `json:"code"` | |
| 54 | + Message string `json:"message"` | |
| 55 | + Data UpdatedataData `json:"data"` | |
| 56 | +} | |
| 57 | + | |
| 58 | +type SyncuserdataData struct { | |
| 59 | + Walletgold int `json:"walletgold"` | |
| 60 | + Guangold int `json:"guangold"` | |
| 61 | + Sumloginday int `json:"sumloginday"` | |
| 62 | + Nowtime int `json:"nowtime"` | |
| 63 | +} | |
| 64 | + | |
| 65 | +type SyncuserdataResp struct { | |
| 66 | + Code int `json:"code"` | |
| 67 | + Message string `json:"message"` | |
| 68 | + Data SyncuserdataData `json:"data"` | |
| 69 | +} | |
| 70 | + | |
| 29 | 71 | type GetuserdataReq struct { |
| 30 | 72 | Gameid string `json:"gameid"` |
| 31 | 73 | Channel string `json:"channel"` |
| ... | ... | @@ -334,10 +376,13 @@ type WithDrawDesc struct { |
| 334 | 376 | |
| 335 | 377 | //玩家数据 |
| 336 | 378 | type UserData struct { |
| 337 | - Userid string //玩家w唯一id | |
| 379 | + Userid string //玩家w唯一id | |
| 338 | 380 | Lv int //玩家当前等级 |
| 339 | 381 | LvRewardGet int //当前等级奖励是否已经领取 1未领取 2普通领取 3双倍领取 |
| 340 | 382 | Exp int //玩家当前经验值 |
| 383 | + NickName string //昵称 | |
| 384 | + HeadUrl string //头像 | |
| 385 | + RegTime int //注册时间 | |
| 341 | 386 | GuanGold int //玩家存钱罐中金币数量 |
| 342 | 387 | RealGold int //玩家实际金币数量(可用于提现的) |
| 343 | 388 | WatchAddsTime int //当天剩余红包次数 初始化50次 | ... | ... |
src/HttpServer/logic/function.go
| ... | ... | @@ -307,6 +307,9 @@ func InitUserInfo(resp *UserLoginResp, uniqueuid ,gameid ,channel string,uuid in |
| 307 | 307 | initdata.LeftFreeRB = FREE_REDBAG_NUM |
| 308 | 308 | initdata.UpLvCostTime = 0 |
| 309 | 309 | initdata.UpLvCostTimeSec = int(time.Now().Unix()) |
| 310 | + initdata.NickName = "著名沙雕" | |
| 311 | + initdata.HeadUrl = "1" | |
| 312 | + initdata.RegTime = int(time.Now().Unix()) | |
| 310 | 313 | |
| 311 | 314 | for _, val := range jsonconf.GetJsonConf().RmbConfig { |
| 312 | 315 | var tmp WithDrawDesc | ... | ... |
src/HttpServer/logic/httpserver.go
| ... | ... | @@ -45,7 +45,12 @@ func startServerHttpServe() { |
| 45 | 45 | http.HandleFunc("/eliminatestar/addcoin", Addcoin) //测试接口 |
| 46 | 46 | http.HandleFunc("/eliminatestar/clear", ClearData) //清除账号 |
| 47 | 47 | //---------------------------------------------------------------------------------------- |
| 48 | - http.HandleFunc("/eliminatestar/login", UserLogin) //登录 | |
| 48 | + http.HandleFunc("/russiaxiaoxiao/login", UserLogin) //登录 | |
| 49 | + http.HandleFunc("/russiaxiaoxiao/uploaduserbasicinfo", Uploaduserbasicinfo) //上传基本信息 | |
| 50 | + http.HandleFunc("/russiaxiaoxiao/updatedata", Updatedata) //update数据 | |
| 51 | + http.HandleFunc("/russiaxiaoxiao/syncuserdata", Syncuserdata) //同步玩家数据 | |
| 52 | + | |
| 53 | + //.......................................... | |
| 49 | 54 | http.HandleFunc("/eliminatestar/getuserdata", Getuserdata) //获取玩家数据 |
| 50 | 55 | http.HandleFunc("/eliminatestar/watchads", Watchads) //观看激励视频 |
| 51 | 56 | http.HandleFunc("/eliminatestar/queryguaninfo", Queryguaninfo) //获取存钱罐数据 |
| ... | ... | @@ -407,7 +412,7 @@ func Onlinentf(w http.ResponseWriter, r *http.Request) { |
| 407 | 412 | s := string(result) |
| 408 | 413 | logger.Info("Onlinentf , body:%v,uuid=%v", s, Uuid) |
| 409 | 414 | |
| 410 | -// HandlerOnlinentf(w, s, Uuid) | |
| 415 | + // HandlerOnlinentf(w, s, Uuid) | |
| 411 | 416 | } |
| 412 | 417 | |
| 413 | 418 | func Getcashrecord(w http.ResponseWriter, r *http.Request) { |
| ... | ... | @@ -512,7 +517,7 @@ func Getguangold(w http.ResponseWriter, r *http.Request) { |
| 512 | 517 | s := string(result) |
| 513 | 518 | logger.Info("Getguangold , body:%v,uuid=%v", s, Uuid) |
| 514 | 519 | |
| 515 | -// HandlerGetguangold(w, s, Uuid) | |
| 520 | + // HandlerGetguangold(w, s, Uuid) | |
| 516 | 521 | } |
| 517 | 522 | |
| 518 | 523 | func Queryguaninfo(w http.ResponseWriter, r *http.Request) { |
| ... | ... | @@ -562,6 +567,87 @@ func Watchads(w http.ResponseWriter, r *http.Request) { |
| 562 | 567 | //HandlerWatchads(w, s, Uuid) |
| 563 | 568 | } |
| 564 | 569 | |
| 570 | +func Syncuserdata(w http.ResponseWriter, r *http.Request) { | |
| 571 | + | |
| 572 | + //gameid := "" | |
| 573 | + //channel := "" | |
| 574 | + uniqueid := "" | |
| 575 | + Uuid := 0 | |
| 576 | + if len(r.Header) > 0 { | |
| 577 | + Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) | |
| 578 | + // gameid = r.Header.Get("Gameid") | |
| 579 | + //channel = r.Header.Get("Channel") | |
| 580 | + uniqueid = r.Header.Get("Uuid") + r.Header.Get("Channel") | |
| 581 | + } | |
| 582 | + | |
| 583 | + if Uuid == 0 { | |
| 584 | + SetHeader(w) | |
| 585 | + logger.Error("Uuid is nil!") | |
| 586 | + return | |
| 587 | + } | |
| 588 | + result, _ := ioutil.ReadAll(r.Body) | |
| 589 | + r.Body.Close() | |
| 590 | + | |
| 591 | + s := string(result) | |
| 592 | + logger.Info("Syncuserdata , body:%v,uuid=%v", s, uniqueid) | |
| 593 | + | |
| 594 | + HandlerSyncuserdata(w, s, uniqueid) | |
| 595 | +} | |
| 596 | + | |
| 597 | +func Updatedata(w http.ResponseWriter, r *http.Request) { | |
| 598 | + | |
| 599 | + //gameid := "" | |
| 600 | + //channel := "" | |
| 601 | + uniqueid := "" | |
| 602 | + Uuid := 0 | |
| 603 | + if len(r.Header) > 0 { | |
| 604 | + Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) | |
| 605 | + // gameid = r.Header.Get("Gameid") | |
| 606 | + //channel = r.Header.Get("Channel") | |
| 607 | + uniqueid = r.Header.Get("Uuid") + r.Header.Get("Channel") | |
| 608 | + } | |
| 609 | + | |
| 610 | + if Uuid == 0 { | |
| 611 | + SetHeader(w) | |
| 612 | + logger.Error("Uuid is nil!") | |
| 613 | + return | |
| 614 | + } | |
| 615 | + result, _ := ioutil.ReadAll(r.Body) | |
| 616 | + r.Body.Close() | |
| 617 | + | |
| 618 | + s := string(result) | |
| 619 | + logger.Info("Updatedata , body:%v,uuid=%v", s, uniqueid) | |
| 620 | + | |
| 621 | + HandlerUpdatedata(w, s, uniqueid) | |
| 622 | +} | |
| 623 | + | |
| 624 | +func Uploaduserbasicinfo(w http.ResponseWriter, r *http.Request) { | |
| 625 | + | |
| 626 | + //gameid := "" | |
| 627 | + //channel := "" | |
| 628 | + uniqueid := "" | |
| 629 | + Uuid := 0 | |
| 630 | + if len(r.Header) > 0 { | |
| 631 | + Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) | |
| 632 | + // gameid = r.Header.Get("Gameid") | |
| 633 | + //channel = r.Header.Get("Channel") | |
| 634 | + uniqueid = r.Header.Get("Uuid") + r.Header.Get("Channel") | |
| 635 | + } | |
| 636 | + | |
| 637 | + if Uuid == 0 { | |
| 638 | + SetHeader(w) | |
| 639 | + logger.Error("Uuid is nil!") | |
| 640 | + return | |
| 641 | + } | |
| 642 | + result, _ := ioutil.ReadAll(r.Body) | |
| 643 | + r.Body.Close() | |
| 644 | + | |
| 645 | + s := string(result) | |
| 646 | + logger.Info("Uploaduserbasicinfo , body:%v,uuid=%v", s, uniqueid) | |
| 647 | + | |
| 648 | + HandlerUploaduserbasicinfo(w, s, uniqueid) | |
| 649 | +} | |
| 650 | + | |
| 565 | 651 | func UserLogin(w http.ResponseWriter, r *http.Request) { |
| 566 | 652 | |
| 567 | 653 | gameid := "" |
| ... | ... | @@ -586,7 +672,7 @@ func UserLogin(w http.ResponseWriter, r *http.Request) { |
| 586 | 672 | s := string(result) |
| 587 | 673 | logger.Info("UserLogin , body:%v,uuid=%v", s, uniqueid) |
| 588 | 674 | |
| 589 | - HandlerLogin(w, s, uniqueid,gameid,channel,Uuid) | |
| 675 | + HandlerLogin(w, s, uniqueid, gameid, channel, Uuid) | |
| 590 | 676 | } |
| 591 | 677 | |
| 592 | 678 | func Getuserdata(w http.ResponseWriter, r *http.Request) { | ... | ... |
src/HttpServer/logic/logic.go
| ... | ... | @@ -7,9 +7,111 @@ import ( |
| 7 | 7 | "encoding/json" |
| 8 | 8 | "fmt" |
| 9 | 9 | "net/http" |
| 10 | + "time" | |
| 10 | 11 | ) |
| 11 | 12 | |
| 12 | -func HandlerLogin(w http.ResponseWriter, data string, uniqueuuid ,gameid,channel string,uuid int) { | |
| 13 | +func HandlerSyncuserdata(w http.ResponseWriter, data string, uniqueuuid string) { | |
| 14 | + SetHeader(w) | |
| 15 | + | |
| 16 | + var resp SyncuserdataResp | |
| 17 | + resp.Code = 0 | |
| 18 | + resp.Message = "success" | |
| 19 | + | |
| 20 | + for { | |
| 21 | + | |
| 22 | + uinfo, err := GetUserInfo(uniqueuuid) | |
| 23 | + | |
| 24 | + if err != nil { | |
| 25 | + logger.Info("GetUserInfo HandlerSyncuserdata data failed:%v,for:%v", err, data) | |
| 26 | + resp.Message = "GetUserInfo failed" | |
| 27 | + resp.Code = 1 | |
| 28 | + break | |
| 29 | + } | |
| 30 | + | |
| 31 | + resp.Data.Walletgold = uinfo.RealGold | |
| 32 | + resp.Data.Guangold = uinfo.GuanGold | |
| 33 | + resp.Data.Sumloginday = uinfo.SumLoginDay | |
| 34 | + resp.Data.Nowtime = int(time.Now().Unix()) | |
| 35 | + break | |
| 36 | + } | |
| 37 | + | |
| 38 | + //回包 | |
| 39 | + respstr, _ := json.Marshal(&resp) | |
| 40 | + fmt.Fprint(w, string(respstr)) | |
| 41 | +} | |
| 42 | + | |
| 43 | +func HandlerUpdatedata(w http.ResponseWriter, data string, uniqueuuid string) { | |
| 44 | + SetHeader(w) | |
| 45 | + | |
| 46 | + var resp UpdatedataResp | |
| 47 | + resp.Code = 0 | |
| 48 | + resp.Message = "success" | |
| 49 | + var rdata UpdatedataReq | |
| 50 | + err := json.Unmarshal([]byte(data), &rdata) | |
| 51 | + for { | |
| 52 | + | |
| 53 | + if err != nil { | |
| 54 | + logger.Info("json decode HandlerUpdatedata data failed:%v,for:%v", err, data) | |
| 55 | + resp.Message = "json解析错误" | |
| 56 | + resp.Code = ERROR_JSONUNMASH_ERROR | |
| 57 | + break | |
| 58 | + } | |
| 59 | + | |
| 60 | + //直接保存 | |
| 61 | + err := SaveUserSelfData(uniqueuuid, rdata.PlayerData) | |
| 62 | + if err != nil { | |
| 63 | + logger.Info("SaveUserSelfData HandlerUpdatedata data failed:%v,for:%v", err, data) | |
| 64 | + resp.Message = "保存失败" | |
| 65 | + resp.Code = ERROR_JSONUNMASH_ERROR | |
| 66 | + break | |
| 67 | + } | |
| 68 | + | |
| 69 | + break | |
| 70 | + } | |
| 71 | + | |
| 72 | + //回包 | |
| 73 | + respstr, _ := json.Marshal(&resp) | |
| 74 | + fmt.Fprint(w, string(respstr)) | |
| 75 | +} | |
| 76 | + | |
| 77 | +func HandlerUploaduserbasicinfo(w http.ResponseWriter, data string, uniqueuuid string) { | |
| 78 | + SetHeader(w) | |
| 79 | + | |
| 80 | + var resp UploaduserbasicinfoResp | |
| 81 | + resp.Code = 0 | |
| 82 | + resp.Message = "success" | |
| 83 | + var rdata UploaduserbasicinfoReq | |
| 84 | + err := json.Unmarshal([]byte(data), &rdata) | |
| 85 | + for { | |
| 86 | + | |
| 87 | + if err != nil { | |
| 88 | + logger.Info("json decode HandlerUploaduserbasicinfo data failed:%v,for:%v", err, data) | |
| 89 | + resp.Message = "json解析错误" | |
| 90 | + resp.Code = ERROR_JSONUNMASH_ERROR | |
| 91 | + break | |
| 92 | + } | |
| 93 | + uinfo, err := GetUserInfo(uniqueuuid) | |
| 94 | + | |
| 95 | + if err != nil { | |
| 96 | + logger.Info("GetUserInfo HandlerUploaduserbasicinfo data failed:%v,for:%v", err, data) | |
| 97 | + resp.Message = "GetUserInfo failed" | |
| 98 | + resp.Code = 1 | |
| 99 | + break | |
| 100 | + } | |
| 101 | + | |
| 102 | + uinfo.HeadUrl = rdata.Headurl | |
| 103 | + uinfo.NickName = rdata.Nickname | |
| 104 | + | |
| 105 | + SaveUserInfo(uinfo, uniqueuuid) | |
| 106 | + break | |
| 107 | + } | |
| 108 | + | |
| 109 | + //回包 | |
| 110 | + respstr, _ := json.Marshal(&resp) | |
| 111 | + fmt.Fprint(w, string(respstr)) | |
| 112 | +} | |
| 113 | + | |
| 114 | +func HandlerLogin(w http.ResponseWriter, data string, uniqueuuid, gameid, channel string, uuid int) { | |
| 13 | 115 | SetHeader(w) |
| 14 | 116 | |
| 15 | 117 | var resp UserLoginResp |
| ... | ... | @@ -29,9 +131,8 @@ func HandlerLogin(w http.ResponseWriter, data string, uniqueuuid ,gameid,channel |
| 29 | 131 | if !isexist { |
| 30 | 132 | //不存在 |
| 31 | 133 | |
| 32 | - //不存在老的数据 之间走新号流程 | |
| 33 | - err = InitUserInfo(&resp, uniqueuuid,gameid,channel,uuid) | |
| 34 | - | |
| 134 | + //不存在老的数据 之间走新号流程 | |
| 135 | + err = InitUserInfo(&resp, uniqueuuid, gameid, channel, uuid) | |
| 35 | 136 | |
| 36 | 137 | } else { |
| 37 | 138 | uinfo, err := GetUserInfo(uniqueuuid) |
| ... | ... | @@ -43,15 +144,13 @@ func HandlerLogin(w http.ResponseWriter, data string, uniqueuuid ,gameid,channel |
| 43 | 144 | break |
| 44 | 145 | } |
| 45 | 146 | |
| 46 | - | |
| 47 | - | |
| 48 | 147 | resp.Data.Guangold = uinfo.GuanGold |
| 49 | 148 | resp.Data.Walletgold = uinfo.RealGold |
| 50 | 149 | |
| 51 | - resp.Data.Isnew= 0 | |
| 150 | + resp.Data.Isnew = 0 | |
| 52 | 151 | } |
| 53 | 152 | |
| 54 | - pdata,err := GetUserSelfData(uniqueuuid) | |
| 153 | + pdata, err := GetUserSelfData(uniqueuuid) | |
| 55 | 154 | |
| 56 | 155 | if err != nil { |
| 57 | 156 | logger.Info("GetUserSelfData HandlerLogin data failed:%v,for:%v", err, data) |
| ... | ... | @@ -61,7 +160,6 @@ func HandlerLogin(w http.ResponseWriter, data string, uniqueuuid ,gameid,channel |
| 61 | 160 | } |
| 62 | 161 | resp.Data.PlayerData = pdata |
| 63 | 162 | |
| 64 | - | |
| 65 | 163 | resp.Code = ERROR_OK |
| 66 | 164 | break |
| 67 | 165 | } |
| ... | ... | @@ -71,4 +169,4 @@ func HandlerLogin(w http.ResponseWriter, data string, uniqueuuid ,gameid,channel |
| 71 | 169 | fmt.Fprint(w, string(respstr)) |
| 72 | 170 | |
| 73 | 171 | logger.Info("###HandlerLogin###rdata:%v", string(respstr)) |
| 74 | -} | |
| 75 | 172 | \ No newline at end of file |
| 173 | +} | ... | ... |