Commit bc29d2f5c4cc7827fa7c093763981b86d8fcf574

Authored by 陆恒
1 parent a79d6ab6

提交测试接口

Showing 1 changed file with 30 additions and 1 deletions   Show diff stats
src/HttpServer/logic/httpserver.go
@@ -2,7 +2,9 @@ package logic @@ -2,7 +2,9 @@ package logic
2 2
3 import ( 3 import (
4 "HttpServer/conf" 4 "HttpServer/conf"
  5 + "HttpServer/redishandler"
5 "common/logger" 6 "common/logger"
  7 + "common/redis"
6 "encoding/json" 8 "encoding/json"
7 "fmt" 9 "fmt"
8 "io/ioutil" 10 "io/ioutil"
@@ -39,7 +41,8 @@ func startServerHttpServe() { @@ -39,7 +41,8 @@ func startServerHttpServe() {
39 //http.HandleFunc("/catcafe/QueryAllAccount", QueryAllAccount) //查询所有账号的等级信息等数据 41 //http.HandleFunc("/catcafe/QueryAllAccount", QueryAllAccount) //查询所有账号的等级信息等数据
40 //------------------------------------------------------------- 42 //-------------------------------------------------------------
41 43
42 - http.HandleFunc("/eliminatestar/test", Testapi) //登录 44 + http.HandleFunc("/eliminatestar/test", Testapi) //测试接口
  45 + http.HandleFunc("/eliminatestar/clear", ClearData) //清除账号
43 //---------------------------------------------------------------------------------------- 46 //----------------------------------------------------------------------------------------
44 http.HandleFunc("/eliminatestar/login", UserLogin) //登录 47 http.HandleFunc("/eliminatestar/login", UserLogin) //登录
45 http.HandleFunc("/eliminatestar/getuserdata", Getuserdata) //获取玩家数据 48 http.HandleFunc("/eliminatestar/getuserdata", Getuserdata) //获取玩家数据
@@ -62,6 +65,32 @@ func startServerHttpServe() { @@ -62,6 +65,32 @@ func startServerHttpServe() {
62 CheckErr(err) 65 CheckErr(err)
63 } 66 }
64 67
  68 +func ClearData(w http.ResponseWriter, r *http.Request) {
  69 +
  70 + Uuid := 0
  71 + if len(r.Header) > 0 {
  72 + Uuid, _ = strconv.Atoi(r.Header.Get("Uuid"))
  73 + }
  74 +
  75 + if Uuid == 0 {
  76 + SetHeader(w)
  77 + //logger.Error("Uuid is nil!")
  78 + return
  79 + }
  80 + result, _ := ioutil.ReadAll(r.Body)
  81 + r.Body.Close()
  82 +
  83 + s := string(result)
  84 + logger.Info("ClearData , body:%v,uuid=%v", s, Uuid)
  85 +
  86 + redishandler.GetRedisClient().HDel(redis.USER_DATA_KEY, strconv.Itoa(Uuid))
  87 + redishandler.GetRedisClient().HDel(redis.USER_TASKINFO_LIST, strconv.Itoa(Uuid))
  88 + redishandler.GetRedisClient().HDel(redis.USER_ACHIEVEMENTINFO_LIST, strconv.Itoa(Uuid))
  89 + redishandler.GetRedisClient().HDel(redis.USER_WITHDRAW_RECORDLIST, strconv.Itoa(Uuid))
  90 +
  91 + fmt.Fprint(w, "success!")
  92 +}
  93 +
65 func Usersign(w http.ResponseWriter, r *http.Request) { 94 func Usersign(w http.ResponseWriter, r *http.Request) {
66 95
67 Uuid := 0 96 Uuid := 0