904118851 8 月之前
父节点
当前提交
fa51b745dd
共有 4 个文件被更改,包括 126 次插入0 次删除
  1. 2 0
      service/backmgr/init.lua
  2. 56 0
      service/backmgr/no_filter_origin.lua
  3. 59 0
      service/backmgr/origin_video_titles.lua
  4. 9 0
      service/doc/cmd_sql.sql

+ 2 - 0
service/backmgr/init.lua

@@ -24,6 +24,7 @@ local pull_data_status = require "pull_data_status"
 local video_applet_product = require "video_applet_product"
 local filter_data = require "filter_data"
 local video_material = require "video_material"
+local no_filter_origin = require "no_filter_origin"
 local status_200 = 200
 local CMD = {
     
@@ -46,6 +47,7 @@ CMD["pull_data_status"] = pull_data_status;
 CMD["video_applet_product"] = video_applet_product;
 CMD["filter_data"] = filter_data;
 CMD["video_material"] = video_material;
+CMD["no_filter_origin"] = no_filter_origin;
 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)

+ 56 - 0
service/backmgr/no_filter_origin.lua

@@ -0,0 +1,56 @@
+--无筛选原始数据
+local M = {}
+local mysqldbx = require "mysqldbx"
+local tools = require "tools"
+local skynet = require "skynet"
+local cjson = require "cjson"
+
+function check_table_exists(table_name)
+    local sql = string.format("SHOW TABLES LIKE '%s'", table_name)
+    local res = mysqldbx.query(sql)
+    return res and #res > 0
+end
+
+function M.search_no_filter_origin_data(msg_body)
+    local isok ,key =  tools.checkData({"date","page_size","page_number"},msg_body)
+    if not isok then
+        return false,string.format("缺少字段: %s.", key)
+    end
+    local table_name = "pull_data_"..string.gsub(msg_body.date, "-", "")
+
+    if not check_table_exists(table_name) then
+        return false,string.format("不存在  %s 这个数据.", table_name)
+    end
+
+    local page_size = msg_body.page_size
+    local page_number = msg_body.page_number
+    local offset = (page_number - 1) * page_size
+
+    local up_down_param = " ORDER BY " .." likeCount DESC "
+
+    local sql = "SELECT * FROM "..table_name.." WHERE 1=1 "..up_down_param..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
+
+    local res =  mysqldbx.query(sql)
+
+    sql =  "SELECT  COUNT(*) AS total  FROM "..table_name
+
+    local total = mysqldbx.query(sql)
+
+    return true,res,total[1].total
+end
+
+function M.delete_no_filter_origin_data(msg_body)
+    local isok ,key =  tools.checkData({"date"},msg_body)
+    if not isok then
+        return false,string.format("缺少字段: %s.", key)
+    end
+    local table_name = "pull_data_"..string.gsub(msg_body.date, "-", "")
+    if not check_table_exists(table_name) then
+        return false,string.format("不存在  %s 这个数据.", table_name)
+    end
+    local sql = string.format("DROP TABLE %s", table_name)
+    mysqldbx.query(sql)
+    return true,{}
+end
+
+return M

+ 59 - 0
service/backmgr/origin_video_titles.lua

@@ -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

+ 9 - 0
service/doc/cmd_sql.sql

@@ -173,3 +173,12 @@ primary key (id));
 
 
 
+create table other_book (  
+	id int not null auto_increment COMMENT '唯一id',
+	product_id  varchar(64),	
+	product_name  varchar(64),
+	tg_platform_id int not null  COMMENT '平台id',	
+	create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+primary key (id));
+
+