From 14db6ea413ec7dc8c7c58f9df34d685f1622e4e2 Mon Sep 17 00:00:00 2001 From: 陆恒 Date: Thu, 30 Apr 2020 10:43:53 +0800 Subject: [PATCH] 提交 --- src/HttpServer/conf/world.xml | 2 +- src/HttpServer/logic/httpserver.go | 22 ++++++++++++++++++++-- src/mysql/dbmysql.go | 27 +++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/HttpServer/conf/world.xml b/src/HttpServer/conf/world.xml index 78db86e..0dd88bd 100644 --- a/src/HttpServer/conf/world.xml +++ b/src/HttpServer/conf/world.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/src/HttpServer/logic/httpserver.go b/src/HttpServer/logic/httpserver.go index 5feb92a..6e2b9ed 100644 --- a/src/HttpServer/logic/httpserver.go +++ b/src/HttpServer/logic/httpserver.go @@ -2,6 +2,7 @@ package logic import ( "HttpServer/conf" + "HttpServer/redishandler" "common/logger" "fmt" "io/ioutil" @@ -80,12 +81,29 @@ func ClearData(w http.ResponseWriter, r *http.Request) { return } uuidnum,_ := strconv.Atoi(uuid) - coin,err := mysql.TestClearData(uuidnum) + /*coin,err := mysql.TestClearData(uuidnum) if err != nil { logger.Error("ClearData err=%v",err) } - fmt.Fprint(w, "ClearData uuid=%v,coin=%v",uuid,coin) + fmt.Fprint(w, "ClearData coin=%v",coin)*/ + err := mysql.DoClearData(uuidnum) + if err != nil { + fmt.Fprint(w, "清除数据失败了,错误码%v",err) + } + + //下面清楚redis + rediskey := "cat:cafe:data:where:data_uid:" + uuid + exist,_ := redishandler.GetRedisClient().Exists(rediskey) + if exist { + //存在,即删除 + err = redishandler.GetRedisClient().Delete(rediskey) + if err != nil { + fmt.Fprint(w, "清除数据失败了,错误码%v",err) + } + } + + fmt.Fprint(w, "清除数据成功了,恭喜!uuid=%v",uuid) //HandleRegeister(w,s) } diff --git a/src/mysql/dbmysql.go b/src/mysql/dbmysql.go index b4ac11e..cdde904 100644 --- a/src/mysql/dbmysql.go +++ b/src/mysql/dbmysql.go @@ -32,6 +32,18 @@ func InitMysqlByConf(cfg conf.MysqlConf) (*sql.DB, error) { return db, nil } +func ExcuteCmd(cmd string) error { + rows, err := m_game_db.Query(cmd) + if rows != nil { + defer rows.Close() + } + if err != nil { + logger.Notic("ExcuteCmd Query error:%v cmd:%v", err, cmd) + return err + } + return err +} + func TestClearData(uid int) (int,error) { cmd := fmt.Sprintf("select coin from b_user_ext_04 where user_id=%d", uid) @@ -58,4 +70,19 @@ func TestClearData(uid int) (int,error) { break } return value,nil +} + +func DoClearData(uuid int) error{ + //先删除十张分表的数据 + for i:=0;i<10;i++ { + tablename := "b_base_data_0" + strconv.Itoa(i) + cmd := "DELETE from " + tablename + " where data_uid= " + strconv.Itoa(uuid) + err := ExcuteCmd(cmd) + if err != nil { + logger.Error("DoClearData err=%v,cmd=%v",err,cmd) + return err + } + } + return nil + } \ No newline at end of file -- libgit2 0.21.0