fix: issues
This commit is contained in:
174
backend/app/consts/consts.gen.go
Normal file
174
backend/app/consts/consts.gen.go
Normal file
@@ -0,0 +1,174 @@
|
||||
// Code generated by go-enum DO NOT EDIT.
|
||||
// Version: -
|
||||
// Revision: -
|
||||
// Build Date: -
|
||||
// Built By: -
|
||||
|
||||
package consts
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
// TokenTypeUser is a TokenType of type User.
|
||||
TokenTypeUser TokenType = "__tu"
|
||||
// TokenTypeTenant is a TokenType of type Tenant.
|
||||
TokenTypeTenant TokenType = "__tt"
|
||||
)
|
||||
|
||||
var ErrInvalidTokenType = fmt.Errorf("not a valid TokenType, try [%s]", strings.Join(_TokenTypeNames, ", "))
|
||||
|
||||
var _TokenTypeNames = []string{
|
||||
string(TokenTypeUser),
|
||||
string(TokenTypeTenant),
|
||||
}
|
||||
|
||||
// TokenTypeNames returns a list of possible string values of TokenType.
|
||||
func TokenTypeNames() []string {
|
||||
tmp := make([]string, len(_TokenTypeNames))
|
||||
copy(tmp, _TokenTypeNames)
|
||||
return tmp
|
||||
}
|
||||
|
||||
// TokenTypeValues returns a list of the values for TokenType
|
||||
func TokenTypeValues() []TokenType {
|
||||
return []TokenType{
|
||||
TokenTypeUser,
|
||||
TokenTypeTenant,
|
||||
}
|
||||
}
|
||||
|
||||
// String implements the Stringer interface.
|
||||
func (x TokenType) 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 TokenType) IsValid() bool {
|
||||
_, err := ParseTokenType(string(x))
|
||||
return err == nil
|
||||
}
|
||||
|
||||
var _TokenTypeValue = map[string]TokenType{
|
||||
"__tu": TokenTypeUser,
|
||||
"__tt": TokenTypeTenant,
|
||||
}
|
||||
|
||||
// ParseTokenType attempts to convert a string to a TokenType.
|
||||
func ParseTokenType(name string) (TokenType, error) {
|
||||
if x, ok := _TokenTypeValue[name]; ok {
|
||||
return x, nil
|
||||
}
|
||||
return TokenType(""), fmt.Errorf("%s is %w", name, ErrInvalidTokenType)
|
||||
}
|
||||
|
||||
var errTokenTypeNilPtr = errors.New("value pointer is nil") // one per type for package clashes
|
||||
|
||||
// Scan implements the Scanner interface.
|
||||
func (x *TokenType) Scan(value interface{}) (err error) {
|
||||
if value == nil {
|
||||
*x = TokenType("")
|
||||
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 = ParseTokenType(v)
|
||||
case []byte:
|
||||
*x, err = ParseTokenType(string(v))
|
||||
case TokenType:
|
||||
*x = v
|
||||
case *TokenType:
|
||||
if v == nil {
|
||||
return errTokenTypeNilPtr
|
||||
}
|
||||
*x = *v
|
||||
case *string:
|
||||
if v == nil {
|
||||
return errTokenTypeNilPtr
|
||||
}
|
||||
*x, err = ParseTokenType(*v)
|
||||
default:
|
||||
return errors.New("invalid type for TokenType")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (x TokenType) Value() (driver.Value, error) {
|
||||
return x.String(), nil
|
||||
}
|
||||
|
||||
// Set implements the Golang flag.Value interface func.
|
||||
func (x *TokenType) Set(val string) error {
|
||||
v, err := ParseTokenType(val)
|
||||
*x = v
|
||||
return err
|
||||
}
|
||||
|
||||
// Get implements the Golang flag.Getter interface func.
|
||||
func (x *TokenType) Get() interface{} {
|
||||
return *x
|
||||
}
|
||||
|
||||
// Type implements the github.com/spf13/pFlag Value interface.
|
||||
func (x *TokenType) Type() string {
|
||||
return "TokenType"
|
||||
}
|
||||
|
||||
type NullTokenType struct {
|
||||
TokenType TokenType
|
||||
Valid bool
|
||||
}
|
||||
|
||||
func NewNullTokenType(val interface{}) (x NullTokenType) {
|
||||
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 *NullTokenType) Scan(value interface{}) (err error) {
|
||||
if value == nil {
|
||||
x.TokenType, x.Valid = TokenType(""), false
|
||||
return
|
||||
}
|
||||
|
||||
err = x.TokenType.Scan(value)
|
||||
x.Valid = (err == nil)
|
||||
return
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (x NullTokenType) Value() (driver.Value, error) {
|
||||
if !x.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
// driver.Value accepts int64 for int values.
|
||||
return string(x.TokenType), nil
|
||||
}
|
||||
|
||||
type NullTokenTypeStr struct {
|
||||
NullTokenType
|
||||
}
|
||||
|
||||
func NewNullTokenTypeStr(val interface{}) (x NullTokenTypeStr) {
|
||||
x.Scan(val) // yes, we ignore this error, it will just be an invalid value.
|
||||
return
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (x NullTokenTypeStr) Value() (driver.Value, error) {
|
||||
if !x.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
return x.TokenType.String(), nil
|
||||
}
|
||||
7
backend/app/consts/consts.go
Normal file
7
backend/app/consts/consts.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package consts
|
||||
|
||||
// swagger:enum TokenType
|
||||
// ENUM(
|
||||
// User = "__tu", Tenant = "__tt"
|
||||
// )
|
||||
type TokenType string
|
||||
Reference in New Issue
Block a user