904118851 11 сар өмнө
parent
commit
29a25973eb
1 өөрчлөгдсөн 79 нэмэгдсэн , 0 устгасан
  1. 79 0
      service/backmgr/init.lua

+ 79 - 0
service/backmgr/init.lua

@@ -289,6 +289,85 @@ end
 s.resp.get_user_share_list = function(msg_body,fd)
     
 end
+
+local function search_video_by_id_list(id_list,call_back)
+    local listToFind= {}
+    for i = 1, #id_list, 1 do
+        table.insert(listToFind,i,id_list[i].id)
+    end
+    local findString = table.concat(listToFind, ',')
+    local sql = string.format("SELECT * FROM generate_video_list_tab WHERE id IN (%s)", findString)
+    local res = db:query(sql)
+    if res and #res > 0 then
+        local tab =  {}
+        if #res == 1 then
+            tab[1] = tools.getDbResData(res)
+        else
+            tab = tools.getDbResData(res)
+        end
+        call_back(tab)
+    else
+        call_back({})
+    end
+end
+
+--生成视频查询
+s.resp.search_video = function(msg_body,fd)
+    local isOk,key = tools.checkData({"page",
+    "count",
+    "video_stype",
+    "search_book_name",
+    "search_user_id","start_time_date","end_time_date"},msg_body)
+    if not isOk then
+        return tools.response(fd,200,cjson.encode({code=9001,msg = string.format("缺少字段: '%s'.", key)}))
+    end
+    function action(isOk,id_list)
+        local error_json = '{"code": 10000,   "msg": "生成视频查询",  "data": [] }'
+        if isOk then
+            local _list = {}
+            local total_count = 0 
+            _list ,total_count = tools.getPageData(msg_body.page,msg_body.count,id_list)
+            if #_list<=0  then
+                return tools.response(fd,200,error_json)
+            end
+            skynet.fork(search_video_by_id_list,_list,function(data_list)
+                tools.response(fd,200,cjson.encode({code=10000,msg = "生成视频查询",data=data_list,total_count=total_count}))
+            end)
+            return
+        end
+        return tools.response(fd,200,error_json)
+    end
+    local param = ""
+
+    if msg_body.search_book_name ~= "" then
+        param = param .." AND book_name = ".."'"..msg_body.search_book_name.."'"
+    end
+
+    if msg_body.video_stype ~= "" then
+        param = param .." AND video_stype = "..msg_body.video_stype
+    end
+
+    if msg_body.search_user_id ~= "" then
+        param = param .." AND user_id = "..msg_body.search_user_id
+    end
+    -- local sql = "SELECT * FROM generate_video_list_tab WHERE create_time BETWEEN '" .. start_time .. "' AND '" .. end_time .. "'".." AND video_state=1"
+    local sql = "SELECT id FROM generate_video_list_tab WHERE DATE(create_time) >= DATE(FROM_UNIXTIME(" .. (msg_body.start_time_date / 1000) .. ")) AND DATE(create_time) <= DATE(FROM_UNIXTIME(" .. (msg_body.end_time_date / 1000) .. "))".." AND video_state=1"..param
+    -- skynet.error("sql",sql)
+    local res = db:query(sql)
+    if res and #res > 0 then
+        local tab =  {}
+        if #res == 1 then
+            tab[1] = tools.getDbResData(res)
+        else
+            tab = tools.getDbResData(res)
+        end
+        action(true,tab)
+        skynet.error("Found data:")
+    else
+        action(false,nil)
+        skynet.error("No data found.")
+    end
+end
 --接口end
 s.resp.on_recv = function (source, fd, msg_id, msg_body)
     skynet.error("接收一后台消息 ",msg_id)