Files
jx-callback/business/authz/authz_utils.go
2019-08-06 11:26:08 +08:00

30 lines
525 B
Go

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
}