fix: issues
This commit is contained in:
277
backend/database/fields/user_oauths.gen.go
Normal file
277
backend/database/fields/user_oauths.gen.go
Normal file
@@ -0,0 +1,277 @@
|
||||
// Code generated by go-enum DO NOT EDIT.
|
||||
// Version: -
|
||||
// Revision: -
|
||||
// Build Date: -
|
||||
// Built By: -
|
||||
|
||||
package fields
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
// AuthChannelWeChat is a AuthChannel of type WeChat.
|
||||
AuthChannelWeChat AuthChannel = iota + 1
|
||||
// AuthChannelWeiBo is a AuthChannel of type WeiBo.
|
||||
AuthChannelWeiBo
|
||||
// AuthChannelQQ is a AuthChannel of type QQ.
|
||||
AuthChannelQQ
|
||||
// AuthChannelGithub is a AuthChannel of type Github.
|
||||
AuthChannelGithub
|
||||
// AuthChannelGoogle is a AuthChannel of type Google.
|
||||
AuthChannelGoogle
|
||||
// AuthChannelFacebook is a AuthChannel of type Facebook.
|
||||
AuthChannelFacebook
|
||||
// AuthChannelTwitter is a AuthChannel of type Twitter.
|
||||
AuthChannelTwitter
|
||||
// AuthChannelLinkedIn is a AuthChannel of type LinkedIn.
|
||||
AuthChannelLinkedIn
|
||||
// AuthChannelApple is a AuthChannel of type Apple.
|
||||
AuthChannelApple
|
||||
)
|
||||
|
||||
var ErrInvalidAuthChannel = fmt.Errorf("not a valid AuthChannel, try [%s]", strings.Join(_AuthChannelNames, ", "))
|
||||
|
||||
const _AuthChannelName = "WeChatWeiBoQQGithubGoogleFacebookTwitterLinkedInApple"
|
||||
|
||||
var _AuthChannelNames = []string{
|
||||
_AuthChannelName[0:6],
|
||||
_AuthChannelName[6:11],
|
||||
_AuthChannelName[11:13],
|
||||
_AuthChannelName[13:19],
|
||||
_AuthChannelName[19:25],
|
||||
_AuthChannelName[25:33],
|
||||
_AuthChannelName[33:40],
|
||||
_AuthChannelName[40:48],
|
||||
_AuthChannelName[48:53],
|
||||
}
|
||||
|
||||
// AuthChannelNames returns a list of possible string values of AuthChannel.
|
||||
func AuthChannelNames() []string {
|
||||
tmp := make([]string, len(_AuthChannelNames))
|
||||
copy(tmp, _AuthChannelNames)
|
||||
return tmp
|
||||
}
|
||||
|
||||
// AuthChannelValues returns a list of the values for AuthChannel
|
||||
func AuthChannelValues() []AuthChannel {
|
||||
return []AuthChannel{
|
||||
AuthChannelWeChat,
|
||||
AuthChannelWeiBo,
|
||||
AuthChannelQQ,
|
||||
AuthChannelGithub,
|
||||
AuthChannelGoogle,
|
||||
AuthChannelFacebook,
|
||||
AuthChannelTwitter,
|
||||
AuthChannelLinkedIn,
|
||||
AuthChannelApple,
|
||||
}
|
||||
}
|
||||
|
||||
var _AuthChannelMap = map[AuthChannel]string{
|
||||
AuthChannelWeChat: _AuthChannelName[0:6],
|
||||
AuthChannelWeiBo: _AuthChannelName[6:11],
|
||||
AuthChannelQQ: _AuthChannelName[11:13],
|
||||
AuthChannelGithub: _AuthChannelName[13:19],
|
||||
AuthChannelGoogle: _AuthChannelName[19:25],
|
||||
AuthChannelFacebook: _AuthChannelName[25:33],
|
||||
AuthChannelTwitter: _AuthChannelName[33:40],
|
||||
AuthChannelLinkedIn: _AuthChannelName[40:48],
|
||||
AuthChannelApple: _AuthChannelName[48:53],
|
||||
}
|
||||
|
||||
// String implements the Stringer interface.
|
||||
func (x AuthChannel) String() string {
|
||||
if str, ok := _AuthChannelMap[x]; ok {
|
||||
return str
|
||||
}
|
||||
return fmt.Sprintf("AuthChannel(%d)", x)
|
||||
}
|
||||
|
||||
// IsValid provides a quick way to determine if the typed value is
|
||||
// part of the allowed enumerated values
|
||||
func (x AuthChannel) IsValid() bool {
|
||||
_, ok := _AuthChannelMap[x]
|
||||
return ok
|
||||
}
|
||||
|
||||
var _AuthChannelValue = map[string]AuthChannel{
|
||||
_AuthChannelName[0:6]: AuthChannelWeChat,
|
||||
_AuthChannelName[6:11]: AuthChannelWeiBo,
|
||||
_AuthChannelName[11:13]: AuthChannelQQ,
|
||||
_AuthChannelName[13:19]: AuthChannelGithub,
|
||||
_AuthChannelName[19:25]: AuthChannelGoogle,
|
||||
_AuthChannelName[25:33]: AuthChannelFacebook,
|
||||
_AuthChannelName[33:40]: AuthChannelTwitter,
|
||||
_AuthChannelName[40:48]: AuthChannelLinkedIn,
|
||||
_AuthChannelName[48:53]: AuthChannelApple,
|
||||
}
|
||||
|
||||
// ParseAuthChannel attempts to convert a string to a AuthChannel.
|
||||
func ParseAuthChannel(name string) (AuthChannel, error) {
|
||||
if x, ok := _AuthChannelValue[name]; ok {
|
||||
return x, nil
|
||||
}
|
||||
return AuthChannel(0), fmt.Errorf("%s is %w", name, ErrInvalidAuthChannel)
|
||||
}
|
||||
|
||||
var errAuthChannelNilPtr = errors.New("value pointer is nil") // one per type for package clashes
|
||||
|
||||
// Scan implements the Scanner interface.
|
||||
func (x *AuthChannel) Scan(value interface{}) (err error) {
|
||||
if value == nil {
|
||||
*x = AuthChannel(0)
|
||||
return
|
||||
}
|
||||
|
||||
// A wider range of scannable types.
|
||||
// driver.Value values at the top of the list for expediency
|
||||
switch v := value.(type) {
|
||||
case int64:
|
||||
*x = AuthChannel(v)
|
||||
case string:
|
||||
*x, err = ParseAuthChannel(v)
|
||||
if err != nil {
|
||||
// try parsing the integer value as a string
|
||||
if val, verr := strconv.Atoi(v); verr == nil {
|
||||
*x, err = AuthChannel(val), nil
|
||||
}
|
||||
}
|
||||
case []byte:
|
||||
*x, err = ParseAuthChannel(string(v))
|
||||
if err != nil {
|
||||
// try parsing the integer value as a string
|
||||
if val, verr := strconv.Atoi(string(v)); verr == nil {
|
||||
*x, err = AuthChannel(val), nil
|
||||
}
|
||||
}
|
||||
case AuthChannel:
|
||||
*x = v
|
||||
case int:
|
||||
*x = AuthChannel(v)
|
||||
case *AuthChannel:
|
||||
if v == nil {
|
||||
return errAuthChannelNilPtr
|
||||
}
|
||||
*x = *v
|
||||
case uint:
|
||||
*x = AuthChannel(v)
|
||||
case uint64:
|
||||
*x = AuthChannel(v)
|
||||
case *int:
|
||||
if v == nil {
|
||||
return errAuthChannelNilPtr
|
||||
}
|
||||
*x = AuthChannel(*v)
|
||||
case *int64:
|
||||
if v == nil {
|
||||
return errAuthChannelNilPtr
|
||||
}
|
||||
*x = AuthChannel(*v)
|
||||
case float64: // json marshals everything as a float64 if it's a number
|
||||
*x = AuthChannel(v)
|
||||
case *float64: // json marshals everything as a float64 if it's a number
|
||||
if v == nil {
|
||||
return errAuthChannelNilPtr
|
||||
}
|
||||
*x = AuthChannel(*v)
|
||||
case *uint:
|
||||
if v == nil {
|
||||
return errAuthChannelNilPtr
|
||||
}
|
||||
*x = AuthChannel(*v)
|
||||
case *uint64:
|
||||
if v == nil {
|
||||
return errAuthChannelNilPtr
|
||||
}
|
||||
*x = AuthChannel(*v)
|
||||
case *string:
|
||||
if v == nil {
|
||||
return errAuthChannelNilPtr
|
||||
}
|
||||
*x, err = ParseAuthChannel(*v)
|
||||
if err != nil {
|
||||
// try parsing the integer value as a string
|
||||
if val, verr := strconv.Atoi(*v); verr == nil {
|
||||
*x, err = AuthChannel(val), nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (x AuthChannel) Value() (driver.Value, error) {
|
||||
return int64(x), nil
|
||||
}
|
||||
|
||||
// Set implements the Golang flag.Value interface func.
|
||||
func (x *AuthChannel) Set(val string) error {
|
||||
v, err := ParseAuthChannel(val)
|
||||
*x = v
|
||||
return err
|
||||
}
|
||||
|
||||
// Get implements the Golang flag.Getter interface func.
|
||||
func (x *AuthChannel) Get() interface{} {
|
||||
return *x
|
||||
}
|
||||
|
||||
// Type implements the github.com/spf13/pFlag Value interface.
|
||||
func (x *AuthChannel) Type() string {
|
||||
return "AuthChannel"
|
||||
}
|
||||
|
||||
type NullAuthChannel struct {
|
||||
AuthChannel AuthChannel
|
||||
Valid bool
|
||||
}
|
||||
|
||||
func NewNullAuthChannel(val interface{}) (x NullAuthChannel) {
|
||||
x.Scan(val) // yes, we ignore this error, it will just be an invalid value.
|
||||
return
|
||||
}
|
||||
|
||||
// Scan implements the Scanner interface.
|
||||
func (x *NullAuthChannel) Scan(value interface{}) (err error) {
|
||||
if value == nil {
|
||||
x.AuthChannel, x.Valid = AuthChannel(0), false
|
||||
return
|
||||
}
|
||||
|
||||
err = x.AuthChannel.Scan(value)
|
||||
x.Valid = (err == nil)
|
||||
return
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (x NullAuthChannel) Value() (driver.Value, error) {
|
||||
if !x.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
// driver.Value accepts int64 for int values.
|
||||
return int64(x.AuthChannel), nil
|
||||
}
|
||||
|
||||
type NullAuthChannelStr struct {
|
||||
NullAuthChannel
|
||||
}
|
||||
|
||||
func NewNullAuthChannelStr(val interface{}) (x NullAuthChannelStr) {
|
||||
x.Scan(val) // yes, we ignore this error, it will just be an invalid value.
|
||||
return
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (x NullAuthChannelStr) Value() (driver.Value, error) {
|
||||
if !x.Valid {
|
||||
return nil, nil
|
||||
}
|
||||
return x.AuthChannel.String(), nil
|
||||
}
|
||||
5
backend/database/fields/user_oauths.go
Normal file
5
backend/database/fields/user_oauths.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package fields
|
||||
|
||||
// swagger:enum AuthChannel
|
||||
// ENUM( WeChat = 1 , WeiBo, QQ, Github, Google, Facebook, Twitter, LinkedIn, Apple)
|
||||
type AuthChannel int16
|
||||
241
backend/database/fields/users.gen.go
Normal file
241
backend/database/fields/users.gen.go
Normal file
@@ -0,0 +1,241 @@
|
||||
// Code generated by go-enum DO NOT EDIT.
|
||||
// Version: -
|
||||
// Revision: -
|
||||
// Build Date: -
|
||||
// Built By: -
|
||||
|
||||
package fields
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
// UserStatusPending is a UserStatus of type Pending.
|
||||
UserStatusPending UserStatus = iota
|
||||
// UserStatusVerified is a UserStatus of type Verified.
|
||||
UserStatusVerified
|
||||
// UserStatusBlocked is a UserStatus of type Blocked.
|
||||
UserStatusBlocked
|
||||
)
|
||||
|
||||
var ErrInvalidUserStatus = fmt.Errorf("not a valid UserStatus, try [%s]", strings.Join(_UserStatusNames, ", "))
|
||||
|
||||
const _UserStatusName = "PendingVerifiedBlocked"
|
||||
|
||||
var _UserStatusNames = []string{
|
||||
_UserStatusName[0:7],
|
||||
_UserStatusName[7:15],
|
||||
_UserStatusName[15:22],
|
||||
}
|
||||
|
||||
// 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{
|
||||
UserStatusPending,
|
||||
UserStatusVerified,
|
||||
UserStatusBlocked,
|
||||
}
|
||||
}
|
||||
|
||||
var _UserStatusMap = map[UserStatus]string{
|
||||
UserStatusPending: _UserStatusName[0:7],
|
||||
UserStatusVerified: _UserStatusName[7:15],
|
||||
UserStatusBlocked: _UserStatusName[15:22],
|
||||
}
|
||||
|
||||
// String implements the Stringer interface.
|
||||
func (x UserStatus) String() string {
|
||||
if str, ok := _UserStatusMap[x]; ok {
|
||||
return str
|
||||
}
|
||||
return fmt.Sprintf("UserStatus(%d)", x)
|
||||
}
|
||||
|
||||
// IsValid provides a quick way to determine if the typed value is
|
||||
// part of the allowed enumerated values
|
||||
func (x UserStatus) IsValid() bool {
|
||||
_, ok := _UserStatusMap[x]
|
||||
return ok
|
||||
}
|
||||
|
||||
var _UserStatusValue = map[string]UserStatus{
|
||||
_UserStatusName[0:7]: UserStatusPending,
|
||||
_UserStatusName[7:15]: UserStatusVerified,
|
||||
_UserStatusName[15:22]: UserStatusBlocked,
|
||||
}
|
||||
|
||||
// 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(0), 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(0)
|
||||
return
|
||||
}
|
||||
|
||||
// A wider range of scannable types.
|
||||
// driver.Value values at the top of the list for expediency
|
||||
switch v := value.(type) {
|
||||
case int64:
|
||||
*x = UserStatus(v)
|
||||
case string:
|
||||
*x, err = ParseUserStatus(v)
|
||||
if err != nil {
|
||||
// try parsing the integer value as a string
|
||||
if val, verr := strconv.Atoi(v); verr == nil {
|
||||
*x, err = UserStatus(val), nil
|
||||
}
|
||||
}
|
||||
case []byte:
|
||||
*x, err = ParseUserStatus(string(v))
|
||||
if err != nil {
|
||||
// try parsing the integer value as a string
|
||||
if val, verr := strconv.Atoi(string(v)); verr == nil {
|
||||
*x, err = UserStatus(val), nil
|
||||
}
|
||||
}
|
||||
case UserStatus:
|
||||
*x = v
|
||||
case int:
|
||||
*x = UserStatus(v)
|
||||
case *UserStatus:
|
||||
if v == nil {
|
||||
return errUserStatusNilPtr
|
||||
}
|
||||
*x = *v
|
||||
case uint:
|
||||
*x = UserStatus(v)
|
||||
case uint64:
|
||||
*x = UserStatus(v)
|
||||
case *int:
|
||||
if v == nil {
|
||||
return errUserStatusNilPtr
|
||||
}
|
||||
*x = UserStatus(*v)
|
||||
case *int64:
|
||||
if v == nil {
|
||||
return errUserStatusNilPtr
|
||||
}
|
||||
*x = UserStatus(*v)
|
||||
case float64: // json marshals everything as a float64 if it's a number
|
||||
*x = UserStatus(v)
|
||||
case *float64: // json marshals everything as a float64 if it's a number
|
||||
if v == nil {
|
||||
return errUserStatusNilPtr
|
||||
}
|
||||
*x = UserStatus(*v)
|
||||
case *uint:
|
||||
if v == nil {
|
||||
return errUserStatusNilPtr
|
||||
}
|
||||
*x = UserStatus(*v)
|
||||
case *uint64:
|
||||
if v == nil {
|
||||
return errUserStatusNilPtr
|
||||
}
|
||||
*x = UserStatus(*v)
|
||||
case *string:
|
||||
if v == nil {
|
||||
return errUserStatusNilPtr
|
||||
}
|
||||
*x, err = ParseUserStatus(*v)
|
||||
if err != nil {
|
||||
// try parsing the integer value as a string
|
||||
if val, verr := strconv.Atoi(*v); verr == nil {
|
||||
*x, err = UserStatus(val), nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Value implements the driver Valuer interface.
|
||||
func (x UserStatus) Value() (driver.Value, error) {
|
||||
return int64(x), 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) {
|
||||
x.Scan(val) // yes, we ignore this error, it will just be an invalid value.
|
||||
return
|
||||
}
|
||||
|
||||
// Scan implements the Scanner interface.
|
||||
func (x *NullUserStatus) Scan(value interface{}) (err error) {
|
||||
if value == nil {
|
||||
x.UserStatus, x.Valid = UserStatus(0), 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 int64(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
|
||||
}
|
||||
5
backend/database/fields/users.go
Normal file
5
backend/database/fields/users.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package fields
|
||||
|
||||
// swagger:enum UserStatus
|
||||
// ENUM( Pending, Verified, Blocked)
|
||||
type UserStatus int16
|
||||
@@ -33,7 +33,6 @@ CREATE TABLE
|
||||
user_id INT8 NOT NULL,
|
||||
union_id VARCHAR(128),
|
||||
open_id VARCHAR(128) NOT NULL UNIQUE,
|
||||
access_key VARCHAR(256) NOT NULL default '',
|
||||
access_token VARCHAR(256) NOT NULL default '',
|
||||
refresh_token VARCHAR(256) NOT NULL default '',
|
||||
expire_at timestamp NOT NULL,
|
||||
|
||||
@@ -8,21 +8,22 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"backend/database/fields"
|
||||
"time"
|
||||
)
|
||||
|
||||
type UserOauths struct {
|
||||
ID int64 `sql:"primary_key" json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt *time.Time `json:"deleted_at"`
|
||||
Channel int16 `json:"channel"`
|
||||
UserID int64 `json:"user_id"`
|
||||
UnionID *string `json:"union_id"`
|
||||
OpenID string `json:"open_id"`
|
||||
AccessKey string `json:"access_key"`
|
||||
AccessToken string `json:"access_token"`
|
||||
RefreshToken string `json:"refresh_token"`
|
||||
ExpireAt time.Time `json:"expire_at"`
|
||||
Meta *string `json:"meta"`
|
||||
ID int64 `sql:"primary_key" json:"id"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt *time.Time `json:"deleted_at"`
|
||||
Channel fields.AuthChannel `json:"channel"`
|
||||
UserID int64 `json:"user_id"`
|
||||
UnionID *string `json:"union_id"`
|
||||
OpenID string `json:"open_id"`
|
||||
AccessKey string `json:"access_key"`
|
||||
AccessToken string `json:"access_token"`
|
||||
RefreshToken string `json:"refresh_token"`
|
||||
ExpireAt time.Time `json:"expire_at"`
|
||||
Meta *string `json:"meta"`
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@ ignores:
|
||||
- river_job
|
||||
- river_leader
|
||||
- river_queue
|
||||
# types:
|
||||
# users: # table name
|
||||
# meta: UserMeta
|
||||
# meta: Json[UserMeta]
|
||||
types:
|
||||
users: # table name
|
||||
status: UserStatus
|
||||
|
||||
user_oauths:
|
||||
channel: AuthChannel
|
||||
|
||||
Reference in New Issue
Block a user