From a1050fdffcefac5fa5fb1916e1509535a96d1f5d Mon Sep 17 00:00:00 2001 From: 陆恒 Date: Wed, 10 Jun 2020 16:18:04 +0800 Subject: [PATCH] 提交 --- src/HttpServer/logic/datadef.go | 11 +++++------ src/HttpServer/logic/httpserver.go | 5 +++-- src/HttpServer/logic/logic.go | 31 +++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/src/HttpServer/logic/datadef.go b/src/HttpServer/logic/datadef.go index c19983e..dfaa1fc 100644 --- a/src/HttpServer/logic/datadef.go +++ b/src/HttpServer/logic/datadef.go @@ -125,15 +125,14 @@ type QueryBuyCatReq struct { //Uuid int `json:"uuid"` } type QueryBuyCatResp struct { - Code int `json:"code"` - Message string `json:"message"` - Maxcatlv int `json:"maxcatlv"` - Data []BuyCatDesc `json:"data"` + Code int `json:"code"` + Message string `json:"message"` + Data []BuyCatDesc `json:"data"` } type BuyCatDesc struct { - Lv int `json:"lv"` - Goldnum int64 `json:"goldnum"` + CatId int `json:"catId"` + Coin string `json:"coin"` } type ClickRandGiftReq struct { diff --git a/src/HttpServer/logic/httpserver.go b/src/HttpServer/logic/httpserver.go index fafa7ce..81dbf64 100644 --- a/src/HttpServer/logic/httpserver.go +++ b/src/HttpServer/logic/httpserver.go @@ -176,6 +176,7 @@ func startServerHttpServe() { http.HandleFunc("/api/ranking/list", QueryPlayerRank) //排行榜 http.HandleFunc("/api/home/index", GetMainPageInfo) //主页面 http.HandleFunc("/api/home/adRate", AcclecteGold) //看广告加速 + http.HandleFunc("api/home/shop", QueryBuyCat) //商店 http.HandleFunc("/happycat/exchangetwoPos", ExchangePos) //交换位置 http.HandleFunc("/happycat/clickcatbox", ClickCatBox) //请求点击猫箱子 @@ -592,7 +593,7 @@ func DoBuyCat(w http.ResponseWriter, r *http.Request) { func QueryBuyCat(w http.ResponseWriter, r *http.Request) { Uuid := 0 if len(r.Header) > 0 { - Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) + Uuid, _ = strconv.Atoi(r.Header.Get("uid")) } if Uuid == 0 { SetHeader(w) @@ -604,7 +605,7 @@ func QueryBuyCat(w http.ResponseWriter, r *http.Request) { s := string(result) logger.Info("QueryBuyCat , body:%v,uuid=%v", s, Uuid) - //HandlerQueryBuyCat(w, s, Uuid) + HandlerQueryBuyCat(w, s, Uuid) } func ClickRandGift(w http.ResponseWriter, r *http.Request) { diff --git a/src/HttpServer/logic/logic.go b/src/HttpServer/logic/logic.go index 9b574d4..87e22bd 100644 --- a/src/HttpServer/logic/logic.go +++ b/src/HttpServer/logic/logic.go @@ -454,3 +454,34 @@ func HandlerAcclecteGold(w http.ResponseWriter, data string, uuid int) { respstr, _ := json.Marshal(&resp) fmt.Fprint(w, string(respstr)) } + +func HandlerQueryBuyCat(w http.ResponseWriter, data string, uuid int) { + SetHeader(w) + var resp QueryBuyCatResp + resp.Code = 0 + resp.Message = "success" + + for { + + uinfo, err := GetUserInfo(strconv.Itoa(uuid)) + if err != nil || uinfo == nil { + logger.Error("HandlerAcclecteGold getuserinfo failed=%v", err) + resp.Code = 1 + resp.Message = "get userinfo failed" + break + } + + for k, v := range uinfo.BuyCatInfo { + var tmp BuyCatDesc + tmp.CatId = k + 1 + tmp.Coin = strconv.FormatInt(v.CurPrice, 10) + resp.Data = append(resp.Data, tmp) + } + + resp.Code = 0 + break + } + //回包 + respstr, _ := json.Marshal(&resp) + fmt.Fprint(w, string(respstr)) +} -- libgit2 0.21.0