2025-10-28 10:33:35 +08:00
|
|
|
|
---
|
|
|
|
|
|
--- Generated by EmmyLua(https://github.com/EmmyLua)
|
|
|
|
|
|
--- Created by admin.
|
|
|
|
|
|
--- DateTime: 2025/10/28 10:05
|
|
|
|
|
|
---
|
|
|
|
|
|
|
2025-10-29 17:29:17 +08:00
|
|
|
|
--解析url路由过滤库
|
|
|
|
|
|
local radix = require("resty.radixtree")
|
|
|
|
|
|
--数据表业务处理
|
2025-11-04 15:30:06 +08:00
|
|
|
|
local systemDepartment = require("service.system.department")
|
2025-10-29 17:29:17 +08:00
|
|
|
|
|
|
|
|
|
|
--定义相关路由,前端接口url地址
|
|
|
|
|
|
local routes = {
|
2025-11-04 21:57:42 +08:00
|
|
|
|
--组织(部门)相关路由接口
|
2025-10-29 17:29:17 +08:00
|
|
|
|
{
|
2025-11-12 09:36:00 +08:00
|
|
|
|
paths = { "/yum/v1/system/departments" },
|
2025-10-29 17:29:17 +08:00
|
|
|
|
methods = { "GET" },
|
2025-11-08 16:10:04 +08:00
|
|
|
|
filter_fun = function(vars)
|
|
|
|
|
|
ngx.ctx.perms = "system::departments::list"
|
|
|
|
|
|
return true
|
|
|
|
|
|
end,
|
2025-11-04 15:30:06 +08:00
|
|
|
|
handler = systemDepartment.getSystemDepartments,
|
2025-10-29 17:29:17 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2025-11-12 09:36:00 +08:00
|
|
|
|
paths = { "/yum/v1/system/departments/:id" },
|
2025-10-29 17:29:17 +08:00
|
|
|
|
methods = { "GET" },
|
2025-11-08 16:10:04 +08:00
|
|
|
|
filter_fun = function(vars)
|
|
|
|
|
|
ngx.ctx.perms = "system::departments::view"
|
|
|
|
|
|
return true
|
|
|
|
|
|
end,
|
2025-11-04 15:30:06 +08:00
|
|
|
|
handler = systemDepartment.getSystemDepartment,
|
2025-10-29 17:29:17 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2025-11-12 09:36:00 +08:00
|
|
|
|
paths = { "/yum/v1/system/departments" },
|
2025-10-29 17:29:17 +08:00
|
|
|
|
methods = { "POST" },
|
2025-11-08 16:10:04 +08:00
|
|
|
|
filter_fun = function(vars)
|
|
|
|
|
|
ngx.ctx.perms = "system::departments::add"
|
|
|
|
|
|
return true
|
|
|
|
|
|
end,
|
2025-11-04 15:30:06 +08:00
|
|
|
|
handler = systemDepartment.addSystemDepartment,
|
2025-10-29 17:29:17 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2025-11-12 09:36:00 +08:00
|
|
|
|
paths = { "/yum/v1/system/departments/:id" },
|
2025-10-29 17:29:17 +08:00
|
|
|
|
methods = { "DELETE" },
|
2025-11-08 16:10:04 +08:00
|
|
|
|
filter_fun = function(vars)
|
|
|
|
|
|
ngx.ctx.perms = "system::departments::delete"
|
|
|
|
|
|
return true
|
|
|
|
|
|
end,
|
2025-11-04 15:30:06 +08:00
|
|
|
|
handler = systemDepartment.deleteSystemDepartment,
|
2025-10-29 17:29:17 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2025-11-12 09:36:00 +08:00
|
|
|
|
paths = { "/yum/v1/system/departments/:id" },
|
2025-10-29 17:29:17 +08:00
|
|
|
|
methods = { "PUT" },
|
2025-11-08 16:10:04 +08:00
|
|
|
|
filter_fun = function(vars)
|
|
|
|
|
|
ngx.ctx.perms = "system::departments::edit"
|
|
|
|
|
|
return true
|
|
|
|
|
|
end,
|
2025-11-04 15:30:06 +08:00
|
|
|
|
handler = systemDepartment.updateSystemDepartment,
|
2025-10-29 17:29:17 +08:00
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-- 初始化路由
|
|
|
|
|
|
local rx, err = radix.new(routes)
|
|
|
|
|
|
if not rx then
|
|
|
|
|
|
ngx.say("Not Found")
|
|
|
|
|
|
ngx.exit(ngx.HTTP_NOT_FOUND)
|
2025-10-28 10:33:35 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
2025-10-29 17:29:17 +08:00
|
|
|
|
--获取访问的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)
|
2025-10-28 10:33:35 +08:00
|
|
|
|
end
|