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