package entity type AdminRole uint const ( AdminSuperAdminRole AdminRole = iota + 1 AdminAdminRole AdminAgentRole ) var AdminRoleStrings = map[AdminRole]string{ AdminSuperAdminRole: "super-admin", AdminAdminRole: "admin", AdminAgentRole: "agent", } func (s AdminRole) String() string { return AdminRoleStrings[s] } func (s AdminRole) IsValid() bool { return s > 0 && int(s) <= len(AdminRoleStrings) } // MapToAdminRole converts a string to the corresponding AdminRole value. func MapToAdminRole(roleStr string) AdminRole { for role, str := range AdminRoleStrings { if str == roleStr { return role } } return AdminRole(0) }