Files
schisandra-album-cloud-micr…/common/ent/scaauthusersocial.go
landaiqing 97ca3fc7b0 🎉 init
2024-11-12 17:00:16 +08:00

216 lines
7.7 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"schisandra-album-cloud-microservices/common/ent/scaauthuser"
"schisandra-album-cloud-microservices/common/ent/scaauthusersocial"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// ScaAuthUserSocial is the model entity for the ScaAuthUserSocial schema.
type ScaAuthUserSocial struct {
config `json:"-"`
// ID of the ent.
// 主键ID
ID int64 `json:"id,omitempty"`
// 用户ID
UserID string `json:"user_id,omitempty"`
// 第三方用户的 open id
OpenID string `json:"open_id,omitempty"`
// 第三方用户来源
Source string `json:"source,omitempty"`
// 状态 0正常 1 封禁
Status int `json:"status,omitempty"`
// 创建时间
CreatedAt time.Time `json:"created_at,omitempty"`
// 更新时间
UpdateAt *time.Time `json:"update_at,omitempty"`
// 是否删除
Deleted int `json:"deleted,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the ScaAuthUserSocialQuery when eager-loading is set.
Edges ScaAuthUserSocialEdges `json:"edges"`
sca_auth_user_sca_auth_user_social *int64
selectValues sql.SelectValues
}
// ScaAuthUserSocialEdges holds the relations/edges for other nodes in the graph.
type ScaAuthUserSocialEdges struct {
// ScaAuthUser holds the value of the sca_auth_user edge.
ScaAuthUser *ScaAuthUser `json:"sca_auth_user,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [1]bool
}
// ScaAuthUserOrErr returns the ScaAuthUser value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e ScaAuthUserSocialEdges) ScaAuthUserOrErr() (*ScaAuthUser, error) {
if e.ScaAuthUser != nil {
return e.ScaAuthUser, nil
} else if e.loadedTypes[0] {
return nil, &NotFoundError{label: scaauthuser.Label}
}
return nil, &NotLoadedError{edge: "sca_auth_user"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*ScaAuthUserSocial) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case scaauthusersocial.FieldID, scaauthusersocial.FieldStatus, scaauthusersocial.FieldDeleted:
values[i] = new(sql.NullInt64)
case scaauthusersocial.FieldUserID, scaauthusersocial.FieldOpenID, scaauthusersocial.FieldSource:
values[i] = new(sql.NullString)
case scaauthusersocial.FieldCreatedAt, scaauthusersocial.FieldUpdateAt:
values[i] = new(sql.NullTime)
case scaauthusersocial.ForeignKeys[0]: // sca_auth_user_sca_auth_user_social
values[i] = new(sql.NullInt64)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the ScaAuthUserSocial fields.
func (saus *ScaAuthUserSocial) 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 scaauthusersocial.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
saus.ID = int64(value.Int64)
case scaauthusersocial.FieldUserID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field user_id", values[i])
} else if value.Valid {
saus.UserID = value.String
}
case scaauthusersocial.FieldOpenID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field open_id", values[i])
} else if value.Valid {
saus.OpenID = value.String
}
case scaauthusersocial.FieldSource:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field source", values[i])
} else if value.Valid {
saus.Source = value.String
}
case scaauthusersocial.FieldStatus:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field status", values[i])
} else if value.Valid {
saus.Status = int(value.Int64)
}
case scaauthusersocial.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 {
saus.CreatedAt = value.Time
}
case scaauthusersocial.FieldUpdateAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field update_at", values[i])
} else if value.Valid {
saus.UpdateAt = new(time.Time)
*saus.UpdateAt = value.Time
}
case scaauthusersocial.FieldDeleted:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field deleted", values[i])
} else if value.Valid {
saus.Deleted = int(value.Int64)
}
case scaauthusersocial.ForeignKeys[0]:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for edge-field sca_auth_user_sca_auth_user_social", value)
} else if value.Valid {
saus.sca_auth_user_sca_auth_user_social = new(int64)
*saus.sca_auth_user_sca_auth_user_social = int64(value.Int64)
}
default:
saus.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the ScaAuthUserSocial.
// This includes values selected through modifiers, order, etc.
func (saus *ScaAuthUserSocial) Value(name string) (ent.Value, error) {
return saus.selectValues.Get(name)
}
// QueryScaAuthUser queries the "sca_auth_user" edge of the ScaAuthUserSocial entity.
func (saus *ScaAuthUserSocial) QueryScaAuthUser() *ScaAuthUserQuery {
return NewScaAuthUserSocialClient(saus.config).QueryScaAuthUser(saus)
}
// Update returns a builder for updating this ScaAuthUserSocial.
// Note that you need to call ScaAuthUserSocial.Unwrap() before calling this method if this ScaAuthUserSocial
// was returned from a transaction, and the transaction was committed or rolled back.
func (saus *ScaAuthUserSocial) Update() *ScaAuthUserSocialUpdateOne {
return NewScaAuthUserSocialClient(saus.config).UpdateOne(saus)
}
// Unwrap unwraps the ScaAuthUserSocial 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 (saus *ScaAuthUserSocial) Unwrap() *ScaAuthUserSocial {
_tx, ok := saus.config.driver.(*txDriver)
if !ok {
panic("ent: ScaAuthUserSocial is not a transactional entity")
}
saus.config.driver = _tx.drv
return saus
}
// String implements the fmt.Stringer.
func (saus *ScaAuthUserSocial) String() string {
var builder strings.Builder
builder.WriteString("ScaAuthUserSocial(")
builder.WriteString(fmt.Sprintf("id=%v, ", saus.ID))
builder.WriteString("user_id=")
builder.WriteString(saus.UserID)
builder.WriteString(", ")
builder.WriteString("open_id=")
builder.WriteString(saus.OpenID)
builder.WriteString(", ")
builder.WriteString("source=")
builder.WriteString(saus.Source)
builder.WriteString(", ")
builder.WriteString("status=")
builder.WriteString(fmt.Sprintf("%v", saus.Status))
builder.WriteString(", ")
builder.WriteString("created_at=")
builder.WriteString(saus.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
if v := saus.UpdateAt; v != nil {
builder.WriteString("update_at=")
builder.WriteString(v.Format(time.ANSIC))
}
builder.WriteString(", ")
builder.WriteString("deleted=")
builder.WriteString(fmt.Sprintf("%v", saus.Deleted))
builder.WriteByte(')')
return builder.String()
}
// ScaAuthUserSocials is a parsable slice of ScaAuthUserSocial.
type ScaAuthUserSocials []*ScaAuthUserSocial