Commit f406ee33b45056c7b13cf944f638b5468ce054bb
Merge branch 'cn/develop' into cn/publish/preview
Showing
2 changed files
with
17 additions
and
1 deletions
Show diff stats
src/utils/CommonFunc.lua
| @@ -349,4 +349,15 @@ function httpGetFormatData(params) | @@ -349,4 +349,15 @@ function httpGetFormatData(params) | ||
| 349 | end | 349 | end |
| 350 | 350 | ||
| 351 | return table.concat(body, "&") | 351 | return table.concat(body, "&") |
| 352 | -end | ||
| 353 | \ No newline at end of file | 352 | \ No newline at end of file |
| 353 | +end | ||
| 354 | + | ||
| 355 | +function logdump(obj, prefix) | ||
| 356 | + for k,v in pairs(obj) do | ||
| 357 | + local vt = type(v) | ||
| 358 | + if vt == "table" then | ||
| 359 | + logdump(v, prefix..':'..k) | ||
| 360 | + elseif vt == 'string' or vt == 'number' then | ||
| 361 | + skynet.error(prefix..':'..k..'='..v) | ||
| 362 | + end | ||
| 363 | + end | ||
| 364 | +end |
src/utils/MysqlUtil.lua
| 1 | local skynet = require "skynet" | 1 | local skynet = require "skynet" |
| 2 | local mysqlproxy = require "shared.mysqlproxy" | 2 | local mysqlproxy = require "shared.mysqlproxy" |
| 3 | +require "utils.CommonFunc" | ||
| 3 | 4 | ||
| 4 | 5 | ||
| 5 | function getDbCfgVal(tbName, keyName, fieldName) | 6 | function getDbCfgVal(tbName, keyName, fieldName) |
| @@ -29,20 +30,24 @@ end | @@ -29,20 +30,24 @@ end | ||
| 29 | 30 | ||
| 30 | function addFriend(roleId, friendId) | 31 | function addFriend(roleId, friendId) |
| 31 | local stmt_csp = mysqlproxy:prepare("call add_friends(?, ?, ?)") | 32 | local stmt_csp = mysqlproxy:prepare("call add_friends(?, ?, ?)") |
| 33 | + --logdump(stmt_csp, '') | ||
| 32 | local r = mysqlproxy:execute(stmt_csp, roleId, friendId, skynet.timex()) | 34 | local r = mysqlproxy:execute(stmt_csp, roleId, friendId, skynet.timex()) |
| 33 | if r[1][1]["t_error"] == 0 then | 35 | if r[1][1]["t_error"] == 0 then |
| 34 | rpcRole(roleId, "addFriend", friendId) | 36 | rpcRole(roleId, "addFriend", friendId) |
| 35 | rpcRole(friendId, "addFriend", roleId) | 37 | rpcRole(friendId, "addFriend", roleId) |
| 36 | end | 38 | end |
| 39 | + mysqlproxy:stmt_close(stmt_csp) | ||
| 37 | end | 40 | end |
| 38 | 41 | ||
| 39 | function delFriend(roleId, friendId) | 42 | function delFriend(roleId, friendId) |
| 40 | local stmt_csp = mysqlproxy:prepare("call del_friends(?, ?)") | 43 | local stmt_csp = mysqlproxy:prepare("call del_friends(?, ?)") |
| 44 | + --logdump(stmt_csp, '') | ||
| 41 | local r = mysqlproxy:execute(stmt_csp, roleId, friendId) | 45 | local r = mysqlproxy:execute(stmt_csp, roleId, friendId) |
| 42 | if r[1][1]["t_error"] == 0 then | 46 | if r[1][1]["t_error"] == 0 then |
| 43 | rpcRole(roleId, "delFriend", friendId) | 47 | rpcRole(roleId, "delFriend", friendId) |
| 44 | rpcRole(friendId, "delFriend", roleId) | 48 | rpcRole(friendId, "delFriend", roleId) |
| 45 | end | 49 | end |
| 50 | + mysqlproxy:stmt_close(stmt_csp) | ||
| 46 | end | 51 | end |
| 47 | 52 | ||
| 48 | function roleExists(roleId) | 53 | function roleExists(roleId) |