1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- --小程序平台
- local M = {}
- local mysqldbx = require "mysqldbx"
- local tools = require "tools"
- local skynet = require "skynet"
- local cjson = require "cjson"
- function M.add_tg_mini_program_platform(msg_body)
- local isok ,key = tools.checkData({"mini_program_platform_name","mini_program_platform_id"},msg_body)
- if not isok then
- return false,string.format("缺少字段: %s.", key)
- end
- local sql = string.format("INSERT INTO `tg_mini_program_platform` (mini_program_platform_name,mini_program_platform_id) VALUES ('%s',%d)",
- msg_body.mini_program_platform_name, msg_body.mini_program_platform_id)
- mysqldbx.query(sql)
- return true
- end
- function M.modify_tg_mini_program_platform(msg_body)
- local isok ,key = tools.checkData({"mini_program_platform_name","mini_program_platform_id","id"},msg_body)
- if not isok then
- return false,string.format("缺少字段: %s.", key)
- end
- local current_time = os.date("%Y-%m-%d %H:%M:%S")
- msg_body.update_time = current_time
- local sql = string.format("UPDATE `tg_mini_program_platform` SET mini_program_platform_name = '%s' , mini_program_platform_id = %d WHERE id = %d ",
- msg_body.mini_program_platform_name,msg_body.mini_program_platform_id,msg_body.id)
- mysqldbx.query(sql)
- return true
- end
- function M.search_tg_mini_program_platform(msg_body)
- local isok ,key = tools.checkData({"page_size","page_number"},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 sql = "SELECT * FROM tg_mini_program_platform WHERE 1=1 "..string.format(" LIMIT %d OFFSET %d ",page_size, offset)
-
- local list = mysqldbx.query(sql)
- sql = "SELECT COUNT(*) AS total FROM tg_mini_program_platform WHERE 1=1 "
- local total = mysqldbx.query(sql)
- return true,list,total[1].total
- end
- return M
|