904118851 8 ay önce
ebeveyn
işleme
9741453229

+ 41 - 0
service/backmgr/filter_data.lua

@@ -0,0 +1,41 @@
+--筛选数据
+local M = {}
+local mysqldbx = require "mysqldbx"
+local tools = require "tools"
+local skynet = require "skynet"
+local cjson = require "cjson"
+
+function M.search_filter_data(msg_body)
+    local isok ,key =  tools.checkData({"tg_platform_id","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 tg_platform_id_param = ""
+    local isFirst = false
+    if msg_body.tg_platform_id~="" then
+        isFirst = true;
+        tg_platform_id_param =  " tg_platform_id = "..msg_body.tg_platform_id.." "
+    end
+
+    local param = tg_platform_id_param
+
+    if param ~= "" then
+        param = " WHERE "..param
+    end
+    local sql = "SELECT * FROM filter_data "..param..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
+
+    local res =  mysqldbx.query(sql)
+
+    sql =  "SELECT  COUNT(*) AS total  FROM filter_data  "..param
+
+    local total = mysqldbx.query(sql)
+
+    return true,res,total[1].total
+end
+
+
+return M

+ 39 - 3
service/backmgr/filter_task.lua

@@ -214,7 +214,7 @@ function M.search_tg_data(msg_body)
     "page_size",
     "page_number",
     "dy_id",
-"d_z","comment","collect","forward"},msg_body)
+"d_z","comment","collect","forward","status"},msg_body)
     if not isok then
         return false,string.format("缺少字段: %s.", key)
     end
@@ -310,6 +310,18 @@ function M.search_tg_data(msg_body)
     end
 
 
+    local status_param = ""
+
+    if msg_body.status~="" then
+        if isFirst == true then
+            status_param = "AND status = "..msg_body.status.." "
+        else
+            isFirst = true
+            status_param = " status = "..msg_body.status.." "
+        end
+    end
+
+
     local d_z_param = ""
     if msg_body.d_z~="" then
         if(msg_body.d_z == 0) then
@@ -346,7 +358,7 @@ function M.search_tg_data(msg_body)
         end
     end
     
-    local param = date_param..product_param..oce_material_param..tg_platform_param..sync_status_param..product_name_param..is_auto_param..material_id_param
+    local param = date_param..product_param..oce_material_param..status_param..tg_platform_param..sync_status_param..product_name_param..is_auto_param..material_id_param
 
     if param ~= "" then
         param = " WHERE "..param
@@ -360,6 +372,8 @@ function M.search_tg_data(msg_body)
         up_down_param = " ORDER BY id DESC "
     end
 
+
+
     local sql = "SELECT * FROM video_material "..param..up_down_param..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
    
     local res = mysqldbx.query(sql)
@@ -534,7 +548,29 @@ function M.search_book_data(msg_body)
    
     end
 
-    local param = is_auto_param..product_param..product_name_param..tg_platform_param;
+    local is_store_param = ""
+    if msg_body.is_store~="" then
+        if isFirst==true then
+            is_store_param = "AND is_store = "..msg_body.is_store.." "
+        else
+            isFirst = true;
+            is_store_param = " is_store = "..msg_body.is_store.." "
+        end
+   
+    end
+
+    local genre_param = ""
+    if msg_body.genre~="" then
+        if isFirst==true then
+            genre_param = "AND genre = "..msg_body.genre.." "
+        else
+            isFirst = true;
+            genre_param = " genre = "..msg_body.genre.." "
+        end
+   
+    end
+
+    local param = is_auto_param..product_param..product_name_param..tg_platform_param..is_store_param..genre_param;
 
     if param ~= "" then
         param = " WHERE "..param

+ 4 - 0
service/backmgr/init.lua

@@ -21,6 +21,8 @@ local book_black_list = require "book_black_list"
 local video_titles = require "video_titles"
 local pull_data_config = require "pull_data_config"
 local pull_data_status = require "pull_data_status"
+local video_applet_product = require "video_applet_product"
+local filter_data = require "filter_data"
 local status_200 = 200
 local CMD = {
     
@@ -40,6 +42,8 @@ CMD["book_black_list"] = book_black_list;
 CMD["video_titles"] = video_titles;
 CMD["pull_data_config"] = pull_data_config;
 CMD["pull_data_status"] = pull_data_status;
+CMD["video_applet_product"] = video_applet_product;
+CMD["filter_data"] = filter_data;
 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)

+ 52 - 0
service/backmgr/video_applet_product.lua

@@ -0,0 +1,52 @@
+--小程序书籍
+local M = {}
+local mysqldbx = require "mysqldbx"
+local tools = require "tools"
+local skynet = require "skynet"
+local cjson = require "cjson"
+local config = require "run_config"
+local mysql = require "skynet.db.mysql"
+local db
+local mysqldtaskbx = {}
+function M.add_applet_product(msg_body)
+    local isok ,key =  tools.checkData({"product_name","product_id","book_platform","dy_small_program_start","dy_small_program_start_data","dy_small_applet_app_id","check_url","main_id","status"},msg_body)
+    if not isok then
+        return false,string.format("缺少字段: %s.", key)
+    end
+    local sql = string.format("INSERT INTO `video_applet_product` (product_name,product_id,book_platform,dy_small_program_start,dy_small_program_start_data,dy_small_applet_app_id,check_url,main_id,status,wait_status)  VALUES ('%s','%s',%d,'%s','%s','%s','%s',%d,%d,%d)",
+    msg_body.product_name,msg_body.product_id,msg_body.book_platform,msg_body.dy_small_program_start,msg_body.dy_small_program_start_data,msg_body.dy_small_applet_app_id,msg_body.check_url,msg_body.main_id,msg_body.status,2)
+    mysqldtaskbx.Singleton().query(sql)
+    return true, {}
+end
+
+function mysqldtaskbx.start()
+    local function on_connect(db)
+        db:query("set charset utf8mb4");
+    end
+    local conf = config.db_cnf.book_server.mysqldb_task_cnf
+    db = mysql.connect{
+        host=conf.ip,
+        port=conf.port,
+        database=conf.db,
+        user=conf.user,
+        password=conf.password,
+        charset="utf8mb4",
+        max_packet_size = 1024 * 1024,
+        on_connect = on_connect
+    }
+    if not db then
+       skynet.error("mysql connect fail")
+    end
+end
+
+function mysqldtaskbx.Singleton()
+    if db == nil then
+        mysqldtaskbx.start()
+    end
+    return mysqldtaskbx
+end
+function mysqldtaskbx.query(sql)
+    return db:query(sql)
+end
+
+return M