--- --- Generated by EmmyLua(https://github.com/EmmyLua) --- Created by frankly. --- DateTime: 2025/10/29 23:36 --- local userDao = require("dao.system.user") local applicationDao = require("dao.system.application") local _M = {} --用户登录业务逻辑处理 function _M.login(jsonData) --解析json中的键和数据值 local name = jsonData["username"] local passwd = jsonData["password"] local captcha = jsonData["captcha"] local checkKey = jsonData["checkKey"] --验证用户名是否为空 local code, res = userDao:getUserByUsername(name) --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 --进行密码验证 获取数据库的密码 local pwdMd5 = ngx.md5(res[1].password) if pwdMd5 ~= passwd then return 0x000001,res --密码错误 end local userid = res[1].id --通过用户id获取应用程序id和应用名称 local err, rest = userDao:userRole(userid) if rest == nil then return 0x01000C,nil end res[1].role_id = rest[1].role_id res[1].role_name = rest[1].role_name return 0, res end --用户登出业务逻辑处理 function _M.logout(jsonData) local code = 0 local ret = "{}" return code, ret end --用户注册业务逻辑处理 function _M.signup(jsonData) return userDao:addSystemUser(jsonData) end function _M.getUser(userid) return userDao:getSystemUser(userid) end function _M.getApplicationBy(client_id, redirect_uri) --print("getApplicationBy client_id:", client_id, " redirect_uri:", redirect_uri) return applicationDao.getApplicationByClientId(client_id, redirect_uri) end return _M