|
@@ -13,4 +13,44 @@ function M.delete_origin_data_by_time(msg_body)
|
|
|
local delete_time_param = " AND DATE(created_at) >= DATE(FROM_UNIXTIME(" .. (msg_body.start_create_time / 1000) .. ")) AND DATE(created_at) <= DATE(FROM_UNIXTIME(" .. (msg_body.end_create_time / 1000) .. "))"
|
|
|
end
|
|
|
|
|
|
+
|
|
|
+function M.search_origin_data(msg_body)
|
|
|
+ local isok ,key = tools.checkData({"page_size","page_number","start_create_time","end_create_time","guajian_info","start_publish_time","end_publish_time"},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 create_date_param = ""
|
|
|
+ if msg_body.start_create_time~="" and msg_body.end_create_time~="" then
|
|
|
+ create_date_param = " AND DATE(create_time) >= DATE(FROM_UNIXTIME(" .. (msg_body.start_create_time / 1000) .. ")) AND DATE(create_time) <= DATE(FROM_UNIXTIME(" .. (msg_body.end_create_time / 1000) .. "))"
|
|
|
+ end
|
|
|
+
|
|
|
+ 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 guajian_info_param = ""
|
|
|
+ if msg_body.guajian_info~="" then
|
|
|
+ guajian_info_param = string.format(" AND ( guajian_link LIKE CONCAT( '%%%s%%')) ",msg_body.guajian_info)
|
|
|
+ end
|
|
|
+
|
|
|
+ local param = date_param..create_date_param..guajian_info_param
|
|
|
+
|
|
|
+
|
|
|
+ local sql = "SELECT * FROM origin_data WHERE 1=1 "..param.."ORDER BY id DESC"..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
|
|
|
+
|
|
|
+ local res = mysqldbx.query(sql)
|
|
|
+
|
|
|
+ sql = "SELECT COUNT(*) AS total FROM origin_data WHERE 1=1 "..param
|
|
|
+
|
|
|
+ local total = mysqldbx.query(sql)
|
|
|
+
|
|
|
+ return true,res,total[1].total
|
|
|
+end
|
|
|
+
|
|
|
return M
|