mirror of
https://github.com/chaitin/MonkeyCode.git
synced 2026-11-24 21:29:00 +08:00
207 lines
7.2 KiB
Go
207 lines
7.2 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package db
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"time"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
"github.com/chaitin/MonkeyCode/backend/db/model"
|
|
"github.com/chaitin/MonkeyCode/backend/db/modelpricing"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// ModelPricing is the model entity for the ModelPricing schema.
|
|
type ModelPricing struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID uuid.UUID `json:"id,omitempty"`
|
|
// ModelID holds the value of the "model_id" field.
|
|
ModelID uuid.UUID `json:"model_id,omitempty"`
|
|
// AccessLevel holds the value of the "access_level" field.
|
|
AccessLevel string `json:"access_level,omitempty"`
|
|
// IsFree holds the value of the "is_free" field.
|
|
IsFree bool `json:"is_free,omitempty"`
|
|
// InputPrice holds the value of the "input_price" field.
|
|
InputPrice int64 `json:"input_price,omitempty"`
|
|
// OutputPrice holds the value of the "output_price" field.
|
|
OutputPrice int64 `json:"output_price,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"`
|
|
// Edges holds the relations/edges for other nodes in the graph.
|
|
// The values are being populated by the ModelPricingQuery when eager-loading is set.
|
|
Edges ModelPricingEdges `json:"edges"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// ModelPricingEdges holds the relations/edges for other nodes in the graph.
|
|
type ModelPricingEdges struct {
|
|
// Model holds the value of the model edge.
|
|
Model *Model `json:"model,omitempty"`
|
|
// loadedTypes holds the information for reporting if a
|
|
// type was loaded (or requested) in eager-loading or not.
|
|
loadedTypes [1]bool
|
|
}
|
|
|
|
// ModelOrErr returns the Model value or an error if the edge
|
|
// was not loaded in eager-loading, or loaded but was not found.
|
|
func (e ModelPricingEdges) ModelOrErr() (*Model, error) {
|
|
if e.Model != nil {
|
|
return e.Model, nil
|
|
} else if e.loadedTypes[0] {
|
|
return nil, &NotFoundError{label: model.Label}
|
|
}
|
|
return nil, &NotLoadedError{edge: "model"}
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*ModelPricing) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case modelpricing.FieldIsFree:
|
|
values[i] = new(sql.NullBool)
|
|
case modelpricing.FieldInputPrice, modelpricing.FieldOutputPrice:
|
|
values[i] = new(sql.NullInt64)
|
|
case modelpricing.FieldAccessLevel:
|
|
values[i] = new(sql.NullString)
|
|
case modelpricing.FieldCreatedAt, modelpricing.FieldUpdatedAt:
|
|
values[i] = new(sql.NullTime)
|
|
case modelpricing.FieldID, modelpricing.FieldModelID:
|
|
values[i] = new(uuid.UUID)
|
|
default:
|
|
values[i] = new(sql.UnknownType)
|
|
}
|
|
}
|
|
return values, nil
|
|
}
|
|
|
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
|
// to the ModelPricing fields.
|
|
func (_m *ModelPricing) 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 modelpricing.FieldID:
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", values[i])
|
|
} else if value != nil {
|
|
_m.ID = *value
|
|
}
|
|
case modelpricing.FieldModelID:
|
|
if value, ok := values[i].(*uuid.UUID); !ok {
|
|
return fmt.Errorf("unexpected type %T for field model_id", values[i])
|
|
} else if value != nil {
|
|
_m.ModelID = *value
|
|
}
|
|
case modelpricing.FieldAccessLevel:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field access_level", values[i])
|
|
} else if value.Valid {
|
|
_m.AccessLevel = value.String
|
|
}
|
|
case modelpricing.FieldIsFree:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field is_free", values[i])
|
|
} else if value.Valid {
|
|
_m.IsFree = value.Bool
|
|
}
|
|
case modelpricing.FieldInputPrice:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field input_price", values[i])
|
|
} else if value.Valid {
|
|
_m.InputPrice = value.Int64
|
|
}
|
|
case modelpricing.FieldOutputPrice:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field output_price", values[i])
|
|
} else if value.Valid {
|
|
_m.OutputPrice = value.Int64
|
|
}
|
|
case modelpricing.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 modelpricing.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
|
|
}
|
|
default:
|
|
_m.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the ModelPricing.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (_m *ModelPricing) Value(name string) (ent.Value, error) {
|
|
return _m.selectValues.Get(name)
|
|
}
|
|
|
|
// QueryModel queries the "model" edge of the ModelPricing entity.
|
|
func (_m *ModelPricing) QueryModel() *ModelQuery {
|
|
return NewModelPricingClient(_m.config).QueryModel(_m)
|
|
}
|
|
|
|
// Update returns a builder for updating this ModelPricing.
|
|
// Note that you need to call ModelPricing.Unwrap() before calling this method if this ModelPricing
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (_m *ModelPricing) Update() *ModelPricingUpdateOne {
|
|
return NewModelPricingClient(_m.config).UpdateOne(_m)
|
|
}
|
|
|
|
// Unwrap unwraps the ModelPricing 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 *ModelPricing) Unwrap() *ModelPricing {
|
|
_tx, ok := _m.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("db: ModelPricing is not a transactional entity")
|
|
}
|
|
_m.config.driver = _tx.drv
|
|
return _m
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (_m *ModelPricing) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("ModelPricing(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
|
builder.WriteString("model_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.ModelID))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("access_level=")
|
|
builder.WriteString(_m.AccessLevel)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("is_free=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.IsFree))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("input_price=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.InputPrice))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("output_price=")
|
|
builder.WriteString(fmt.Sprintf("%v", _m.OutputPrice))
|
|
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.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// ModelPricings is a parsable slice of ModelPricing.
|
|
type ModelPricings []*ModelPricing
|