39 lines
1.2 KiB
Go
39 lines
1.2 KiB
Go
package api
|
|
|
|
func GetGameApiInstance() IGameApi {
|
|
return gameApiInstance
|
|
}
|
|
|
|
var gameApiInstance IGameApi
|
|
|
|
type IGameApi interface {
|
|
GetRoutes(req *GetRoutesReq) (*GetRoutesRsp, error) // 用户服务通过用户权限拉取游戏项目路由权限,生成动态菜单
|
|
}
|
|
|
|
func RegisterGameApi(handler IGameApi) {
|
|
gameApiInstance = handler
|
|
}
|
|
|
|
type ResourceInitInfo struct {
|
|
Resource string `json:"resource"`
|
|
Desc string `json:"desc"`
|
|
ShowMethods []string `json:"show_methods"` // 资源权限列表
|
|
MethodsPermissionStr []string `json:"methods_permission"` // 资源权限字符串
|
|
}
|
|
|
|
type ProjectInitInfo struct {
|
|
ProjectId int `json:"project_id"`
|
|
ProjectName string `json:"project_name"`
|
|
ResourceList []*ResourceInitInfo `json:"resource_list"` // 权限过滤后客户端可以显示的资源操作
|
|
ResourceTotalList []*ResourceInitInfo `json:"resource_total_list"` // 所有资源操作权限,可以用来做权限分配树初始化
|
|
}
|
|
|
|
type GetRoutesReq struct {
|
|
IsAdmin bool
|
|
Permissions []string
|
|
}
|
|
|
|
type GetRoutesRsp struct {
|
|
Projects []*ProjectInitInfo
|
|
}
|