|
@@ -4,6 +4,11 @@ local mysqldbx = require "mysqldbx"
|
|
local tools = require "tools"
|
|
local tools = require "tools"
|
|
local skynet = require "skynet"
|
|
local skynet = require "skynet"
|
|
|
|
|
|
|
|
+function M.get_all_black_books()
|
|
|
|
+ local sql = "SELECT * FROM black_list "
|
|
|
|
+ local res = mysqldbx.query(sql)
|
|
|
|
+ return true,res
|
|
|
|
+end
|
|
function M.add_book(msg_body)
|
|
function M.add_book(msg_body)
|
|
local isok ,key = tools.checkData({"product_id","product_name"},msg_body)
|
|
local isok ,key = tools.checkData({"product_id","product_name"},msg_body)
|
|
if not isok then
|
|
if not isok then
|
|
@@ -17,6 +22,7 @@ function M.add_book(msg_body)
|
|
end
|
|
end
|
|
sql = string.format("INSERT INTO `black_list` (product_id,product_name) VALUES ('%s','%s')",msg_body.product_id,msg_body.product_name)
|
|
sql = string.format("INSERT INTO `black_list` (product_id,product_name) VALUES ('%s','%s')",msg_body.product_id,msg_body.product_name)
|
|
mysqldbx.query(sql)
|
|
mysqldbx.query(sql)
|
|
|
|
+ skynet.send("backmgr","lua","on_recv",nil,"push_msg","updateBlackBooks")
|
|
return true, {}
|
|
return true, {}
|
|
end
|
|
end
|
|
|
|
|
|
@@ -27,9 +33,21 @@ function M.delete_book(msg_body)
|
|
end
|
|
end
|
|
local sql = string.format("DELETE FROM black_list WHERE product_id = '%s' ",msg_body.product_id)
|
|
local sql = string.format("DELETE FROM black_list WHERE product_id = '%s' ",msg_body.product_id)
|
|
mysqldbx.query(sql)
|
|
mysqldbx.query(sql)
|
|
|
|
+ skynet.send("backmgr","lua","on_recv",nil,"push_msg","updateBlackBooks")
|
|
return true, {}
|
|
return true, {}
|
|
end
|
|
end
|
|
|
|
|
|
|
|
+function M.is_black_book(msg_body)
|
|
|
|
+ local isok ,key = tools.checkData({"product_id"},msg_body)
|
|
|
|
+ if not isok then
|
|
|
|
+ return false,string.format("缺少字段: %s.", key)
|
|
|
|
+ end
|
|
|
|
+ local sql = string.format("SELECT * FROM black_list WHERE product_id = '%s' LIMIT 1", msg_body.product_id)
|
|
|
|
+ local isok,res;
|
|
|
|
+ res = mysqldbx.query(sql)
|
|
|
|
+ return true, {is_black_book = #res > 0}
|
|
|
|
+end
|
|
|
|
+
|
|
function M.search_book_list(msg_body)
|
|
function M.search_book_list(msg_body)
|
|
local isok ,key = tools.checkData({"page_size","page_number","product_id","product_name"},msg_body)
|
|
local isok ,key = tools.checkData({"page_size","page_number","product_id","product_name"},msg_body)
|
|
if not isok then
|
|
if not isok then
|