This commit is contained in:
2023-09-04 14:21:29 +08:00
3 changed files with 80 additions and 120 deletions

View File

@@ -25,60 +25,46 @@ func Routers() []services.RouterItem {
rs := [...]services.RouterItem{ rs := [...]services.RouterItem{
{ {
Method: "GET", Method: "GET",
Pattern: "/menus", Pattern: "/menus",
Handler: apis.List, Handler: apis.List,
Middleware: midware.Authorize(map[string][]string{ Middleware: midware.Authorize(nil),
"hasPerms": {"system:menu:list"},
}),
}, },
{ {
Method: "GET", Method: "GET",
Pattern: "/menu/{menuId}", Pattern: "/menu/{menuId}",
Handler: apis.Info, Handler: apis.Info,
Middleware: midware.Authorize(map[string][]string{ Middleware: midware.Authorize(nil),
"hasPerms": {"system:menu:query"},
}),
}, },
{ {
Method: "POST", Method: "POST",
Pattern: "/menu", Pattern: "/menu",
Handler: apis.Add, Handler: apis.Add,
Middleware: midware.Authorize(map[string][]string{ Middleware: midware.Authorize(nil),
"hasPerms": {"system:menu:add"},
}),
}, },
{ {
Method: "PUT", Method: "PUT",
Pattern: "/menu", Pattern: "/menu",
Handler: apis.Edit, Handler: apis.Edit,
Middleware: midware.Authorize(map[string][]string{ Middleware: midware.Authorize(nil),
"hasPerms": {"system:menu:edit"},
}),
}, },
{ {
Method: "DELETE", Method: "DELETE",
Pattern: "/menu/{menuId}", Pattern: "/menu/{menuId}",
Handler: apis.Remove, Handler: apis.Remove,
Middleware: midware.Authorize(map[string][]string{ Middleware: midware.Authorize(nil),
"hasPerms": {"system:menu:edit"},
}),
}, },
{ {
Method: "GET", Method: "GET",
Pattern: "/menus/treeSelect", Pattern: "/menus/treeSelect",
Handler: apis.TreeSelect, Handler: apis.TreeSelect,
Middleware: midware.Authorize(map[string][]string{ Middleware: midware.Authorize(nil),
"hasPerms": {"system:menu:list"},
}),
}, },
{ {
Method: "GET", Method: "GET",
Pattern: "/menu/roleMenuTreeSelect/{roleId}", Pattern: "/menu/roleMenuTreeSelect/{roleId}",
Handler: apis.RoleMenuTreeSelect, Handler: apis.RoleMenuTreeSelect,
Middleware: midware.Authorize(map[string][]string{ Middleware: midware.Authorize(nil),
"hasPerms": {"system:menu:list"},
}),
}, },
// 添加更多的 Router 对象... // 添加更多的 Router 对象...
} }

View File

@@ -26,68 +26,52 @@ func Routers() []services.RouterItem {
rs := [...]services.RouterItem{ rs := [...]services.RouterItem{
{ {
Method: "GET", Method: "GET",
Pattern: "/roles", Pattern: "/roles",
Handler: apis.List, Handler: apis.List,
Middleware: midware.Authorize(map[string][]string{ Middleware: midware.Authorize(nil),
"hasPerms": {"system:menu:list"},
}),
}, },
{ {
Method: "GET", Method: "GET",
Pattern: "/role/{roleId}", Pattern: "/role/{roleId}",
Handler: apis.Info, Handler: apis.Info,
Middleware: midware.Authorize(map[string][]string{ Middleware: midware.Authorize(nil),
"hasPerms": {"system:menu:query"},
}),
}, },
{ {
Method: "POST", Method: "POST",
Pattern: "/role", Pattern: "/role",
Handler: apis.Add, Handler: apis.Add,
Middleware: midware.Authorize(map[string][]string{ Middleware: midware.Authorize(nil),
"hasPerms": {"system:menu:add"},
}),
}, },
{ {
Method: "PUT", Method: "PUT",
Pattern: "/role", Pattern: "/role",
Handler: apis.Edit, Handler: apis.Edit,
Middleware: midware.Authorize(map[string][]string{ Middleware: midware.Authorize(nil),
"hasPerms": {"system:menu:edit"},
}),
}, },
{ {
Method: "DELETE", Method: "DELETE",
Pattern: "/role/{roleIds}", Pattern: "/role/{roleIds}",
Handler: apis.Remove, Handler: apis.Remove,
Middleware: midware.Authorize(map[string][]string{ Middleware: midware.Authorize(nil),
"hasPerms": {"system:menu:edit"},
}),
}, },
{ {
Method: "PUT", Method: "PUT",
Pattern: "/role/changeStatus", Pattern: "/role/changeStatus",
Handler: apis.Status, Handler: apis.Status,
Middleware: midware.Authorize(map[string][]string{ Middleware: midware.Authorize(nil),
"hasPerms": {"system:role:edit"},
}),
}, },
{ {
Method: "GET", Method: "GET",
Pattern: "/role/authUser/allocatedList", Pattern: "/role/authUser/allocatedList",
Handler: apis.AuthUserAllocatedList, Handler: apis.AuthUserAllocatedList,
Middleware: midware.Authorize(map[string][]string{ Middleware: midware.Authorize(nil),
"hasPerms": {"system:user:list"},
}),
}, },
{ {
Method: "PUT", Method: "PUT",
Pattern: "/role/authUser/checked", Pattern: "/role/authUser/checked",
Handler: apis.AuthUserChecked, Handler: apis.AuthUserChecked,
Middleware: midware.Authorize(map[string][]string{ Middleware: midware.Authorize(nil),
"hasPerms": {"system:role:edit"},
}),
}, },
// 添加更多的 Router 对象... // 添加更多的 Router 对象...
} }

View File

@@ -28,44 +28,34 @@ func Routers() []services.RouterItem {
rs := [...]services.RouterItem{ rs := [...]services.RouterItem{
{ {
Method: "GET", Method: "GET",
Pattern: "/users", Pattern: "/users",
Handler: apis.List, Handler: apis.List,
Middleware: midware.Authorize(map[string][]string{ Middleware: midware.Authorize(nil),
"hasPerms": {"system:user:list"},
}),
}, },
{ {
Method: "GET", Method: "GET",
Pattern: "/user/{userId}", Pattern: "/user/{userId}",
Handler: apis.Info, Handler: apis.Info,
Middleware: midware.Authorize(map[string][]string{ Middleware: midware.Authorize(nil),
"hasPerms": {"system:user:query"},
}),
}, },
{ {
Method: "POST", Method: "POST",
Pattern: "/user", Pattern: "/user",
Handler: apis.Add, Handler: apis.Add,
Middleware: midware.Authorize(map[string][]string{ Middleware: midware.Authorize(nil),
"hasPerms": {"system:user:add"},
}),
}, },
{ {
Method: "PUT", Method: "PUT",
Pattern: "/user", Pattern: "/user",
Handler: apis.Edit, Handler: apis.Edit,
Middleware: midware.Authorize(map[string][]string{ Middleware: midware.Authorize(nil),
"hasPerms": {"system:user:edit"},
}),
}, },
{ {
Method: "DELETE", Method: "DELETE",
Pattern: "/user/{userIds}", Pattern: "/user/{userIds}",
Handler: apis.Remove, Handler: apis.Remove,
Middleware: midware.Authorize(map[string][]string{ Middleware: midware.Authorize(nil),
"hasPerms": {"system:user:edit"},
}),
}, },
// 添加更多的 Router 对象... // 添加更多的 Router 对象...
} }