diff --git a/internal/biz/enum/const.go b/internal/biz/enum/const.go index 7f755ad8..5450be8f 100644 --- a/internal/biz/enum/const.go +++ b/internal/biz/enum/const.go @@ -30,6 +30,7 @@ const GetInstanceStatus = "get_instance_status" const ConnectInstance = "connect_instance" const InstanceProxy = "instance_proxy" +var All = []string{CreateUser, UpdateUser, DeleteUser, GetUser, SearchUser, CreateRole, UpdateRole, DeleteRole, GetRole, SearchRole, ListPermission} var Admin = []string{CreateUser, UpdateUser, DeleteUser, GetUser, SearchUser, CreateRole, UpdateRole, DeleteRole, GetRole, SearchRole, ListPermission} var AdminUser = []string{CreateUser, UpdateUser, DeleteUser, GetUser, SearchUser} var AdminRole = []string{CreateRole, UpdateRole, DeleteRole, GetRole, SearchRole, ListPermission} diff --git a/internal/biz/permission.go b/internal/biz/permission.go index 48453648..dd4f5a59 100644 --- a/internal/biz/permission.go +++ b/internal/biz/permission.go @@ -36,24 +36,18 @@ func NewRole(typ string) (r IRole, err error) { } type ConsolePermisson struct { - Id string `json:"id"` - Name string `json:"name"` + Api []string `json:"api"` + Menu []Menu `json:"menu"` +} +type Menu struct { + Id string `json:"id"` + Name string `json:"name"` + Switch []string `json:"switch,omitempty"` + Children []Menu `json:"children,omitempty"` } func (r ConsoleRole) ListPermission() interface{} { - //list := []ConsolePermisson{ - // { - // Id: "cluster_overview", - // Name: "平台概览", - // }, - // { - // Id: "cluster_search", - // Name: "平台搜索", - // }, - // { - // Id: "cluster_elasticsearch", - // Name: "集群监控", - // }, + // { // Id: "cluster_elasticsearch_refresh", // Name: "集群监控刷新", @@ -68,10 +62,36 @@ func (r ConsoleRole) ListPermission() interface{} { // }, // //} - m := make(map[string]map[string][]string) - m["api"]["用户管理"] = enum.AdminUser - m["api"]["角色管理"] = enum.AdminRole - return m + menu := []Menu{ + { + Id: "cluster", + Name: "平台管理", + Children: []Menu{ + { + Id: "cluster_overview", + Name: "平台概览", + Switch: []string{"none", "write", "read"}, + }, + { + + Id: "cluster_elasticsearch", + Name: "集群监控", + Switch: []string{"none", "write", "read"}, + }, { + + Id: "cluster_activities", + Name: "集群动态", + Switch: []string{"none", "write", "read"}, + }, + }, + }, + } + p := ConsolePermisson{ + Api: enum.All, + Menu: menu, + } + + return p } func (r ElasticsearchRole) ListPermission() interface{} { list := ElasticsearchPermisson{