78 lines
1.9 KiB
Lua
78 lines
1.9 KiB
Lua
---
|
|
--- Generated by EmmyLua(https://github.com/EmmyLua)
|
|
--- Created by admin.
|
|
--- DateTime: 2025/9/25 08:19
|
|
---
|
|
|
|
local _M = {}
|
|
|
|
local dao = require("service.system.account")
|
|
local resp = require("util.response")
|
|
local validator = require("util.validator")
|
|
|
|
--获取所有账号信息
|
|
function _M.get_allaccount()
|
|
local code,ret = dao.getAllAccount()
|
|
local result = resp:json(code, ret)
|
|
resp:send(result)
|
|
end
|
|
|
|
--根据账号id获取账号信息
|
|
function _M.get_account(m)
|
|
local id = m.id
|
|
local code,ret = dao.getAccount(id)
|
|
local result = resp:json(code, ret)
|
|
resp:send(result)
|
|
end
|
|
|
|
--根据账号id获取账号信息
|
|
function _M.add_account()
|
|
--获取请求头并进行校验
|
|
if validator.checkReqHeader() == false then
|
|
local result = resp:json(0x000001)
|
|
resp:send(result)
|
|
return
|
|
end
|
|
--读取请求体的数据
|
|
ngx.req.read_body()
|
|
--获取请求数据
|
|
local body_data = ngx.req.get_body_data()
|
|
--判断请求体数据是否为空
|
|
if body_data == nil then
|
|
local result = resp:json(0x000001)
|
|
resp:send(result)
|
|
return
|
|
end
|
|
--ngx.say(body_data)
|
|
local code, ret = dao.addAccount(body_data)
|
|
local result = resp:json(code, ret)
|
|
resp:send(result)
|
|
end
|
|
|
|
--根据账号id删除账号信息
|
|
function _M.delete_account(m)
|
|
local id = m.id
|
|
local code, ret = dao.deleteAccount(id)
|
|
local result = resp:json(code, ret)
|
|
resp:send(result)
|
|
end
|
|
|
|
--根据账号id删除账号信息
|
|
function _M.update_account(m)
|
|
local id = m.id
|
|
--读取请求体的数据
|
|
ngx.req.read_body()
|
|
--获取请求数据
|
|
local body_data = ngx.req.get_body_data()
|
|
--判断请求体数据是否为空
|
|
if body_data == nil then
|
|
local result = resp:json(0x000001)
|
|
resp:send(result)
|
|
return
|
|
end
|
|
local code, ret = dao.updateAccount(id, body_data)
|
|
local result = resp:json(code, ret)
|
|
resp:send(result)
|
|
end
|
|
|
|
return _M |