Files
sub2api/backend/ent/identityadoptiondecision.go
2026-04-20 17:39:57 +08:00

224 lines
8.9 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/Wei-Shaw/sub2api/ent/authidentity"
"github.com/Wei-Shaw/sub2api/ent/identityadoptiondecision"
"github.com/Wei-Shaw/sub2api/ent/pendingauthsession"
)
// IdentityAdoptionDecision is the model entity for the IdentityAdoptionDecision schema.
type IdentityAdoptionDecision struct {
config `json:"-"`
// ID of the ent.
ID int64 `json:"id,omitempty"`
// CreatedAt holds the value of the "created_at" field.
CreatedAt time.Time `json:"created_at,omitempty"`
// UpdatedAt holds the value of the "updated_at" field.
UpdatedAt time.Time `json:"updated_at,omitempty"`
// PendingAuthSessionID holds the value of the "pending_auth_session_id" field.
PendingAuthSessionID int64 `json:"pending_auth_session_id,omitempty"`
// IdentityID holds the value of the "identity_id" field.
IdentityID *int64 `json:"identity_id,omitempty"`
// AdoptDisplayName holds the value of the "adopt_display_name" field.
AdoptDisplayName bool `json:"adopt_display_name,omitempty"`
// AdoptAvatar holds the value of the "adopt_avatar" field.
AdoptAvatar bool `json:"adopt_avatar,omitempty"`
// DecidedAt holds the value of the "decided_at" field.
DecidedAt time.Time `json:"decided_at,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the IdentityAdoptionDecisionQuery when eager-loading is set.
Edges IdentityAdoptionDecisionEdges `json:"edges"`
selectValues sql.SelectValues
}
// IdentityAdoptionDecisionEdges holds the relations/edges for other nodes in the graph.
type IdentityAdoptionDecisionEdges struct {
// PendingAuthSession holds the value of the pending_auth_session edge.
PendingAuthSession *PendingAuthSession `json:"pending_auth_session,omitempty"`
// Identity holds the value of the identity edge.
Identity *AuthIdentity `json:"identity,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [2]bool
}
// PendingAuthSessionOrErr returns the PendingAuthSession value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e IdentityAdoptionDecisionEdges) PendingAuthSessionOrErr() (*PendingAuthSession, error) {
if e.PendingAuthSession != nil {
return e.PendingAuthSession, nil
} else if e.loadedTypes[0] {
return nil, &NotFoundError{label: pendingauthsession.Label}
}
return nil, &NotLoadedError{edge: "pending_auth_session"}
}
// IdentityOrErr returns the Identity value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e IdentityAdoptionDecisionEdges) IdentityOrErr() (*AuthIdentity, error) {
if e.Identity != nil {
return e.Identity, nil
} else if e.loadedTypes[1] {
return nil, &NotFoundError{label: authidentity.Label}
}
return nil, &NotLoadedError{edge: "identity"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*IdentityAdoptionDecision) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case identityadoptiondecision.FieldAdoptDisplayName, identityadoptiondecision.FieldAdoptAvatar:
values[i] = new(sql.NullBool)
case identityadoptiondecision.FieldID, identityadoptiondecision.FieldPendingAuthSessionID, identityadoptiondecision.FieldIdentityID:
values[i] = new(sql.NullInt64)
case identityadoptiondecision.FieldCreatedAt, identityadoptiondecision.FieldUpdatedAt, identityadoptiondecision.FieldDecidedAt:
values[i] = new(sql.NullTime)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the IdentityAdoptionDecision fields.
func (_m *IdentityAdoptionDecision) 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 identityadoptiondecision.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
_m.ID = int64(value.Int64)
case identityadoptiondecision.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
_m.CreatedAt = value.Time
}
case identityadoptiondecision.FieldUpdatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
} else if value.Valid {
_m.UpdatedAt = value.Time
}
case identityadoptiondecision.FieldPendingAuthSessionID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field pending_auth_session_id", values[i])
} else if value.Valid {
_m.PendingAuthSessionID = value.Int64
}
case identityadoptiondecision.FieldIdentityID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field identity_id", values[i])
} else if value.Valid {
_m.IdentityID = new(int64)
*_m.IdentityID = value.Int64
}
case identityadoptiondecision.FieldAdoptDisplayName:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field adopt_display_name", values[i])
} else if value.Valid {
_m.AdoptDisplayName = value.Bool
}
case identityadoptiondecision.FieldAdoptAvatar:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field adopt_avatar", values[i])
} else if value.Valid {
_m.AdoptAvatar = value.Bool
}
case identityadoptiondecision.FieldDecidedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field decided_at", values[i])
} else if value.Valid {
_m.DecidedAt = value.Time
}
default:
_m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the IdentityAdoptionDecision.
// This includes values selected through modifiers, order, etc.
func (_m *IdentityAdoptionDecision) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// QueryPendingAuthSession queries the "pending_auth_session" edge of the IdentityAdoptionDecision entity.
func (_m *IdentityAdoptionDecision) QueryPendingAuthSession() *PendingAuthSessionQuery {
return NewIdentityAdoptionDecisionClient(_m.config).QueryPendingAuthSession(_m)
}
// QueryIdentity queries the "identity" edge of the IdentityAdoptionDecision entity.
func (_m *IdentityAdoptionDecision) QueryIdentity() *AuthIdentityQuery {
return NewIdentityAdoptionDecisionClient(_m.config).QueryIdentity(_m)
}
// Update returns a builder for updating this IdentityAdoptionDecision.
// Note that you need to call IdentityAdoptionDecision.Unwrap() before calling this method if this IdentityAdoptionDecision
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *IdentityAdoptionDecision) Update() *IdentityAdoptionDecisionUpdateOne {
return NewIdentityAdoptionDecisionClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the IdentityAdoptionDecision 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 (_m *IdentityAdoptionDecision) Unwrap() *IdentityAdoptionDecision {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: IdentityAdoptionDecision is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *IdentityAdoptionDecision) String() string {
var builder strings.Builder
builder.WriteString("IdentityAdoptionDecision(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("created_at=")
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("updated_at=")
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("pending_auth_session_id=")
builder.WriteString(fmt.Sprintf("%v", _m.PendingAuthSessionID))
builder.WriteString(", ")
if v := _m.IdentityID; v != nil {
builder.WriteString("identity_id=")
builder.WriteString(fmt.Sprintf("%v", *v))
}
builder.WriteString(", ")
builder.WriteString("adopt_display_name=")
builder.WriteString(fmt.Sprintf("%v", _m.AdoptDisplayName))
builder.WriteString(", ")
builder.WriteString("adopt_avatar=")
builder.WriteString(fmt.Sprintf("%v", _m.AdoptAvatar))
builder.WriteString(", ")
builder.WriteString("decided_at=")
builder.WriteString(_m.DecidedAt.Format(time.ANSIC))
builder.WriteByte(')')
return builder.String()
}
// IdentityAdoptionDecisions is a parsable slice of IdentityAdoptionDecision.
type IdentityAdoptionDecisions []*IdentityAdoptionDecision