This commit is contained in:
2025-12-15 17:55:32 +08:00
commit 28ab17324d
170 changed files with 18373 additions and 0 deletions

View File

@@ -0,0 +1,344 @@
// Code generated by go-enum DO NOT EDIT.
// Version: -
// Revision: -
// Build Date: -
// Built By: -
package consts
import (
"database/sql/driver"
"errors"
"fmt"
"strings"
)
const (
// RoleUser is a Role of type user.
RoleUser Role = "user"
// RoleTenantAdmin is a Role of type tenant_admin.
RoleTenantAdmin Role = "tenant_admin"
// RoleSuperAdmin is a Role of type super_admin.
RoleSuperAdmin Role = "super_admin"
)
var ErrInvalidRole = fmt.Errorf("not a valid Role, try [%s]", strings.Join(_RoleNames, ", "))
var _RoleNames = []string{
string(RoleUser),
string(RoleTenantAdmin),
string(RoleSuperAdmin),
}
// RoleNames returns a list of possible string values of Role.
func RoleNames() []string {
tmp := make([]string, len(_RoleNames))
copy(tmp, _RoleNames)
return tmp
}
// RoleValues returns a list of the values for Role
func RoleValues() []Role {
return []Role{
RoleUser,
RoleTenantAdmin,
RoleSuperAdmin,
}
}
// String implements the Stringer interface.
func (x Role) String() string {
return string(x)
}
// IsValid provides a quick way to determine if the typed value is
// part of the allowed enumerated values
func (x Role) IsValid() bool {
_, err := ParseRole(string(x))
return err == nil
}
var _RoleValue = map[string]Role{
"user": RoleUser,
"tenant_admin": RoleTenantAdmin,
"super_admin": RoleSuperAdmin,
}
// ParseRole attempts to convert a string to a Role.
func ParseRole(name string) (Role, error) {
if x, ok := _RoleValue[name]; ok {
return x, nil
}
return Role(""), fmt.Errorf("%s is %w", name, ErrInvalidRole)
}
var errRoleNilPtr = errors.New("value pointer is nil") // one per type for package clashes
// Scan implements the Scanner interface.
func (x *Role) Scan(value interface{}) (err error) {
if value == nil {
*x = Role("")
return
}
// A wider range of scannable types.
// driver.Value values at the top of the list for expediency
switch v := value.(type) {
case string:
*x, err = ParseRole(v)
case []byte:
*x, err = ParseRole(string(v))
case Role:
*x = v
case *Role:
if v == nil {
return errRoleNilPtr
}
*x = *v
case *string:
if v == nil {
return errRoleNilPtr
}
*x, err = ParseRole(*v)
default:
return errors.New("invalid type for Role")
}
return
}
// Value implements the driver Valuer interface.
func (x Role) Value() (driver.Value, error) {
return x.String(), nil
}
// Set implements the Golang flag.Value interface func.
func (x *Role) Set(val string) error {
v, err := ParseRole(val)
*x = v
return err
}
// Get implements the Golang flag.Getter interface func.
func (x *Role) Get() interface{} {
return *x
}
// Type implements the github.com/spf13/pFlag Value interface.
func (x *Role) Type() string {
return "Role"
}
type NullRole struct {
Role Role
Valid bool
}
func NewNullRole(val interface{}) (x NullRole) {
err := x.Scan(val) // yes, we ignore this error, it will just be an invalid value.
_ = err // make any errcheck linters happy
return
}
// Scan implements the Scanner interface.
func (x *NullRole) Scan(value interface{}) (err error) {
if value == nil {
x.Role, x.Valid = Role(""), false
return
}
err = x.Role.Scan(value)
x.Valid = (err == nil)
return
}
// Value implements the driver Valuer interface.
func (x NullRole) Value() (driver.Value, error) {
if !x.Valid {
return nil, nil
}
// driver.Value accepts int64 for int values.
return string(x.Role), nil
}
type NullRoleStr struct {
NullRole
}
func NewNullRoleStr(val interface{}) (x NullRoleStr) {
x.Scan(val) // yes, we ignore this error, it will just be an invalid value.
return
}
// Value implements the driver Valuer interface.
func (x NullRoleStr) Value() (driver.Value, error) {
if !x.Valid {
return nil, nil
}
return x.Role.String(), nil
}
const (
// UserStatusPendingVerify is a UserStatus of type pending_verify.
UserStatusPendingVerify UserStatus = "pending_verify"
// UserStatusVerified is a UserStatus of type verified.
UserStatusVerified UserStatus = "verified"
// UserStatusBanned is a UserStatus of type banned.
UserStatusBanned UserStatus = "banned"
)
var ErrInvalidUserStatus = fmt.Errorf("not a valid UserStatus, try [%s]", strings.Join(_UserStatusNames, ", "))
var _UserStatusNames = []string{
string(UserStatusPendingVerify),
string(UserStatusVerified),
string(UserStatusBanned),
}
// UserStatusNames returns a list of possible string values of UserStatus.
func UserStatusNames() []string {
tmp := make([]string, len(_UserStatusNames))
copy(tmp, _UserStatusNames)
return tmp
}
// UserStatusValues returns a list of the values for UserStatus
func UserStatusValues() []UserStatus {
return []UserStatus{
UserStatusPendingVerify,
UserStatusVerified,
UserStatusBanned,
}
}
// String implements the Stringer interface.
func (x UserStatus) String() string {
return string(x)
}
// IsValid provides a quick way to determine if the typed value is
// part of the allowed enumerated values
func (x UserStatus) IsValid() bool {
_, err := ParseUserStatus(string(x))
return err == nil
}
var _UserStatusValue = map[string]UserStatus{
"pending_verify": UserStatusPendingVerify,
"verified": UserStatusVerified,
"banned": UserStatusBanned,
}
// ParseUserStatus attempts to convert a string to a UserStatus.
func ParseUserStatus(name string) (UserStatus, error) {
if x, ok := _UserStatusValue[name]; ok {
return x, nil
}
return UserStatus(""), fmt.Errorf("%s is %w", name, ErrInvalidUserStatus)
}
var errUserStatusNilPtr = errors.New("value pointer is nil") // one per type for package clashes
// Scan implements the Scanner interface.
func (x *UserStatus) Scan(value interface{}) (err error) {
if value == nil {
*x = UserStatus("")
return
}
// A wider range of scannable types.
// driver.Value values at the top of the list for expediency
switch v := value.(type) {
case string:
*x, err = ParseUserStatus(v)
case []byte:
*x, err = ParseUserStatus(string(v))
case UserStatus:
*x = v
case *UserStatus:
if v == nil {
return errUserStatusNilPtr
}
*x = *v
case *string:
if v == nil {
return errUserStatusNilPtr
}
*x, err = ParseUserStatus(*v)
default:
return errors.New("invalid type for UserStatus")
}
return
}
// Value implements the driver Valuer interface.
func (x UserStatus) Value() (driver.Value, error) {
return x.String(), nil
}
// Set implements the Golang flag.Value interface func.
func (x *UserStatus) Set(val string) error {
v, err := ParseUserStatus(val)
*x = v
return err
}
// Get implements the Golang flag.Getter interface func.
func (x *UserStatus) Get() interface{} {
return *x
}
// Type implements the github.com/spf13/pFlag Value interface.
func (x *UserStatus) Type() string {
return "UserStatus"
}
type NullUserStatus struct {
UserStatus UserStatus
Valid bool
}
func NewNullUserStatus(val interface{}) (x NullUserStatus) {
err := x.Scan(val) // yes, we ignore this error, it will just be an invalid value.
_ = err // make any errcheck linters happy
return
}
// Scan implements the Scanner interface.
func (x *NullUserStatus) Scan(value interface{}) (err error) {
if value == nil {
x.UserStatus, x.Valid = UserStatus(""), false
return
}
err = x.UserStatus.Scan(value)
x.Valid = (err == nil)
return
}
// Value implements the driver Valuer interface.
func (x NullUserStatus) Value() (driver.Value, error) {
if !x.Valid {
return nil, nil
}
// driver.Value accepts int64 for int values.
return string(x.UserStatus), nil
}
type NullUserStatusStr struct {
NullUserStatus
}
func NewNullUserStatusStr(val interface{}) (x NullUserStatusStr) {
x.Scan(val) // yes, we ignore this error, it will just be an invalid value.
return
}
// Value implements the driver Valuer interface.
func (x NullUserStatusStr) Value() (driver.Value, error) {
if !x.Valid {
return nil, nil
}
return x.UserStatus.String(), nil
}

View File

@@ -0,0 +1,16 @@
package consts
// Format
//
// // swagger:enum CacheKey
// // ENUM(
// // VerifyCode = "code:__CHANNEL__:%s",
// // )
// swagger:enum Role
// ENUM( user, tenant_admin, super_admin)
type Role string
// swagger:enum UserStatus
// ENUM(pending_verify, verified, banned, )
type UserStatus string