115 lines
3.4 KiB
Go
115 lines
3.4 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
"github.com/xmdhs/authlib-skin/db/ent/usertoken"
|
|
)
|
|
|
|
// UserToken is the model entity for the UserToken schema.
|
|
type UserToken struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID int `json:"id,omitempty"`
|
|
// TokenID holds the value of the "token_id" field.
|
|
TokenID uint64 `json:"token_id,omitempty"`
|
|
// UUID holds the value of the "uuid" field.
|
|
UUID string `json:"uuid,omitempty"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*UserToken) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case usertoken.FieldID, usertoken.FieldTokenID:
|
|
values[i] = new(sql.NullInt64)
|
|
case usertoken.FieldUUID:
|
|
values[i] = new(sql.NullString)
|
|
default:
|
|
values[i] = new(sql.UnknownType)
|
|
}
|
|
}
|
|
return values, nil
|
|
}
|
|
|
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
|
// to the UserToken fields.
|
|
func (ut *UserToken) assignValues(columns []string, values []any) error {
|
|
if m, n := len(values), len(columns); m < n {
|
|
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
|
}
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case usertoken.FieldID:
|
|
value, ok := values[i].(*sql.NullInt64)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", value)
|
|
}
|
|
ut.ID = int(value.Int64)
|
|
case usertoken.FieldTokenID:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field token_id", values[i])
|
|
} else if value.Valid {
|
|
ut.TokenID = uint64(value.Int64)
|
|
}
|
|
case usertoken.FieldUUID:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field uuid", values[i])
|
|
} else if value.Valid {
|
|
ut.UUID = value.String
|
|
}
|
|
default:
|
|
ut.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the UserToken.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (ut *UserToken) Value(name string) (ent.Value, error) {
|
|
return ut.selectValues.Get(name)
|
|
}
|
|
|
|
// Update returns a builder for updating this UserToken.
|
|
// Note that you need to call UserToken.Unwrap() before calling this method if this UserToken
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (ut *UserToken) Update() *UserTokenUpdateOne {
|
|
return NewUserTokenClient(ut.config).UpdateOne(ut)
|
|
}
|
|
|
|
// Unwrap unwraps the UserToken entity that was returned from a transaction after it was closed,
|
|
// so that all future queries will be executed through the driver which created the transaction.
|
|
func (ut *UserToken) Unwrap() *UserToken {
|
|
_tx, ok := ut.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: UserToken is not a transactional entity")
|
|
}
|
|
ut.config.driver = _tx.drv
|
|
return ut
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (ut *UserToken) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("UserToken(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", ut.ID))
|
|
builder.WriteString("token_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", ut.TokenID))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("uuid=")
|
|
builder.WriteString(ut.UUID)
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// UserTokens is a parsable slice of UserToken.
|
|
type UserTokens []*UserToken
|