package constants // IsRoleTypeMatchUserType 检查角色类型是否与用户类型匹配 // 返回 true 表示匹配,false 表示不匹配 func IsRoleTypeMatchUserType(roleType, userType int) bool { switch userType { case UserTypeSuperAdmin: // 超级管理员不需要角色 return false case UserTypePlatform: // 平台用户只能分配平台角色 return roleType == RoleTypePlatform case UserTypeAgent, UserTypeEnterprise: // 代理/企业账号只能分配客户角色 return roleType == RoleTypeCustomer default: return false } } // GetMaxRolesForUserType 获取用户类型允许的最大角色数量 // 返回 0 表示不允许分配角色,-1 表示无限制 func GetMaxRolesForUserType(userType int) int { switch userType { case UserTypeSuperAdmin: // 超级管理员不需要角色 return 0 case UserTypePlatform: // 平台用户可分配多个角色,无限制 return -1 case UserTypeAgent, UserTypeEnterprise: // 代理/企业账号只能分配一个角色 return 1 default: return 0 } }