904118851 5 ay önce
ebeveyn
işleme
a6e828941a

+ 1 - 1
common/dbproxy/redisdb/redisdb_slave.lua

@@ -203,7 +203,7 @@ end
 
 skynet.start(function()
     skynet.dispatch("lua", function(_, _, cmd, ...)
-        -- DEBUG("redis slave cmd = ", cmd)
+        skynet.error("redis slave cmd = ", ...)
         local f = assert(CMD[cmd], cmd .. " not found")
         skynet.retpack(f(...))
     end)

+ 1 - 1
common/dbproxy/redisdb/redisdbpool.lua

@@ -1,6 +1,6 @@
 local skynet = require "skynet"
 require "skynet.manager"
-local setting_template = require "settings"
+local setting_template = require "run_config"
 
 local skynet_node_name = ...
 

+ 63 - 0
service/backmgr/data_manager.lua

@@ -0,0 +1,63 @@
+local M = {}
+local redisdbx = require "redisdbx"
+local tools = require "tools"
+local skynet = require "skynet"
+local mysqldbx = require "mysqldbx"
+local cjson = require "cjson"
+function M.set(msg_body)
+    local isok ,key =  tools.checkData({"key","value"},msg_body)
+    if not isok then
+        return false,string.format("缺少字段: %s.", key)
+    end
+    -- local current_time = os.date("%Y-%m-%d %H:%M:%S")
+    redisdbx.exec("set",nil,"xs-"..msg_body.key,msg_body.value)
+    return true, {}
+end
+
+
+function M.get(msg_body)
+    local isok ,key =  tools.checkData({"key"},msg_body)
+    if not isok then
+        return false,string.format("缺少字段: %s.", key)
+    end
+    local res = redisdbx.exec("get",nil,"xs-"..msg_body.key)
+    return true, res
+end
+
+
+
+function M.db_set(msg_body)
+    local isok ,key =  tools.checkData({"key","value"},msg_body)
+    if not isok then
+        return false,string.format("缺少字段: %s.", key)
+    end
+
+    local sql = string.format("SELECT * FROM data_manager WHERE key = '%s' LIMIT 1", msg_body.key)
+    local isok,res;
+    res = mysqldbx.query(sql)
+    if #res > 0 then
+        sql = string.format("UPDATE  data_manager SET db_value = '%s' WHERE db_key = '%s' ",msg_body.value,msg_body.key)
+    else
+        sql = string.format("INSERT INTO `data_manager` (db_key,db_value)  VALUES ('%s','%s')",msg_body.key,cjson.encode(msg_body.value))
+    end
+    skynet.error("sql:",sql)
+    mysqldbx.query(sql)
+    return true, {}
+end
+
+
+function M.db_get(msg_body)
+    local isok ,key =  tools.checkData({"key"},msg_body)
+    if not isok then
+        return false,string.format("缺少字段: %s.", key)
+    end
+    local sql = string.format("SELECT * FROM data_manager WHERE db_key = '%s' LIMIT 1", msg_body.key)
+    local isok,res;
+    res = mysqldbx.query(sql)
+    if #res > 0 then
+        res = res[1]
+    end
+    return true, res
+end
+
+return M

+ 2 - 0
service/backmgr/init.lua

@@ -44,6 +44,7 @@ local material_review = require "material_review"
 local yw_book = require "yw_book"
 local wechat_miniapp_product = require "wechat_miniapp_product"
 local material_platform = require "material_platform"
+local data_manager = require "data_manager"
 local status_200 = 200
 local CMD = {
     
@@ -86,6 +87,7 @@ CMD["material_review"] = material_review;
 CMD["yw_book"] = yw_book;
 CMD["wechat_miniapp_product"] = wechat_miniapp_product;
 CMD["material_platform"] = material_platform;
+CMD["data_manager"] = data_manager;
 function run(target,fun,msg_body,fd)
     if target~=nil and fun~=nil and target[fun]~=nil then
         local isok,data,total = target[fun](msg_body)