|
@@ -15,6 +15,7 @@ local mysqldtaskbx = {}
|
|
|
--product_name 书名
|
|
|
function M.search_book_data(msg_body)
|
|
|
local isok ,key = tools.checkData({
|
|
|
+ "is_top",
|
|
|
"status",
|
|
|
"start_publish_time",
|
|
|
"end_publish_time",
|
|
@@ -37,6 +38,11 @@ function M.search_book_data(msg_body)
|
|
|
local page_number = msg_body.page_number
|
|
|
local offset = (page_number - 1) * page_size
|
|
|
|
|
|
+ local is_top_param = ""
|
|
|
+ if msg_body.is_top~="" then
|
|
|
+ is_top_param = string.format(" AND is_top = %d ",msg_body.is_top)
|
|
|
+ end
|
|
|
+
|
|
|
local status_param = ""
|
|
|
if msg_body.status~="" then
|
|
|
status_param = string.format(" AND status = %d ",msg_body.status)
|
|
@@ -109,7 +115,7 @@ function M.search_book_data(msg_body)
|
|
|
alias_name_param = string.format(" AND ( alias_name LIKE CONCAT( '%%%s%%')) ",msg_body.alias_name)
|
|
|
end
|
|
|
|
|
|
- local param = status_param..date_param..totalChapterNum_param..product_param..product_name_param..tg_platform_param..is_auto_param..is_store_param..genre_param..alias_name_param..word_param;
|
|
|
+ local param = is_top_param..status_param..date_param..totalChapterNum_param..product_param..product_name_param..tg_platform_param..is_auto_param..is_store_param..genre_param..alias_name_param..word_param;
|
|
|
|
|
|
if stat_cost_param~="" and up_or_down_publish_time_param ~="" then
|
|
|
up_or_down_publish_time_param = " , "..up_or_down_publish_time_param
|
|
@@ -133,9 +139,11 @@ function M.search_book_data(msg_body)
|
|
|
return true,res,total[1].total
|
|
|
end
|
|
|
|
|
|
-
|
|
|
+--一键发布搜索
|
|
|
function M.search_book_data_on_main(msg_body)
|
|
|
local isok ,key = tools.checkData({
|
|
|
+ "start_publish_time",
|
|
|
+ "end_publish_time",
|
|
|
"alias_name",
|
|
|
"product_name",
|
|
|
"product_id",
|
|
@@ -157,6 +165,12 @@ function M.search_book_data_on_main(msg_body)
|
|
|
local offset = (page_number - 1) * page_size
|
|
|
|
|
|
|
|
|
+ local date_param = ""
|
|
|
+ if msg_body.start_publish_time~="" and msg_body.end_publish_time~="" then
|
|
|
+
|
|
|
+ date_param = " AND DATE(publish_time) >= DATE(FROM_UNIXTIME(" .. (msg_body.start_publish_time / 1000) .. ")) AND DATE(publish_time) <= DATE(FROM_UNIXTIME(" .. (msg_body.end_publish_time / 1000) .. ")) "
|
|
|
+ end
|
|
|
+
|
|
|
local word_param = ""
|
|
|
if msg_body.min_book_word~="" and msg_body.max_book_word~="" then
|
|
|
word_param = string.format(" AND CAST(words AS UNSIGNED) >= %d AND CAST(words AS UNSIGNED) <= %d ",msg_body.min_book_word,msg_body.max_book_word)
|
|
@@ -199,15 +213,14 @@ function M.search_book_data_on_main(msg_body)
|
|
|
alias_name_param = string.format(" AND ( alias_name LIKE CONCAT( '%%%s%%')) ",msg_body.alias_name)
|
|
|
end
|
|
|
|
|
|
- local param = stat_cost_param..word_param..product_param..product_name_param..tg_platform_param..is_auto_param..is_store_param..genre_param..alias_name_param;
|
|
|
+ local param = date_param..stat_cost_param..word_param..product_param..product_name_param..tg_platform_param..is_auto_param..is_store_param..genre_param..alias_name_param;
|
|
|
|
|
|
-
|
|
|
- local sql = "SELECT * FROM video_product where 1=1 "..param..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
|
|
|
+ local sql = "SELECT * FROM video_product where 1=1 "..param.."ORDER BY is_top DESC "..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
|
|
|
|
|
|
skynet.error("sql:",sql)
|
|
|
local res = mysqldtaskbx.Singleton().query(sql)
|
|
|
|
|
|
- sql = "SELECT COUNT(*) AS total FROM video_product where 1=1 "..param.."ORDER BY id DESC"
|
|
|
+ sql = "SELECT COUNT(*) AS total FROM video_product where 1=1 "..param
|
|
|
|
|
|
local total = mysqldtaskbx.Singleton().query(sql)
|
|
|
|
|
@@ -251,6 +264,31 @@ function M.set_status(msg_body)
|
|
|
return true, {}
|
|
|
end
|
|
|
|
|
|
+--设置书优先级
|
|
|
+function M.set_top(msg_body)
|
|
|
+ local isok ,key = tools.checkData({"expired_time","id_list"},msg_body)
|
|
|
+ if not isok then
|
|
|
+ return false,string.format("缺少字段: %s.", key)
|
|
|
+ end
|
|
|
+ -- local current_time = os.date("%Y-%m-%d %H:%M:%S")
|
|
|
+ local sql = ""
|
|
|
+ local isok,res;
|
|
|
+ for i = 1, #msg_body.id_list, 1 do
|
|
|
+ local id = msg_body.id_list[i]
|
|
|
+ sql = string.format("SELECT * FROM video_product where id = %d ", id)
|
|
|
+ res = mysqldtaskbx.Singleton().query(sql)
|
|
|
+ if #res >0 then
|
|
|
+ local publish_time = res[1].publish_time
|
|
|
+ sql = string.format("UPDATE video_product SET is_top = 1 , expired_time = '%s' , y_publish_time = '%s' WHERE id = %d ",msg_body.expired_time,publish_time,id)
|
|
|
+ mysqldtaskbx.Singleton().query(sql)
|
|
|
+ end
|
|
|
+ end
|
|
|
+ -- local idString = table.concat(msg_body.id_list, ",")
|
|
|
+ -- local sql = string.format("UPDATE video_product SET is_top = 1 , expired_time = '%s' WHERE id IN (%s) ",msg_body.expired_time,idString)
|
|
|
+ -- mysqldtaskbx.Singleton().query(sql)
|
|
|
+ return true, {}
|
|
|
+end
|
|
|
+
|
|
|
function mysqldtaskbx.start()
|
|
|
local function on_connect(db)
|
|
|
db:query("set charset utf8mb4");
|