template.lua 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 conn = mysql.new(_G[fwutils_config.db.mysql_pool_name]):get()
  44. develop_template.make_bytecode(conn)
  45. succ({})
  46. end
  47. M.exec = function()
  48. exec({
  49. get_by_id = M.get_by_id,
  50. list = M.list,
  51. add = M.add,
  52. update = M.update,
  53. delete = M.delete,
  54. refresh = M.refresh,
  55. })
  56. end
  57. return M