39 lines
1.2 KiB
Go
Raw Normal View History

2025-04-30 15:46:14 +08:00
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
}