Documentation ¶
Overview ¶
rpcx服务列表 1. 加载用户关系数据到redis中 2. 新增系统账户,修改系统或者员工角色时,需要修改用户与角色之间的关系
Index ¶
- Variables
- func AddRoleFunctions(funcId int, roleIds []int, o *orm.Ormer) (retCode int, err error)
- func AddUserRole(userId, roleId int) (id int, retcode int, err error)
- func GetFuncId(info *HttpRequestInfo) (funcId int, entityStr string, retcode int, err error)
- func GetFuncIdsByRoleId(id int) (funcIds []int, retcode int, err error)
- func GetMethodNameByType(methodType int) (methodName string)
- func GetMethodTypeByName(methodName string) (methodType int)
- func GetRoleIdByName(name string) (id int, retcode int, err error)
- func GetRoleIdsByUserId(id int) (roleIds []int, retcode int, err error)
- func GetRoleName(roles []*Role, roleId int64) (name string, retcode int, err error)
- func GetThirdReginMarkKey(uri string) (markKey string, retcode int, err error)
- func IsExistInWhiteList(info *HttpRequestInfo) (isInWhiteList bool, retcode int, err error)
- func LoadMapTree() (err error)
- func LoadWhiteList(pageIndex, pageSize int64) (retcode int, err error)
- func PrintTree()
- type Entities
- type FunctionInfos
- type Functions
- type GrbacServer
- func (s *GrbacServer) AddUserRole(in *pb.UserRole, out *pb.UserRole) (err error)
- func (s *GrbacServer) DelUserRole(in *pb.UserRole, out *pb.UserRole) (err error)
- func (s *GrbacServer) GetRoleByRoleCode(in *pb.String, out *pb.Role) (err error)
- func (t *GrbacServer) LoadGrbacUserRel(in *pb.GrbacUserRel, out *pb.GrbacUserRel) (err error)
- func (t *GrbacServer) ModifyUserRole(in *pb.GrbacUserRel, out *pb.GrbacUserRel) (err error)
- type HttpRequestInfo
- type Regions
- type Role
- type RoleFunctionRelationships
- func (t *RoleFunctionRelationships) InsertRoleFunctionNoLock(o *orm.Ormer) (retcode int, err error)
- func (t *RoleFunctionRelationships) ReadRoleFunctionNoLock(o *orm.Ormer) (retcode int, err error)
- func (t *RoleFunctionRelationships) TableName() string
- func (t *RoleFunctionRelationships) UpdateRoleFunctionNoLock(o *orm.Ormer) (retcode int, err error)
- type Stack
- type Tree
- type UserRole
- type UserRoleInfos
- type WhiteList
- type WhiteListInfo
Constants ¶
This section is empty.
Variables ¶
View Source
var ( METHOD_TYPE_GET = 10 // GET METHOD_TYPE_POST = 20 // POST METHOD_TYPE_PUT = 30 // PUT METHOD_TYPE_PATCH = 40 // PATCH METHOD_TYPE_DELETE = 50 // DELETE )
View Source
var ( RootMap map[string]*Tree = map[string]*Tree{ "GET": &Tree{Value: -1}, "POST": &Tree{Value: -1}, "PUT": &Tree{Value: -1}, "PATCH": &Tree{Value: -1}, "DELETE": &Tree{Value: -1}, } )
View Source
var (
WhiteLists []*WhiteListInfo // 白名单信息列表
)
Functions ¶
func AddRoleFunctions ¶
func GetFuncId ¶
func GetFuncId(info *HttpRequestInfo) (funcId int, entityStr string, retcode int, err error)
func GetFuncIdsByRoleId ¶
根据角色ID, 获取功能ID列表
func GetMethodNameByType ¶
根据HTTP方法类型,获取方法名称
func GetMethodTypeByName ¶
根据HTTP方法名,获取方法类型
func GetRoleIdByName ¶
通过角色名称,获取角色ID
func GetRoleIdsByUserId ¶
根据用户ID,获取角色ID列表 input: @param userId output: @param roleIds
func GetRoleName ¶
func GetThirdReginMarkKey ¶
解析获取thid_region_mark_key eg. /v1/storages/warehouses/:id/invalid -> :id 错误判断,如果不是以'/'开头,则返回错误
func IsExistInWhiteList ¶
func IsExistInWhiteList(info *HttpRequestInfo) (isInWhiteList bool, retcode int, err error)
func LoadWhiteList ¶
2. 加载白名单列表到内存中
Types ¶
type Entities ¶
type Entities struct { Id int `orm:"column(entity_id);auto"` RegionId int `orm:"column(region_id);null"` Name string `orm:"column(name);size(300);null"` ThirdId int `orm:"column(third_id);null"` Status int16 `orm:"column(status);null"` UpdatedAt time.Time `orm:"column(updated_at);type(datetime);null"` CreatedAt time.Time `orm:"column(created_at);type(datetime);null"` }
type FunctionInfos ¶
type FunctionInfos struct { Id int `json:"function_id"` Method string `json:"method"` Name string `json:"name"` Uri string `json:"uri"` }
func GetFunctions ¶
func GetFunctions(pageIndex int64, pageSize int64, searchKey string) (funcInfos []*FunctionInfos, count int64, realCount int64, retcode int, err error)
获取功能列表与搜索 搜索支持:名称和URI
type Functions ¶
type Functions struct { Id int `orm:"column(function_id);auto"` Name string `orm:"column(name);size(60);null"` RegionId int `orm:"column(region_id);null"` Uri string `orm:"column(uri);size(500);null"` ThirdRegionMarkKey string `orm:"column(third_region_mark_key);size(300);null"` MethodType int16 `orm:"column(method_type);null"` Status int16 `orm:"column(status);null"` UpdatedAt time.Time `orm:"column(updated_at);type(datetime);null"` CreatedAt time.Time `orm:"column(created_at);type(datetime);null"` }
func (*Functions) InsertFunctionNoLock ¶
func (*Functions) ReadFunctionNoLock ¶
type GrbacServer ¶
type GrbacServer struct{}
func (*GrbacServer) AddUserRole ¶
func (*GrbacServer) DelUserRole ¶
func (*GrbacServer) GetRoleByRoleCode ¶
func (*GrbacServer) LoadGrbacUserRel ¶
func (t *GrbacServer) LoadGrbacUserRel(in *pb.GrbacUserRel, out *pb.GrbacUserRel) (err error)
func (*GrbacServer) ModifyUserRole ¶
func (t *GrbacServer) ModifyUserRole(in *pb.GrbacUserRel, out *pb.GrbacUserRel) (err error)
2. 新增系统账户,修改系统或者员工角色时,需要修改用户与角色之间的关系
type HttpRequestInfo ¶
type Regions ¶
type Regions struct { Id int `orm:"column(region_id);auto"` Code string `orm:"column(code);size(50);null"` Name string `orm:"column(name);size(50);null"` Status int16 `orm:"column(status);null"` UpdatedAt time.Time `orm:"column(updated_at);type(datetime);null"` CreatedAt time.Time `orm:"column(created_at);type(datetime);null"` }
type Role ¶
type Role struct { RoleId int `orm:"column(role_id);auto" json:"role_id"` RegionId int `orm:"column(region_id);null"` Name string `orm:"column(name);size(50);null" json:"name"` Code string `orm:"column(code);size(20);null" json:"code"` Status int16 `orm:"column(status);null"` UpdatedAt time.Time `orm:"column(updated_at);type(datetime);null"` CreatedAt time.Time `orm:"column(created_at);type(datetime);null"` }
func GetRoleByRoleCode ¶
func (*Role) InsertRoleNoLock ¶
type RoleFunctionRelationships ¶
type RoleFunctionRelationships struct { Id int `orm:"column(role_function_relationship_id);auto"` RoleId int `orm:"column(role_id);null"` FunctionId int `orm:"column(function_id);null"` RegionId int `orm:"column(region_id);null"` Status int16 `orm:"column(status);null"` UpdatedAt time.Time `orm:"column(updated_at);type(datetime);null"` CreatedAt time.Time `orm:"column(created_at);type(datetime);null"` }
func GetRoleFunctions ¶
func (*RoleFunctionRelationships) InsertRoleFunctionNoLock ¶
func (t *RoleFunctionRelationships) InsertRoleFunctionNoLock(o *orm.Ormer) (retcode int, err error)
func (*RoleFunctionRelationships) ReadRoleFunctionNoLock ¶
func (t *RoleFunctionRelationships) ReadRoleFunctionNoLock(o *orm.Ormer) (retcode int, err error)
func (*RoleFunctionRelationships) TableName ¶
func (t *RoleFunctionRelationships) TableName() string
func (*RoleFunctionRelationships) UpdateRoleFunctionNoLock ¶
func (t *RoleFunctionRelationships) UpdateRoleFunctionNoLock(o *orm.Ormer) (retcode int, err error)
type Tree ¶
type Tree struct { Trees []*Tree RegMatch *regexp.Regexp Name string // 节点名称 Value int // 节点值, 也称功能ID }
每个节点由两部分组成:1.非正则;2.正则
type UserRole ¶
type UserRole struct { UserRoleId int `orm:"column(user_role_id);auto" json:"user_role_id"` UserId int `orm:"column(user_id);null" json:"user_id"` RoleId int `orm:"column(role_id);null" json:"role_id"` RegionId int `orm:"column(region_id);null" json:"region_id"` Status int16 `orm:"column(status);null" json:"status"` UpdatedAt time.Time `orm:"column(updated_at);type(datetime);null" json:"updated_at"` CreatedAt time.Time `orm:"column(created_at);type(datetime);null" json:"created_at"` }
func (*UserRole) InsertUserRoleNoLock ¶
func (*UserRole) ReadUserRoleNoLock ¶
type UserRoleInfos ¶
type UserRoleInfos struct { Mobile string `json:"mobile"` Name string `json:"name"` RoleFunctionRelationshipId int64 `json:"role_function_relationship_id"` UserId int64 `json:"user_id"` }
func GetUserRoles ¶
func GetUserRoles(pageIndex, pageSize int64, roleId int, searchKey string) (userRoleInfos []*UserRoleInfos, count int64, realCount int64, retcode int, err error)
3. 用户与角色关系列表和搜索 @param page_index: 页码(1+), page_size: 页面大小,role_id:角色ID,search_key={手机号,用户ID} 难点:1. 搜索手机号,跨服务rpc
- 手机号或者用户ID,需要组织两个列表,然后求Union集
- 分页
type WhiteList ¶
type WhiteList struct { Id int `orm:"column(white_list_id);auto"` Name string `orm:"column(name);size(50);null"` Url string `orm:"column(url);size(100);null"` MethodType int16 `orm:"column(method_type);null"` Desc string `orm:"column(desc);size(300);null"` Status int16 `orm:"column(status);null"` UpdatedAt time.Time `orm:"column(updated_at);type(datetime);null"` CreatedAt time.Time `orm:"column(created_at);type(datetime);null"` }
func GetWhiteLists ¶
func (*WhiteList) InsertWhiteListNoLock ¶
func (*WhiteList) ReadWhiteListNoLock ¶
Click to show internal directories.
Click to hide internal directories.