template.lua 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. require("app.app")
  2. local fwutils_config = require("fwutils.config")
  3. local develop_template = require("fwutils.develop.function.template")
  4. local function get_by_id()
  5. local conn = mysql.new(_G[fwutils_config.db.mysql_pool_name]):get()
  6. succ(develop_template.get_by_id(pint("id"),conn))
  7. end
  8. local function add()
  9. local data = pjson()
  10. local conn = mysql.new(_G[fwutils_config.db.mysql_pool_name]):get()
  11. if develop_template.add(data,conn) then
  12. succ({})
  13. else
  14. error("")
  15. end
  16. end
  17. local function update()
  18. local data = pjson()
  19. local conn = mysql.new(_G[fwutils_config.db.mysql_pool_name]):get()
  20. if develop_template.update(data,conn) then
  21. succ({})
  22. else
  23. error("")
  24. end
  25. end
  26. local function delete()
  27. local data = pjson()
  28. local conn = mysql.new(_G[fwutils_config.db.mysql_pool_name]):get()
  29. if develop_template.delete(data.id,conn) then
  30. succ({})
  31. else
  32. error("")
  33. end
  34. end
  35. local function list()
  36. local data = pjson()
  37. local conn = mysql.new(_G[fwutils_config.db.mysql_pool_name]):get()
  38. local d = develop_template.list(data.search,data.limit,conn)
  39. succ(d)
  40. end
  41. local function refresh()
  42. local module_template = require("fwutils.template_engine")
  43. local conn = mysql.new(_G[fwutils_config.db.mysql_pool_name]):get()
  44. module_template.update(conn)
  45. succ()
  46. end
  47. exec({
  48. get_by_id = get_by_id,
  49. list = list,
  50. add = add,
  51. update = update,
  52. delete = delete,
  53. refresh = refresh,
  54. })