Commit 95bfb593832f01fabb6c327f991bd2d9a4b4343a
1 parent
0a5e55b4
Exists in
master
提交登录接口
Showing
6 changed files
with
243 additions
and
60 deletions
Show diff stats
src/HttpServer/jsonconf/jsonconf.go
| @@ -61,6 +61,14 @@ func GetJsonConf() *GameConfig { | @@ -61,6 +61,14 @@ func GetJsonConf() *GameConfig { | ||
| 61 | return g_jsonconf | 61 | return g_jsonconf |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | +func GetCatConfig(lv int) *CatDesc { | ||
| 65 | + for _, v := range g_jsonconf.CatConfig { | ||
| 66 | + if v.Id == lv { | ||
| 67 | + return &v | ||
| 68 | + } | ||
| 69 | + } | ||
| 70 | + return nil | ||
| 71 | +} | ||
| 64 | 72 | ||
| 65 | 73 | ||
| 66 | func file_get_contents(path string) ([]byte, error) { | 74 | func file_get_contents(path string) ([]byte, error) { |
src/HttpServer/logic/datadef.go
| 1 | package logic | 1 | package logic |
| 2 | 2 | ||
| 3 | -type UserLoginData struct { | ||
| 4 | - //Uuid int `json:"uuid"` | 3 | +type UserLoginReq struct { |
| 4 | + Lype int `json:"type"` | ||
| 5 | + UserId int `json:"userId"` | ||
| 5 | Fromid int `json:"fromid"` | 6 | Fromid int `json:"fromid"` |
| 6 | - Sharetype int `json:"sharetype"` | 7 | + |
| 8 | +} | ||
| 9 | + | ||
| 10 | +type UserLoginData struct { | ||
| 11 | + UserId string `json:"userId"` | ||
| 12 | + AccessToken string `json:"accessToken"` | ||
| 13 | + LoginType int `json:"loginType"` | ||
| 14 | + Nickname string `json:"nickname"` | ||
| 15 | + HeadImg string `json:"headImg"` | ||
| 7 | } | 16 | } |
| 8 | 17 | ||
| 9 | type UserLoginResp struct { | 18 | type UserLoginResp struct { |
| 10 | Code int `json:"code"` | 19 | Code int `json:"code"` |
| 20 | + Data UserLoginData `json:"data"` | ||
| 11 | Message string `json:"message"` | 21 | Message string `json:"message"` |
| 12 | - Gold int64 `json:"gold"` | ||
| 13 | - Love int64 `json:"love"` | ||
| 14 | - Goldrate int64 `json:"goldrate"` | ||
| 15 | - Loverate int64 `json:"loverate"` | ||
| 16 | - Highestlv int `json:"highestlv"` | ||
| 17 | - Curboxlv int `json:"curboxlv"` | ||
| 18 | - Isdoublegold int `json:"isdoublegold"` | ||
| 19 | - Isauto int `json:"isauto"` | ||
| 20 | - Offlinegold int64 `json:"offlinegold"` | ||
| 21 | - Offlinelove int64 `json:"offlinelove"` | ||
| 22 | - Data []DataDesc `json:"data"` | ||
| 23 | } | 22 | } |
| 24 | 23 | ||
| 25 | type GetUserDataReq struct { | 24 | type GetUserDataReq struct { |
| @@ -403,6 +402,8 @@ type AchieveMentData struct { | @@ -403,6 +402,8 @@ type AchieveMentData struct { | ||
| 403 | 402 | ||
| 404 | //玩家数据 | 403 | //玩家数据 |
| 405 | type UserData struct { | 404 | type UserData struct { |
| 405 | + UserId int //玩家id | ||
| 406 | + RegTime int //注册时间 | ||
| 406 | Gold int64 //金币 | 407 | Gold int64 //金币 |
| 407 | Love int64 //爱心值 | 408 | Love int64 //爱心值 |
| 408 | Goldrate int64 //金币生成速率 | 409 | Goldrate int64 //金币生成速率 |
| @@ -0,0 +1,116 @@ | @@ -0,0 +1,116 @@ | ||
| 1 | +package logic | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "HttpServer/jsonconf" | ||
| 5 | + "HttpServer/redishandler" | ||
| 6 | + "common/logger" | ||
| 7 | + "common/redis" | ||
| 8 | + "encoding/json" | ||
| 9 | + "strconv" | ||
| 10 | + "time" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func SaveUserInfo(data *UserData, uniqueid string) error { | ||
| 14 | + | ||
| 15 | + savestr, err := json.Marshal(data) | ||
| 16 | + if err != nil { | ||
| 17 | + return err | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + err = redishandler.GetRedisClient().HSet(redis.USER_INFO__KEY, uniqueid, string(savestr)) | ||
| 21 | + | ||
| 22 | + return err | ||
| 23 | +} | ||
| 24 | + | ||
| 25 | +func GetUserInfo(uid string) (*UserData, error) { | ||
| 26 | + | ||
| 27 | + data, err := redishandler.GetRedisClient().HGet(redis.USER_INFO__KEY, uid) | ||
| 28 | + if err != nil { | ||
| 29 | + return nil, err | ||
| 30 | + } | ||
| 31 | + var tmp UserData | ||
| 32 | + err = json.Unmarshal([]byte(data), &tmp) | ||
| 33 | + if err != nil { | ||
| 34 | + return nil, err | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + return &tmp, nil | ||
| 38 | +} | ||
| 39 | + | ||
| 40 | +//初始化玩家信息 | ||
| 41 | +func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int) { | ||
| 42 | + udata := new(UserData) | ||
| 43 | + udata.Gold = 0 | ||
| 44 | + udata.Love = 0 | ||
| 45 | + udata.InviteId = data.Fromid | ||
| 46 | + udata.Highestlv = 0 | ||
| 47 | + udata.CurBoxLv = 1 | ||
| 48 | + udata.IsDouble = 0 | ||
| 49 | + udata.IsAuto = 0 | ||
| 50 | + udata.IsBoxAcc = 0 | ||
| 51 | + udata.RandGiftDay = time.Now().Day() | ||
| 52 | + udata.RandGiftNum = 6 | ||
| 53 | + udata.RandGiftTime = int(time.Now().Unix()) | ||
| 54 | + udata.Redbag = 0 | ||
| 55 | + udata.IsFirstRedBgCat = 0 | ||
| 56 | + | ||
| 57 | + //初始化16个猫爬架 | ||
| 58 | + for i := 0; i < 16; i++ { | ||
| 59 | + var d1 PosData | ||
| 60 | + d1.Pos = i | ||
| 61 | + d1.Catlv = 0 | ||
| 62 | + udata.PosInfo = append(udata.PosInfo, d1) | ||
| 63 | + var d2 DataDesc | ||
| 64 | + d2.Pos = i | ||
| 65 | + d2.Catlv = 0 | ||
| 66 | + | ||
| 67 | + } | ||
| 68 | + udata.Goldrate = 0 | ||
| 69 | + udata.Loverate = 0 | ||
| 70 | + | ||
| 71 | + | ||
| 72 | + //初始化商店信息 | ||
| 73 | + initcatcfg := jsonconf.GetCatConfig(1) | ||
| 74 | + if initcatcfg == nil { | ||
| 75 | + logger.Error("get 1catcfg err") | ||
| 76 | + return | ||
| 77 | + } | ||
| 78 | + var info BuyCatInfoData | ||
| 79 | + info.Buytime = 0 | ||
| 80 | + info.CurPrice,_= strconv.ParseInt(initcatcfg.Price,10,64) | ||
| 81 | + info.IsMaxBuytime = 0 | ||
| 82 | + udata.BuyCatInfo = append(udata.BuyCatInfo, info) | ||
| 83 | + | ||
| 84 | + //初始化猫咖门店数据 | ||
| 85 | + udata.CatShopInfo.LeftTime = 0 | ||
| 86 | + udata.CatShopInfo.Chapter = 1 | ||
| 87 | + udata.CatShopInfo.DayNum = time.Now().Day() | ||
| 88 | + udata.CatShopInfo.IsPlaying = 0 | ||
| 89 | + udata.CatShopInfo.PlayTimes = 0 | ||
| 90 | + udata.CatShopInfo.Section = 1 | ||
| 91 | + udata.CatShopInfo.ThisIsWatch = 0 | ||
| 92 | + udata.CatShopInfo.TotalWatchNumLeft = 8 // | ||
| 93 | + | ||
| 94 | + logger.Info("Init user data=%v", udata) | ||
| 95 | + | ||
| 96 | + //保存redis | ||
| 97 | + SaveUserInfo(udata, strconv.Itoa(uuid)) | ||
| 98 | + | ||
| 99 | + | ||
| 100 | + //初始化玩家仓库信息 | ||
| 101 | + pware := new(UserWareHouseData) | ||
| 102 | + for i := 0; i < 15; i++ { | ||
| 103 | + var tmp WareHouseDesc | ||
| 104 | + tmp.Warelv = 0 | ||
| 105 | + pware.Info = append(pware.Info, tmp) | ||
| 106 | + } | ||
| 107 | + wares, err := json.Marshal(pware) | ||
| 108 | + if err != nil { | ||
| 109 | + logger.Info("InitUserInfo warehouse failed err=%v", err) | ||
| 110 | + } | ||
| 111 | + redishandler.GetRedisClient().HSet(redis.USER_WAREHOUSE_INFO, strconv.Itoa(uuid), string(wares)) | ||
| 112 | + | ||
| 113 | + //保存此次计算时间 | ||
| 114 | + nowtimestr := strconv.Itoa(int(time.Now().Unix())) | ||
| 115 | + redishandler.GetRedisClient().HSet(redis.USER_LAST_CALC_TIME, strconv.Itoa(uuid), nowtimestr) | ||
| 116 | +} | ||
| 0 | \ No newline at end of file | 117 | \ No newline at end of file |
src/HttpServer/logic/httpserver.go
| @@ -169,37 +169,37 @@ func CheckErr(err error) { | @@ -169,37 +169,37 @@ func CheckErr(err error) { | ||
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | func startServerHttpServe() { | 171 | func startServerHttpServe() { |
| 172 | - http.HandleFunc("/cat/login", UserLogin) //登录 | ||
| 173 | - http.HandleFunc("/cat/getuserdata", GetUserData) //拉取用户数据 | ||
| 174 | - http.HandleFunc("/cat/exchangetwoPos", ExchangePos) //交换位置 | ||
| 175 | - http.HandleFunc("/cat/clickcatbox", ClickCatBox) //请求点击猫箱子 | ||
| 176 | - http.HandleFunc("/cat/upgradecatbox", UpgradeCatBox) //请求点击猫箱子 | ||
| 177 | - http.HandleFunc("/cat/acclecte", AcclecteGold) //请求点击猫箱子 | ||
| 178 | - http.HandleFunc("/cat/automerge", AutoMerge) //请求自动合成 | ||
| 179 | - http.HandleFunc("/cat/generatebox", GenerateBox) //请求点击猫箱子 | ||
| 180 | - http.HandleFunc("/cat/clickrandgift", ClickRandGift) //请求点击猫箱子 | ||
| 181 | - http.HandleFunc("/cat/querybuycat", QueryBuyCat) //请求商店购买信息 | ||
| 182 | - http.HandleFunc("/cat/dobuycat", DoBuyCat) //购买猫 | ||
| 183 | - http.HandleFunc("/cat/querwarehouse", QueryWareHouse) //请求仓库信息 | ||
| 184 | - http.HandleFunc("/cat/putcattowarehouse", PutCattoWareHouse) //将合成界面的猫放入仓库 | ||
| 185 | - http.HandleFunc("/cat/takecatoutfromwarehouse", TakeCatoutfromWareHouse) //将仓库的猫取出 | ||
| 186 | - http.HandleFunc("/cat/acclecteboxrate ", AcclecteBoxRate) //请求点击猫箱子 | ||
| 187 | - http.HandleFunc("/cat/queryautomergeinfo ", QueryAutomergeInfo) //请求点击猫箱子 | ||
| 188 | - http.HandleFunc("/cat/querycatroominfo ", QueryCatRoomInfo) //请求点击猫箱子 | ||
| 189 | - http.HandleFunc("/cat/buycatroom ", BuyCatRoom) //请求点击猫箱子 | ||
| 190 | - http.HandleFunc("/cat/upcattoroom ", UpCattoRoom) //请求点击猫箱子 | ||
| 191 | - http.HandleFunc("/cat/querycatshopinfo ", QueryCatShopInfo) //请求点击猫箱子 | ||
| 192 | - http.HandleFunc("/cat/catshoplay ", CatShoPlay) //请求点击猫箱子 | ||
| 193 | - http.HandleFunc("/cat/getcatshopreward ", GetCatShopReward) //请求点击猫箱子 | ||
| 194 | - http.HandleFunc("/cat/acclectecatstory ", AcclecteCatStory) //请求点击猫箱子 | ||
| 195 | - http.HandleFunc("/cat/updateuserinfo ", UpdateUserInfo) //请求点击猫箱子 | ||
| 196 | - http.HandleFunc("/cat/queryplayerrank ", QueryPlayerRank) //请求点击猫箱子 | ||
| 197 | - http.HandleFunc("/cat/querycompletetask ", QueryCompleteTask) //请求点击猫箱子 | ||
| 198 | - http.HandleFunc("/cat/querycompleteachievement ", QueryCompleteAchievement) //请求点击猫箱子 | ||
| 199 | - http.HandleFunc("/cat/gettaskreward ", GetTaskReward) //请求点击猫箱子 | ||
| 200 | - http.HandleFunc("/cat/getachievereward ", GetAchieveReward) //请求点击猫箱子 | ||
| 201 | - http.HandleFunc("/cat/startonlinetask ", StartOnlineTask) //请求开始在线时长任务 | ||
| 202 | - http.HandleFunc("/cat/getofflinereward ", GetOfflineReward) //请求开始在线时长任务 | 172 | + http.HandleFunc("/happycat/login", UserLogin) //登录 |
| 173 | + http.HandleFunc("/happycat/getuserdata", GetUserData) //拉取用户数据 | ||
| 174 | + http.HandleFunc("/happycat/exchangetwoPos", ExchangePos) //交换位置 | ||
| 175 | + http.HandleFunc("/happycat/clickcatbox", ClickCatBox) //请求点击猫箱子 | ||
| 176 | + http.HandleFunc("/happycat/upgradecatbox", UpgradeCatBox) //请求点击猫箱子 | ||
| 177 | + http.HandleFunc("/happycat/acclecte", AcclecteGold) //请求点击猫箱子 | ||
| 178 | + http.HandleFunc("/happycat/automerge", AutoMerge) //请求自动合成 | ||
| 179 | + http.HandleFunc("/happycat/generatebox", GenerateBox) //请求点击猫箱子 | ||
| 180 | + http.HandleFunc("/happycat/clickrandgift", ClickRandGift) //请求点击猫箱子 | ||
| 181 | + http.HandleFunc("/happycat/querybuycat", QueryBuyCat) //请求商店购买信息 | ||
| 182 | + http.HandleFunc("/happycat/dobuycat", DoBuyCat) //购买猫 | ||
| 183 | + http.HandleFunc("/happycat/querwarehouse", QueryWareHouse) //请求仓库信息 | ||
| 184 | + http.HandleFunc("/happycat/putcattowarehouse", PutCattoWareHouse) //将合成界面的猫放入仓库 | ||
| 185 | + http.HandleFunc("/happycat/takecatoutfromwarehouse", TakeCatoutfromWareHouse) //将仓库的猫取出 | ||
| 186 | + http.HandleFunc("/happycat/acclecteboxrate ", AcclecteBoxRate) //请求点击猫箱子 | ||
| 187 | + http.HandleFunc("/happycat/queryautomergeinfo ", QueryAutomergeInfo) //请求点击猫箱子 | ||
| 188 | + http.HandleFunc("/happycat/querycatroominfo ", QueryCatRoomInfo) //请求点击猫箱子 | ||
| 189 | + http.HandleFunc("/happycat/buycatroom ", BuyCatRoom) //请求点击猫箱子 | ||
| 190 | + http.HandleFunc("/happycat/upcattoroom ", UpCattoRoom) //请求点击猫箱子 | ||
| 191 | + http.HandleFunc("/happycat/querycatshopinfo ", QueryCatShopInfo) //请求点击猫箱子 | ||
| 192 | + http.HandleFunc("/happycat/catshoplay ", CatShoPlay) //请求点击猫箱子 | ||
| 193 | + http.HandleFunc("/happycat/getcatshopreward ", GetCatShopReward) //请求点击猫箱子 | ||
| 194 | + http.HandleFunc("/happycat/acclectecatstory ", AcclecteCatStory) //请求点击猫箱子 | ||
| 195 | + http.HandleFunc("/chappycatat/updateuserinfo ", UpdateUserInfo) //请求点击猫箱子 | ||
| 196 | + http.HandleFunc("/happycat/queryplayerrank ", QueryPlayerRank) //请求点击猫箱子 | ||
| 197 | + http.HandleFunc("/happycat/querycompletetask ", QueryCompleteTask) //请求点击猫箱子 | ||
| 198 | + http.HandleFunc("/happycat/querycompleteachievement ", QueryCompleteAchievement) //请求点击猫箱子 | ||
| 199 | + http.HandleFunc("/happycat/gettaskreward ", GetTaskReward) //请求点击猫箱子 | ||
| 200 | + http.HandleFunc("/happycat/getachievereward ", GetAchieveReward) //请求点击猫箱子 | ||
| 201 | + http.HandleFunc("/happycat/startonlinetask ", StartOnlineTask) //请求开始在线时长任务 | ||
| 202 | + http.HandleFunc("/happycat/getofflinereward ", GetOfflineReward) //请求开始在线时长任务 | ||
| 203 | 203 | ||
| 204 | err := http.ListenAndServe(conf.GetServerHttpAddrConf(), nil) | 204 | err := http.ListenAndServe(conf.GetServerHttpAddrConf(), nil) |
| 205 | CheckErr(err) | 205 | CheckErr(err) |
| @@ -755,8 +755,10 @@ func UserLogin(w http.ResponseWriter, r *http.Request) { | @@ -755,8 +755,10 @@ func UserLogin(w http.ResponseWriter, r *http.Request) { | ||
| 755 | w.Header().Set("Access-Control-Allow-Headers", "Authorization, Content-Length, X-CSRF-Token, Token,session,X_Requested_With,Accept, Origin, Host, Connection, Accept-Encoding, Accept-Language,DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Pragma") | 755 | w.Header().Set("Access-Control-Allow-Headers", "Authorization, Content-Length, X-CSRF-Token, Token,session,X_Requested_With,Accept, Origin, Host, Connection, Accept-Encoding, Accept-Language,DNT, X-CustomHeader, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Pragma") |
| 756 | */ | 756 | */ |
| 757 | Uuid := 0 | 757 | Uuid := 0 |
| 758 | + Token := "" | ||
| 758 | if len(r.Header) > 0 { | 759 | if len(r.Header) > 0 { |
| 759 | - Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) | 760 | + Uuid, _ = strconv.Atoi(r.Header.Get("uid")) |
| 761 | + Token = r.Header.Get("token") | ||
| 760 | } | 762 | } |
| 761 | 763 | ||
| 762 | if Uuid == 0 { | 764 | if Uuid == 0 { |
| @@ -773,9 +775,9 @@ func UserLogin(w http.ResponseWriter, r *http.Request) { | @@ -773,9 +775,9 @@ func UserLogin(w http.ResponseWriter, r *http.Request) { | ||
| 773 | r.Body.Close() | 775 | r.Body.Close() |
| 774 | 776 | ||
| 775 | s := string(result) | 777 | s := string(result) |
| 776 | - logger.Info("UserLogin , body:%v,uuid=%v", s, Uuid) | 778 | + logger.Info("UserLogin , body:%v,uuid=%v token=%v", s, Uuid,Token) |
| 777 | 779 | ||
| 778 | -// HandlerLogin(w, s, Uuid) | 780 | + HandlerLogin(w, s, Uuid,Token) |
| 779 | } | 781 | } |
| 780 | 782 | ||
| 781 | func ReviewAllianceHandler(w http.ResponseWriter, r *http.Request) { | 783 | func ReviewAllianceHandler(w http.ResponseWriter, r *http.Request) { |
src/HttpServer/logic/logic.go
| 1 | package logic | 1 | package logic |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | - "common/beegomap" | 4 | + "HttpServer/redishandler" |
| 5 | + "common/logger" | ||
| 6 | + "common/redis" | ||
| 7 | + "encoding/json" | ||
| 8 | + "fmt" | ||
| 5 | "net/http" | 9 | "net/http" |
| 10 | + "strconv" | ||
| 6 | "sync" | 11 | "sync" |
| 7 | ) | 12 | ) |
| 8 | 13 | ||
| 9 | var ( | 14 | var ( |
| 10 | - m_userInfo *beegomap.BeeMap //make(map[int32]*UserData | 15 | + //m_userInfo *beegomap.BeeMap //make(map[int32]*UserData |
| 11 | Maplock *sync.RWMutex | 16 | Maplock *sync.RWMutex |
| 12 | ) | 17 | ) |
| 13 | 18 | ||
| 14 | func init() { | 19 | func init() { |
| 15 | - m_userInfo = beegomap.NewBeeMap() | 20 | + //m_userInfo = beegomap.NewBeeMap() |
| 16 | Maplock = new(sync.RWMutex) | 21 | Maplock = new(sync.RWMutex) |
| 17 | } | 22 | } |
| 18 | 23 | ||
| @@ -20,4 +25,56 @@ func SetHeader(w http.ResponseWriter) { | @@ -20,4 +25,56 @@ func SetHeader(w http.ResponseWriter) { | ||
| 20 | w.Header().Set("Access-Control-Allow-Origin", "*") //允许访问所有域 | 25 | w.Header().Set("Access-Control-Allow-Origin", "*") //允许访问所有域 |
| 21 | w.Header().Set("Content-Type", "application/json") | 26 | w.Header().Set("Content-Type", "application/json") |
| 22 | w.Header().Set("Access-Control-Allow-Headers", "Content-Type,Uuid") | 27 | w.Header().Set("Access-Control-Allow-Headers", "Content-Type,Uuid") |
| 28 | +} | ||
| 29 | + | ||
| 30 | +func HandlerLogin(w http.ResponseWriter, data string, uuid int,token string) { | ||
| 31 | + SetHeader(w) | ||
| 32 | + var resp UserLoginResp | ||
| 33 | + resp.Code = 0 | ||
| 34 | + resp.Message = "success" | ||
| 35 | + var rdata UserLoginReq | ||
| 36 | + err := json.Unmarshal([]byte(data), &rdata) | ||
| 37 | + if err != nil { | ||
| 38 | + logger.Info("json decode HandlerLogin data failed:%v,for:%v", err, data) | ||
| 39 | + resp.Message = "json unmarshal failed" | ||
| 40 | + resp.Code = 1 | ||
| 41 | + respstr, _ := json.Marshal(&resp) | ||
| 42 | + logger.Info("###HandlerLogin###rdata:%v", string(respstr)) | ||
| 43 | + fmt.Fprint(w, string(respstr)) | ||
| 44 | + return | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + //首先判断一下是否是首次登陆 | ||
| 48 | + isexist, _ := redishandler.GetRedisClient().HExists(redis.USER_INFO__KEY, strconv.Itoa(uuid)) | ||
| 49 | + if !isexist { | ||
| 50 | + //不存在 | ||
| 51 | + //属于新登录的玩家数据 | ||
| 52 | + InitUserInfo(&rdata, &resp, uuid) | ||
| 53 | + | ||
| 54 | + } else { | ||
| 55 | + uinfo,err := GetUserInfo(strconv.Itoa(rdata.UserId)) | ||
| 56 | + if err != nil { | ||
| 57 | + logger.Info("GetUserInfo HandlerLogin data failed:%v,for:%v", err, data) | ||
| 58 | + resp.Message = "GetUserInfo failed" | ||
| 59 | + resp.Code = 2 | ||
| 60 | + respstr, _ := json.Marshal(&resp) | ||
| 61 | + fmt.Fprint(w, string(respstr)) | ||
| 62 | + return | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + resp.Data.Nickname = uinfo.NickName | ||
| 66 | + resp.Data.UserId = strconv.Itoa(rdata.UserId) | ||
| 67 | + resp.Data.AccessToken = token | ||
| 68 | + resp.Data.HeadImg = uinfo.Head | ||
| 69 | + resp.Data.LoginType = rdata.Lype | ||
| 70 | + | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + | ||
| 74 | + | ||
| 75 | + //回包 | ||
| 76 | + respstr, _ := json.Marshal(&resp) | ||
| 77 | + fmt.Fprint(w, string(respstr)) | ||
| 78 | + | ||
| 79 | + logger.Info("###HandlerLogin###rdata:%v", string(respstr)) | ||
| 23 | } | 80 | } |
| 24 | \ No newline at end of file | 81 | \ No newline at end of file |
src/common/redis/def.go
| 1 | package redis | 1 | package redis |
| 2 | 2 | ||
| 3 | const ( | 3 | const ( |
| 4 | - USER_LAST_LOGIN_TIME = "CATSERVER_USER_LAST_LOGIN_TIME" //玩家上次登陆时间 | ||
| 5 | - USER_INFO = "CATSERVER_USER_USER_INFO" //玩家数据 | ||
| 6 | - USER_LAST_CALC_TIME = "CATSERVER_USER_LAST_CALC_TIME" //玩家上一次数据计算时间 | ||
| 7 | - USER_INVITE_ID = "CATSERVER_USER_INVITE_ID" //玩家邀请者ID | ||
| 8 | - USER_STARTDOUBLE_TIME = "CATSERVER_USER_STARTDOUBLE_TIME" //开启双倍时间 | ||
| 9 | - USER_STARTAUTO_TIME = "CATSERVER_USER_STARTAUTO_TIME" //开启自动合成时间 | ||
| 10 | - USER_STARTACC_BOX_TIME = "CATSERVER_USER_STARTACC_BOX_TIME" //开启加速成产箱子 | ||
| 11 | - USER_WAREHOUSE_INFO = "CATSERVER_USER_WAREHOUSE_INFO" //玩家仓库信息 | ||
| 12 | - USER_GOLD_RANK = "CATSERVER_USER_GOLD_RANK" //玩家排行榜,根据金币排 | 4 | + USER_INFO__KEY = "HAPPYCATSERVER_USER_USER_INFO" //玩家数据 |
| 5 | + USER_LAST_CALC_TIME = "HAPPYCATSERVER_USER_LAST_CALC_TIME" //玩家上一次数据计算时间 | ||
| 6 | + USER_INVITE_ID = "HAPPYCATSERVER_USER_INVITE_ID" //玩家邀请者ID | ||
| 7 | + USER_STARTDOUBLE_TIME = "HAPPYCATSERVER_USER_STARTDOUBLE_TIME" //开启双倍时间 | ||
| 8 | + USER_STARTAUTO_TIME = "HAPPYCATSERVER_USER_STARTAUTO_TIME" //开启自动合成时间 | ||
| 9 | + USER_STARTACC_BOX_TIME = "HAPPYCATSERVER_USER_STARTACC_BOX_TIME" //开启加速成产箱子 | ||
| 10 | + USER_WAREHOUSE_INFO = "HAPPYCATSERVER_USER_WAREHOUSE_INFO" //玩家仓库信息 | ||
| 11 | + USER_GOLD_RANK = "HAPPYCATSERVER_USER_GOLD_RANK" //玩家排行榜,根据金币排 | ||
| 13 | ) | 12 | ) |