user.lua 614 B

123456789101112131415161718192021222324
  1. --用户
  2. local M = {}
  3. local mysqldbx = require "mysqldbx"
  4. local tools = require "tools"
  5. local skynet = require "skynet"
  6. function M.Login(msg_body)
  7. local isok ,key = tools.checkData({"account","password"},msg_body)
  8. if not isok then
  9. return false,string.format("缺少字段: %s.", key)
  10. end
  11. local sql = string.format("SELECT * FROM admin_user WHERE account = '%s' and password = '%s' ", msg_body.account, msg_body.password)
  12. local isok,res;
  13. res = mysqldbx.query(sql)
  14. if #res <= 0 then
  15. return false ,"账号或密码错误!"
  16. end
  17. return true, {}
  18. end
  19. return M