Files
gazebo 34506d08a9 添加Store.OperatorPhone2
门店搜索支持电话号码
2019-10-08 14:18:44 +08:00

56 lines
1.2 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package authz
import (
"strings"
"git.rosy.net.cn/baseapi/utils"
)
const (
StoreRoleBoss = "StoreBoss"
RoleNameSep = "/"
RolePrefix = "Role"
StoreRolePrefix = "Store"
)
type RoleInfo struct {
Name string `json:"name"`
Description string `json:"description"`
StoreID int `json:"storeID,omitempty"` // 如果这个值非0表示门店角色
}
var (
StoreRoleDescriptionMap = map[string]string{
StoreRoleBoss: "门店老板",
}
StoreRoleList = []*RoleInfo{
&RoleInfo{
Name: StoreRoleBoss,
Description: StoreRoleDescriptionMap[StoreRoleBoss],
},
}
)
type IAuthz interface {
AddRole4User(userID string, r *RoleInfo) (err error)
DeleteRole4User(userID string, r *RoleInfo) (err error)
GetUserRoleList(userID string) (roleList []*RoleInfo, err error)
GetRoleUserList(r *RoleInfo) (userIDList []string, err error)
// GetAllRoleList() (roleList []*RoleInfo)
}
func (r *RoleInfo) GetFullName() (fullRoleName string) {
strList := []string{
RolePrefix,
r.Name,
}
if r.StoreID > 0 {
strList = append(strList, StoreRolePrefix, utils.Int2Str(r.StoreID))
} else if r.StoreID != 0 {
strList = append(strList, StoreRolePrefix, "")
}
fullRoleName = strings.Join(strList, RoleNameSep)
return fullRoleName
}