Commit e0129d0d8c2aa0a55292e5b5ee1a28294e4b1ea2
1 parent
629a330b
Exists in
master
猫咖啡接口提交
Showing
7 changed files
with
561 additions
and
467 deletions
Show diff stats
src/HttpServer/logic/datadef.go
| 1 | 1 | package logic |
| 2 | 2 | |
| 3 | -type UserLoginData struct { | |
| 4 | - //Uuid int `json:"uuid"` | |
| 5 | - Fromid int `json:"fromid"` | |
| 6 | - Sharetype int `json:"sharetype"` | |
| 7 | -} | |
| 8 | - | |
| 9 | -type UserLoginResp struct { | |
| 10 | - Code int `json:"code"` | |
| 11 | - 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 | -} | |
| 24 | - | |
| 25 | -type GetUserDataReq struct { | |
| 26 | - //Uuid int `json:"uuid"` | |
| 27 | -} | |
| 28 | - | |
| 29 | -type GetUserDataResp struct { | |
| 30 | - Code int `json:"code"` | |
| 31 | - Message string `json:"message"` | |
| 32 | - Gold int64 `json:"gold"` | |
| 33 | - Love int64 `json:"love"` | |
| 34 | - Dougoldlefttime int `json:"dougoldlefttime"` | |
| 35 | - Automlefttime int `json:"automlefttime"` | |
| 36 | - Acclcteboxlefttime int `json:"acclcteboxlefttime"` | |
| 37 | - Israndgift int `json:"israndgift"` | |
| 38 | -} | |
| 39 | - | |
| 40 | -type DataDesc struct { | |
| 41 | - Pos int `json:"pos"` | |
| 42 | - Catlv int `json:"cat_lv"` | |
| 43 | - Countdown int `json:"countdown"` | |
| 44 | -} | |
| 45 | - | |
| 46 | -type ExchangePosReq struct { | |
| 47 | - //Uuid int `json:"uuid"` | |
| 48 | - Pos_1 int `json:"pos_1"` | |
| 49 | - Pos_2 int `json:"pos_2"` | |
| 50 | -} | |
| 51 | - | |
| 52 | -type ExchangePosResp struct { | |
| 53 | - Code int `json:"code"` | |
| 54 | - Message string `json:"message"` | |
| 55 | - Pos1_lv int `json:"pos1_lv"` | |
| 56 | - Pos2_lv int `json:"pos2_lv"` | |
| 57 | - Highest_lv int `json:"highest_lv"` | |
| 58 | - Add_num int `json:"add_num"` | |
| 59 | -} | |
| 60 | - | |
| 61 | -type ClickBoxReq struct { | |
| 62 | - //Uuid int `json:"uuid"` | |
| 63 | - Pos int `json:"pos"` | |
| 64 | -} | |
| 65 | - | |
| 66 | -type ClickBoxResp struct { | |
| 67 | - Code int `json:"code"` | |
| 68 | - Message string `json:"message"` | |
| 69 | - Pos int `json:"pos"` | |
| 70 | - Lv int `json:"lv"` | |
| 71 | -} | |
| 72 | - | |
| 73 | -type UpgradeBoxReq struct { | |
| 74 | - //Uuid int `json:"uuid"` | |
| 75 | -} | |
| 76 | -type UpgradeBoxResp struct { | |
| 77 | - Code int `json:"code"` | |
| 78 | - Message string `json:"message"` | |
| 79 | - Boxlv int `json:"boxlv"` | |
| 80 | -} | |
| 81 | - | |
| 82 | -type GenerateBoxReq struct { | |
| 83 | - //Uuid int `json:"uuid"` | |
| 84 | - Pos int `json:"pos"` | |
| 85 | -} | |
| 86 | - | |
| 87 | -type GenerateBoxResp struct { | |
| 88 | - Code int `json:"code"` | |
| 89 | - Message string `json:"message"` | |
| 90 | -} | |
| 91 | - | |
| 92 | -type AcclecteReq struct { | |
| 93 | - //Uuid int `json:"uuid"` | |
| 94 | -} | |
| 95 | -type AcclecteResp struct { | |
| 96 | - Code int `json:"code"` | |
| 97 | - Message string `json:"message"` | |
| 98 | -} | |
| 99 | - | |
| 100 | -type AcclecteBoxResp struct { | |
| 101 | - Code int `json:"code"` | |
| 102 | - Message string `json:"message"` | |
| 103 | -} | |
| 104 | - | |
| 105 | -type AutomergeReq struct { | |
| 106 | - //Uuid int `json:"uuid"` | |
| 107 | -} | |
| 108 | -type AutomergeResp struct { | |
| 109 | - Code int `json:"code"` | |
| 110 | - Message string `json:"message"` | |
| 111 | -} | |
| 112 | - | |
| 113 | -type QueryBuyCatReq struct { | |
| 114 | - //Uuid int `json:"uuid"` | |
| 115 | -} | |
| 116 | -type QueryBuyCatResp struct { | |
| 117 | - Code int `json:"code"` | |
| 118 | - Message string `json:"message"` | |
| 119 | - Maxcatlv int `json:"maxcatlv"` | |
| 120 | - Data []BuyCatDesc `json:"data"` | |
| 121 | -} | |
| 122 | - | |
| 123 | -type BuyCatDesc struct { | |
| 124 | - Lv int `json:"lv"` | |
| 125 | - Goldnum int64 `json:"goldnum"` | |
| 126 | -} | |
| 127 | - | |
| 128 | -type ClickRandGiftReq struct { | |
| 129 | - //Uuid int `json:"uuid"` | |
| 130 | -} | |
| 131 | -type ClickRandGiftResp struct { | |
| 132 | - Code int `json:"code"` | |
| 133 | - Message string `json:"message"` | |
| 134 | - Gold int64 `json:"gold"` | |
| 135 | - Lefttime int `json:"lefttime"` | |
| 136 | -} | |
| 137 | - | |
| 138 | -type DoBuyCatReq struct { | |
| 139 | - Lv int `json:"lv"` | |
| 140 | -} | |
| 141 | -type DoBuyCatResp struct { | |
| 142 | - Code int `json:"code"` | |
| 143 | - Message string `json:"message"` | |
| 144 | - Pos int `json:"pos"` | |
| 145 | -} | |
| 146 | - | |
| 147 | -type QueryWareHouseResp struct { | |
| 148 | - Code int `json:"code"` | |
| 149 | - Message string `json:"message"` | |
| 150 | - Data []DataDesc `json:"data"` | |
| 151 | -} | |
| 152 | - | |
| 153 | -type QueryAutomergeResp struct { | |
| 154 | - Code int `json:"code"` | |
| 155 | - Message string `json:"message"` | |
| 156 | - Goldrate int64 `json:"goldrate"` | |
| 157 | - Higestlv int `json:"higestlv"` | |
| 158 | - Curcatjianum int `json:"curcatjianum"` | |
| 159 | - Data []DataDesc `json:"data"` | |
| 160 | -} | |
| 161 | - | |
| 162 | -type PutWareHouseReq struct { | |
| 163 | - Pos int `json:"pos"` | |
| 164 | -} | |
| 165 | -type PutWareHouseResp struct { | |
| 166 | - Code int `json:"code"` | |
| 167 | - Message string `json:"message"` | |
| 168 | - Warepos int `json:"warepos"` | |
| 169 | -} | |
| 170 | - | |
| 171 | -type TakeWareHouseReq struct { | |
| 172 | - Warepos int `json:"warepos"` | |
| 173 | -} | |
| 174 | -type TakeWareHouseResp struct { | |
| 175 | - Code int `json:"code"` | |
| 176 | - Message string `json:"message"` | |
| 177 | - Pos int `json:"pos"` | |
| 178 | -} | |
| 179 | 3 | |
| 180 | -type CatRoomDesc struct { | |
| 181 | - Pos int `json:"pos"` | |
| 182 | - Catlv int `json:"cat_lv"` | |
| 183 | -} | |
| 4 | +//登录类型枚举 | |
| 5 | +const ( | |
| 6 | + LOGIN_TYPE_TOURIST = 1 //游客登录 | |
| 7 | + LOGIN_TYPE_ACCOUNT = 2 //账号密码登录 | |
| 8 | + LOGIN_TYPE_WECHAT = 3 //微信登录 | |
| 184 | 9 | |
| 185 | -type QueryCatRoomInfoResp struct { | |
| 186 | - Code int `json:"code"` | |
| 187 | - Message string `json:"message"` | |
| 188 | - Data []CatRoomDesc `json:"data"` | |
| 189 | -} | |
| 10 | +) | |
| 190 | 11 | |
| 191 | -type BuyCatRoomReq struct { | |
| 12 | +type UserLoginReq struct { | |
| 13 | + Channel_id int `json:"channel_id"` | |
| 14 | + Invite_type int `json:"invite_type"` | |
| 15 | + Invite_res_id int `json:"invite_res_id"` | |
| 16 | + User_invite_uid int `json:"user_invite_uid"` | |
| 17 | + Scene int `json:"scene"` | |
| 18 | + RefAppId int `json:"refAppId"` | |
| 19 | + Code string `json:"code"` | |
| 20 | + Token string `json:"token"` | |
| 21 | + Logintype int `json:"logintype"` | |
| 22 | + Useraccount string `json:"useraccount"` | |
| 23 | + Userpwd string `json:"userpwd"` | |
| 24 | + Version string `json:"version"` | |
| 25 | + | |
| 26 | +} | |
| 27 | + | |
| 28 | +type UserBaseData struct { | |
| 29 | + User_id int `json:"user_id"` | |
| 30 | + User_gender int `json:"user_gender"` | |
| 31 | + User_nickname string `json:"user_nickname"` | |
| 32 | + User_openid string `json:"user_openid"` | |
| 33 | + User_avatar_url string `json:"user_avatar_url"` | |
| 34 | + User_city string `json:"user_city"` | |
| 35 | + User_token string `json:"user_token"` | |
| 36 | +} | |
| 37 | + | |
| 38 | +type UserExtData struct { | |
| 39 | + User_id int `json:"user_id"` | |
| 40 | + Hot int `json:"hot"` | |
| 41 | + Coin int64 `json:"coin"` | |
| 42 | + LoveExp int `json:"loveExp"` | |
| 43 | + Bean int `json:"bean"` | |
| 44 | + ShopNum int `json:"shopNum"` | |
| 192 | 45 | Lv int `json:"lv"` |
| 46 | + Exp int `json:"exp"` | |
| 47 | + User_invite_uid int `json:"user_invite_uid"` | |
| 48 | + User_reg_time int `json:"user_reg_time"` | |
| 49 | + User_channel int `json:"user_channel"` | |
| 50 | + User_is_black int `json:"user_is_black"` | |
| 51 | + User_scene int `json:"user_scene"` | |
| 52 | + Reg_time int `json:"reg_time"` | |
| 53 | + Invite_uid int `json:"invite_uid"` | |
| 193 | 54 | } |
| 194 | 55 | |
| 195 | -type BuyCatRoomResp struct { | |
| 196 | - Code int `json:"code"` | |
| 197 | - Message string `json:"message"` | |
| 198 | -} | |
| 199 | - | |
| 200 | -type UpCattoRoomReq struct { | |
| 201 | - Roompos int `json:"roompos"` | |
| 202 | - Callv int `json:"callv"` | |
| 203 | - Optype int `json:"optype"` | |
| 204 | -} | |
| 205 | - | |
| 206 | -type UpCattoRoommResp struct { | |
| 207 | - Code int `json:"code"` | |
| 208 | - Message string `json:"message"` | |
| 209 | -} | |
| 210 | - | |
| 211 | -type QueryCatShopInfoResp struct { | |
| 212 | - Code int `json:"code"` | |
| 213 | - Message string `json:"message"` | |
| 214 | - Chapter int `json:"chapter"` | |
| 215 | - Section int `json:"section"` | |
| 216 | - Lefttime int `json:"lefttime"` | |
| 217 | - Canwatch int `json:"canwatch"` | |
| 218 | - Storyhappen int `json:"storyhappen"` | |
| 219 | -} | |
| 220 | - | |
| 221 | -type CatShoPlayReq struct { | |
| 222 | - Catlv int `json:"catlv"` | |
| 223 | -} | |
| 224 | -type CatShoPlayResp struct { | |
| 225 | - Code int `json:"code"` | |
| 226 | - Message string `json:"message"` | |
| 227 | - Lefttime int `json:"lefttime"` | |
| 228 | - Canwatch int `json:"canwatch"` | |
| 229 | -} | |
| 230 | - | |
| 231 | -type GetCatShopRewardReq struct { | |
| 232 | - Optype int `json:"optype"` | |
| 233 | -} | |
| 234 | - | |
| 235 | -type GetCatShopRewardResp struct { | |
| 236 | - Code int `json:"code"` | |
| 237 | - Message string `json:"message"` | |
| 238 | - Love int64 `json:"love"` | |
| 239 | -} | |
| 240 | - | |
| 241 | -type AcclecteCatStoryResp struct { | |
| 242 | - Code int `json:"code"` | |
| 243 | - Message string `json:"message"` | |
| 244 | -} | |
| 245 | - | |
| 246 | -type UpdateUserInfoReq struct { | |
| 247 | - Headurl string `json:"headurl"` | |
| 248 | - Nickname string `json:"nickname"` | |
| 249 | - Realname string `json:"realname"` | |
| 250 | -} | |
| 251 | - | |
| 252 | -type UpdateUserInfoResp struct { | |
| 253 | - Code int `json:"code"` | |
| 254 | - Message string `json:"message"` | |
| 56 | +type UserLoginData struct { | |
| 57 | + Dasedata UserBaseData `json:"UserBaseData"` | |
| 58 | + Extdata UserExtData `json:"user_ext_data"` | |
| 255 | 59 | } |
| 256 | 60 | |
| 257 | -type RankInfoDesc struct { | |
| 258 | - Rank int `json:"rank"` | |
| 259 | - Headurl string `json:"headurl"` | |
| 260 | - Nickname string `json:"nickname"` | |
| 261 | - Catlv int `json:"catlv"` | |
| 262 | - Goldnum int64 `json:"goldnum"` | |
| 61 | +type UserLoginResult struct { | |
| 62 | + Code int `json:"code"` | |
| 63 | + Data UserLoginData `json:"data"` | |
| 263 | 64 | } |
| 264 | 65 | |
| 265 | -type QueryPlayerRankResp struct { | |
| 266 | - Code int `json:"code"` | |
| 267 | - Message string `json:"message"` | |
| 268 | - Data []RankInfoDesc `json:"data"` | |
| 269 | -} | |
| 270 | 66 | |
| 271 | -type QueryCompleteTaskDesc struct { | |
| 272 | - Taskid int `json:"taskid"` | |
| 273 | -} | |
| 274 | 67 | |
| 275 | -type QueryOnlienTaskDesc struct { | |
| 276 | - Taskid int `json:"taskid"` | |
| 277 | - Lefttime int64 `json:"lefttime"` | |
| 278 | -} | |
| 68 | +type UserLoginResp struct { | |
| 69 | + Status string `json:"status"` | |
| 70 | + Result UserLoginResult `json:"result"` | |
| 279 | 71 | |
| 280 | -type QueryCompleteTaskResp struct { | |
| 281 | - Code int `json:"code"` | |
| 282 | - Message string `json:"message"` | |
| 283 | - Data []QueryCompleteTaskDesc `json:"data"` | |
| 284 | - Online []QueryOnlienTaskDesc `json:"online"` | |
| 285 | 72 | } |
| 286 | 73 | |
| 287 | -type QueryCompleteAchievementDesc struct { | |
| 288 | - Achieveid int `json:"achieveid"` | |
| 74 | +type SaveUserDataReq struct{ | |
| 75 | + Token string `json:"token"` | |
| 76 | + Hot int `json:"hot"` | |
| 77 | + Coin int64 `json:"coin"` | |
| 78 | + Loveexp int `json:"loveexp"` | |
| 79 | + Bean int `json:"bean"` | |
| 80 | + Shopnum int `json:"shopnum"` | |
| 289 | 81 | } |
| 290 | 82 | |
| 291 | -type QueryCompleteAchievementResp struct { | |
| 292 | - Code int `json:"code"` | |
| 293 | - Message string `json:"message"` | |
| 294 | - Data []QueryCompleteAchievementDesc `json:"data"` | |
| 83 | +type SaveUserDataResp struct { | |
| 84 | + Status string `json:"status"` | |
| 85 | + Result UserLoginResult `json:"result"` | |
| 295 | 86 | } |
| 296 | 87 | |
| 297 | -type GetTaskRewardReq struct { | |
| 298 | - Taskid int `json:"taskid"` | |
| 88 | +type CommonResult struct { | |
| 89 | + Code int `json:"code"` | |
| 90 | + Data string `json:"data"` | |
| 299 | 91 | } |
| 300 | 92 | |
| 301 | -type GetTaskRewardResp struct { | |
| 302 | - Code int `json:"code"` | |
| 303 | - Message string `json:"message"` | |
| 93 | +type SaveDataReq struct{ | |
| 94 | + Token string `json:"token"` | |
| 95 | + Field string `json:"field"` | |
| 96 | + Value string `json:"value"` | |
| 304 | 97 | } |
| 305 | 98 | |
| 306 | -type GetAchieveRewardReq struct { | |
| 307 | - Achieveid int `json:"achieveid"` | |
| 99 | +type SaveDataResp struct { | |
| 100 | + Status string `json:"status"` | |
| 101 | + Result CommonResult `json:"result"` | |
| 308 | 102 | } |
| 309 | 103 | |
| 310 | -type GetAchieveRewardResp struct { | |
| 311 | - Code int `json:"code"` | |
| 312 | - Message string `json:"message"` | |
| 104 | +type GetDataDesc struct { | |
| 105 | + Base_data string `json:"base_data"` | |
| 313 | 106 | } |
| 314 | 107 | |
| 315 | -type StartOnlineTaskReq struct { | |
| 316 | - Taskid int `json:"taskid"` | |
| 108 | +type GetDataResult struct { | |
| 109 | + Code int `json:"code"` | |
| 110 | + Data GetDataDesc `json:"data"` | |
| 317 | 111 | } |
| 318 | 112 | |
| 319 | -type StartOnlineTaskResp struct { | |
| 320 | - Code int `json:"code"` | |
| 321 | - Message string `json:"message"` | |
| 322 | - Lefttime int `json:"lefttime"` | |
| 113 | +type GetDataReq struct{ | |
| 114 | + Token string `json:"token"` | |
| 115 | + Field string `json:"field"` | |
| 323 | 116 | } |
| 324 | 117 | |
| 325 | -type GetOfflineRewardReq struct { | |
| 326 | - Optype int `json:"optype"` | |
| 118 | +type GetDataResp struct { | |
| 119 | + Status string `json:"status"` | |
| 120 | + Result GetDataResult `json:"result"` | |
| 327 | 121 | } |
| 328 | 122 | |
| 329 | -type GetOfflineRewardResp struct { | |
| 330 | - Code int `json:"code"` | |
| 331 | - Message string `json:"message"` | |
| 332 | - Gold int64 `json:"gold"` | |
| 333 | - Love int64 `json:"love"` | |
| 334 | -} | |
| 335 | 123 | |
| 336 | 124 | //********************************************************************************************************** |
| 337 | 125 | |
| 338 | -type PosData struct { | |
| 339 | - Pos int | |
| 340 | - Catlv int | |
| 341 | - Countdown int //倒计时 为0表示没有 | |
| 342 | - //UpPos int //上阵的位置 0表示未上阵 | |
| 343 | -} | |
| 344 | - | |
| 345 | -//玩家购买猫详情 | |
| 346 | -type BuyCatInfoData struct { | |
| 347 | - Buytime int //购买次数 | |
| 348 | - IsMaxBuytime int //是否达到涨价上线 1是0否 | |
| 349 | - CurPrice int64 //当前价格 | |
| 350 | -} | |
| 351 | - | |
| 352 | -//猫咖店家具数据 | |
| 353 | -type CatRoomData struct { | |
| 354 | - LvCatlv int //入住猫的等级 | |
| 355 | -} | |
| 356 | - | |
| 357 | -//猫咖门店数据 | |
| 358 | -type CatShopData struct { | |
| 359 | - Chapter int //当前所处进度 对应shopcaofig的id | |
| 360 | - Section int //当前小节进度 ,即当前大章节第几次故事 | |
| 361 | - IsPlaying int //是否处于探险模式 1是0否 | |
| 362 | - LeftTime int //探险剩余时间 | |
| 363 | - PlayTimes int //当前为第几次探险 | |
| 364 | - DayNum int //当天日期,用于判断跨天 | |
| 365 | - TotalWatchNumLeft int //当天剩余看视频次数 | |
| 366 | - ThisIsWatch int //本次探险是否已经看过视频 | |
| 367 | - IsMax int //是否已经通关 1是0否 | |
| 368 | - CurCatLv int //参加探险的猫等级 | |
| 369 | - IsStoryHappen int //此次是否触发故事 | |
| 370 | -} | |
| 371 | - | |
| 372 | -//玩家排行榜数据 | |
| 373 | -type UserRankInfo struct { | |
| 374 | - Gold int64 //金币 | |
| 375 | - Head string //头像地址 | |
| 376 | - NickName string //昵称 | |
| 377 | - Highestlv int //当前最高猫等级 | |
| 378 | - Uuid int //uuid | |
| 379 | -} | |
| 380 | - | |
| 381 | -//玩家任务数据 每日清零 | |
| 382 | -type TaskData struct { | |
| 383 | - //StartOnline int //开始计算在线时间 | |
| 384 | - StartOnline map[int]int64 //记录对应takid 和开始计时的时间 | |
| 385 | - BuyCatTime int //商店购买猫次数 | |
| 386 | - MergeTime int //合成猫次数 | |
| 387 | - PlayWithTime int //陪玩次数 | |
| 388 | - WatchAddTime int //看广告次数 | |
| 389 | - CompleteId map[int]int //已经完成的任务的id,对应task表的id value无用 | |
| 390 | - HaveComplete map[int]int //记录当日已完成的任务,已完成则不再完成 | |
| 391 | -} | |
| 392 | - | |
| 393 | -//玩家成就数据 | |
| 394 | -type AchieveMentData struct { | |
| 395 | - GetNewCatTime int //累计解锁新猫次数 | |
| 396 | - GetAllJia int //累计获得猫爬架次数 | |
| 397 | - GetRoomJu int //累计解锁新家具次数 | |
| 398 | - StoryTime int //累计解锁故事 | |
| 399 | - ShopTime int //累计解锁店铺 | |
| 400 | - CompleteId map[int]int //已经完成的任务的id,对应achievement表id value为无用 | |
| 401 | - HaveComplete map[int]int //记录已完成成就已完成则不再触发 | |
| 402 | -} | |
| 403 | 126 | |
| 404 | 127 | //玩家数据 |
| 405 | 128 | type UserData struct { |
| 406 | - Gold int64 //金币 | |
| 407 | - Love int64 //爱心值 | |
| 408 | - Goldrate int64 //金币生成速率 | |
| 409 | - Loverate int64 //爱心生产速率 | |
| 410 | - Highestlv int //当前最高猫等级 | |
| 411 | - InviteId int //邀请者uid | |
| 412 | - CurBoxLv int //当前猫箱子等级 | |
| 413 | - IsDouble int //当前加速标签 1表示双倍收益 0表示正常 | |
| 414 | - IsAuto int //当前是否自动合成 | |
| 415 | - IsBoxAcc int //是否处于加速生成箱子状态 | |
| 416 | - RandGiftNum int //当前剩余空投猫粮次数 | |
| 417 | - RandGiftDay int //记录当前猫粮日期,当日期变化则重置RandGiftNum | |
| 418 | - RandGiftTime int //记录上一次空投猫粮时间 | |
| 419 | - Redbag int //红包值 单位为分 | |
| 420 | - Head string //头像地址 | |
| 421 | - NickName string //昵称 | |
| 422 | - RealName string //实名 | |
| 423 | - IsFirstRedBgCat int //是否合成过红包猫 0表示否1表示是 | |
| 424 | - OfflineGold int64 //离线金币 | |
| 425 | - OfflineLove int64 //离线爱心 | |
| 426 | - CatShopInfo CatShopData //猫咖门店数据 | |
| 427 | - Taskinfo TaskData //任务数据 | |
| 428 | - AchieveMent AchieveMentData //成就数据 | |
| 429 | - PosInfo []PosData //位置信息 从0开始 | |
| 430 | - BuyCatInfo []BuyCatInfoData //商店购买猫数据 第一个元素为1级猫 第二个为2级猫以此类推 | |
| 431 | - CatRoomInfo []CatRoomData //猫咖店数据 | |
| 129 | + Userid int //玩家id | |
| 130 | + Hot int | |
| 131 | + Coin int64 //金币 | |
| 132 | + Loevexp int | |
| 133 | + Bean int //咖啡豆 | |
| 134 | + Shopnum int //店铺数量 | |
| 135 | + Lv int | |
| 136 | + Exp int | |
| 137 | + UserInviteId int | |
| 138 | + Userregtime int | |
| 139 | + Channel int | |
| 140 | + Isblack int | |
| 141 | + Scene int | |
| 142 | + Regtime int | |
| 143 | + InviteUid int | |
| 432 | 144 | |
| 433 | 145 | } |
| 434 | 146 | |
| 435 | -//仓库数据详情 | |
| 436 | -type WareHouseDesc struct { | |
| 437 | - Warelv int //红包猫等级 对应表id | |
| 438 | -} | |
| 439 | - | |
| 440 | -//玩家仓库数据 | |
| 441 | -type UserWareHouseData struct { | |
| 442 | - Info []WareHouseDesc //下标表示位置 | |
| 443 | -} | |
| 444 | - | |
| 445 | -const ( | |
| 446 | - TASK_TYPE_ONLINE = 1 //在线 | |
| 447 | - TASK_TYPE_BUYCAT = 2 //商店购买猫 | |
| 448 | - TASK_TYPE_MERGE = 3 //合成猫 | |
| 449 | - TASK_TYPE_PLAYWITHCAT = 4 //猫咪陪玩 | |
| 450 | - TASK_TYPE_WATCHADD = 5 //观看广告 | |
| 451 | - ACH_TYPE_GETCAT = 6 //累计解锁猫 | |
| 452 | - ACH_TYPE_GETCATJIA = 7 //累计获得猫爬架 | |
| 453 | - ACH_TYPE_GETCATROOMJIA = 8 //累计解锁新家具 | |
| 454 | - ACH_TYPE_GETSTORY = 9 //累计解锁新故事 | |
| 455 | - ACH_TYPE_GBESHOP = 10 //累计用于新店铺 | |
| 456 | -) | ... | ... |
| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | +package logic | |
| 2 | + | |
| 3 | + | |
| 4 | +const ( | |
| 5 | + ERROR_OK = 0 //没有错误 | |
| 6 | + ERROR_JSONUNMASHFAILED = 1 //json解析失败 | |
| 7 | + ERROR_GETUSERBASICFAILED = 2 //获取玩家basic数据失败 | |
| 8 | + ERROR_GETUSEREXTFAILED = 3 //获取玩家ext数据失败 | |
| 9 | + ERROR_GETUSERIDFAILED = 4 //获取玩家uuid失败 | |
| 10 | + ERROR_GETUSERMAPBYUIDFAILED = 5 //从玩家在线数据获取失败 | |
| 11 | + ERROR_SRVDB_FAILED = 6 //服務器存储数据失败或者读取失败 | |
| 12 | +) | |
| 0 | 13 | \ No newline at end of file | ... | ... |
| ... | ... | @@ -0,0 +1,104 @@ |
| 1 | +package logic | |
| 2 | + | |
| 3 | +import ( | |
| 4 | + "HttpServer/redishandler" | |
| 5 | + "common/logger" | |
| 6 | + "common/redis" | |
| 7 | + "encoding/json" | |
| 8 | + "net/http" | |
| 9 | + "strconv" | |
| 10 | +) | |
| 11 | + | |
| 12 | +func SetHeader(w http.ResponseWriter) { | |
| 13 | + w.Header().Set("Access-Control-Allow-Origin", "*") //允许访问所有域 | |
| 14 | + w.Header().Set("Content-Type", "application/json") | |
| 15 | + w.Header().Set("Access-Control-Allow-Headers", "Content-Type,Uuid") | |
| 16 | +} | |
| 17 | + | |
| 18 | +//设置 | |
| 19 | +func SetTouristUid(utoken string,uid int) error{ | |
| 20 | + err := redishandler.GetRedisClient().HSet(redis.USER_TOURIST_UID, utoken,strconv.Itoa(uid)) | |
| 21 | + if err != nil { | |
| 22 | + logger.Error("SetTouristUid failed,err=%v",err) | |
| 23 | + return err | |
| 24 | + } | |
| 25 | + return nil | |
| 26 | +} | |
| 27 | + | |
| 28 | +//获取游客的uid 返回值为uid | |
| 29 | +func GetTouristUid(utoken string) (int,error){ | |
| 30 | + uidstr, err := redishandler.GetRedisClient().HGet(redis.USER_TOURIST_UID, utoken) | |
| 31 | + if err != nil { | |
| 32 | + return 0,err | |
| 33 | + } | |
| 34 | + | |
| 35 | + uid,err := strconv.Atoi(uidstr) | |
| 36 | + return uid,err | |
| 37 | +} | |
| 38 | + | |
| 39 | +//获取新的uuid | |
| 40 | +func GetNewUUid() int { | |
| 41 | + redishandler.GetRedisClient().Incr(redis.USER_MAX_UUID) | |
| 42 | + newuuid ,err:= redishandler.GetRedisClient().GetInt(redis.USER_MAX_UUID) | |
| 43 | + if err != nil { | |
| 44 | + logger.Error("GetNewUUid failed,err=%v",err) | |
| 45 | + return 0 | |
| 46 | + } | |
| 47 | + | |
| 48 | + return newuuid+10000 | |
| 49 | +} | |
| 50 | + | |
| 51 | +func SaveUserBaseData(uuid int,value string) error { | |
| 52 | + err := redishandler.GetRedisClient().HSet(redis.USER_BASE_DATA, strconv.Itoa(uuid), value) | |
| 53 | + return err | |
| 54 | +} | |
| 55 | + | |
| 56 | +func GetUserBaseData(uuid int ) (string,error) { | |
| 57 | + strval,err := redishandler.GetRedisClient().HGet(redis.USER_BASIC_DATA, strconv.Itoa(uuid)) | |
| 58 | + if err != nil { | |
| 59 | + logger.Error("GetUserBasic failed,err=%v",err) | |
| 60 | + return "",err | |
| 61 | + } | |
| 62 | + | |
| 63 | + return strval,err | |
| 64 | + | |
| 65 | +} | |
| 66 | + | |
| 67 | +func SaveUserBasic(uuid int,value string) error { | |
| 68 | + err := redishandler.GetRedisClient().HSet(redis.USER_BASIC_DATA, strconv.Itoa(uuid), value) | |
| 69 | + return err | |
| 70 | +} | |
| 71 | + | |
| 72 | +func GetUserBasic(uuid int ) (*UserBaseData,error) { | |
| 73 | + strval,err := redishandler.GetRedisClient().HGet(redis.USER_BASIC_DATA, strconv.Itoa(uuid)) | |
| 74 | + if err != nil { | |
| 75 | + logger.Error("GetUserBasic failed,err=%v",err) | |
| 76 | + return nil,err | |
| 77 | + } | |
| 78 | + basic := new(UserBaseData) | |
| 79 | + err = json.Unmarshal([]byte(strval), basic) | |
| 80 | + return basic,err | |
| 81 | + | |
| 82 | +} | |
| 83 | + | |
| 84 | +func SaveUserExt(extdata * UserData) error { | |
| 85 | + if extdata == nil { | |
| 86 | + return nil | |
| 87 | + } | |
| 88 | + m_userInfo.Set(uint32(extdata.Userid),extdata) | |
| 89 | + | |
| 90 | + ext,_ := json.Marshal(&extdata) | |
| 91 | + err := redishandler.GetRedisClient().HSet(redis.USER_EXT_DATA, strconv.Itoa(extdata.Userid), string(ext)) | |
| 92 | + return err | |
| 93 | +} | |
| 94 | + | |
| 95 | +func GetUserExt(uuid int) (*UserExtData,error) { | |
| 96 | + strval,err := redishandler.GetRedisClient().HGet(redis.USER_EXT_DATA, strconv.Itoa(uuid)) | |
| 97 | + if err != nil { | |
| 98 | + logger.Error("GetUserExt failed,err=%v",err) | |
| 99 | + return nil,err | |
| 100 | + } | |
| 101 | + ext := new(UserExtData) | |
| 102 | + err = json.Unmarshal([]byte(strval), ext) | |
| 103 | + return ext,err | |
| 104 | +} | |
| 0 | 105 | \ No newline at end of file | ... | ... |
src/HttpServer/logic/httpserver.go
| ... | ... | @@ -2,11 +2,7 @@ package logic |
| 2 | 2 | |
| 3 | 3 | import ( |
| 4 | 4 | "HttpServer/conf" |
| 5 | - "bytes" | |
| 6 | 5 | "common/logger" |
| 7 | - "encoding/json" | |
| 8 | - "strconv" | |
| 9 | - | |
| 10 | 6 | "io/ioutil" |
| 11 | 7 | //"log" |
| 12 | 8 | "net/http" |
| ... | ... | @@ -23,42 +19,7 @@ func StartHttpServe() { |
| 23 | 19 | |
| 24 | 20 | //just for test |
| 25 | 21 | func Testsendhttp() { |
| 26 | - var test UserLoginData | |
| 27 | - //test.Uuid = 100 | |
| 28 | - test.Fromid = 200 | |
| 29 | - test.Sharetype = 1 | |
| 30 | - | |
| 31 | - client := &http.Client{} | |
| 32 | 22 | |
| 33 | - bys, err := json.Marshal(&test) | |
| 34 | - if err != nil { | |
| 35 | - logger.Error("testsendhttp failed=%v", err) | |
| 36 | - return | |
| 37 | - } | |
| 38 | - body := bytes.NewBuffer(bys) | |
| 39 | - url := "http://127.0.0.1:50056/cat/login" | |
| 40 | - reqest, err := http.NewRequest("POST", url, body) | |
| 41 | - if err != nil { | |
| 42 | - logger.Error("http.NewRequest failed") | |
| 43 | - } | |
| 44 | - reqest.Header.Add("Uuid", "101") | |
| 45 | - //发送 | |
| 46 | - //res, err := http.Post(url, "application/json;charset=utf-8", body) | |
| 47 | - res, err := client.Do(reqest) | |
| 48 | - if err != nil { | |
| 49 | - logger.Error(" post failed to %v err:%v data:%v", url, err, string(bys)) | |
| 50 | - return | |
| 51 | - } | |
| 52 | - | |
| 53 | - result, _ := ioutil.ReadAll(res.Body) | |
| 54 | - res.Body.Close() | |
| 55 | - | |
| 56 | - s := string(result) | |
| 57 | - var resp GetUserDataResp | |
| 58 | - resp.Code = 0 | |
| 59 | - var rdata UserLoginResp | |
| 60 | - _ = json.Unmarshal([]byte(s), &rdata) | |
| 61 | - logger.Info("testsendhttp , body:%v", rdata) | |
| 62 | 23 | } |
| 63 | 24 | |
| 64 | 25 | func CheckErr(err error) { |
| ... | ... | @@ -68,13 +29,48 @@ func CheckErr(err error) { |
| 68 | 29 | } |
| 69 | 30 | |
| 70 | 31 | func startServerHttpServe() { |
| 71 | - http.HandleFunc("/cat/login", UserLogin) //登录 | |
| 32 | + http.HandleFunc("/catcafe/login", UserLogin) //登录 | |
| 33 | + http.HandleFunc("/catcafe/user/saveUserData", saveUserData) //登录 | |
| 34 | + http.HandleFunc("/catcafe/data/saveData", saveData) //登录 | |
| 35 | + http.HandleFunc("/catcafe/data/getData", getData) //登录 | |
| 72 | 36 | |
| 73 | 37 | |
| 74 | 38 | err := http.ListenAndServe(conf.GetServerHttpAddrConf(), nil) |
| 75 | 39 | CheckErr(err) |
| 76 | 40 | } |
| 77 | 41 | |
| 42 | +func saveUserData(w http.ResponseWriter, r *http.Request) { | |
| 43 | + | |
| 44 | + result, _ := ioutil.ReadAll(r.Body) | |
| 45 | + r.Body.Close() | |
| 46 | + | |
| 47 | + s := string(result) | |
| 48 | + logger.Info("saveUserData , body:%v,uuid=%v", s) | |
| 49 | + | |
| 50 | + HandleSaveUserData(w,s) | |
| 51 | +} | |
| 52 | + | |
| 53 | +func saveData(w http.ResponseWriter, r *http.Request) { | |
| 54 | + | |
| 55 | + result, _ := ioutil.ReadAll(r.Body) | |
| 56 | + r.Body.Close() | |
| 57 | + | |
| 58 | + s := string(result) | |
| 59 | + logger.Info("saveData , body:%v,uuid=%v", s) | |
| 60 | + | |
| 61 | + HandlesaveData(w,s) | |
| 62 | +} | |
| 63 | + | |
| 64 | +func getData(w http.ResponseWriter, r *http.Request) { | |
| 65 | + | |
| 66 | + result, _ := ioutil.ReadAll(r.Body) | |
| 67 | + r.Body.Close() | |
| 68 | + | |
| 69 | + s := string(result) | |
| 70 | + logger.Info("UserLogin , body:%v,uuid=%v", s) | |
| 71 | + | |
| 72 | + HandlegetData(w,s) | |
| 73 | +} | |
| 78 | 74 | |
| 79 | 75 | |
| 80 | 76 | func UserLogin(w http.ResponseWriter, r *http.Request) { |
| ... | ... | @@ -86,21 +82,21 @@ func UserLogin(w http.ResponseWriter, r *http.Request) { |
| 86 | 82 | //w.Header().Add("Access-Control-Allow-Headers", "") |
| 87 | 83 | //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") |
| 88 | 84 | |
| 89 | - Uuid := 0 | |
| 85 | + /*Uuid := 0 | |
| 90 | 86 | if len(r.Header) > 0 { |
| 91 | 87 | Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) |
| 92 | 88 | } |
| 93 | 89 | |
| 94 | 90 | if Uuid == 0 { |
| 95 | 91 | return |
| 96 | - } | |
| 92 | + }*/ | |
| 97 | 93 | result, _ := ioutil.ReadAll(r.Body) |
| 98 | 94 | r.Body.Close() |
| 99 | 95 | |
| 100 | 96 | s := string(result) |
| 101 | - logger.Info("UserLogin , body:%v,uuid=%v", s, Uuid) | |
| 97 | + logger.Info("UserLogin , body:%v,uuid=%v", s) | |
| 102 | 98 | |
| 103 | - //HandlerLogin(w, s, Uuid) | |
| 99 | + HandleUserLogin(w,s) | |
| 104 | 100 | } |
| 105 | 101 | |
| 106 | 102 | ... | ... |
src/HttpServer/logic/logic.go
| 1 | -package logic | |
| 2 | 1 | \ No newline at end of file |
| 2 | +package logic | |
| 3 | + | |
| 4 | +import ( | |
| 5 | + | |
| 6 | + "common/beegomap" | |
| 7 | + "common/logger" | |
| 8 | + | |
| 9 | + "encoding/json" | |
| 10 | + "fmt" | |
| 11 | + "net/http" | |
| 12 | + | |
| 13 | + "time" | |
| 14 | +) | |
| 15 | + | |
| 16 | +var ( | |
| 17 | + m_userInfo *beegomap.BeeMap //make(map[int32]*UserData | |
| 18 | +) | |
| 19 | + | |
| 20 | +func init() { | |
| 21 | + m_userInfo = beegomap.NewBeeMap() | |
| 22 | +} | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | +func InitTourist(req *UserLoginReq,resp *UserLoginResp) { | |
| 27 | + //首先生成user_base_data | |
| 28 | + var basedata UserBaseData | |
| 29 | + basedata.User_id = GetNewUUid() | |
| 30 | + basedata.User_avatar_url = "" | |
| 31 | + basedata.User_city = "天堂" | |
| 32 | + basedata.User_gender = 1 | |
| 33 | + basedata.User_nickname = "游客" + string(basedata.User_id) | |
| 34 | + basedata.User_openid = "" | |
| 35 | + basedata.User_token = req.Token | |
| 36 | + resp.Result.Data.Dasedata = basedata | |
| 37 | + //保存base data | |
| 38 | + basic, _ := json.Marshal(&basedata) | |
| 39 | + SaveUserBasic(basedata.User_id,string(basic)) | |
| 40 | + | |
| 41 | + SetTouristUid(req.Token,basedata.User_id) | |
| 42 | + //然后生成user_ext_data | |
| 43 | + var extdata UserExtData | |
| 44 | + extdata.User_id = basedata.User_id | |
| 45 | + extdata.Lv = 1 | |
| 46 | + extdata.Bean = 0 | |
| 47 | + extdata.Coin = 0 | |
| 48 | + extdata.Exp = 0 | |
| 49 | + extdata.Hot = 0 | |
| 50 | + extdata.Invite_uid = req.User_invite_uid | |
| 51 | + extdata.LoveExp = 0 | |
| 52 | + extdata.Reg_time = int(time.Now().Unix()) | |
| 53 | + extdata.ShopNum = 0 | |
| 54 | + extdata.User_channel = req.Channel_id | |
| 55 | + extdata.User_is_black = 0 | |
| 56 | + extdata.User_reg_time = int(time.Now().Unix()) | |
| 57 | + extdata.User_scene = req.Scene | |
| 58 | + resp.Result.Data.Extdata = extdata | |
| 59 | + //保存 | |
| 60 | + udata :=new(UserData) | |
| 61 | + udata.Scene = extdata.User_scene | |
| 62 | + udata.Hot = extdata.Hot | |
| 63 | + udata.Exp = extdata.Exp | |
| 64 | + udata.Coin = extdata.Coin | |
| 65 | + udata.Bean = extdata.Bean | |
| 66 | + udata.Lv = extdata.Lv | |
| 67 | + udata.Channel = extdata.User_channel | |
| 68 | + udata.InviteUid = extdata.Invite_uid | |
| 69 | + udata.Isblack = extdata.User_is_black | |
| 70 | + udata.Loevexp = extdata.LoveExp | |
| 71 | + udata.Regtime = extdata.Reg_time | |
| 72 | + udata.Shopnum = extdata.ShopNum | |
| 73 | + udata.Userid = extdata.User_id | |
| 74 | + udata.UserInviteId = extdata.User_invite_uid | |
| 75 | + udata.Userregtime = extdata.User_reg_time | |
| 76 | + | |
| 77 | + SaveUserExt(udata) | |
| 78 | + | |
| 79 | +} | |
| 80 | + | |
| 81 | +//处理游客登录 | |
| 82 | +func HandleTouristLogin(w http.ResponseWriter, req *UserLoginReq,resp *UserLoginResp) { | |
| 83 | + | |
| 84 | + logger.Info("HandleTouristLogin req=%v,resp=%v",req,resp) | |
| 85 | + for { | |
| 86 | + //首先判断是否存在这个游客账号 | |
| 87 | + uuid,err := GetTouristUid(req.Token) | |
| 88 | + if err != nil { | |
| 89 | + //新账号 初始化 | |
| 90 | + InitTourist(req,resp) | |
| 91 | + }else { | |
| 92 | + //读取数据 | |
| 93 | + basic,err := GetUserBasic(uuid) | |
| 94 | + if err != nil { | |
| 95 | + logger.Error("HandleTouristLogin getbasic failed=%v", err) | |
| 96 | + resp.Result.Code = ERROR_GETUSERBASICFAILED | |
| 97 | + break | |
| 98 | + } | |
| 99 | + resp.Result.Data.Dasedata = *basic | |
| 100 | + | |
| 101 | + ext,err := GetUserExt(uuid) | |
| 102 | + if err != nil { | |
| 103 | + logger.Error("HandleTouristLogin getext failed=%v", err) | |
| 104 | + resp.Result.Code = ERROR_GETUSEREXTFAILED | |
| 105 | + break | |
| 106 | + } | |
| 107 | + resp.Result.Data.Extdata = *ext | |
| 108 | + | |
| 109 | + m_userInfo.Set(uint32(ext.User_id),ext) | |
| 110 | + } | |
| 111 | + | |
| 112 | + resp.Result.Code = ERROR_OK | |
| 113 | + break | |
| 114 | + } | |
| 115 | + //回包 | |
| 116 | + respstr, _ := json.Marshal(&resp) | |
| 117 | + fmt.Fprint(w, string(respstr)) | |
| 118 | +} | |
| 119 | + | |
| 120 | +func HandleUserLogin(w http.ResponseWriter, data string) { | |
| 121 | + SetHeader(w) | |
| 122 | + var resp UserLoginResp | |
| 123 | + resp.Status = "true" | |
| 124 | + resp.Result.Code = ERROR_OK | |
| 125 | + var rdata UserLoginReq | |
| 126 | + err := json.Unmarshal([]byte(data), &rdata) | |
| 127 | + for { | |
| 128 | + if err != nil { | |
| 129 | + logger.Error("HandleUserLogin json unmarshal failed=%v", err) | |
| 130 | + resp.Result.Code = ERROR_JSONUNMASHFAILED | |
| 131 | + break | |
| 132 | + } | |
| 133 | + | |
| 134 | + if rdata.Logintype ==LOGIN_TYPE_TOURIST { | |
| 135 | + //游客登录 | |
| 136 | + HandleTouristLogin(w,&rdata,&resp) | |
| 137 | + break | |
| 138 | + } | |
| 139 | + | |
| 140 | + if rdata.Logintype == LOGIN_TYPE_ACCOUNT { | |
| 141 | + //账号密码登录 | |
| 142 | + | |
| 143 | + break | |
| 144 | + } | |
| 145 | + | |
| 146 | + if rdata.Logintype == LOGIN_TYPE_WECHAT { | |
| 147 | + //微信登录 | |
| 148 | + | |
| 149 | + break | |
| 150 | + } | |
| 151 | + | |
| 152 | + | |
| 153 | + } | |
| 154 | + | |
| 155 | + //回包 | |
| 156 | + //respstr, _ := json.Marshal(&resp) | |
| 157 | + //fmt.Fprint(w, string(respstr)) | |
| 158 | +} | |
| 159 | + | |
| 160 | +func HandleSaveUserData(w http.ResponseWriter, data string) { | |
| 161 | + SetHeader(w) | |
| 162 | + var resp SaveUserDataResp | |
| 163 | + resp.Status = "true" | |
| 164 | + resp.Result.Code = ERROR_OK | |
| 165 | + var rdata SaveUserDataReq | |
| 166 | + err := json.Unmarshal([]byte(data), &rdata) | |
| 167 | + for { | |
| 168 | + if err != nil { | |
| 169 | + logger.Error("HandleSaveUserData json unmarshal failed=%v", err) | |
| 170 | + resp.Result.Code = ERROR_JSONUNMASHFAILED | |
| 171 | + break | |
| 172 | + } | |
| 173 | + | |
| 174 | + uuid,err := GetTouristUid(rdata.Token) | |
| 175 | + if err != nil || uuid==0{ | |
| 176 | + logger.Error("HandleSaveUserData json unmarshal failed=%v", err) | |
| 177 | + resp.Result.Code = ERROR_GETUSERIDFAILED | |
| 178 | + break | |
| 179 | + } | |
| 180 | + | |
| 181 | + vv := m_userInfo.Get(uint32(uuid)) | |
| 182 | + if vv == nil { | |
| 183 | + logger.Error("HandleSaveUserData failed=%v", err) | |
| 184 | + resp.Result.Code = ERROR_GETUSERMAPBYUIDFAILED | |
| 185 | + break | |
| 186 | + } | |
| 187 | + | |
| 188 | + uinfo := vv.(*UserData) | |
| 189 | + uinfo.Coin = rdata.Coin | |
| 190 | + uinfo.Loevexp = rdata.Loveexp | |
| 191 | + uinfo.Hot = rdata.Hot | |
| 192 | + uinfo.Bean = rdata.Bean | |
| 193 | + uinfo.Shopnum = rdata.Shopnum | |
| 194 | + SaveUserExt(uinfo) | |
| 195 | + | |
| 196 | + basic,err := GetUserBasic(uuid) | |
| 197 | + if err != nil { | |
| 198 | + logger.Error("HandleTouristLogin getbasic failed=%v", err) | |
| 199 | + resp.Result.Code = ERROR_GETUSERBASICFAILED | |
| 200 | + break | |
| 201 | + } | |
| 202 | + resp.Result.Data.Dasedata = *basic | |
| 203 | + | |
| 204 | + ext,err := GetUserExt(uuid) | |
| 205 | + if err != nil { | |
| 206 | + logger.Error("HandleTouristLogin getext failed=%v", err) | |
| 207 | + resp.Result.Code = ERROR_GETUSEREXTFAILED | |
| 208 | + break | |
| 209 | + } | |
| 210 | + resp.Result.Data.Extdata = *ext | |
| 211 | + | |
| 212 | + resp.Result.Code = ERROR_OK | |
| 213 | + break | |
| 214 | + } | |
| 215 | + | |
| 216 | + //回包 | |
| 217 | + respstr, _ := json.Marshal(&resp) | |
| 218 | + fmt.Fprint(w, string(respstr)) | |
| 219 | +} | |
| 220 | + | |
| 221 | +func HandlesaveData(w http.ResponseWriter, data string) { | |
| 222 | + SetHeader(w) | |
| 223 | + var resp SaveDataResp | |
| 224 | + resp.Status = "true" | |
| 225 | + resp.Result.Code = ERROR_OK | |
| 226 | + var rdata SaveDataReq | |
| 227 | + err := json.Unmarshal([]byte(data), &rdata) | |
| 228 | + for { | |
| 229 | + if err != nil { | |
| 230 | + logger.Error("HandlesaveData json unmarshal failed=%v", err) | |
| 231 | + resp.Result.Code = ERROR_JSONUNMASHFAILED | |
| 232 | + break | |
| 233 | + } | |
| 234 | + | |
| 235 | + uuid,err := GetTouristUid(rdata.Token) | |
| 236 | + if err != nil || uuid==0{ | |
| 237 | + logger.Error("HandlesaveData GetTouristUid failed=%v", err) | |
| 238 | + resp.Result.Code = ERROR_GETUSERIDFAILED | |
| 239 | + break | |
| 240 | + } | |
| 241 | + | |
| 242 | + | |
| 243 | + err = SaveUserBaseData(uuid,rdata.Value) | |
| 244 | + | |
| 245 | + if err != nil { | |
| 246 | + logger.Error("HandlesaveData save failed=%v", err) | |
| 247 | + resp.Result.Code = ERROR_SRVDB_FAILED | |
| 248 | + break | |
| 249 | + } | |
| 250 | + | |
| 251 | + resp.Result.Code = ERROR_OK | |
| 252 | + break | |
| 253 | + } | |
| 254 | + | |
| 255 | + //回包 | |
| 256 | + respstr, _ := json.Marshal(&resp) | |
| 257 | + fmt.Fprint(w, string(respstr)) | |
| 258 | +} | |
| 259 | + | |
| 260 | +func HandlegetData(w http.ResponseWriter, data string) { | |
| 261 | + SetHeader(w) | |
| 262 | + var resp SaveDataResp | |
| 263 | + resp.Status = "true" | |
| 264 | + resp.Result.Code = ERROR_OK | |
| 265 | + var rdata SaveDataReq | |
| 266 | + err := json.Unmarshal([]byte(data), &rdata) | |
| 267 | + for { | |
| 268 | + if err != nil { | |
| 269 | + logger.Error("HandlegetData json unmarshal failed=%v", err) | |
| 270 | + resp.Result.Code = ERROR_JSONUNMASHFAILED | |
| 271 | + break | |
| 272 | + } | |
| 273 | + | |
| 274 | + uuid,err := GetTouristUid(rdata.Token) | |
| 275 | + if err != nil || uuid==0{ | |
| 276 | + logger.Error("HandlegetData GetTouristUid failed=%v", err) | |
| 277 | + resp.Result.Code = ERROR_GETUSERIDFAILED | |
| 278 | + break | |
| 279 | + } | |
| 280 | + | |
| 281 | + | |
| 282 | + ubase,err := GetUserBaseData(uuid) | |
| 283 | + | |
| 284 | + if err != nil { | |
| 285 | + logger.Error("HandlegetData get failed=%v", err) | |
| 286 | + resp.Result.Code = ERROR_SRVDB_FAILED | |
| 287 | + break | |
| 288 | + } | |
| 289 | + | |
| 290 | + resp.Result.Data = ubase | |
| 291 | + resp.Result.Code = ERROR_OK | |
| 292 | + break | |
| 293 | + } | |
| 294 | + | |
| 295 | + //回包 | |
| 296 | + respstr, _ := json.Marshal(&resp) | |
| 297 | + fmt.Fprint(w, string(respstr)) | |
| 298 | +} | |
| 3 | 299 | \ No newline at end of file | ... | ... |
src/HttpServer/main/main.go
src/common/redis/def.go
| 1 | 1 | package redis |
| 2 | 2 | |
| 3 | 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_TOURIST_UID = "CATCAFE_USER_TOURIST_UID" //存储对应设备编码与uid的对应关系 | |
| 5 | + USER_MAX_UUID = "CATCAFE_USER_MAX_UUID" //记录当前最大的uid,新增自增即可 | |
| 6 | + USER_BASIC_DATA = "CATCAFE_USER_BASIC_DATA" //玩家基础信息 | |
| 7 | + USER_EXT_DATA = "CATCAFE_USER_EXT_DATA" //玩家游戏数据 | |
| 8 | + USER_BASE_DATA = "CATCAFE_USER_BASE_DATA" //小游戏自定义数据 | |
| 13 | 9 | ) | ... | ... |