- 开始添加casbin做角色,权限管理
This commit is contained in:
29
business/authz/authz_utils.go
Normal file
29
business/authz/authz_utils.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package authz
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
RoleNameSep = "/"
|
||||
RolePrefix = "role"
|
||||
StoreRolePrefix = "store"
|
||||
)
|
||||
|
||||
func GenStoreRoleName(storeID int) (roleName string) {
|
||||
return strings.Join([]string{
|
||||
RolePrefix,
|
||||
StoreRolePrefix,
|
||||
utils.Int2Str(storeID),
|
||||
}, RoleNameSep)
|
||||
}
|
||||
|
||||
func GetStoreIDFromRole(roleName string) (storeID int) {
|
||||
list := strings.Split(roleName, RoleNameSep)
|
||||
if len(list) == 3 {
|
||||
storeID = int(utils.Str2Int64WithDefault(list[2], 0))
|
||||
}
|
||||
return storeID
|
||||
}
|
||||
Reference in New Issue
Block a user