// Code generated by ent, DO NOT EDIT. package ent import ( "fmt" "strings" "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" "git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/user" "git.noahlan.cn/n-admin/n-admin-server/rpc/core/ent/usersocial" ) // 用户社交信息表 type UserSocial struct { config `json:"-"` // ID of the ent. // Primary Key | 主键 ID int64 `json:"id,omitempty"` // Create Time | 创建时间 CreatedAt time.Time `json:"created_at,omitempty"` // Update Time | 更新时间 UpdatedAt time.Time `json:"updated_at,omitempty"` // 系统用户ID UserID int64 `json:"user_id,omitempty"` // OAuth Provider | 服务提供商 Provider string `json:"provider,omitempty"` // Access Token | 用户在提供商最近一次登录的访问凭证 AccessToken string `json:"access_token,omitempty"` // Refresh Token | 用户在提供商最近一次登录的刷新凭证 RefreshToken string `json:"refresh_token,omitempty"` // User's ID | 提供商用户ID,不一定存在 UID string `json:"uid,omitempty"` // OpenID | 用户在提供商的OpenID OpenID string `json:"open_id,omitempty"` // UnionID | 用户在提供商的UnionID UnionID string `json:"union_id,omitempty"` // Key | 用户在提供商的用于解密的key Key string `json:"key,omitempty"` // Expires in | 访问凭证过期时长,单位:秒 ExpiresIn uint64 `json:"expires_in,omitempty"` // User Profile | 提供商用户信息,不一定存在 UserProfile string `json:"user_profile,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the UserSocialQuery when eager-loading is set. Edges UserSocialEdges `json:"edges"` selectValues sql.SelectValues } // UserSocialEdges holds the relations/edges for other nodes in the graph. type UserSocialEdges struct { // User holds the value of the user edge. User *User `json:"user,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. loadedTypes [1]bool } // UserOrErr returns the User value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e UserSocialEdges) UserOrErr() (*User, error) { if e.loadedTypes[0] { if e.User == nil { // Edge was loaded but was not found. return nil, &NotFoundError{label: user.Label} } return e.User, nil } return nil, &NotLoadedError{edge: "user"} } // scanValues returns the types for scanning values from sql.Rows. func (*UserSocial) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case usersocial.FieldID, usersocial.FieldUserID, usersocial.FieldExpiresIn: values[i] = new(sql.NullInt64) case usersocial.FieldProvider, usersocial.FieldAccessToken, usersocial.FieldRefreshToken, usersocial.FieldUID, usersocial.FieldOpenID, usersocial.FieldUnionID, usersocial.FieldKey, usersocial.FieldUserProfile: values[i] = new(sql.NullString) case usersocial.FieldCreatedAt, usersocial.FieldUpdatedAt: 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 UserSocial fields. func (us *UserSocial) 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 usersocial.FieldID: value, ok := values[i].(*sql.NullInt64) if !ok { return fmt.Errorf("unexpected type %T for field id", value) } us.ID = int64(value.Int64) case usersocial.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 { us.CreatedAt = value.Time } case usersocial.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 { us.UpdatedAt = value.Time } case usersocial.FieldUserID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field user_id", values[i]) } else if value.Valid { us.UserID = value.Int64 } case usersocial.FieldProvider: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field provider", values[i]) } else if value.Valid { us.Provider = value.String } case usersocial.FieldAccessToken: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field access_token", values[i]) } else if value.Valid { us.AccessToken = value.String } case usersocial.FieldRefreshToken: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field refresh_token", values[i]) } else if value.Valid { us.RefreshToken = value.String } case usersocial.FieldUID: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field uid", values[i]) } else if value.Valid { us.UID = value.String } case usersocial.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 { us.OpenID = value.String } case usersocial.FieldUnionID: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field union_id", values[i]) } else if value.Valid { us.UnionID = value.String } case usersocial.FieldKey: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field key", values[i]) } else if value.Valid { us.Key = value.String } case usersocial.FieldExpiresIn: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field expires_in", values[i]) } else if value.Valid { us.ExpiresIn = uint64(value.Int64) } case usersocial.FieldUserProfile: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field user_profile", values[i]) } else if value.Valid { us.UserProfile = value.String } default: us.selectValues.Set(columns[i], values[i]) } } return nil } // Value returns the ent.Value that was dynamically selected and assigned to the UserSocial. // This includes values selected through modifiers, order, etc. func (us *UserSocial) Value(name string) (ent.Value, error) { return us.selectValues.Get(name) } // QueryUser queries the "user" edge of the UserSocial entity. func (us *UserSocial) QueryUser() *UserQuery { return NewUserSocialClient(us.config).QueryUser(us) } // Update returns a builder for updating this UserSocial. // Note that you need to call UserSocial.Unwrap() before calling this method if this UserSocial // was returned from a transaction, and the transaction was committed or rolled back. func (us *UserSocial) Update() *UserSocialUpdateOne { return NewUserSocialClient(us.config).UpdateOne(us) } // Unwrap unwraps the UserSocial 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 (us *UserSocial) Unwrap() *UserSocial { _tx, ok := us.config.driver.(*txDriver) if !ok { panic("ent: UserSocial is not a transactional entity") } us.config.driver = _tx.drv return us } // String implements the fmt.Stringer. func (us *UserSocial) String() string { var builder strings.Builder builder.WriteString("UserSocial(") builder.WriteString(fmt.Sprintf("id=%v, ", us.ID)) builder.WriteString("created_at=") builder.WriteString(us.CreatedAt.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("updated_at=") builder.WriteString(us.UpdatedAt.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("user_id=") builder.WriteString(fmt.Sprintf("%v", us.UserID)) builder.WriteString(", ") builder.WriteString("provider=") builder.WriteString(us.Provider) builder.WriteString(", ") builder.WriteString("access_token=") builder.WriteString(us.AccessToken) builder.WriteString(", ") builder.WriteString("refresh_token=") builder.WriteString(us.RefreshToken) builder.WriteString(", ") builder.WriteString("uid=") builder.WriteString(us.UID) builder.WriteString(", ") builder.WriteString("open_id=") builder.WriteString(us.OpenID) builder.WriteString(", ") builder.WriteString("union_id=") builder.WriteString(us.UnionID) builder.WriteString(", ") builder.WriteString("key=") builder.WriteString(us.Key) builder.WriteString(", ") builder.WriteString("expires_in=") builder.WriteString(fmt.Sprintf("%v", us.ExpiresIn)) builder.WriteString(", ") builder.WriteString("user_profile=") builder.WriteString(us.UserProfile) builder.WriteByte(')') return builder.String() } // UserSocials is a parsable slice of UserSocial. type UserSocials []*UserSocial