|
@@ -0,0 +1,81 @@
|
|
|
+--拉取数据配置
|
|
|
+local M = {}
|
|
|
+local mysqldbx = require "mysqldbx"
|
|
|
+local tools = require "tools"
|
|
|
+local skynet = require "skynet"
|
|
|
+local cjson = require "cjson"
|
|
|
+
|
|
|
+function M.get_all_pull_data_list(msg_body)
|
|
|
+ local sql = "SELECT * FROM pull_data_config "
|
|
|
+ local list = mysqldbx.query(sql)
|
|
|
+ return true,list
|
|
|
+end
|
|
|
+
|
|
|
+
|
|
|
+function M.modify_pull_data_config(msg_body)
|
|
|
+ local isok ,key = tools.checkData({"id","start","name","interval_minute"},msg_body)
|
|
|
+ if not isok then
|
|
|
+ return false,string.format("缺少字段: %s.", key)
|
|
|
+ end
|
|
|
+ local sql = string.format("UPDATE `pull_data_config` SET start = '%s' ,name ='%s' , interval_minute = %d WHERE id = %d ",
|
|
|
+ msg_body.start,msg_body.name,msg_body.interval_minute,msg_body.id)
|
|
|
+ mysqldbx.query(sql)
|
|
|
+ return true, {}
|
|
|
+end
|
|
|
+
|
|
|
+function M.add_pull_data_list_config(msg_body)
|
|
|
+ local isok ,key = tools.checkData({"config_list"},msg_body)
|
|
|
+ if not isok then
|
|
|
+ return false,string.format("缺少字段: %s.", key)
|
|
|
+ end
|
|
|
+ for i = 1, #msg_body.config_list, 1 do
|
|
|
+ local config_item = msg_body.config_list[i]
|
|
|
+ local sql = string.format("INSERT INTO `pull_data_config` (start,name,interval_minute) VALUES ('%s','%s',%d)",config_item.start,config_item.name,config_item.interval_minute)
|
|
|
+ skynet.error(sql)
|
|
|
+ mysqldbx.query(sql)
|
|
|
+ end
|
|
|
+ return true, {}
|
|
|
+end
|
|
|
+
|
|
|
+function M.add_pull_data_config(msg_body)
|
|
|
+ local isok ,key = tools.checkData({"start","name","interval_minute"},msg_body)
|
|
|
+ if not isok then
|
|
|
+ return false,string.format("缺少字段: %s.", key)
|
|
|
+ end
|
|
|
+ local sql = string.format("INSERT INTO `pull_data_config` (start,name,interval_minute) VALUES ('%s','%s',%d)",msg_body.start,msg_body.name,msg_body.interval_minute)
|
|
|
+ mysqldbx.query(sql)
|
|
|
+ return true, {}
|
|
|
+end
|
|
|
+
|
|
|
+function M.delete_pull_data_config(msg_body)
|
|
|
+ local isok ,key = tools.checkData({"id"},msg_body)
|
|
|
+ if not isok then
|
|
|
+ return false,string.format("缺少字段: %s.", key)
|
|
|
+ end
|
|
|
+ local sql = string.format("DELETE FROM pull_data_config WHERE id = %d ",msg_body.id)
|
|
|
+ mysqldbx.query(sql)
|
|
|
+ return true, {}
|
|
|
+end
|
|
|
+
|
|
|
+function M.pull_data_list(msg_body)
|
|
|
+ local isok ,key = tools.checkData({"page_size","page_number"},msg_body)
|
|
|
+ if not isok then
|
|
|
+ return false,string.format("缺少字段: %s.", key)
|
|
|
+ end
|
|
|
+ local page_size = msg_body.page_size
|
|
|
+ local page_number = msg_body.page_number
|
|
|
+ local offset = (page_number - 1) * page_size
|
|
|
+ local sql = "SELECT * FROM pull_data_config "..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
|
|
|
+ local list = mysqldbx.query(sql)
|
|
|
+ sql = "SELECT COUNT(*) AS total FROM pull_data_config "
|
|
|
+ local total = mysqldbx.query(sql)
|
|
|
+ return true,list,total[1].total
|
|
|
+end
|
|
|
+
|
|
|
+function M.sync_pull_data_config(msg_body)
|
|
|
+ local sql = "SELECT * FROM pull_data_config "
|
|
|
+ local list = mysqldbx.query(sql)
|
|
|
+ skynet.send("backmgr","lua","on_recv",nil,"ws_push_msg",cjson.encode({cmd="updatePullConig",data=list}))
|
|
|
+ return true,{}
|
|
|
+end
|
|
|
+return M
|