Commit a8930016f5013a69953cc35e5d9828adc3b64c4c

Authored by 陆恒
1 parent e1db3a17

登录接口相关

src/HttpServer/jsonconf/AchievementConfig.json
1 -[{"id":1,"task":"观看%d%条广告","num":10,"reward":[7,100]},{"id":1,"task":"观看%d%条广告","num":30,"reward":[7,300]},{"id":1,"task":"观看%d%条广告","num":50,"reward":[7,500]},{"id":1,"task":"观看%d%条广告","num":100,"reward":[7,1000]},{"id":1,"task":"观看%d%条广告","num":150,"reward":[7,1500]},{"id":2,"task":"人物达到%d%级","num":5,"reward":[7,500]},{"id":2,"task":"人物达到%d%级","num":10,"reward":[7,1000]},{"id":2,"task":"人物达到%d%级","num":15,"reward":[7,1500]},{"id":2,"task":"人物达到%d%级","num":20,"reward":[7,2000]},{"id":3,"task":"累计消除%d%颗星星","num":1000,"reward":[1,50]},{"id":3,"task":"累计消除%d%颗星星","num":5000,"reward":[1,80]},{"id":3,"task":"累计消除%d%颗星星","num":10000,"reward":[1,100]},{"id":3,"task":"累计消除%d%颗星星","num":30000,"reward":[2,10]},{"id":3,"task":"累计消除%d%颗星星","num":50000,"reward":[3,10]},{"id":3,"task":"累计消除%d%颗星星","num":100000,"reward":[4,10]},{"id":3,"task":"累计消除%d%颗星星","num":500000,"reward":[5,10]},{"id":4,"task":"存钱罐累计提取%d%次","num":5,"reward":[7,50]},{"id":4,"task":"存钱罐累计提取%d%次","num":10,"reward":[7,100]},{"id":4,"task":"存钱罐累计提取%d%次","num":20,"reward":[7,200]},{"id":4,"task":"存钱罐累计提取%d%次","num":30,"reward":[7,300]},{"id":4,"task":"存钱罐累计提取%d%次","num":50,"reward":[7,500]},{"id":5,"task":"使用%d%次任意道具","num":20,"reward":[7,200]},{"id":5,"task":"使用%d%次任意道具","num":50,"reward":[7,500]},{"id":5,"task":"使用%d%次任意道具","num":100,"reward":[7,1000]},{"id":5,"task":"使用%d%次任意道具","num":300,"reward":[7,3000]},{"id":5,"task":"使用%d%次任意道具","num":500,"reward":[7,5000]}]  
2 \ No newline at end of file 1 \ No newline at end of file
  2 +[{"id":1,"task":"观看%d%条广告","num":10,"reward":[7,100],"type":1},{"id":2,"task":"观看%d%条广告","num":30,"reward":[7,300],"type":1},{"id":3,"task":"观看%d%条广告","num":50,"reward":[7,500],"type":1},{"id":4,"task":"观看%d%条广告","num":100,"reward":[7,1000],"type":1},{"id":5,"task":"观看%d%条广告","num":150,"reward":[7,1500],"type":1},{"id":6,"task":"人物达到%d%级","num":5,"reward":[7,500],"type":2},{"id":7,"task":"人物达到%d%级","num":10,"reward":[7,1000],"type":2},{"id":8,"task":"人物达到%d%级","num":15,"reward":[7,1500],"type":2},{"id":9,"task":"人物达到%d%级","num":20,"reward":[7,2000],"type":2},{"id":10,"task":"累计消除%d%颗星星","num":1000,"reward":[1,50],"type":3},{"id":11,"task":"累计消除%d%颗星星","num":5000,"reward":[1,80],"type":3},{"id":12,"task":"累计消除%d%颗星星","num":10000,"reward":[1,100],"type":3},{"id":13,"task":"累计消除%d%颗星星","num":30000,"reward":[2,10],"type":3},{"id":14,"task":"累计消除%d%颗星星","num":50000,"reward":[3,10],"type":3},{"id":15,"task":"累计消除%d%颗星星","num":100000,"reward":[4,10],"type":3},{"id":16,"task":"累计消除%d%颗星星","num":500000,"reward":[5,10],"type":3},{"id":17,"task":"存钱罐累计提取%d%次","num":5,"reward":[7,50],"type":4},{"id":18,"task":"存钱罐累计提取%d%次","num":10,"reward":[7,100],"type":4},{"id":19,"task":"存钱罐累计提取%d%次","num":20,"reward":[7,200],"type":4},{"id":20,"task":"存钱罐累计提取%d%次","num":30,"reward":[7,300],"type":4},{"id":21,"task":"存钱罐累计提取%d%次","num":50,"reward":[7,500],"type":4},{"id":22,"task":"使用%d%次任意道具","num":20,"reward":[7,200],"type":5},{"id":23,"task":"使用%d%次任意道具","num":50,"reward":[7,500],"type":5},{"id":24,"task":"使用%d%次任意道具","num":100,"reward":[7,1000],"type":5},{"id":25,"task":"使用%d%次任意道具","num":300,"reward":[7,3000],"type":5},{"id":26,"task":"使用%d%次任意道具","num":500,"reward":[7,5000],"type":5}]
3 \ No newline at end of file 3 \ No newline at end of file
src/HttpServer/jsonconf/DailyTask.json
1 -[{"id":1,"task":"每日登录","num":1,"reward":[1,20]},{"id":2,"task":"提取一次存钱罐","num":1,"reward":[6,50]},{"id":3,"task":"今日通过%d%关","num":10,"reward":[6,50]},{"id":4,"task":"使用%d%次道具","num":5,"reward":[6,20]},{"id":5,"task":"领取%d%次红包","num":5,"reward":[6,20]},{"id":5,"task":"领取%d%次红包","num":10,"reward":[6,30]},{"id":5,"task":"领取%d%次红包","num":15,"reward":[6,50]},{"id":6,"task":"收集%d%枚金币","num":20,"reward":[6,100]},{"id":7,"task":"累计在线%d%分钟","num":5,"reward":[2,2]},{"id":7,"task":"累计在线%d%分钟","num":10,"reward":[4,3]},{"id":7,"task":"累计在线%d%分钟","num":15,"reward":[5,4]}]  
2 \ No newline at end of file 1 \ No newline at end of file
  2 +[{"id":1,"task":"每日登录","num":1,"reward":[1,20],"type":1},{"id":2,"task":"提取一次存钱罐","num":1,"reward":[6,50],"type":2},{"id":3,"task":"今日通过%d%关","num":10,"reward":[6,50],"type":3},{"id":4,"task":"使用%d%次道具","num":5,"reward":[6,20],"type":4},{"id":5,"task":"领取%d%次红包","num":5,"reward":[6,20],"type":5},{"id":6,"task":"领取%d%次红包","num":10,"reward":[6,30],"type":5},{"id":7,"task":"领取%d%次红包","num":15,"reward":[6,50],"type":5},{"id":8,"task":"收集%d%枚金币","num":20,"reward":[6,100],"type":6},{"id":9,"task":"累计在线%d%分钟","num":5,"reward":[2,2],"type":7},{"id":10,"task":"累计在线%d%分钟","num":10,"reward":[4,3],"type":7},{"id":11,"task":"累计在线%d%分钟","num":15,"reward":[5,4],"type":7}]
3 \ No newline at end of file 3 \ No newline at end of file
src/HttpServer/logic/constdef.go
@@ -6,9 +6,5 @@ var ( @@ -6,9 +6,5 @@ var (
6 ) 6 )
7 7
8 const ( 8 const (
9 - FRIEND_MAX_NUM = 50 //好友人数上限  
10 - FRIEND_APPLY_LIMIT = 50 //好友申请当日上限  
11 - FRIEND_APPROVE_LIMIT = 50 //好友批准当日上限  
12 - FRIEND_RECOMMAND_NUM = 3 //推荐好友数量  
13 - TEAM_MAXNUM = 4 //队伍最大人数 9 + WATCH_ADD_DAY_LIMIT = 9 //当天观看视频次数限制
14 ) 10 )
15 \ No newline at end of file 11 \ No newline at end of file
src/HttpServer/logic/datadef.go
1 package logic 1 package logic
2 2
3 -//微信url定义  
4 -const (  
5 - URL_WEIXINMSG_CHECK = "https://api.weixin.qq.com/wxa/msg_sec_check"  
6 - URL_WEIXINGETACCESS_TOKEN = "https://api.weixin.qq.com/cgi-bin/token"  
7 -)  
8 -  
9 -//登录类型枚举  
10 -const (  
11 - LOGIN_TYPE_TOURIST = 1 //游客登录  
12 - LOGIN_TYPE_ACCOUNT = 2 //账号密码登录  
13 - LOGIN_TYPE_WECHAT = 3 //微信登录  
14 -  
15 -)  
16 -  
17 -type WechatLoginReq struct {  
18 - Channel_id int `json:"channel_id"`  
19 - Invite_type int `json:"invite_type"`  
20 - Invite_res_id int `json:"invite_res_id"`  
21 - User_invite_uid int `json:"user_invite_uid"`  
22 - Code string `json:"code"`  
23 - Signature string `json:"signature"`  
24 - Iv string `json:"iv"`  
25 - Raw_data string `json:"raw_data"`  
26 - Encrypted_data string `json:"encrypted_data"`  
27 - Token string `json:"token"`  
28 - Version string `json:"version"`  
29 -}  
30 -  
31 type UserLoginReq struct { 3 type UserLoginReq struct {
32 - Channel_id int `json:"channel_id"`  
33 - Invite_type int `json:"invite_type"`  
34 - Invite_res_id int `json:"invite_res_id"`  
35 - User_invite_uid int `json:"user_invite_uid"`  
36 - Scene int `json:"scene"`  
37 - RefAppId int `json:"refAppId"`  
38 - Code string `json:"code"`  
39 - Token string `json:"token"`  
40 - Version string `json:"version"`  
41 -  
42 -}  
43 -  
44 -type UserBaseData struct {  
45 - User_id int `json:"user_id"`  
46 - User_gender int `json:"user_gender"`  
47 - User_nickname string `json:"user_nickname"`  
48 - User_openid string `json:"user_openid"`  
49 - User_avatar_url string `json:"user_avatar_url"`  
50 - User_city string `json:"user_city"`  
51 - User_token string `json:"user_token"`  
52 -}  
53 -  
54 -type UserExtData struct {  
55 - User_id int `json:"user_id"`  
56 - Hot int `json:"hot"`  
57 - Coin int64 `json:"coin"`  
58 - LoveExp int `json:"loveExp"`  
59 - Bean int `json:"bean"`  
60 - ShopNum int `json:"shopNum"`  
61 - Lv int `json:"lv"`  
62 - Exp int `json:"exp"`  
63 - User_invite_uid int `json:"user_invite_uid"`  
64 - User_reg_time int `json:"user_reg_time"`  
65 - User_channel int `json:"user_channel"`  
66 - User_is_black int `json:"user_is_black"`  
67 - User_scene int `json:"user_scene"`  
68 - Reg_time int `json:"reg_time"`  
69 - Invite_uid int `json:"invite_uid"`  
70 -}  
71 -  
72 -type UserLoginData struct {  
73 - Dasedata UserBaseData `json:"UserBaseData"`  
74 - Extdata UserExtData `json:"user_ext_data"`  
75 -}  
76 -  
77 -type UserLoginResult struct {  
78 - Code int `json:"code"`  
79 - Data UserLoginData `json:"data"` 4 + Fromid int `json:"fromid"`
  5 + Sharetype int `json:"sharetype"`
80 } 6 }
81 7
82 -  
83 -  
84 type UserLoginResp struct { 8 type UserLoginResp struct {
85 - Status string `json:"status"`  
86 - Result UserLoginResult `json:"result"`  
87 -  
88 -}  
89 -  
90 -  
91 -type RegeisterReq struct{  
92 - Account string `json:"account"`  
93 - Password string `json:"password"`  
94 -}  
95 -  
96 -type RegeisteraResp struct {  
97 - Status string `json:"status"`  
98 - Result CommonResult `json:"result"`  
99 -}  
100 -  
101 -type AccounLoginReq struct{  
102 - Account string `json:"account"`  
103 - Password string `json:"password"`  
104 -}  
105 -  
106 -type AccounLoginResp struct {  
107 - Status string `json:"status"`  
108 - Result UserLoginResult `json:"result"`  
109 -}  
110 -  
111 -  
112 -type SaveUserDataReq struct{  
113 - Token string `json:"token"`  
114 - Hot int `json:"hot"`  
115 - Coin int64 `json:"coin"`  
116 - Loveexp int `json:"loveexp"`  
117 - Bean int `json:"bean"`  
118 - Shopnum int `json:"shopnum"`  
119 -}  
120 -  
121 -type SaveUserDataResp struct {  
122 - Status string `json:"status"`  
123 - Result UserLoginResult `json:"result"`  
124 -}  
125 -  
126 -type CommonResult struct {  
127 - Code int `json:"code"`  
128 - Data string `json:"data"`  
129 -}  
130 -  
131 -type SaveDataReq struct{  
132 - Token string `json:"token"`  
133 - Field string `json:"field"`  
134 - Value string `json:"value"`  
135 -}  
136 -  
137 -type SaveDataResp struct {  
138 - Status string `json:"status"`  
139 - Result CommonResult `json:"result"`  
140 -}  
141 -  
142 -type GetDataDesc struct {  
143 - Base_data string `json:"base_data"`  
144 -}  
145 -  
146 -type GetDataResult struct {  
147 - Code int `json:"code"`  
148 - Data GetDataDesc `json:"data"`  
149 -}  
150 -  
151 -type GetDataReq struct{  
152 - Token string `json:"token"`  
153 - Field string `json:"field"`  
154 -}  
155 -  
156 -type GetDataResp struct {  
157 - Status string `json:"status"`  
158 - Result GetDataResult `json:"result"`  
159 -}  
160 -  
161 -type TextCheckReq struct{  
162 - Token string `json:"token"`  
163 - Text string `json:"text"`  
164 -}  
165 -  
166 -type TextCheckResp struct {  
167 - Status string `json:"status"`  
168 - Result CommonResult `json:"result"`  
169 -}  
170 -  
171 -type MsgCheckDesc struct {  
172 - Content string `json:"content"`  
173 -} 9 + Code int `json:"code"`
  10 + Message string `json:"message"`
  11 + Loginday int `json:"loginday"`
  12 + Leftads int `json:"leftads"`
  13 + Guangold int `json:"guangold"`
174 14
175 -type MsgCheckResp struct {  
176 - Errcode string `json:"errcode"`  
177 - Errmsg string `json:"errmsg"`  
178 } 15 }
179 16
180 -type GetAccessTokenResp struct {  
181 - Access_token string `json:"access_token"`  
182 - Expires_in string `json:"expires_in"`  
183 -}  
184 -  
185 -  
186 -type CreateTeamReq struct{  
187 - Token string `json:"token"`  
188 - Name string `json:"name"`  
189 - Is_open int `json:"is_open"`  
190 - Limit int `json:"limit"`  
191 -}  
192 -  
193 -//队伍列表人员id  
194 -type TeamMemInfo struct {  
195 - MemList []int  
196 -}  
197 -  
198 -//玩家投资信心  
199 -type TeamDevoteInfo struct {  
200 - UserId int `json:"userid"`  
201 - Type int `json:"type"`  
202 - Assets int `json:"assets"`  
203 -}  
204 -  
205 -//玩家buff  
206 -type TeamBuffInfo struct {  
207 - BeginTime int  
208 - EndTime int  
209 -}  
210 -  
211 -//  
212 -type TeamAllBuff struct {  
213 - Type int  
214 - BuffInfo []TeamBuffInfo  
215 -}  
216 -  
217 -//队伍建筑信息  
218 -type TeamBuildingInfo struct {  
219 - Devote []TeamDevoteInfo  
220 - Buff []TeamAllBuff  
221 -}  
222 -  
223 -type CreateTeamInfo struct {  
224 - Id int `json:"id"`  
225 - Name string `json:"name"`  
226 - Is_open int `json:"is_open"`  
227 - Num int `json:"num"`  
228 - Assets int `json:"assets"`  
229 - Least int `json:"least"`  
230 - Captain_id int `json:"captain_id"`  
231 - Creator_id int `json:"creator_id"`  
232 - Status int `json:"status"`  
233 - Create_time int `json:"create_time"`  
234 - Update_time int `json:"update_time"`  
235 -}  
236 -  
237 -//队伍信息  
238 -type TeamInfo struct {  
239 - BaseInfo CreateTeamInfo  
240 - MemInfo TeamMemInfo  
241 - BInfo TeamBuildingInfo  
242 -}  
243 -  
244 -type CreateTeamDesc struct {  
245 - Team_data CreateTeamInfo `json:"team_data"`  
246 -}  
247 -  
248 -type CreateTeamData struct {  
249 - Code int `json:"code"`  
250 - Data CreateTeamDesc `json:"data"`  
251 -}  
252 -  
253 -type CreateTeamResp struct {  
254 - Status string `json:"status"`  
255 - Result CreateTeamData `json:"result"`  
256 -}  
257 -  
258 -  
259 -type JoinTeamReq struct{  
260 - Token string `json:"token"`  
261 - Team_id int `json:"team_id"`  
262 -}  
263 -  
264 -type JoinTeamResp struct {  
265 - Status string `json:"status"`  
266 - Result CommonResult `json:"result"`  
267 -}  
268 -  
269 -  
270 -type JoinTeamByInviteReq struct{  
271 - Token string `json:"token"`  
272 - Inviter_id int `json:"inviter_id"`  
273 -}  
274 -  
275 -type JoinTeamByInviteResp struct {  
276 - Status string `json:"status"`  
277 - Result CommonResult `json:"result"`  
278 -}  
279 -  
280 -type QuitTeamReq struct{  
281 - Token string `json:"token"`  
282 - User_id int `json:"user_id"`  
283 - Type int `json:"type"`  
284 -}  
285 -  
286 -type QuitTeamResp struct {  
287 - Status string `json:"status"`  
288 - Result CommonResult `json:"result"`  
289 -}  
290 -  
291 -type UpdateTeamBuildReq struct{  
292 - Token string `json:"token"`  
293 - Build_type int `json:"build_type"`  
294 - Assets int `json:"assets"`  
295 - Muti int `json:"muti"`  
296 -}  
297 -  
298 -type QuitTeamDesc struct {  
299 - Build_list []TeamDevoteInfo `json:"build_list"`  
300 -}  
301 -  
302 -type QuitTeamResult struct {  
303 - Code int `json:"code"`  
304 - Data QuitTeamDesc `json:"data"`  
305 -}  
306 -  
307 -type UpdateTeamBuildResp struct {  
308 - Status string `json:"status"`  
309 - Result QuitTeamResult `json:"result"`  
310 -}  
311 -  
312 -  
313 -  
314 -type AddTeamBuffReq struct{  
315 - Token string `json:"token"`  
316 - Build_type int `json:"build_type"`  
317 - Muti int `json:"muti"`  
318 -}  
319 -  
320 -type BuffTimeInfo struct {  
321 - Buff_begin_time int `json:"buff_begin_time"`  
322 - Buff_end_time int `json:"buff_end_time"`  
323 -}  
324 -  
325 -type AddTeamBuffSpec struct {  
326 - Build_type int `json:"build_type"`  
327 - Buff_time []BuffTimeInfo `json:"buff_time"`  
328 -}  
329 -  
330 -type AddTeamBuffDesc struct {  
331 - Build_list []AddTeamBuffSpec `json:"build_list"`  
332 -}  
333 -  
334 -type AddTeamBuffResult struct {  
335 - Code int `json:"code"`  
336 - Data AddTeamBuffDesc `json:"data"`  
337 -}  
338 -  
339 -type AddTeamBuffResp struct {  
340 - Status string `json:"status"`  
341 - Result AddTeamBuffResult `json:"result"`  
342 -}  
343 -  
344 -type GetTeamBuffReq struct{  
345 - Token string `json:"token"`  
346 -}  
347 -  
348 -type GetTeamBuffResp struct {  
349 - Status string `json:"status"`  
350 - Result AddTeamBuffResult `json:"result"`  
351 -}  
352 -  
353 -type GetTeamDataReq struct{  
354 - Token string `json:"token"`  
355 -}  
356 -  
357 -type GetTeamDataTeamUserList struct {  
358 - Uuid int `json:"uuid"`  
359 -}  
360 -  
361 -type GetTeamDataDesc struct {  
362 - Team_data CreateTeamInfo `json:"team_data"`  
363 - Team_user_list []GetTeamDataTeamUserList `json:"team_user_list"`  
364 - Build_list QuitTeamDesc `json:"build_list"`  
365 -}  
366 -  
367 -type GetTeamDataResult struct {  
368 - Code int `json:"code"`  
369 - Data GetTeamDataDesc `json:"data"`  
370 -}  
371 -  
372 -type GetTeamDataResp struct {  
373 - Status string `json:"status"`  
374 - Result GetTeamDataResult `json:"result"`  
375 -}  
376 -  
377 -type GetDataByUserIdReq struct{  
378 - Token string `json:"token"`  
379 - Field string `json:"field"`  
380 - User_id int `json:"user_id"`  
381 -}  
382 -  
383 -type GetDataByUserIdDesc struct {  
384 - Base_data string `json:"base_data"`  
385 - User_base_data UserBaseData `json:"user_base_data"`  
386 - Extdata UserExtData `json:"user_ext_data"`  
387 -}  
388 -  
389 -type GetDataByUserIdResult struct {  
390 - Code int `json:"code"`  
391 - Data GetDataByUserIdDesc `json:"data"`  
392 -}  
393 -  
394 -type GetDataByUserIdResp struct {  
395 - Status string `json:"status"`  
396 - Result GetDataByUserIdResult `json:"result"`  
397 -}  
398 -  
399 -  
400 -type GetTeamListReq struct{  
401 - Token string `json:"token"`  
402 - Store_num int `json:"store_num"`  
403 - Page int `json:"page"`  
404 -}  
405 -  
406 -type GetTeamListDesc struct {  
407 - Items []int `json:"items"`  
408 - Count int `json:"count"`  
409 -}  
410 -  
411 -type GetTeamListResult struct {  
412 - Code int `json:"code"`  
413 - Data GetTeamListDesc `json:"data"`  
414 -}  
415 -  
416 -  
417 -type GetTeamListResp struct {  
418 - Status string `json:"status"`  
419 - Result GetTeamListResult `json:"result"`  
420 -}  
421 -  
422 -type SearchTeamReq struct{  
423 - Token string `json:"token"`  
424 - Name string `json:"name"`  
425 - Store_num int `json:"store_num"`  
426 - Page int `json:"page"`  
427 -}  
428 -  
429 -type SearchTeamResp struct {  
430 - Status string `json:"status"`  
431 - Result GetTeamListResult `json:"result"`  
432 -}  
433 -  
434 -type FriendInfo struct {  
435 - Uuid int `json:"uuid"`  
436 - Status int `json:"status"`  
437 -}  
438 -  
439 -type FriendList struct {  
440 - Friends []FriendInfo `json:"friends"`  
441 -}  
442 -  
443 -type ApplyInfo struct {  
444 - Uuid int `json:"uuid"`  
445 - Apply_time int `json:"apply_time"`  
446 -}  
447 -type ApplyList struct {  
448 - Apply_info []ApplyInfo `json:"apply_info"`  
449 -}  
450 -  
451 -type ApproveList struct {  
452 - Approve_info []ApplyInfo `json:"approve_info"`  
453 -}  
454 -  
455 -type SetFriendReq struct{  
456 - Token string `json:"token"`  
457 - User_id int `json:"user_id"`  
458 -}  
459 -  
460 -  
461 -type SetFriendResp struct {  
462 - Status string `json:"status"`  
463 - Result CommonResult `json:"result"`  
464 -}  
465 -  
466 -type GetFriendListReq struct{  
467 - Token string `json:"token"`  
468 -}  
469 -  
470 -type GetFriendListDesc struct {  
471 - Friend_list []FriendInfo `json:"friend_list"`  
472 -}  
473 -  
474 -type GetFriendListResult struct {  
475 - Code int `json:"code"`  
476 - Data GetFriendListDesc `json:"data"`  
477 -}  
478 -  
479 -type GetFriendListResp struct {  
480 - Status string `json:"status"`  
481 - Result GetFriendListResult `json:"result"`  
482 -}  
483 -  
484 -  
485 -type GetAuditListReq struct{  
486 - Token string `json:"token"`  
487 -}  
488 -  
489 -type GetAuditListDesc struct {  
490 - Approve_list []ApplyInfo `json:"approve_list"`  
491 -}  
492 -  
493 -type GetAuditListResult struct {  
494 - Code int `json:"code"`  
495 - Data GetAuditListDesc `json:"data"`  
496 -}  
497 -  
498 -type GetAuditListResp struct {  
499 - Status string `json:"status"`  
500 - Result GetAuditListResult `json:"result"`  
501 -}  
502 -  
503 -  
504 -type GetRecommendListReq struct{  
505 - Token string `json:"token"`  
506 -}  
507 -  
508 -type GetRecommendListInfo struct {  
509 - Userid int `json:"userid"`  
510 - Nickname string `json:"nickname"`  
511 - Avatar_url string `json:"avatar_url"`  
512 - Gender int `json:"gender"`  
513 - City string `json:"city"`  
514 - Hot int `json:"hot"`  
515 - Coin int64 `json:"coin"`  
516 - Love_exp int `json:"love_exp"`  
517 - Bean int `json:"bean"`  
518 - Shop_num int `json:"shop_num"`  
519 - Cat_num int `json:"cat_num"`  
520 - Lv int `json:"lv"`  
521 - Exp int `json:"exp"`  
522 - Reg_time int `json:"reg_time"`  
523 -}  
524 -  
525 -type GetRecommendListDesc struct {  
526 - Recommend_list []GetRecommendListInfo `json:"recommend_list"`  
527 -}  
528 -  
529 -type GetRecommendListResult struct {  
530 - Code int `json:"code"`  
531 - Data GetRecommendListDesc `json:"data"`  
532 -}  
533 -  
534 -type GetRecommendListResp struct {  
535 - Status string `json:"status"`  
536 - Result GetRecommendListResult `json:"result"`  
537 -}  
538 -  
539 -  
540 -type HandleFriendRequestReq struct{  
541 - Token string `json:"token"`  
542 - User_id int `json:"user_id"`  
543 - Type int `json:"type"`  
544 -}  
545 -  
546 -  
547 -type HandleFriendRequestResp struct {  
548 - Status string `json:"status"`  
549 - Result CommonResult `json:"result"`  
550 -}  
551 -  
552 -type DelFriendReq struct{  
553 - Token string `json:"token"`  
554 - User_id int `json:"user_id"`  
555 -}  
556 -  
557 -  
558 -type DelFriendResp struct {  
559 - Status string `json:"status"`  
560 - Result CommonResult `json:"result"`  
561 -} 17 +//**********************************************************************************************************
562 18
563 -type QueryPlayerDataReq struct{  
564 - Token string `json:"token"`  
565 - User_id int `json:"user_id"`  
566 -} 19 +type TaskInfo struct {
567 20
568 -type QueryPlayerDataDesc struct {  
569 - Player_data GetRecommendListInfo `json:"player_data"`  
570 } 21 }
571 22
572 -type QueryPlayerDataResult struct {  
573 - Code int `json:"code"`  
574 - Data QueryPlayerDataDesc `json:"data"`  
575 -} 23 +type AchieveMentInfo struct {
576 24
577 -type QueryPlayerDataResp struct {  
578 - Status string `json:"status"`  
579 - Result QueryPlayerDataResult `json:"result"`  
580 } 25 }
581 26
582 -//**********************************************************************************************************  
583 -  
584 -  
585 //玩家数据 27 //玩家数据
586 type UserData struct { 28 type UserData struct {
587 Userid int //玩家id 29 Userid int //玩家id
588 - Hot int  
589 - Coin int64 //金币  
590 - Loevexp int  
591 - Bean int //咖啡豆  
592 - Shopnum int //店铺数量  
593 - Lv int  
594 - Exp int  
595 - UserInviteId int  
596 - Userregtime int  
597 - Channel int  
598 - Isblack int  
599 - Scene int  
600 - Regtime int  
601 - InviteUid int  
602 - LoginTime int  
603 - LoginDay int 30 + Lv int //玩家当前等级
  31 + Exp int //玩家当前经验值
  32 + GuanGold int //玩家存钱罐中金币数量
  33 + RealGold int //玩家实际金币数量(可用于提现的)
  34 + WatchAddsTime int //当天观看激励视频次数
  35 + LastLoginTime int //上次登陆时间
  36 + ContinueLoginDay int //连续登录天数
  37 + GetFromGuanCnt int //当天从存钱款提取金币次数
  38 + Task TaskInfo //玩家任务完成相关信息
  39 + Achieve AchieveMentInfo //玩家成就完成相关数据
604 } 40 }
605 41
src/HttpServer/logic/errordef.go
@@ -2,5 +2,7 @@ package logic @@ -2,5 +2,7 @@ package logic
2 2
3 3
4 const ( 4 const (
5 - ERROR_OK = 0 //没有错误 5 + ERROR_OK =0 //没有错误
  6 + ERROR_SRV_ERROR =1 //服务器错误
  7 + ERROR_JSONUNMASH_ERROR =2 //json解析错误
6 ) 8 )
7 \ No newline at end of file 9 \ No newline at end of file
src/HttpServer/logic/function.go
1 package logic 1 package logic
2 2
3 import ( 3 import (
  4 + "HttpServer/redishandler"
  5 + "common/redis"
  6 + "encoding/json"
4 "net/http" 7 "net/http"
  8 + "strconv"
  9 + "time"
5 ) 10 )
6 11
7 func SetHeader(w http.ResponseWriter) { 12 func SetHeader(w http.ResponseWriter) {
@@ -10,4 +15,113 @@ func SetHeader(w http.ResponseWriter) { @@ -10,4 +15,113 @@ func SetHeader(w http.ResponseWriter) {
10 w.Header().Set("Access-Control-Allow-Headers", "Content-Type,Uuid") 15 w.Header().Set("Access-Control-Allow-Headers", "Content-Type,Uuid")
11 } 16 }
12 17
  18 +func SaveUserInfo(data *UserData) error {
13 19
  20 + savestr,err := json.Marshal(data)
  21 + if err != nil {
  22 + return err
  23 + }
  24 +
  25 + err = redishandler.GetRedisClient().HSet(redis.USER_DATA_KEY,strconv.Itoa(data.Userid),string(savestr))
  26 +
  27 + return err
  28 +}
  29 +
  30 +func GetUserInfo(uuid int) (*UserData,error) {
  31 +
  32 + data,err := redishandler.GetRedisClient().HGet(redis.USER_DATA_KEY,strconv.Itoa(uuid))
  33 + if err != nil {
  34 + return nil,err
  35 + }
  36 + var tmp UserData
  37 + err = json.Unmarshal([]byte(data),&tmp)
  38 + if err != nil {
  39 + return nil,err
  40 + }
  41 +
  42 + return &tmp,nil
  43 +}
  44 +
  45 +func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int) error{
  46 +
  47 + var initdata UserData
  48 + initdata.Lv = 1
  49 + initdata.Exp = 0
  50 + initdata.Userid = uuid
  51 + initdata.ContinueLoginDay = 1
  52 + initdata.GetFromGuanCnt = 0
  53 + initdata.GuanGold = 0
  54 + initdata.LastLoginTime = int(time.Now().Unix())
  55 + initdata.RealGold = 0
  56 + initdata.WatchAddsTime =WATCH_ADD_DAY_LIMIT
  57 +
  58 + resp.Guangold = initdata.GuanGold
  59 + resp.Leftads = initdata.WatchAddsTime
  60 + resp.Loginday = initdata.ContinueLoginDay
  61 +
  62 + err := SaveUserInfo(&initdata)
  63 +
  64 + return err
  65 +}
  66 +
  67 +
  68 +func (u *UserData) HandlePassDay() {
  69 + isdiffday := false
  70 + nowtime := time.Now()
  71 + lasttime := time.Unix(int64(u.LastLoginTime), 0)
  72 + nowdaynum := time.Now().Day()
  73 + lastdaynum := time.Unix(int64(u.LastLoginTime), 0).Day()
  74 + nowtimestamp := time.Date(nowtime.Year(), nowtime.Month(), nowtime.Day(), 0, 0, 0, 0, nowtime.Location())
  75 + lasttimestamp := time.Date(lasttime.Year(), lasttime.Month(), lasttime.Day(), 0, 0, 0, 0, lasttime.Location())
  76 +
  77 +
  78 + if nowdaynum == lastdaynum {
  79 + //同一天
  80 + if int64(u.LastLoginTime) - time.Now().Unix() > 86400 {
  81 + //已经过了很多天了
  82 + //u.LastLoginTime = int(time.Now().Unix())
  83 + u.ContinueLoginDay = 1
  84 + isdiffday = true
  85 + }else {
  86 + //t同一天 不做处理
  87 + }
  88 + }else {
  89 + //不是同一天了
  90 + isdiffday = true
  91 + if nowtimestamp.Unix() > lasttimestamp.Unix() + 86399 {
  92 + //超过一天了
  93 + u.ContinueLoginDay = 1
  94 + }else {
  95 + u.ContinueLoginDay ++
  96 + }
  97 + }
  98 +
  99 + if isdiffday {
  100 + //跨天了
  101 + u.WatchAddsTime = WATCH_ADD_DAY_LIMIT
  102 + //todo 重置任务相关的数据
  103 + u.GetFromGuanCnt = 0
  104 + }
  105 +
  106 + u.LastLoginTime = int(nowtime.Unix())
  107 +
  108 + SaveUserInfo(u)
  109 +}
  110 +
  111 +func GetUserData(uuid int, resp *UserLoginResp) error{
  112 + data,err := GetUserInfo(uuid)
  113 + if err != nil || data == nil{
  114 + resp.Code = ERROR_SRV_ERROR
  115 + resp.Message = "ERROR_SRV_ERROR"
  116 + return err
  117 + }
  118 +
  119 + //此处要处理一下跨天逻辑
  120 + data.HandlePassDay()
  121 +
  122 + resp.Loginday = data.ContinueLoginDay
  123 + resp.Leftads = data.WatchAddsTime
  124 + resp.Guangold = data.GuanGold
  125 +
  126 + return nil
  127 +}
14 \ No newline at end of file 128 \ No newline at end of file
src/HttpServer/logic/httpserver.go
@@ -2,6 +2,10 @@ package logic @@ -2,6 +2,10 @@ package logic
2 2
3 import ( 3 import (
4 "HttpServer/conf" 4 "HttpServer/conf"
  5 + "common/logger"
  6 + "io/ioutil"
  7 + "strconv"
  8 +
5 //"log" 9 //"log"
6 "net/http" 10 "net/http"
7 ) 11 )
@@ -34,11 +38,30 @@ func startServerHttpServe() { @@ -34,11 +38,30 @@ func startServerHttpServe() {
34 //------------------------------------------------------------- 38 //-------------------------------------------------------------
35 39
36 40
37 - 41 + http.HandleFunc("/elimatestar/login", UserLogin) //登录
38 err := http.ListenAndServe(conf.GetServerHttpAddrConf(), nil) 42 err := http.ListenAndServe(conf.GetServerHttpAddrConf(), nil)
39 CheckErr(err) 43 CheckErr(err)
40 } 44 }
41 45
42 46
  47 +func UserLogin(w http.ResponseWriter, r *http.Request) {
  48 +
  49 + Uuid := 0
  50 + if len(r.Header) > 0 {
  51 + Uuid, _ = strconv.Atoi(r.Header.Get("Uuid"))
  52 + }
  53 +
  54 + if Uuid == 0 {
  55 + SetHeader(w)
  56 + logger.Error("Uuid is nil!")
  57 + return
  58 + }
  59 + result, _ := ioutil.ReadAll(r.Body)
  60 + r.Body.Close()
  61 +
  62 + s := string(result)
  63 + logger.Info("UserLogin , body:%v,uuid=%v", s, Uuid)
43 64
  65 + HandlerLogin(w, s, Uuid)
  66 +}
44 67
src/HttpServer/logic/logic.go
1 -package logic  
2 \ No newline at end of file 1 \ No newline at end of file
  2 +package logic
  3 +
  4 +import (
  5 + "HttpServer/redishandler"
  6 + "common/logger"
  7 + "common/redis"
  8 + "encoding/json"
  9 + "fmt"
  10 + "net/http"
  11 + "strconv"
  12 +)
  13 +
  14 +func HandlerLogin(w http.ResponseWriter, data string, uuid int) {
  15 + SetHeader(w)
  16 + var resp UserLoginResp
  17 + resp.Code = 0
  18 + var rdata UserLoginReq
  19 + err := json.Unmarshal([]byte(data), &rdata)
  20 + for {
  21 + if err != nil {
  22 + logger.Info("json decode HandlerLogin data failed:%v,for:%v", err, data)
  23 + resp.Message = "json unmarshal failed"
  24 + resp.Code = ERROR_JSONUNMASH_ERROR
  25 + }
  26 +
  27 + //先判断一下是否是新用户
  28 + isexist,err := redishandler.GetRedisClient().HExists(redis.USER_DATA_KEY, strconv.Itoa(uuid))
  29 + if err != nil {
  30 + logger.Error("redis failed err=%v", err)
  31 + resp.Message = "ERROR_SRV_ERROR"
  32 + resp.Code = ERROR_SRV_ERROR
  33 + }
  34 +
  35 + if !isexist {
  36 + //不存在
  37 + //属于新登录的玩家数据
  38 + err = InitUserInfo(&rdata, &resp, uuid)
  39 + } else {
  40 + //已经登陆过了 需要获取玩家数据
  41 + err = GetUserData(uuid, &resp)
  42 + }
  43 +
  44 + if err != nil {
  45 + logger.Error("redis failed err=%v", err)
  46 + resp.Message = "ERROR_SRV_ERROR"
  47 + resp.Code = ERROR_SRV_ERROR
  48 + }
  49 + }
  50 +
  51 + //回包
  52 + respstr, _ := json.Marshal(&resp)
  53 + fmt.Fprint(w, string(respstr))
  54 +
  55 + logger.Info("###HandlerLogin###rdata:%v", string(respstr))
  56 +}
3 \ No newline at end of file 57 \ 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_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" //小游戏自定义数据  
9 - MSG_CKECK_ACCESSTOKEN = "CATCAFE_MSG_CKECK_ACCESSTOKEN" //敏感词检测的key  
10 - TEAM_USERTEAM_NAME = "CATCAFE_TEAM_USERTEAM_NAME" //存储了玩家队伍名称  
11 - TEAM_INFO = "CATCAFE_TEAM_INFO" //存储了玩家队伍信息  
12 - TEAM_MAX_UUID = "CATCAFE_TEAM_MAX_UUID" //记录当前最大的teamid,新增自增即可  
13 - TEAM_TEAMID_TOUUID = "CATCAFE_TEAM_TEAMID_TOUUID" //记录teamid与uuid的关系  
14 - FRIEND_LIST_KEY = "CATCAFE_FRIEND_LIST_KEY" //玩家的好友列表的key,需要在末尾加死":uuid"  
15 - FRIEND_APPLYLIST_KEY = "CATCAFE_FRIEND_APPLYLIST_KEY" //玩家申请好友列表,需要在末尾加死":uuid"  
16 - FRIEND_APPROVELIST_KEY = "CATCAFE_FRIEND_APPROVELIST_KEY" //待批准好友列表,需要在末尾加死":uuid"  
17 - FRIEND_RECOMMANDLIST_KEY = "CATCAFE_FRIEND_RECOMMANDLIST_KEY" //推荐好友缓存key  
18 - USER_ACCOUNT_PASSWORD_KEY = "CATCAFE_USER_ACCOUNT_PASSWORD_KEY" //玩家账号密码的key 4 + USER_DATA_KEY = "STARSTAR_USER_DATA_KEY" //玩家数据
  5 +
19 ) 6 )