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