You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
194 lines
6.1 KiB
Go
194 lines
6.1 KiB
Go
// 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/usermeta"
|
|
)
|
|
|
|
// 系统用户元数据表
|
|
type UserMeta struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
// Primary Key | 主键
|
|
ID int64 `json:"id,omitempty"`
|
|
// 创建时间
|
|
CreatedAt time.Time `json:"created_at,omitempty"`
|
|
// 更新时间
|
|
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
|
// optimistic lock | 乐观锁
|
|
Version int64 `json:"version,omitempty"`
|
|
// User id | 用户ID
|
|
UserID int64 `json:"user_id,omitempty"`
|
|
// Key | 键
|
|
Key string `json:"key,omitempty"`
|
|
// Key | 值
|
|
Value string `json:"value,omitempty"`
|
|
// Edges holds the relations/edges for other nodes in the graph.
|
|
// The values are being populated by the UserMetaQuery when eager-loading is set.
|
|
Edges UserMetaEdges `json:"edges"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// UserMetaEdges holds the relations/edges for other nodes in the graph.
|
|
type UserMetaEdges 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 UserMetaEdges) 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 (*UserMeta) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case usermeta.FieldID, usermeta.FieldVersion, usermeta.FieldUserID:
|
|
values[i] = new(sql.NullInt64)
|
|
case usermeta.FieldKey, usermeta.FieldValue:
|
|
values[i] = new(sql.NullString)
|
|
case usermeta.FieldCreatedAt, usermeta.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 UserMeta fields.
|
|
func (um *UserMeta) 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 usermeta.FieldID:
|
|
value, ok := values[i].(*sql.NullInt64)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", value)
|
|
}
|
|
um.ID = int64(value.Int64)
|
|
case usermeta.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 {
|
|
um.CreatedAt = value.Time
|
|
}
|
|
case usermeta.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 {
|
|
um.UpdatedAt = value.Time
|
|
}
|
|
case usermeta.FieldVersion:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field version", values[i])
|
|
} else if value.Valid {
|
|
um.Version = value.Int64
|
|
}
|
|
case usermeta.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 {
|
|
um.UserID = value.Int64
|
|
}
|
|
case usermeta.FieldKey:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field key", values[i])
|
|
} else if value.Valid {
|
|
um.Key = value.String
|
|
}
|
|
case usermeta.FieldValue:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field value", values[i])
|
|
} else if value.Valid {
|
|
um.Value = value.String
|
|
}
|
|
default:
|
|
um.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetValue returns the ent.Value that was dynamically selected and assigned to the UserMeta.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (um *UserMeta) GetValue(name string) (ent.Value, error) {
|
|
return um.selectValues.Get(name)
|
|
}
|
|
|
|
// QueryUser queries the "user" edge of the UserMeta entity.
|
|
func (um *UserMeta) QueryUser() *UserQuery {
|
|
return NewUserMetaClient(um.config).QueryUser(um)
|
|
}
|
|
|
|
// Update returns a builder for updating this UserMeta.
|
|
// Note that you need to call UserMeta.Unwrap() before calling this method if this UserMeta
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (um *UserMeta) Update() *UserMetaUpdateOne {
|
|
return NewUserMetaClient(um.config).UpdateOne(um)
|
|
}
|
|
|
|
// Unwrap unwraps the UserMeta 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 (um *UserMeta) Unwrap() *UserMeta {
|
|
_tx, ok := um.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: UserMeta is not a transactional entity")
|
|
}
|
|
um.config.driver = _tx.drv
|
|
return um
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (um *UserMeta) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("UserMeta(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", um.ID))
|
|
builder.WriteString("created_at=")
|
|
builder.WriteString(um.CreatedAt.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("updated_at=")
|
|
builder.WriteString(um.UpdatedAt.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("version=")
|
|
builder.WriteString(fmt.Sprintf("%v", um.Version))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("user_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", um.UserID))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("key=")
|
|
builder.WriteString(um.Key)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("value=")
|
|
builder.WriteString(um.Value)
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// UserMetaSlice is a parsable slice of UserMeta.
|
|
type UserMetaSlice []*UserMeta
|