去掉菜单暂时不使用菜单

This commit is contained in:
wanglei 2025-11-05 20:21:25 +08:00
parent f12c32db08
commit 5e6777e48b
5 changed files with 0 additions and 271 deletions

View File

@ -24,12 +24,6 @@ location /api/system/departments {
content_by_lua_file '${APP_PATH}/src/api/system/department.lua';
}
#菜单信息数据接口
location /api/system/menus {
access_by_lua_file '${APP_PATH}/src/auth/jwt-auth.lua';
content_by_lua_file '${APP_PATH}/src/api/system/menu.lua';
}
#权限信息数据接口
location /api/system/permissions {
access_by_lua_file '${APP_PATH}/src/auth/jwt-auth.lua';

View File

@ -1,61 +0,0 @@
---
--- Generated by EmmyLua(https://github.com/EmmyLua)
--- Created by admin.
--- DateTime: 2025/11/04 10:45
---
--解析url路由过滤库
local radix = require("resty.radixtree")
--数据表业务处理
local systemMenu = require("service.system.menu")
--定义相关路由前端接口url地址
local routes = {
--菜单相关路由接口
{
paths = { "/api/system/menus" },
methods = { "GET" },
handler = systemMenu.getSystemMenus,
},
{
paths = { "/api/system/menus/:id" },
methods = { "GET" },
handler = systemMenu.getSystemMenu,
},
{
paths = { "/api/system/menus" },
methods = { "POST" },
handler = systemMenu.addSystemMenu,
},
{
paths = { "/api/system/menus/:id" },
methods = { "DELETE" },
handler = systemMenu.deleteSystemMenu,
},
{
paths = { "/api/system/menus/:id" },
methods = { "PUT" },
handler = systemMenu.updateSystemMenu,
},
}
-- 初始化路由
local rx, err = radix.new(routes)
if not rx then
ngx.say("Not Found")
ngx.exit(ngx.HTTP_NOT_FOUND)
end
--获取访问的uri地址
local uri = ngx.var.uri
local opts = {
method = ngx.var.request_method,
matched = {}
}
-- 进行路由匹配和相关函数调用
local ok = rx:dispatch(uri, opts, opts.matched)
if not ok then
ngx.say("Not Found")
ngx.exit(ngx.HTTP_NOT_FOUND)
end

View File

@ -1,91 +0,0 @@
---
--- Generated by EmmyLua(https://github.com/EmmyLua)
--- Created by admin.
--- DateTime: 2025/11/04 15:06
--- 数据表模型文件
local helpers = require("share.helpers")
--引用使用的库文件
local model = require("share.model")
--创建一个数据表相关的模型
local menuModel = model:new('sys_menu')
local _M = {}
--判断菜单是否存在
local function isExistMenu(id)
--根据菜单id进行验证菜单是否存在
local code, res = menuModel:find(id)
if code ~= 0 then
return false
end
local num = 0
if res ~= nil then
num = table.getn(res)
end
--组织不存在返回错误
if num <= 0 then
return false
end
return true
end
-- 查询数据表中的所有菜单信息
function _M.getSystemMenus(pageNum, pageSize)
return menuModel:paginate(pageNum, pageSize)
end
--根据菜单id获取菜单信息
function _M.getSystemMenu(id)
return menuModel.find(id)
end
--增加菜单息到数据表
function _M.addSystemMenu(jsonData)
--解析json中的键和数据值
local menuid = jsonData['menu_id']
--根据菜单名称进行验证菜单是否存在
local code, res = menuModel:where("menu_id", "=", menuid):get()
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
--键值为id产生uuid数据值增加到json中
jsonData.id = helpers.getUuid()
-- 创建一个菜单
return menuModel:create(jsonData)
end
--删除菜单信息到数据表
function _M.deleteSystemDepartment(id)
--根据菜单id进行验证菜单是否存在
local ok = isExistMenu(id)
--菜单不存在则返回
if ok == false then
return 0x000001,nil
end
return menuModel:delete(id)
end
--更新菜单信息到数据表
function _M.updateSystemMenu(id, jsonData)
--根据菜单id进行验证菜单是否存在
local ok = isExistMenu(id)
--组织不存在则返回
if ok == false then
return 0x000001,nil
end
jsonData.update_time = ngx.time()
--对数据内容进行更新
return menuModel:where('menu_id', '=', id):update(jsonData)
end
return _M

View File

@ -1,76 +0,0 @@
---
--- Generated by EmmyLua(https://github.com/EmmyLua)
--- Created by .
--- DateTime: 2025/11/04 14:35
--- 业务逻辑 对菜单数据表进行数据表业务处理
local resp = require("util.response")
local menuDao = require("dao.menu")
local validatorJson = require("validator.system.menu")
local cjson = require("cjson.safe")
local _M = {}
--获取所有菜单信息
function _M.getSystemMenus()
--获取页码和请求的数据量
local pageNum = ngx.var.pagenum or 1
local pageSize = ngx.var.pagesize or 10
local code,ret = menuDao.getSystemMenus(pageNum, pageSize)
local result = resp:json(code, ret)
resp:send(result)
end
--根据菜单id获取菜单信息
function _M.getSystemMenu(m)
local code,ret = menuDao.getSystemMenu(m.id)
local result = resp:json(code, ret)
resp:send(result)
end
--根据菜单id添加菜单信息
function _M.addSystemMenu()
--读取请求体的数据
ngx.req.read_body()
--获取请求数据
local body_data = ngx.req.get_body_data()
-- 验证数据是否符合schema
local ok = validatorJson.validatorJson(body_data)
--验证失败则返回
if not ok then
local result = resp:json(0x000001)
resp:send(result)
return
end
--ngx.say(body_data)
local code, ret = menuDao.addSystemMenu(cjson.decode(body_data))
local result = resp:json(code, ret)
resp:send(result)
end
--根据菜单id删除菜单信息
function _M.deleteSystemMenu(m)
local code, ret = menuDao.deleteSystemMenu(m.id)
local result = resp:json(code, ret)
resp:send(result)
end
--根据菜单id删除菜单信息
function _M.updateSystemMenu(m)
--读取请求体的数据
ngx.req.read_body()
--获取请求数据
local body_data = ngx.req.get_body_data()
-- 验证数据是否符合schema
local ok = validatorJson.validatorJson(body_data)
--验证失败则返回
if not ok then
local result = resp:json(0x000001)
resp:send(result)
return
end
local code, ret = menuDao.updateSystemMenu(m.id, cjson.decode(body_data))
local result = resp:json(code, ret)
resp:send(result)
end
return _M

View File

@ -1,37 +0,0 @@
---
--- Generated by EmmyLua(https://github.com/EmmyLua)
--- Created by .
--- DateTime: 2025/11/04 11:12
--- 业务逻辑 对菜单数据进行参数数据的验证
local jsonschema = require("jsonschema")
local _M = {}
-- 定义一个JSON Schema
local schema = {
{type = "object", properties = {
{name = "menu_id", type = "string"},
{name = "menu_name", type = "string"},
{name = "parent_id", type = "string"},
{name = "order_num", type = "number"},
{name = "url", type = "string"},
{name = "target", type = "string"},
{name = "menu_type", type = "string"},
{name = "status", type = "string"},
{name = "is_refresh", type = "string"},
{name = "perms", type = "string"},
{name = "perms", type = "string"},
{name = "create_by", type = "string"},
{name = "update_by", type = "string"},
{name = "remark", type = "string"},
}, required = {"menu_id", "menu_name"}}
}
function _M.validatorJson(jsonData)
-- 验证数据是否符合schema
local validator = jsonschema.generate_validator(schema)
local result = validator(jsonData)
return result
end
return _M