template.lua 1.5 KB

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