2025-10-27 21:18:16 +08:00
|
|
|
---
|
|
|
|
|
--- Generated by EmmyLua(https://github.com/EmmyLua)
|
|
|
|
|
--- Created by admin.
|
|
|
|
|
--- DateTime: 2025/9/25 08:19
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
local _M = {}
|
|
|
|
|
|
|
|
|
|
local dao = require("service.system.permission")
|
|
|
|
|
local resp = require("util.response")
|
|
|
|
|
local validator = require("util.validator")
|
|
|
|
|
|
|
|
|
|
--获取所有权限信息
|
|
|
|
|
function _M.get_allpermission()
|
|
|
|
|
local code,ret = dao.getAllPermission()
|
|
|
|
|
local result = resp:json(code, ret)
|
|
|
|
|
resp:send(result)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--根据权限id获取权限信息
|
|
|
|
|
function _M.get_permission(m)
|
|
|
|
|
local id = m.id
|
|
|
|
|
local code,ret = dao.getPermission(id)
|
|
|
|
|
local result = resp:json(code, ret)
|
|
|
|
|
resp:send(result)
|
|
|
|
|
end
|
|
|
|
|
|
2025-10-28 08:39:22 +08:00
|
|
|
--根据角色id获取使用的权限
|
|
|
|
|
function _M.get_permission_by_role(m)
|
|
|
|
|
local id = m.id
|
|
|
|
|
local code,ret = dao.getPermissionByRole(id)
|
|
|
|
|
local result = resp:json(code, ret)
|
|
|
|
|
resp:send(result)
|
|
|
|
|
end
|
|
|
|
|
|
2025-10-27 21:18:16 +08:00
|
|
|
--根据账号id获取账号信息
|
|
|
|
|
function _M.add_permission()
|
|
|
|
|
--获取请求头并进行校验
|
|
|
|
|
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.addPermission(body_data)
|
|
|
|
|
local result = resp:json(code, ret)
|
|
|
|
|
resp:send(result)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--根据账号id删除账号信息
|
|
|
|
|
function _M.delete_permission(m)
|
|
|
|
|
local id = m.id
|
|
|
|
|
local code, ret = dao.deletePermission(id)
|
|
|
|
|
local result = resp:json(code, ret)
|
|
|
|
|
resp:send(result)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--根据账号id删除账号信息
|
|
|
|
|
function _M.update_permission(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.updatePermission(id, body_data)
|
|
|
|
|
local result = resp:json(code, ret)
|
|
|
|
|
resp:send(result)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return _M
|