57 lines
1.5 KiB
Lua
57 lines
1.5 KiB
Lua
require("app.app")
|
|
|
|
local fwutils_config = require("fwutils.config")
|
|
local develop_template = require("fwutils.develop.function.template")
|
|
|
|
local function get_by_id()
|
|
local conn = mysql.new(_G[fwutils_config.db.mysql_pool_name]):get()
|
|
succ(develop_template.get_by_id(pint("id"),conn))
|
|
end
|
|
|
|
local function add()
|
|
local data = pjson()
|
|
local conn = mysql.new(_G[fwutils_config.db.mysql_pool_name]):get()
|
|
if develop_template.add(data,conn) then
|
|
succ({})
|
|
else
|
|
error("")
|
|
end
|
|
end
|
|
local function update()
|
|
local data = pjson()
|
|
local conn = mysql.new(_G[fwutils_config.db.mysql_pool_name]):get()
|
|
if develop_template.update(data,conn) then
|
|
succ({})
|
|
else
|
|
error("")
|
|
end
|
|
end
|
|
local function delete()
|
|
local data = pjson()
|
|
local conn = mysql.new(_G[fwutils_config.db.mysql_pool_name]):get()
|
|
if develop_template.delete(data.id,conn) then
|
|
succ({})
|
|
else
|
|
error("")
|
|
end
|
|
end
|
|
local function list()
|
|
local data = pjson()
|
|
local conn = mysql.new(_G[fwutils_config.db.mysql_pool_name]):get()
|
|
local d = develop_template.list(data.search,data.limit,conn)
|
|
succ(d)
|
|
end
|
|
local function refresh()
|
|
local module_template = require("fwutils.template_engine")
|
|
local conn = mysql.new(_G[fwutils_config.db.mysql_pool_name]):get()
|
|
module_template.update(conn)
|
|
succ()
|
|
end
|
|
exec({
|
|
get_by_id = get_by_id,
|
|
list = list,
|
|
add = add,
|
|
update = update,
|
|
delete = delete,
|
|
refresh = refresh,
|
|
}) |