修改返回数据的结果内容为json
This commit is contained in:
parent
d5a73a21db
commit
94dcca1c72
|
|
@ -11,15 +11,17 @@ local resp = require("util.response")
|
|||
|
||||
--获取所有用户信息
|
||||
function _M.get_allusers()
|
||||
local res = dao.getAllUser()
|
||||
response:json(0, 'index args', res)
|
||||
local ret = dao.getAllUser()
|
||||
local result = resp:json(0, 'ok', ret)
|
||||
resp:send(result)
|
||||
end
|
||||
|
||||
--根据用户id获取用户信息
|
||||
function _M.get_user(m)
|
||||
local id = m.id
|
||||
local res = dao.getUser(id)
|
||||
response:json(0, 'index args', res)
|
||||
local ret = dao.getUser(id)
|
||||
local result = resp:json(0, 'ok', ret)
|
||||
resp:send(result)
|
||||
end
|
||||
|
||||
return _M
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
--- Created by .
|
||||
--- DateTime: 2025/9/25 08:19
|
||||
--- 业务逻辑
|
||||
local cjson = require('cjson')
|
||||
--local cjson = require('cjson')
|
||||
local pgmoon = require('pgmoon')
|
||||
local dbconf = require("config.database")
|
||||
|
||||
|
|
@ -45,8 +45,7 @@ function _M.getAllUser()
|
|||
--end
|
||||
--关闭数据库
|
||||
conn:disconnect()
|
||||
|
||||
return cjson.encode(res)
|
||||
return res
|
||||
end
|
||||
|
||||
--根据用户id获取用户信息
|
||||
|
|
@ -74,6 +73,6 @@ function _M.getUser(id)
|
|||
--关闭数据库
|
||||
conn:disconnect()
|
||||
|
||||
return cjson.encode(res)
|
||||
return res
|
||||
end
|
||||
return _M
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user