--- --- Generated by EmmyLua(https://github.com/EmmyLua) --- Created by frankly. --- DateTime: 2025/10/29 23:36 --- --引用使用的库文件 local model = require("share.model") --创建一个数据表相关的模型 local userModel = model:new('sys_user') local _M = {} --认证用户返回用户数据信息 local function authenticate(name, passwd) --验证用户名是否为空 if name == "" then return 0x010003, nil end --验证密码是否为空 if passwd == "" then return 0x010002, nil end --根据用户进行验证用户是否存在 local code, res = userModel:where("username", "=", name):where("password", "=", passwd):get() if code == 0 and res ~= nil then return code, res end --根据手机号进行验证用户是否存在 code, res = userModel:where("phone", "=", name):where("password", "=", passwd):get() if code == 0 and res ~= nil then return code, res end --根据邮箱进行验证用户是否存在 code, res = userModel:where("email", "=", name):where("password", "=", passwd):get() if code == 0 and res ~= nil then return code, res end --查询不到用户信息 return 0x010003, nil end --用户登录业务逻辑处理 function _M.login(jsonData) --解析json中的键和数据值 local name = jsonData["username"] local passwd = jsonData["password"] local captcha = jsonData["captcha"] local checkKey = jsonData["checkKey"] --验证用户名是否为空 local code, res = authenticate(name, passwd) if code ~= 0 then return 0x000001,res end local num = 0 if res ~= nil then num = table.getn(res) end --用户存在时返回用户已经存在 if num <= 0 then return 0x01000C,nil end return 0, res end --用户登出业务逻辑处理 function _M.logout(jsonData) local code = 0 local ret = "{}" return code, ret end function _M.getUser(userid) return userModel:find(userid) end return _M