Files
kanhole/pkg/db/ent/frpcclient.go
T

195 lines
6.5 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/fatedier/frp/pkg/db/ent/frpcclient"
)
// FrpcClient is the model entity for the FrpcClient schema.
type FrpcClient struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// Name holds the value of the "name" field.
Name string `json:"name,omitempty"`
// Key holds the value of the "key" field.
Key string `json:"key,omitempty"`
// Addr holds the value of the "addr" field.
Addr string `json:"addr,omitempty"`
// Port holds the value of the "port" field.
Port int `json:"port,omitempty"`
// Status holds the value of the "status" field.
Status string `json:"status,omitempty"`
// Metadata holds the value of the "metadata" field.
Metadata string `json:"metadata,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"`
// LastSeen holds the value of the "last_seen" field.
LastSeen time.Time `json:"last_seen,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*FrpcClient) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case frpcclient.FieldID, frpcclient.FieldPort:
values[i] = new(sql.NullInt64)
case frpcclient.FieldName, frpcclient.FieldKey, frpcclient.FieldAddr, frpcclient.FieldStatus, frpcclient.FieldMetadata:
values[i] = new(sql.NullString)
case frpcclient.FieldCreatedAt, frpcclient.FieldUpdatedAt, frpcclient.FieldLastSeen:
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 FrpcClient fields.
func (_m *FrpcClient) 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 frpcclient.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
_m.ID = int(value.Int64)
case frpcclient.FieldName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field name", values[i])
} else if value.Valid {
_m.Name = value.String
}
case frpcclient.FieldKey:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field key", values[i])
} else if value.Valid {
_m.Key = value.String
}
case frpcclient.FieldAddr:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field addr", values[i])
} else if value.Valid {
_m.Addr = value.String
}
case frpcclient.FieldPort:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field port", values[i])
} else if value.Valid {
_m.Port = int(value.Int64)
}
case frpcclient.FieldStatus:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field status", values[i])
} else if value.Valid {
_m.Status = value.String
}
case frpcclient.FieldMetadata:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field metadata", values[i])
} else if value.Valid {
_m.Metadata = value.String
}
case frpcclient.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 frpcclient.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 frpcclient.FieldLastSeen:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field last_seen", values[i])
} else if value.Valid {
_m.LastSeen = 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 FrpcClient.
// This includes values selected through modifiers, order, etc.
func (_m *FrpcClient) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// Update returns a builder for updating this FrpcClient.
// Note that you need to call FrpcClient.Unwrap() before calling this method if this FrpcClient
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *FrpcClient) Update() *FrpcClientUpdateOne {
return NewFrpcClientClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the FrpcClient 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 *FrpcClient) Unwrap() *FrpcClient {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: FrpcClient is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *FrpcClient) String() string {
var builder strings.Builder
builder.WriteString("FrpcClient(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("name=")
builder.WriteString(_m.Name)
builder.WriteString(", ")
builder.WriteString("key=")
builder.WriteString(_m.Key)
builder.WriteString(", ")
builder.WriteString("addr=")
builder.WriteString(_m.Addr)
builder.WriteString(", ")
builder.WriteString("port=")
builder.WriteString(fmt.Sprintf("%v", _m.Port))
builder.WriteString(", ")
builder.WriteString("status=")
builder.WriteString(_m.Status)
builder.WriteString(", ")
builder.WriteString("metadata=")
builder.WriteString(_m.Metadata)
builder.WriteString(", ")
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("last_seen=")
builder.WriteString(_m.LastSeen.Format(time.ANSIC))
builder.WriteByte(')')
return builder.String()
}
// FrpcClients is a parsable slice of FrpcClient.
type FrpcClients []*FrpcClient