904118851 1 жил өмнө
parent
commit
6250c8f02b

+ 1 - 0
etc/run_config.lua

@@ -40,5 +40,6 @@ return {
     db_name = "video_tools_user_db",
     testHttpProt = 9910;
     tools_api = "http://clipvideoup.hainanmlwl.com"; --测试
+    is_debug  = true;
     -- tools_api = "http://clipvideoup.s6kuwan.com"; --正式
 }

+ 64 - 21
lualib/tools.lua

@@ -4,6 +4,7 @@ local skynet = require "skynet"
 local httpd = require "http.httpd"
 local cjson = require "cjson"
 local crypt = require "client.crypt"
+local runConfig  = require "run_config"
 local M = {
 
 }
@@ -46,25 +47,28 @@ M.checkData= function(origin,table)
 end
 
 M.dump = function(res, tab)
-    -- tab = tab or 0
-    -- if(tab == 0) then
-    --     skynet.error("............dump...........")
-    -- end
+    if runConfig.is_debug == nil then
+        return
+    end
+    tab = tab or 0
+    if(tab == 0) then
+        skynet.error("............dump...........")
+    end
     
-    -- if type(res) == "table" then
-    --     skynet.error(string.rep("\t", tab).."{")
-    --     for k,v in pairs(res) do
-    --         if type(v) == "table" then
-    --             skynet.error(k.."=")
-    --             M.dump(v, tab + 1)
-    --          else
-    --             skynet.error(string.rep("\t", tab), k, "=", v, ",")
-    --         end
-    --     end
-    --     skynet.error(string.rep("\t", tab).."}")
-    -- else
-    --     skynet.error(string.rep("\t", tab) , res)
-    -- end
+    if type(res) == "table" then
+        skynet.error(string.rep("\t", tab).."{")
+        for k,v in pairs(res) do
+            if type(v) == "table" then
+                skynet.error(k.."=")
+                M.dump(v, tab + 1)
+             else
+                skynet.error(string.rep("\t", tab), k, "=", v, ",")
+            end
+        end
+        skynet.error(string.rep("\t", tab).."}")
+    else
+        skynet.error(string.rep("\t", tab) , res)
+    end
 end
 
 M.getDbResData = function(res)
@@ -147,8 +151,11 @@ M.getPageData = function(page, count,list)
 end
 
 --回应db新建文件夹
-M.response_db_new_folder = function(fd,is_ok)
+M.response_db_new_folder = function(fd,is_ok,error_info)
     if not is_ok then
+        if error_info~=nil then
+            return M.response(fd,200,cjson.encode({code=10001,msg = error_info}))
+        end
         return M.response(fd,200,cjson.encode({code=10001,msg = "新建文件夹失败!"}))
     end
     return M.response(fd,200,cjson.encode({code=10000,msg = "新建文件夹成功!"}))
@@ -351,7 +358,7 @@ M.response_db_get_video_list_by_folder_id = function(fd,msg_body,isok,tab)
     local total_count = 0 
     list,total_count = M.getPageData(msg_body.page,msg_body.count,list)
     for i = 1, #list, 1 do
-        table.insert(folder_list,i,{template_id=list[i].template_id,video_state=list[i].video_state,video_url=list[i].video_url,create_time=list[i].create_time,file_id=list[i].id,info=list[i].generate_video_info,file_name=list[i].video_name,custom=list[i].custom})
+        table.insert(folder_list,i,{template_id=list[i].template_id,video_state=list[i].video_state,video_url=list[i].video_url,create_time=list[i].create_time,file_id=list[i].id,info=list[i].generate_video_info,file_name=list[i].video_name,custom=list[i].custom,path=list[i].path})
     end
     if #list<=0  then
         return M.response(fd,200,'{"code": 10000,   "msg": "获取文件夹内的生成视频失败",  "data": [] }')
@@ -369,7 +376,7 @@ M.response_db_search_generate_video_file = function(fd,msg_body,isok,tab)
     local total_count = 0 
     list ,total_count = M.getPageData(msg_body.page,msg_body.count,list)
     for i = 1, #list, 1 do
-        table.insert(file_list,i,{template_id=list[i].template_id,video_state=list[i].video_state,video_url=list[i].video_url,create_time=list[i].create_time,file_id=list[i].id,info=list[i].generate_video_info,file_name=list[i].video_name,custom=list[i].custom})
+        table.insert(file_list,i,{template_id=list[i].template_id,video_state=list[i].video_state,video_url=list[i].video_url,create_time=list[i].create_time,file_id=list[i].id,info=list[i].generate_video_info,file_name=list[i].video_name,custom=list[i].custom,path=list[i].path})
         -- table.insert(file_list,i,{create_time=list[i].create_time,file_id=list[i].id,info=list[i].generate_video_info,file_name=list[i].video_name})
     end
     if #list<=0  then
@@ -383,6 +390,42 @@ M.response_db_generate_video = function(fd,isok)
     end
     return M.response(fd,200,cjson.encode({code=10000,msg = "生成视频成功"}))
 end
+
+M.response_db_check_folder_repeat_file = function(fd,msg_body,isok,tab)
+    -- skynet.error("response_db_check_folder_repeat_file",tab)
+    -- M.dump(tab)
+    if #tab.normal_file_name_list<=0 then
+        tab.normal_file_name_list = ''
+    end
+    if #tab.repeat_file_name_list<=0 then
+        tab.repeat_file_name_list = ''
+    end
+    return M.response(fd,200,cjson.encode({code=10000,msg = "检测完毕!",data=tab}))
+end
+
+M.response_db_get_share_user_list = function(fd,msg_body,isok,tab)
+    local error_json = '{"code": 10000,   "msg": "获取失败",  "data": [] }'
+    local list = tab
+    local user_list = {}
+    local total_count = 0 
+    list ,total_count = M.getPageData(msg_body.page,msg_body.count,list)
+    if #list<=0  then
+        return M.response(fd,200,error_json)
+    end
+    local temp = {}
+    for i = 1, #list, 1 do
+        table.insert(temp,i,{user_id=list[i].id,name=list[i].name,group_id=list[i].group_id})
+    end
+    return M.response(fd,200,cjson.encode({code=10000,msg = "获取成功!",data=temp,total_count=total_count}))
+end
+
+M.response_db_get_folder_info = function(fd,msg_body,isok,tab)
+      local error_json = '{"code": 10000,   "msg": "获取失败",  "data": [] }'
+      if not isok or #tab<=0 then
+        return M.response(fd,200,error_json)
+      end
+      return M.response(fd,200,cjson.encode({code=10000,msg = "获取成功!",data=tab}))
+end
 M.getRandomIndex = function(array)
     local count = #array
     local index = math.random(1,count)

+ 139 - 5
service/agentmgr/init.lua

@@ -376,11 +376,19 @@ s.resp.create_template = function(fd,msg_body,user_data)
         return tools.response(fd,200,cjson.encode({code=9001,msg = string.format("缺少字段: %s.", key)}))
     end
     local error_info = ""
-    isok,error_info = skynet.call("dbmgr","lua","on_recv","check_template_isRight", msg_body)
 
-    if not isok then
-        return tools.response(fd,200,error_info)
+    if msg_body.video_stype == 1 then  --1 解压
+        isok,error_info = skynet.call("dbmgr","lua","on_recv","check_template_isRight", msg_body)
+        if not isok then
+            return tools.response(fd,200,error_info)
+        end
+    else  --2 滚屏
+        isok,error_info = skynet.call("dbmgr","lua","on_recv","check_template_scroll_isRight", msg_body)
+        if not isok then
+            return tools.response(fd,200,error_info)
+        end
     end
+
     -- isok  = skynet.call("dbmgr","lua","on_recv","checkNumsByType",{
     --     duration = 0,
     --     type = 1,
@@ -438,8 +446,7 @@ s.resp.create_template = function(fd,msg_body,user_data)
     -- if not isok then
     --     return tools.response(fd,200,cjson.encode({code=10001,msg = "BGM音效资源不足!"}))
     -- end
-
-
+    -- tools.dump(msg_body)
     isok = skynet.call("dbmgr","lua","on_recv","create_template",msg_body,fd)
     if not isok then
         return tools.response(fd,200,cjson.encode({code=10001,msg = "新建模板失败"}))
@@ -866,6 +873,130 @@ s.resp.get_user_file_count_by_type  = function(user_id,file_type)
         return count
     end
 end
+
+--分享文件列表
+s.resp.share_file_list = function(fd,msg_body,user_data)
+    msg_body = cjson.decode(msg_body)
+    if type(user_data) ~= "table" then
+        return  tools.response(fd, 200, "token error!")
+    end
+    local user_id = user_data.user_id
+    -- tools.dump(msg_body)
+    if user_id==nil then
+        return tools.response(fd,100,"user_id==nil share_file_list !")
+    end
+    msg_body["user_id"] = user_id
+    local isok ,key =  tools.checkData({"file_id_list","target_user_id_list"},msg_body)
+    if not isok then
+        return tools.response(fd,200,cjson.encode({code=9001,msg = string.format("缺少字段: %s.", key)}))
+    end
+    isok  = skynet.call("dbmgr","lua","on_recv","share_file_list",{
+        file_id_list = msg_body.file_id_list,
+        target_user_id_list = msg_body.target_user_id_list,
+        user_id = user_id},fd
+    )
+
+    if not isok then
+        return tools.response(fd,200,cjson.encode({code=10001,msg = "分享文件列表失败!"}))
+    end
+    return tools.response(fd,200,cjson.encode({code=10000,msg = "分享文件列表成功!"}))
+end
+
+
+--分享文件夹列表
+s.resp.share_folder_list = function(fd,msg_body,user_data)
+    msg_body = cjson.decode(msg_body)
+    if type(user_data) ~= "table" then
+        return  tools.response(fd, 200, "token error!")
+    end
+    local user_id = user_data.user_id
+    -- tools.dump(msg_body)
+    if user_id==nil then
+        return tools.response(fd,100,"user_id==nil share_folder_list !")
+    end
+    msg_body["user_id"] = user_id
+    local isok ,key =  tools.checkData({"folder_id_list","target_user_id_list"},msg_body)
+    if not isok then
+        return tools.response(fd,200,cjson.encode({code=9001,msg = string.format("缺少字段: %s.", key)}))
+    end
+    isok  = skynet.call("dbmgr","lua","on_recv","share_folder_list",{
+        folder_id_list = msg_body.folder_id_list,
+        target_user_id_list = msg_body.target_user_id_list,
+        user_id = user_id},fd
+    )
+    if not isok then
+        return tools.response(fd,200,cjson.encode({code=10001,msg = "分享文件夹列表失败!"}))
+    end
+    return tools.response(fd,200,cjson.encode({code=10000,msg = "分享文件夹列表成功!"}))
+end
+
+--获取用户的分享用户列表
+s.resp.get_share_user_list = function(fd,msg_body,user_data)
+    msg_body = cjson.decode(msg_body)
+    if type(user_data) ~= "table" then
+        return  tools.response(fd, 200, "token error!")
+    end
+    local user_id = user_data.user_id
+    -- tools.dump(msg_body)
+    if user_id==nil then
+        return tools.response(fd,100,"user_id==nil get_share_user_list !")
+    end
+    msg_body["user_id"] = user_id
+    local isok ,key =  tools.checkData({"count","page"},msg_body)
+    if not isok then
+        return tools.response(fd,200,cjson.encode({code=9001,msg = string.format("缺少字段: %s.", key)}))
+    end
+    isok  = skynet.call("dbmgr","lua","on_recv","get_share_user_list",{
+        count = msg_body.count,
+        page = msg_body.page,
+        user_id = user_id},fd
+    )
+end
+
+--检测文件夹下是否有相同命名的资源
+s.resp.check_file_name_list_is_repeat_by_folder_id = function(fd,msg_body,user_data)
+    msg_body = cjson.decode(msg_body)
+    if type(user_data) ~= "table" then
+        return  tools.response(fd, 200, "token error!")
+    end
+    local user_id = user_data.user_id
+    -- tools.dump(msg_body)
+    if user_id==nil then
+        return tools.response(fd,100,"user_id==nil check_file_name_list_is_repeat_by_folder_id !")
+    end
+    msg_body["user_id"] = user_id
+    local isok ,key =  tools.checkData({"folder_id","file_name_list"},msg_body)
+    if not isok then
+        return tools.response(fd,200,cjson.encode({code=9001,msg = string.format("缺少字段: %s.", key)}))
+    end
+    isok  = skynet.call("dbmgr","lua","on_recv","check_file_name_list_is_repeat_by_folder_id",{
+        folder_id = msg_body.folder_id,
+        file_name_list = msg_body.file_name_list,
+        user_id = user_id},fd
+    )
+end
+
+s.resp.get_folder_info = function(fd,msg_body,user_data)
+    msg_body = cjson.decode(msg_body)
+    if type(user_data) ~= "table" then
+        return  tools.response(fd, 200, "token error!")
+    end
+    local user_id = user_data.user_id
+    -- tools.dump(msg_body)
+    if user_id==nil then
+        return tools.response(fd,100,"user_id==nil get_folder_info !")
+    end
+    msg_body["user_id"] = user_id
+    local isok ,key =  tools.checkData({"folder_id_list"},msg_body)
+    if not isok then
+        return tools.response(fd,200,cjson.encode({code=9001,msg = string.format("缺少字段: %s.", key)}))
+    end
+    isok  = skynet.call("dbmgr","lua","on_recv","get_folder_info",{
+        folder_id_list = msg_body.folder_id_list,
+        user_id = user_id},fd
+    )
+end
+
 --踢掉
 s.resp.kick = function(fd,msg_body,user_data)
     
@@ -876,6 +1007,9 @@ end
 s.resp.on_recv = function (source, fd, msg_id, msg_body,user_data)
     skynet.error("接收一条客户端消息 ",msg_id,user_data)
     local func = string.gsub(msg_id, '/', '')
+    if s.resp[func] ==nil then 
+        return ools.response(fd,200,"???")
+    end
     if func ~= "login" then
        if not  s.resp.account_is_other_user_login(source,user_data.user_id,user_data.index) then
        

+ 22 - 3
service/backmgr/init.lua

@@ -21,9 +21,13 @@ s.resp.admin_login = function(msg_body,fd)
     end
     skynet.error("msg_body")
     if msg_body.account == "zhuoyueweizhong2024" and msg_body.password == "zywz123" then
-        return tools.response(fd,200,cjson.encode({code=10000,msg = "成功!",data={user_name="卓越微众"}}))
+        return tools.response(fd,200,cjson.encode({code=10000,msg = "成功!",data={user_name="卓越微众",user_id=-1,info="{}",group_id=-1,permit_id=-1}}))
     else
-        return tools.response(fd,200,cjson.encode({code=10001,msg = "登陆失败,密码错误!"}))
+        local isok,user_data =  skynet.call("dbmgr","lua","on_recv","verify",msg_body)
+        if not isok then
+            return tools.response(fd,200,cjson.encode({code=10001,msg = "登陆失败,账号密码错误!"}))
+        end
+        return tools.response(fd,200,cjson.encode({code=10000,msg = "成功!",data={user_name=user_data.name,user_id=user_data.id,info=user_data.user_info,group_id=user_data.group_id,permit_id=user_data.permit_id}}))
     end
     tools.dump(msg_body)
 end
@@ -58,7 +62,12 @@ s.resp.modify_user = function(msg_body,fd)
         end
         return tools.response(fd,200,cjson.encode({code=10001,msg = "修改用户失败!"}))
     end
-    local sql = string.format("UPDATE users SET password ='%s' ,group_id = %d ,permit_id = %d , is_ban = %d  , name = '%s' WHERE id = %d ",msg_body.modify_password,msg_body.modify_group_id,msg_body.modify_permissions_id,msg_body.is_ban,msg_body.user_name,msg_body.user_id)
+
+    local user_info = "{}"
+    if  msg_body.user_info~=nil then
+        user_info = msg_body.user_info
+    end
+    local sql = string.format("UPDATE users SET password ='%s' ,group_id = %d ,permit_id = %d , is_ban = %d  , name = '%s' ,user_info = '%s' WHERE id = %d ",msg_body.modify_password,msg_body.modify_group_id,msg_body.modify_permissions_id,msg_body.is_ban,msg_body.user_name,user_info,msg_body.user_id)
     db:query(sql)
     skynet.error(sql)
     action(true)
@@ -271,6 +280,14 @@ s.resp.modify_classification = function(msg_body,fd)
     -- skynet.error("sql",sql)
     db:query(sql)
     action(true)
+end
+--给用户添加可分享的用户
+s.resp.add_user_share = function(msg_body,fd)
+    
+end
+--获取用户可分享的用户列表
+s.resp.get_user_share_list = function(msg_body,fd)
+    
 end
 --接口end
 s.resp.on_recv = function (source, fd, msg_id, msg_body)
@@ -283,6 +300,8 @@ s.resp.on_recv = function (source, fd, msg_id, msg_body)
     end
     return tools.response(fd,200,string.format("接口 %s 不存在",func))
 end
+
+
 s.init = function()
     db=mysql.connect({
 		host=runconfig.db_tost,

+ 25 - 2
service/config_mgr/init.lua

@@ -73,6 +73,22 @@ local config = {
                 describe = "",
             }
         },
+        ["7"] = { --角标
+            [1]={
+                name = "全部",
+                is_ban = 0,
+                classification_id = 1,
+                describe = "",
+            }
+        },
+        ["8"] = { --底纹
+            [1]={
+                name = "全部",
+                is_ban = 0,
+                classification_id = 1,
+                describe = "",
+            }
+        },
     },
     permissions_info = {
 
@@ -167,11 +183,12 @@ s.resp.update_config_info = function(msg_body,fd)
     local config_info = {}
     skynet.error("update_config_info")
     function action(isOk,info)
-        local error_json = '{"code": 10000,   "msg": "更新权限失败成功"}'
+        local error_json = '{"code": 10000,   "msg": "更新权限失败"}'
         if isOk then
             config.config_info = info.info
         else
             config_info =  cjson.encode(config.config_info)
+            config.config_info = config_info
             local sql = string.format("INSERT INTO classification_list_tab (info,self_id) VALUES ('%s',%d)",config_info,1)
             local res = db:query(sql)
             skynet.error(sql)
@@ -196,10 +213,16 @@ s.resp.update_config_info = function(msg_body,fd)
 end
 
 s.resp.get_config_info = function(msg_body,fd)
-    return tools.response(fd,200,cjson.encode({code=10000,msg = "成功!",data=config.config_info}))
+    -- skynet.error("config.config_info",config.config_info)
+    return tools.response(fd,200,cjson.encode({code=10000,msg = "成功!",data=cjson.decode(config.config_info)}))
 end
 
 s.resp.get_permissions_info = function(msg_body,fd)
+    -- local isOk,key = tools.checkData({"permissions_id"},msg_body)
+    -- if not isOk then
+    --     return tools.response(fd,200,cjson.encode({code=9001,msg = string.format("缺少字段: '%s'.", key)}))
+    -- end
+
     local permissions_info = {} 
     if config.permissions_info~=nil and #config.permissions_info>0 then
         permissions_info = config.permissions_info

+ 427 - 13
service/dbmgr/init.lua

@@ -207,11 +207,60 @@ s.resp.parse_template_info = function(info,template_info)
         table.insert(bgm_audio,1,{video_id =data.info.id,path =data.info.path,duration=data.info.duration,info = data })
         -- table.insert(bgm_audio,1,data)
     end
-    return head_video,content_video,end_video,bgm_audio
+
+
+    --底部
+    local bottom = {}
+
+    if  template_info.bottom_text_image_data.select_video_file~=nil then
+        local data = template_info.bottom_text_image_data.select_video_file
+        table.insert(bottom,1,{info = data })
+        -- table.insert(bgm_audio,1,data)
+    end
+
+    ---
+    local corner = {}
+    if  template_info.corner_mark_image_data.select_video_file~=nil then
+        local data = template_info.corner_mark_image_data.select_video_file
+        table.insert(corner,1,{info = data })
+        -- table.insert(bgm_audio,1,data)
+    end
+    return head_video,content_video,end_video,bgm_audio,bottom,corner
+end
+
+--根据部门id获取部门列表
+s.resp.get_group_list = function(group_id,call_back)
+    skynet.fork(function()
+        local sql = string.format("select * from users where group_id = %d ",group_id)
+        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({})
+            skynet.error("No data found.")
+        end
+    end)
 end
 
 s.resp.getUserById = function(id)
-    
+    local sql = string.format("select * from users where id = %d ",id)
+    skynet.error("sql",sql)
+    local res = db:query(sql)
+      -- 判断是否找到数据
+    if res and #res > 0 then
+        local tab = tools.getDbResData(res)
+        skynet.error("Found data:",tab)
+        return true,tab
+    else
+        skynet.error("No data found.")
+        return false,nil
+    end
 end
 
 s.resp.updateUserInfoById = function(id)
@@ -273,6 +322,10 @@ end
 --- 新建文件夹
 s.resp.new_folder = function(msg_body,fd)
     skynet.fork(function(_fd)
+        local isOk,folder_info = s.resp.get_folder_by_name(msg_body)
+        if isOk then
+            return  tools.response_db_new_folder(_fd,false,string.format("创建失败,已存在 %s !",msg_body.folder_name))
+        end
         local sql = string.format("INSERT INTO folder_list_tab (user_id,folder_name, folder_type,is_public,classification_id) VALUES (%d, '%s',%d,%d,%d)",msg_body.user_id,msg_body.folder_name,msg_body.folder_type,msg_body.is_public,msg_body.classification_id)
         -- skynet.error(sql)
         local res = db:query(sql)
@@ -341,7 +394,7 @@ s.resp.folder_res_list = function(msg_body,fd,call_back)
         end
         local sql = string.format("select * from res_list_tab where user_id = %d AND folder_id = %d AND is_public = %d  AND is_delete = 0"..sql_duration,msg_body.user_id,msg_body.folder_id,msg_body.is_public)
         local res = db:query(sql)
-        skynet.error('folder_res_list',sql)
+        skynet.error('获取指定文件夹内的资源列表',sql)
         -- 判断是否找到数据
         if res and #res > 0 then
             local tab =  {}
@@ -463,7 +516,7 @@ s.resp.search_res = function(msg_body,fd)
         if msg_body.duration~=nil then
             sql_duration = string.format(" AND duration >= %f",msg_body.duration)
         end
-        local sql = string.format("SELECT * FROM res_list_tab WHERE file_type = %d AND file_name LIKE '%%%s%%'  AND is_delete = 0 AND classification_id = %d"..sql_duration,msg_body.type ,msg_body.search_content,msg_body.classification_id)
+        local sql = string.format("SELECT * FROM res_list_tab WHERE file_type = %d AND file_name LIKE '%%%s%%'  AND is_delete = 0 AND classification_id = %d AND user_id = %d"..sql_duration,msg_body.type ,msg_body.search_content,msg_body.classification_id,msg_body.user_id)
         -- skynet.error("sql",sql)
         local res = db:query(sql)
         if res and #res > 0 then
@@ -578,7 +631,7 @@ end
 --新建模板
 s.resp.create_template = function(msg_body,fd)
     local template_info = "{}"
-    if msg_body.template_info~=nil then
+    if msg_body.template_info~=nil and msg_body.template_info~="" then
         template_info = msg_body.template_info
     end
     local sql = string.format("INSERT INTO template_list_tab (user_id,project_name, book_name,ratio,video_stype,subtitles,subtitles_audio,video_nums,video_crop_time,template_info) VALUES (%d, '%s','%s',%d,%d,'%s','%s',%d,%d,'%s')",msg_body.user_id,msg_body.project_name,msg_body.book_name,msg_body.ratio,msg_body.video_stype,msg_body.subtitles,msg_body.subtitles_audio,msg_body.video_nums,msg_body.video_crop_time,template_info)
@@ -782,16 +835,28 @@ s.resp.get_random_res_by_folder_list = function(file_type,classification_id,fold
     end
 end
 
---生成视频数据库
+--生成滚动视频
+s.resp.generate_scroll_video = function(template_tab,fd)
+    local isOk,error_info = s.resp.check_template_scroll_isRight(template_tab)
+    return isOk,error_info
+end
+--生成解压视频数据库
 s.resp.generate_video = function(msg_body,fd)
     s.resp.get_template_info_by_id(msg_body,nil,function(tab)
         -- tools.dump(tab)
         if tab ~=nil then
             local isOk,error_info = s.resp.check_template_isRight(tab)
-            if  not isOk then
-                
-                return  tools.response(fd,200,error_info)
+            if tab.video_stype == 1 then --解压
+                if  not isOk then
+                    return  tools.response(fd,200,error_info)
+                end
+            else
+                isOk,error_info =  s.resp.generate_scroll_video(tab,fd)
+                if  not isOk then
+                    return  tools.response(fd,200,error_info)
+                end
             end
+ 
             -- tools.dump(tab)
             local user_id = msg_body.user_id
             local template_id = msg_body.template_id
@@ -804,7 +869,10 @@ s.resp.generate_video = function(msg_body,fd)
             local write_video_db = function(folder_id)
                 skynet.error("开始生成",folder_id)
                 local template_info = cjson.decode(tab.template_info)
-                local gen_num = #template_info.creat_video_list
+                local gen_num = 0
+                if  template_info.creat_video_list~=nil then
+                    gen_num =  #template_info.creat_video_list
+                end
                 local custom = {}
                 if template_info.custom~=nil and template_info.custom~="" then
                     custom = template_info.custom
@@ -813,7 +881,7 @@ s.resp.generate_video = function(msg_body,fd)
                 -- tools.dump(custom)
                 for i = 1, gen_num, 1 do  -- 模拟数据每次生成5条 
                     local item_info = template_info.creat_video_list[i]
-                    local head_video,content_video,end_video,bgm_audio = s.resp.parse_template_info(tab,item_info)
+                    local head_video,content_video,end_video,bgm_audio,bottom,corner = s.resp.parse_template_info(tab,item_info)
                     -- tools.dump(head_video)
                     -- tools.dump(content_video)
                     -- tools.dump(end_video)
@@ -845,9 +913,11 @@ s.resp.generate_video = function(msg_body,fd)
                     video_list = content_video,
                     subtitles = {stype=0,subtitle_font="",subtitles_path=template_info.subtitles_path},
                     subtitles_audio={path = template_info.subtitles_audio_path,duration=template_info.subtitles_audio_duration },
-                    video_last_frame =end_video[1],
-                    video_first_frame = head_video[1],
+                    video_last_frame =end_video[1] or {},
+                    video_first_frame = head_video[1] or {},
                     bgm_list = bgm_audio[1],
+                    corner_mark_image = corner[1] or {},
+                    bottom_text_image = bottom[1] or {},
                     hot_tag = {type=hot_tag_type,path=""}, --上边
                     fictitious_tag = {type=fictitious_tag_type,path=""}, --下边
                     custom = custom,
@@ -1215,6 +1285,44 @@ s.resp.check_have_folder = function(msg_body)
     end
 end
 
+--检测滚屏模板是否正常
+s.resp.check_template_scroll_isRight = function(info)
+    local isok  = s.resp.checkNumsByType({
+    duration = 0,
+    type = 6,
+    limit = 1,
+    user_id = info.user_id})
+
+    if not isok then
+        return false,cjson.encode({code=10001,msg = "新建模板失败,图片资源不足!"})
+    end
+        
+    isok  = s.resp.checkNumsByType({
+        duration = 0,
+        type = 4,
+        limit = 1,
+        user_id = info.user_id}
+    )
+
+    if not isok then
+        return false,cjson.encode({code=10001,msg = "新建模板失败,BGM音频不足!"})
+    end
+
+
+    isok  = s.resp.checkNumsByType({
+        duration = 0,
+        type = 3,
+        limit = 1,
+        user_id = info.user_id}
+    )
+
+    if not isok then
+        return false,cjson.encode({code=10001,msg = "新建模板失败,片尾资源不足!"})
+    end
+
+
+    return true,nil
+end
 --检查模板是否正常
 s.resp.check_template_isRight = function(info)
  
@@ -1448,6 +1556,312 @@ s.resp.get_user_file_count_by_type = function(msg_body)
     return count
 end
 
+s.resp.check_file_name_list_is_repeat_by_folder_id = function(msg_body,fd,call_back)
+    skynet.fork(function()
+        local nameString  = ""
+        for i = 1, #msg_body.file_name_list, 1 do
+            nameString = nameString.."'"..msg_body.file_name_list[i].."'"
+            if i<#msg_body.file_name_list then
+                nameString = nameString..","
+            end
+        end
+        local sql = string.format("SELECT file_name FROM res_list_tab WHERE file_name IN (%s) AND folder_id = %d AND user_id = %d ", 
+        nameString,
+        msg_body.folder_id,
+        msg_body.user_id)
+        local res = db:query(sql)
+        local tab =  {}
+        -- skynet.error("sql",sql)
+        if #res == 1 then
+            tab[1] = tools.getDbResData(res)
+        else
+            tab = tools.getDbResData(res)
+        end
+        -- tools.dump(tab)
+        local normal_file_name_list ={}
+        local repeat_file_name_list ={}
+        for i = 1, #tab, 1 do
+            table.insert(repeat_file_name_list,i,tab[i].file_name)
+        end
+
+        function check(file_name,list)
+            for i = 1, #list, 1 do
+               if list[i]==file_name then
+                    return false
+               end 
+            end
+            return true
+        end
+        local count = 1
+        for i = 1, #msg_body.file_name_list, 1 do
+            if check(msg_body.file_name_list[i],repeat_file_name_list) then
+                table.insert(normal_file_name_list,count,msg_body.file_name_list[i])
+                count = count+1
+            end 
+         end
+         if call_back~=nil then
+            call_back({normal_file_name_list=normal_file_name_list,repeat_file_name_list=repeat_file_name_list})
+         else
+            tools.response_db_check_folder_repeat_file(fd,msg_body,true,{normal_file_name_list=normal_file_name_list,repeat_file_name_list=repeat_file_name_list})
+         end
+       
+    end)
+    return true
+end
+
+
+--获取用户的分享用户列表
+s.resp.get_share_user_list  = function(msg_body,fd)
+    local isOk,user_data = s.resp.getUserById(msg_body.user_id)
+    local temp = {}
+    if isOk then
+        local select_share =  nil
+        if user_data.user_info~=nil and user_data.user_info~="" then
+            local info = cjson.decode(user_data.user_info)
+            select_share = info.select_share
+        end
+        local count = 1
+        skynet.fork(function()
+            function action()
+                tools.response_db_get_share_user_list(fd,msg_body,true,temp)
+            end
+            if select_share~=nil and select_share~="" then
+                for i = 1, #select_share, 1 do
+                    local user_id = select_share[i]
+                    local _,ud = s.resp.getUserById(user_id)
+                    if _ then
+                        if ud.id~=msg_body.user_id then
+                            table.insert(temp,count,ud)
+                            count = count +1
+                        end
+                    end
+                end
+            end
+  
+            if user_data.permit_id == 2 then  --说明是管理
+                s.resp.get_group_list(user_data.group_id,function(list)
+                    -- skynet.error("user_data.group_id",user_data.group_id)
+                    -- tools.dump(list)
+                    for i = 1, #list, 1 do
+                        if list[i].permit_id~=2 and list[i].id~=user_data.id then
+                            table.insert(temp,count,list[i])
+                            count = count +1
+                        end
+                    end
+                    action()
+                end)
+            else
+                action()
+            end
+
+        end)
+        return true
+    end
+    return false
+end
+--根据名字获取文件夹
+s.resp.get_folder_by_name = function(msg_body,fd)
+    local sql = string.format("SELECT * FROM folder_list_tab WHERE folder_name = '%s' AND classification_id = %d AND folder_type = %d AND user_id = %d LIMit 1", msg_body.folder_name,msg_body.classification_id,msg_body.folder_type,msg_body.user_id)
+    local res = db:query(sql)
+    local tab =  {}
+    tab = tools.getDbResData(res)
+    if #res <=0 then
+        return false,nil
+    end
+    return true,tab
+end
+
+s.resp.get_folder_have_file_name = function(user_id,folder_id,file_name)
+    local sql = string.format("SELECT * FROM res_list_tab WHERE file_name = '%s' AND user_id = %d AND folder_id = %d LIMit 1", file_name,user_id,folder_id)
+    local res = db:query(sql)
+    local tab =  {}
+    tab = tools.getDbResData(res)
+    skynet.error("#res",#res)
+    if #res <=0 then
+        return false,nil
+    end
+    return true,tab
+end
+--分享文件列表
+s.resp.share_file_list = function(msg_body,fd)
+    function insert_target(file,folder_id,target_user_id)
+        local is_have,_ = s.resp.get_folder_have_file_name(target_user_id,folder_id,file.file_name)
+
+        if is_have==true then
+
+        else
+            local sql = string.format("INSERT INTO res_list_tab (user_id, folder_id, file_type, file_name,file_info,duration,classification_id,ref_id) VALUES (%d, %d, %d, '%s','%s',%f,%d,%d)",
+            target_user_id,
+            folder_id,
+            file.file_type,
+            file.file_name,
+            file.file_info,
+            file.duration,
+            file.classification_id,
+            file.id)
+            skynet.error("sql",sql)
+            db:query(sql)
+        end
+        -- skynet.error(sql)
+    end
+    for j = 1, #msg_body.target_user_id_list, 1 do
+        local target_user_id = msg_body.target_user_id_list[j]
+        local my_user_id = msg_body.user_id
+        skynet.fork(function()
+            for i = 1, #msg_body.file_id_list, 1 do
+                local file_id = msg_body.file_id_list[i].file_id
+                local folder_name = msg_body.file_id_list[i].folder_name
+                local sql = string.format("SELECT * FROM res_list_tab WHERE id = %d limit 1", file_id)
+                local res = db:query(sql)
+                local tab = tools.getDbResData(res)
+                if #res>0 then
+                    --检测被分享的是否拥有此文件夹
+                    local isOk,folder_data = s.resp.get_folder_by_name({user_id=target_user_id,folder_name=folder_name,classification_id=tab.classification_id,folder_type=tab.file_type})
+                    if isOk then --拥有此文件夹,直接插入
+                        skynet.error("拥有此文件夹,直接插入",folder_name)
+                        insert_target(tab,folder_data.id,target_user_id)
+                    else -- 没有此文件夹,创建一个再插入  
+                        local new_sql = string.format("INSERT INTO folder_list_tab (user_id,folder_name, folder_type,is_public,classification_id) VALUES (%d, '%s',%d,%d,%d)",
+                        target_user_id,
+                        folder_name,
+                        tab.file_type
+                        ,0
+                        ,tab.classification_id)
+                        -- skynet.error(sql)
+                        local new_res = db:query(new_sql)
+                        new_sql = string.format("select *from folder_list_tab where user_id = %d AND folder_name = '%s' AND folder_type = %d AND  classification_id = %d limit 1",
+                        target_user_id,
+                        folder_name,
+                        tab.file_type,
+                        tab.classification_id)
+                        new_res = db:query(new_sql)
+                        if new_res and #new_res > 0 then
+                            local folder_info =  {}
+                            folder_info = tools.getDbResData(new_res)
+                            insert_target(tab,folder_info.id,target_user_id)
+                        end
+                    end 
+                end
+        
+            end
+        end)
+    end
+    
+    return true
+end
+--分享文件夹列表    
+s.resp.share_folder_list = function(msg_body,fd)
+
+    function getInfoByName(name,list)
+        for i = 1, #list, 1 do
+            if list[i].file_name == name then
+                return list[i]
+            end
+        end
+        return nil
+    end
+    function insert_target_folder(target_folder_id,my_folder_id,my_user_id,target_user_id)
+        local  isok = s.resp.folder_res_list({
+            folder_id = my_folder_id,
+            user_id =my_user_id,
+            is_public=0},nil,function(list)
+                skynet.error("insert_target_folder",#list)
+                if #list>0 then
+                    local file_name_list = {}
+                    for i = 1, #list, 1 do
+                        local _f = list[i]
+                        table.insert(file_name_list,i,_f.file_name)
+                    end
+                    s.resp.check_file_name_list_is_repeat_by_folder_id({file_name_list=file_name_list,user_id=msg_body.user_id,folder_id=target_folder_id},fd,function(data)
+                        for i = 1, #data.normal_file_name_list, 1 do
+                            local file = getInfoByName(data.normal_file_name_list[i],list)
+                            if file~=nil then
+                                local sql = string.format("INSERT INTO res_list_tab (user_id, folder_id, file_type, file_name,file_info,duration,classification_id,ref_id) VALUES (%d, %d, %d, '%s','%s',%f,%d,%d)",
+                                target_user_id,
+                                target_folder_id,
+                                file.file_type,
+                                file.file_name,
+                                file.file_info,
+                                file.duration,
+                                file.classification_id,
+                                file.id)
+                                db:query(sql)
+                            end
+                        end
+                    end)
+                end
+        end)
+    end
+    for j = 1, #msg_body.target_user_id_list, 1 do
+        local target_user_id = msg_body.target_user_id_list[j]
+        local my_user_id = msg_body.user_id
+
+        skynet.fork(function()
+            for i = 1, #msg_body.folder_id_list, 1 do
+                local folder_id = msg_body.folder_id_list[i].folder_id
+                local folder_name = msg_body.folder_id_list[i].folder_name
+                local sql = string.format("SELECT * FROM folder_list_tab WHERE id = %d limit 1", folder_id)
+                local res = db:query(sql)
+                local tab = tools.getDbResData(res)
+                if #res>0 then
+                    --检测被分享的是否拥有此文件夹
+                    local isOk,folder_data = s.resp.get_folder_by_name({user_id=target_user_id,folder_name=folder_name,classification_id=tab.classification_id,folder_type=tab.folder_type})
+                    if isOk then --拥有此文件夹,直接插入
+                        skynet.error("拥有此文件夹,直接插入 ")
+                        insert_target_folder(folder_data.id,folder_id,my_user_id,target_user_id)
+                    else -- 没有此文件夹,创建一个再插入  
+                        local new_sql = string.format("INSERT INTO folder_list_tab (user_id,folder_name, folder_type,is_public,classification_id) VALUES (%d, '%s',%d,%d,%d)",
+                        target_user_id,
+                        folder_name,
+                        tab.folder_type
+                        ,0
+                        ,tab.classification_id)
+                        skynet.error("没有此文件夹,创建一个再插入 ")
+                        skynet.error(sql)
+                        db:query(new_sql)
+        
+                        new_sql = string.format("select *from folder_list_tab where user_id = %d AND folder_name = '%s' AND folder_type = %d AND  classification_id = %d limit 1",
+                        target_user_id,
+                        folder_name,
+                        tab.folder_type,
+                        tab.classification_id)
+                        local new_res = db:query(new_sql)
+                        if new_res and #new_res > 0 then
+                            local folder_info =  {}
+                            folder_info = tools.getDbResData(new_res)
+                            insert_target_folder(folder_info.id,folder_id,my_user_id,target_user_id)
+                        end
+                    end 
+                end
+        
+            end
+        end)
+    end
+    return true
+end
+
+s.resp.get_folder_info = function(msg_body,fd)
+    local listToFind= {}
+    for i = 1, #msg_body.folder_id_list, 1 do
+        table.insert(listToFind,i,msg_body.folder_id_list[i])
+    end
+    local findString = table.concat(listToFind, ',')
+    skynet.fork(function()
+        local sql = string.format("SELECT * FROM folder_list_tab WHERE id IN (%s) AND user_id = %d ", findString,msg_body.user_id)
+        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
+            tools.response_db_get_folder_info(fd,msg_body,true,tab)
+        else
+            tools.response_db_get_folder_info(fd,msg_body,false,{})
+        end
+    end)
+end
 s.init = function()
     db=mysql.connect({
 		host=runconfig.db_tost,

+ 7 - 0
service/http_work/init.lua

@@ -18,6 +18,13 @@ local dispatch = function(session, address,id, addr,...)
     -- skynet.error('body,',req.body)
     -- local color,text = "red", "hello"
     -- skynet.error("req.url",req.url)
+
+    if req.url == nil or #req.url==0 or req.code~=200 then
+        skynet.error(req.url)
+        return  tools.response(id, req.code, "error!")
+    end
+
+
     if  string.find(req.url, "/config/") then
         skynet.send("config_mgr","lua","on_recv",id,req.url,req.body)
         return

+ 1 - 1
service/main.lua

@@ -81,7 +81,7 @@ skynet.start(function()
 	local balance = 1
 	local id = socket.listen("0.0.0.0",runconfig.testHttpProt )
 	-- json_test()
-	skynet.error(string.format("Listen web port 8001 protocol:%s", protocol))
+	-- skynet.error(string.format("Listen web port 8001 protocol:%s", protocol))
 	socket.start(id , function(id, addr)
 		-- skynet.error(string.format("%s connected, pass it to http_works :%08x", addr, http_works[balance]))
 		skynet.send(http_works[balance], "lua", id,addr)

+ 62 - 2
service/public_mgr/init.lua

@@ -366,6 +366,51 @@ s.resp.db_public_delete_res = function(msg_body,fd)
     return true
 end
 
+s.resp.db_public_check_file_name_list_is_repeat_by_folder_id = function(msg_body,fd,call_back)
+    skynet.fork(function()
+        local nameString  = ""
+        for i = 1, #msg_body.file_name_list, 1 do
+            nameString = nameString.."'"..msg_body.file_name_list[i].."'"
+            if i<#msg_body.file_name_list then
+                nameString = nameString..","
+            end
+        end
+        local sql = string.format("SELECT file_name FROM public_res_list_tab WHERE file_name IN (%s) AND folder_id = %d ", nameString,msg_body.folder_id)
+        local res = db:query(sql)
+        local tab =  {}
+        skynet.error("sql",sql)
+        if #res == 1 then
+            tab[1] = tools.getDbResData(res)
+        else
+            tab = tools.getDbResData(res)
+        end
+        tools.dump(tab)
+        local normal_file_name_list ={}
+        local repeat_file_name_list ={}
+        for i = 1, #tab, 1 do
+            table.insert(repeat_file_name_list,i,tab[i].file_name)
+        end
+
+        function check(file_name,list)
+            for i = 1, #list, 1 do
+               if list[i]==file_name then
+                    return false
+               end 
+            end
+            return true
+        end
+        local count = 1
+        for i = 1, #msg_body.file_name_list, 1 do
+            if check(msg_body.file_name_list[i],repeat_file_name_list) then
+                table.insert(normal_file_name_list,count,msg_body.file_name_list[i])
+                count = count+1
+            end 
+         end
+         call_back({normal_file_name_list=normal_file_name_list,repeat_file_name_list=repeat_file_name_list})
+    end)
+    return true
+end
+
 --根据id获取文件夹 
 s.resp.get_res_folder_by_id = function(folder_id)
     local sql = string.format("select * from public_folder_list_tab where id = %d ",folder_id)
@@ -638,7 +683,7 @@ s.resp.db_public_add_file_to_private = function(msg_body,fd,call_back)
             local sql = string.format("INSERT INTO folder_list_tab (user_id,folder_name, folder_type,classification_id,ref_id) VALUES (%d, '%s',%d,%d,%d)",msg_body.user_id,public_folder_info.folder_name,public_folder_info.folder_type,public_folder_info.classification_id,public_folder_info.id)
             local res = db:query(sql)
             --获取刚刚创建的私人文件夹
-            sql = string.format("select *from folder_list_tab where user_id = %d AND folder_name = '%s' AND folder_type = %d AND  classification_id = %d limit 1",msg_body.user_id,public_folder_info.folder_name,public_folder_info.folder_type,public_folder_info.classification_id)
+            sql = string.format("select *from folder_list_tab where user_id = %d AND folder_name = '%s' AND folder_type = %d AND  classification_id = %d AND ref_id = %d limit 1",msg_body.user_id,public_folder_info.folder_name,public_folder_info.folder_type,public_folder_info.classification_id,public_folder_info.id)
             res = db:query(sql)
 
             if res and #res > 0 then
@@ -931,7 +976,7 @@ s.resp.add_folder_to_private = function(msg_body,fd,user_data)
             public_folder_id = msg_body.folder_id,
             user_id = user_id},fd,function(isFinish)
                 if isFinish == true then
-                    return tools.response(fd,200,cjson.encode({code=10001,msg = "--添加公共文件夹到个人成功!"}))
+                    return tools.response(fd,200,cjson.encode({code=10000,msg = "--添加公共文件夹到个人成功!"}))
                 else
                     return tools.response(fd,200,cjson.encode({code=10001,msg = "--添加公共文件夹到个人失败!"}))
                 end
@@ -942,6 +987,21 @@ s.resp.add_folder_to_private = function(msg_body,fd,user_data)
     end
 end
 
+s.resp.check_public_file_name_list_is_repeat_by_folder_id = function(msg_body,fd,user_data)
+    local isOk,err_code,key,user_id = checkMsg(msg_body,user_data,
+    {"folder_id","file_name_list"})
+    if isOk then
+        isOk =  s.resp.db_public_check_file_name_list_is_repeat_by_folder_id({
+            public_folder_id = msg_body.folder_id,
+            file_name_list = msg_body.file_name_list,
+            user_id = user_id},fd,function(tab)
+                tools.response(fd,200,cjson.encode({code=10000,msg = "--检测成功!",data=tab}))
+            end)
+            return
+    else
+        response_error(isOk,err_code,key,fd,"check_public_file_name_list_is_repeat_by_folder_id")
+    end
+end
 --==========================逻辑 end