Commit a1050fdffcefac5fa5fb1916e1509535a96d1f5d
1 parent
54358dd1
Exists in
master
提交
Showing
3 changed files
with
39 additions
and
8 deletions
Show diff stats
src/HttpServer/logic/datadef.go
| ... | ... | @@ -125,15 +125,14 @@ type QueryBuyCatReq struct { |
| 125 | 125 | //Uuid int `json:"uuid"` |
| 126 | 126 | } |
| 127 | 127 | type QueryBuyCatResp struct { |
| 128 | - Code int `json:"code"` | |
| 129 | - Message string `json:"message"` | |
| 130 | - Maxcatlv int `json:"maxcatlv"` | |
| 131 | - Data []BuyCatDesc `json:"data"` | |
| 128 | + Code int `json:"code"` | |
| 129 | + Message string `json:"message"` | |
| 130 | + Data []BuyCatDesc `json:"data"` | |
| 132 | 131 | } |
| 133 | 132 | |
| 134 | 133 | type BuyCatDesc struct { |
| 135 | - Lv int `json:"lv"` | |
| 136 | - Goldnum int64 `json:"goldnum"` | |
| 134 | + CatId int `json:"catId"` | |
| 135 | + Coin string `json:"coin"` | |
| 137 | 136 | } |
| 138 | 137 | |
| 139 | 138 | type ClickRandGiftReq struct { | ... | ... |
src/HttpServer/logic/httpserver.go
| ... | ... | @@ -176,6 +176,7 @@ func startServerHttpServe() { |
| 176 | 176 | http.HandleFunc("/api/ranking/list", QueryPlayerRank) //排行榜 |
| 177 | 177 | http.HandleFunc("/api/home/index", GetMainPageInfo) //主页面 |
| 178 | 178 | http.HandleFunc("/api/home/adRate", AcclecteGold) //看广告加速 |
| 179 | + http.HandleFunc("api/home/shop", QueryBuyCat) //商店 | |
| 179 | 180 | |
| 180 | 181 | http.HandleFunc("/happycat/exchangetwoPos", ExchangePos) //交换位置 |
| 181 | 182 | http.HandleFunc("/happycat/clickcatbox", ClickCatBox) //请求点击猫箱子 |
| ... | ... | @@ -592,7 +593,7 @@ func DoBuyCat(w http.ResponseWriter, r *http.Request) { |
| 592 | 593 | func QueryBuyCat(w http.ResponseWriter, r *http.Request) { |
| 593 | 594 | Uuid := 0 |
| 594 | 595 | if len(r.Header) > 0 { |
| 595 | - Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) | |
| 596 | + Uuid, _ = strconv.Atoi(r.Header.Get("uid")) | |
| 596 | 597 | } |
| 597 | 598 | if Uuid == 0 { |
| 598 | 599 | SetHeader(w) |
| ... | ... | @@ -604,7 +605,7 @@ func QueryBuyCat(w http.ResponseWriter, r *http.Request) { |
| 604 | 605 | s := string(result) |
| 605 | 606 | logger.Info("QueryBuyCat , body:%v,uuid=%v", s, Uuid) |
| 606 | 607 | |
| 607 | - //HandlerQueryBuyCat(w, s, Uuid) | |
| 608 | + HandlerQueryBuyCat(w, s, Uuid) | |
| 608 | 609 | } |
| 609 | 610 | |
| 610 | 611 | func ClickRandGift(w http.ResponseWriter, r *http.Request) { | ... | ... |
src/HttpServer/logic/logic.go
| ... | ... | @@ -454,3 +454,34 @@ func HandlerAcclecteGold(w http.ResponseWriter, data string, uuid int) { |
| 454 | 454 | respstr, _ := json.Marshal(&resp) |
| 455 | 455 | fmt.Fprint(w, string(respstr)) |
| 456 | 456 | } |
| 457 | + | |
| 458 | +func HandlerQueryBuyCat(w http.ResponseWriter, data string, uuid int) { | |
| 459 | + SetHeader(w) | |
| 460 | + var resp QueryBuyCatResp | |
| 461 | + resp.Code = 0 | |
| 462 | + resp.Message = "success" | |
| 463 | + | |
| 464 | + for { | |
| 465 | + | |
| 466 | + uinfo, err := GetUserInfo(strconv.Itoa(uuid)) | |
| 467 | + if err != nil || uinfo == nil { | |
| 468 | + logger.Error("HandlerAcclecteGold getuserinfo failed=%v", err) | |
| 469 | + resp.Code = 1 | |
| 470 | + resp.Message = "get userinfo failed" | |
| 471 | + break | |
| 472 | + } | |
| 473 | + | |
| 474 | + for k, v := range uinfo.BuyCatInfo { | |
| 475 | + var tmp BuyCatDesc | |
| 476 | + tmp.CatId = k + 1 | |
| 477 | + tmp.Coin = strconv.FormatInt(v.CurPrice, 10) | |
| 478 | + resp.Data = append(resp.Data, tmp) | |
| 479 | + } | |
| 480 | + | |
| 481 | + resp.Code = 0 | |
| 482 | + break | |
| 483 | + } | |
| 484 | + //回包 | |
| 485 | + respstr, _ := json.Marshal(&resp) | |
| 486 | + fmt.Fprint(w, string(respstr)) | |
| 487 | +} | ... | ... |