Commit 14db6ea413ec7dc8c7c58f9df34d685f1622e4e2
1 parent
871cee35
Exists in
master
提交
Showing
3 changed files
with
48 additions
and
3 deletions
Show diff stats
src/HttpServer/conf/world.xml
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <Config> | 2 | <Config> |
3 | <GameDB Ip="172.21.0.34" Port="3306" User="mini_game_db" Pwd="TXsql@VFhzcWxAV1Z" Database="cat_cafe" LoadInterval="5" /> | 3 | <GameDB Ip="172.21.0.34" Port="3306" User="mini_game_db" Pwd="TXsql@VFhzcWxAV1Z" Database="cat_cafe" LoadInterval="5" /> |
4 | - <ServerHttpAddr Host="127.0.0.1:50057" /> | 4 | + <ServerHttpAddr Host=":50057" /> |
5 | <Redis Host="172.21.0.25:6379" Db="27" Password="crs-lzslccdc:redis@YXp8Jk#MV" /> | 5 | <Redis Host="172.21.0.25:6379" Db="27" Password="crs-lzslccdc:redis@YXp8Jk#MV" /> |
6 | </Config> | 6 | </Config> |
7 | \ No newline at end of file | 7 | \ No newline at end of file |
src/HttpServer/logic/httpserver.go
@@ -2,6 +2,7 @@ package logic | @@ -2,6 +2,7 @@ package logic | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "HttpServer/conf" | 4 | "HttpServer/conf" |
5 | + "HttpServer/redishandler" | ||
5 | "common/logger" | 6 | "common/logger" |
6 | "fmt" | 7 | "fmt" |
7 | "io/ioutil" | 8 | "io/ioutil" |
@@ -80,12 +81,29 @@ func ClearData(w http.ResponseWriter, r *http.Request) { | @@ -80,12 +81,29 @@ func ClearData(w http.ResponseWriter, r *http.Request) { | ||
80 | return | 81 | return |
81 | } | 82 | } |
82 | uuidnum,_ := strconv.Atoi(uuid) | 83 | uuidnum,_ := strconv.Atoi(uuid) |
83 | - coin,err := mysql.TestClearData(uuidnum) | 84 | + /*coin,err := mysql.TestClearData(uuidnum) |
84 | if err != nil { | 85 | if err != nil { |
85 | logger.Error("ClearData err=%v",err) | 86 | logger.Error("ClearData err=%v",err) |
86 | } | 87 | } |
87 | 88 | ||
88 | - fmt.Fprint(w, "ClearData uuid=%v,coin=%v",uuid,coin) | 89 | + fmt.Fprint(w, "ClearData coin=%v",coin)*/ |
90 | + err := mysql.DoClearData(uuidnum) | ||
91 | + if err != nil { | ||
92 | + fmt.Fprint(w, "清除数据失败了,错误码%v",err) | ||
93 | + } | ||
94 | + | ||
95 | + //下面清楚redis | ||
96 | + rediskey := "cat:cafe:data:where:data_uid:" + uuid | ||
97 | + exist,_ := redishandler.GetRedisClient().Exists(rediskey) | ||
98 | + if exist { | ||
99 | + //存在,即删除 | ||
100 | + err = redishandler.GetRedisClient().Delete(rediskey) | ||
101 | + if err != nil { | ||
102 | + fmt.Fprint(w, "清除数据失败了,错误码%v",err) | ||
103 | + } | ||
104 | + } | ||
105 | + | ||
106 | + fmt.Fprint(w, "清除数据成功了,恭喜!uuid=%v",uuid) | ||
89 | 107 | ||
90 | //HandleRegeister(w,s) | 108 | //HandleRegeister(w,s) |
91 | } | 109 | } |
src/mysql/dbmysql.go
@@ -32,6 +32,18 @@ func InitMysqlByConf(cfg conf.MysqlConf) (*sql.DB, error) { | @@ -32,6 +32,18 @@ func InitMysqlByConf(cfg conf.MysqlConf) (*sql.DB, error) { | ||
32 | return db, nil | 32 | return db, nil |
33 | } | 33 | } |
34 | 34 | ||
35 | +func ExcuteCmd(cmd string) error { | ||
36 | + rows, err := m_game_db.Query(cmd) | ||
37 | + if rows != nil { | ||
38 | + defer rows.Close() | ||
39 | + } | ||
40 | + if err != nil { | ||
41 | + logger.Notic("ExcuteCmd Query error:%v cmd:%v", err, cmd) | ||
42 | + return err | ||
43 | + } | ||
44 | + return err | ||
45 | +} | ||
46 | + | ||
35 | func TestClearData(uid int) (int,error) { | 47 | func TestClearData(uid int) (int,error) { |
36 | cmd := fmt.Sprintf("select coin from b_user_ext_04 where user_id=%d", uid) | 48 | cmd := fmt.Sprintf("select coin from b_user_ext_04 where user_id=%d", uid) |
37 | 49 | ||
@@ -58,4 +70,19 @@ func TestClearData(uid int) (int,error) { | @@ -58,4 +70,19 @@ func TestClearData(uid int) (int,error) { | ||
58 | break | 70 | break |
59 | } | 71 | } |
60 | return value,nil | 72 | return value,nil |
73 | +} | ||
74 | + | ||
75 | +func DoClearData(uuid int) error{ | ||
76 | + //先删除十张分表的数据 | ||
77 | + for i:=0;i<10;i++ { | ||
78 | + tablename := "b_base_data_0" + strconv.Itoa(i) | ||
79 | + cmd := "DELETE from " + tablename + " where data_uid= " + strconv.Itoa(uuid) | ||
80 | + err := ExcuteCmd(cmd) | ||
81 | + if err != nil { | ||
82 | + logger.Error("DoClearData err=%v,cmd=%v",err,cmd) | ||
83 | + return err | ||
84 | + } | ||
85 | + } | ||
86 | + return nil | ||
87 | + | ||
61 | } | 88 | } |
62 | \ No newline at end of file | 89 | \ No newline at end of file |