|
@@ -0,0 +1,59 @@
|
|
|
+--视频标题
|
|
|
+local M = {}
|
|
|
+local mysqldbx = require "mysqldbx"
|
|
|
+local tools = require "tools"
|
|
|
+local skynet = require "skynet"
|
|
|
+local md5 = require "md5"
|
|
|
+
|
|
|
+
|
|
|
+function M.delete_origin_video_titles(msg_body)
|
|
|
+ local isok ,key = tools.checkData({"id_list"},msg_body)
|
|
|
+ if not isok then
|
|
|
+ return false,string.format("缺少字段: %s.", key)
|
|
|
+ end
|
|
|
+ for i = 1, #msg_body.id_list, 1 do
|
|
|
+ local id = msg_body.id_list[i]
|
|
|
+ local sql = string.format("DELETE FROM origin_video_titles WHERE id = %d ",id)
|
|
|
+ mysqldbx.query(sql)
|
|
|
+ end
|
|
|
+ return true, {}
|
|
|
+end
|
|
|
+
|
|
|
+function M.publish_origin_video_titles(msg_body)
|
|
|
+ local isok ,key = tools.checkData({"id_list"},msg_body)
|
|
|
+ if not isok then
|
|
|
+ return false,string.format("缺少字段: %s.", key)
|
|
|
+ end
|
|
|
+
|
|
|
+ for i = 1, #msg_body.title_list, 1 do
|
|
|
+ local title_tab = msg_body.title_list[i]
|
|
|
+ local sql = string.format("INSERT INTO `video_titles` (title,md5_tag) VALUES ('%s','%s')",title_tab.title,title_tab.md5_tag)
|
|
|
+ mysqldbx.query(sql)
|
|
|
+ sql = string.format("DELETE FROM origin_video_titles WHERE id = %d ",title_tab.id)
|
|
|
+ mysqldbx.query(sql)
|
|
|
+ end
|
|
|
+ return true, {}
|
|
|
+end
|
|
|
+
|
|
|
+function M.search_origin_video_titles(msg_body)
|
|
|
+ local isok ,key = tools.checkData({"page_size","page_number","content","start_create_time","end_create_time"},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 create_date_param = ""
|
|
|
+ if msg_body.start_create_time~="" and msg_body.end_create_time~="" then
|
|
|
+ create_date_param = " AND DATE(create_time) >= DATE(FROM_UNIXTIME(" .. (msg_body.start_create_time / 1000) .. ")) AND DATE(create_time) <= DATE(FROM_UNIXTIME(" .. (msg_body.end_create_time / 1000) .. "))"
|
|
|
+ end
|
|
|
+
|
|
|
+ local sql = "SELECT * FROM origin_video_titles WHERE 1=1 "..create_date_param..string.format(" AND (title LIKE CONCAT( '%%%s%%')) ",msg_body.content)..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
|
|
|
+ local list = mysqldbx.query(sql)
|
|
|
+ sql = "SELECT COUNT(*) AS total FROM origin_video_titles WHERE 1=1 "..create_date_param..string.format(" AND (title LIKE CONCAT( '%%%s%%')) ",msg_body.content)
|
|
|
+ local total = mysqldbx.query(sql)
|
|
|
+ return true,list,total[1].total
|
|
|
+end
|
|
|
+
|
|
|
+return M
|