179 lines
6.1 KiB
Go
179 lines
6.1 KiB
Go
|
// Code generated by ent, DO NOT EDIT.
|
||
|
|
||
|
package ent
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"fmt"
|
||
|
"online-order/ent/business"
|
||
|
"online-order/ent/businessconfig"
|
||
|
"online-order/ent/schema"
|
||
|
"strings"
|
||
|
|
||
|
"entgo.io/ent"
|
||
|
"entgo.io/ent/dialect/sql"
|
||
|
)
|
||
|
|
||
|
// BusinessConfig is the model entity for the BusinessConfig schema.
|
||
|
type BusinessConfig struct {
|
||
|
config `json:"-"`
|
||
|
// ID of the ent.
|
||
|
ID int `json:"id,omitempty"`
|
||
|
// Company holds the value of the "company" field.
|
||
|
Company string `json:"company,omitempty"`
|
||
|
// AuthConfig holds the value of the "auth_config" field.
|
||
|
AuthConfig schema.AuthConfig `json:"auth_config,omitempty"`
|
||
|
// {type:'products',uri:''}
|
||
|
Config []string `json:"config,omitempty"`
|
||
|
// BusinessID holds the value of the "business_id" field.
|
||
|
BusinessID *int `json:"business_id,omitempty"`
|
||
|
// Edges holds the relations/edges for other nodes in the graph.
|
||
|
// The values are being populated by the BusinessConfigQuery when eager-loading is set.
|
||
|
Edges BusinessConfigEdges `json:"edges"`
|
||
|
selectValues sql.SelectValues
|
||
|
}
|
||
|
|
||
|
// BusinessConfigEdges holds the relations/edges for other nodes in the graph.
|
||
|
type BusinessConfigEdges struct {
|
||
|
// Businesses holds the value of the businesses edge.
|
||
|
Businesses *Business `json:"businesses,omitempty"`
|
||
|
// loadedTypes holds the information for reporting if a
|
||
|
// type was loaded (or requested) in eager-loading or not.
|
||
|
loadedTypes [1]bool
|
||
|
}
|
||
|
|
||
|
// BusinessesOrErr returns the Businesses value or an error if the edge
|
||
|
// was not loaded in eager-loading, or loaded but was not found.
|
||
|
func (e BusinessConfigEdges) BusinessesOrErr() (*Business, error) {
|
||
|
if e.loadedTypes[0] {
|
||
|
if e.Businesses == nil {
|
||
|
// Edge was loaded but was not found.
|
||
|
return nil, &NotFoundError{label: business.Label}
|
||
|
}
|
||
|
return e.Businesses, nil
|
||
|
}
|
||
|
return nil, &NotLoadedError{edge: "businesses"}
|
||
|
}
|
||
|
|
||
|
// scanValues returns the types for scanning values from sql.Rows.
|
||
|
func (*BusinessConfig) scanValues(columns []string) ([]any, error) {
|
||
|
values := make([]any, len(columns))
|
||
|
for i := range columns {
|
||
|
switch columns[i] {
|
||
|
case businessconfig.FieldAuthConfig, businessconfig.FieldConfig:
|
||
|
values[i] = new([]byte)
|
||
|
case businessconfig.FieldID, businessconfig.FieldBusinessID:
|
||
|
values[i] = new(sql.NullInt64)
|
||
|
case businessconfig.FieldCompany:
|
||
|
values[i] = new(sql.NullString)
|
||
|
default:
|
||
|
values[i] = new(sql.UnknownType)
|
||
|
}
|
||
|
}
|
||
|
return values, nil
|
||
|
}
|
||
|
|
||
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||
|
// to the BusinessConfig fields.
|
||
|
func (bc *BusinessConfig) 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 businessconfig.FieldID:
|
||
|
value, ok := values[i].(*sql.NullInt64)
|
||
|
if !ok {
|
||
|
return fmt.Errorf("unexpected type %T for field id", value)
|
||
|
}
|
||
|
bc.ID = int(value.Int64)
|
||
|
case businessconfig.FieldCompany:
|
||
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||
|
return fmt.Errorf("unexpected type %T for field company", values[i])
|
||
|
} else if value.Valid {
|
||
|
bc.Company = value.String
|
||
|
}
|
||
|
case businessconfig.FieldAuthConfig:
|
||
|
if value, ok := values[i].(*[]byte); !ok {
|
||
|
return fmt.Errorf("unexpected type %T for field auth_config", values[i])
|
||
|
} else if value != nil && len(*value) > 0 {
|
||
|
if err := json.Unmarshal(*value, &bc.AuthConfig); err != nil {
|
||
|
return fmt.Errorf("unmarshal field auth_config: %w", err)
|
||
|
}
|
||
|
}
|
||
|
case businessconfig.FieldConfig:
|
||
|
if value, ok := values[i].(*[]byte); !ok {
|
||
|
return fmt.Errorf("unexpected type %T for field config", values[i])
|
||
|
} else if value != nil && len(*value) > 0 {
|
||
|
if err := json.Unmarshal(*value, &bc.Config); err != nil {
|
||
|
return fmt.Errorf("unmarshal field config: %w", err)
|
||
|
}
|
||
|
}
|
||
|
case businessconfig.FieldBusinessID:
|
||
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||
|
return fmt.Errorf("unexpected type %T for field business_id", values[i])
|
||
|
} else if value.Valid {
|
||
|
bc.BusinessID = new(int)
|
||
|
*bc.BusinessID = int(value.Int64)
|
||
|
}
|
||
|
default:
|
||
|
bc.selectValues.Set(columns[i], values[i])
|
||
|
}
|
||
|
}
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// Value returns the ent.Value that was dynamically selected and assigned to the BusinessConfig.
|
||
|
// This includes values selected through modifiers, order, etc.
|
||
|
func (bc *BusinessConfig) Value(name string) (ent.Value, error) {
|
||
|
return bc.selectValues.Get(name)
|
||
|
}
|
||
|
|
||
|
// QueryBusinesses queries the "businesses" edge of the BusinessConfig entity.
|
||
|
func (bc *BusinessConfig) QueryBusinesses() *BusinessQuery {
|
||
|
return NewBusinessConfigClient(bc.config).QueryBusinesses(bc)
|
||
|
}
|
||
|
|
||
|
// Update returns a builder for updating this BusinessConfig.
|
||
|
// Note that you need to call BusinessConfig.Unwrap() before calling this method if this BusinessConfig
|
||
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
||
|
func (bc *BusinessConfig) Update() *BusinessConfigUpdateOne {
|
||
|
return NewBusinessConfigClient(bc.config).UpdateOne(bc)
|
||
|
}
|
||
|
|
||
|
// Unwrap unwraps the BusinessConfig 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 (bc *BusinessConfig) Unwrap() *BusinessConfig {
|
||
|
_tx, ok := bc.config.driver.(*txDriver)
|
||
|
if !ok {
|
||
|
panic("ent: BusinessConfig is not a transactional entity")
|
||
|
}
|
||
|
bc.config.driver = _tx.drv
|
||
|
return bc
|
||
|
}
|
||
|
|
||
|
// String implements the fmt.Stringer.
|
||
|
func (bc *BusinessConfig) String() string {
|
||
|
var builder strings.Builder
|
||
|
builder.WriteString("BusinessConfig(")
|
||
|
builder.WriteString(fmt.Sprintf("id=%v, ", bc.ID))
|
||
|
builder.WriteString("company=")
|
||
|
builder.WriteString(bc.Company)
|
||
|
builder.WriteString(", ")
|
||
|
builder.WriteString("auth_config=")
|
||
|
builder.WriteString(fmt.Sprintf("%v", bc.AuthConfig))
|
||
|
builder.WriteString(", ")
|
||
|
builder.WriteString("config=")
|
||
|
builder.WriteString(fmt.Sprintf("%v", bc.Config))
|
||
|
builder.WriteString(", ")
|
||
|
if v := bc.BusinessID; v != nil {
|
||
|
builder.WriteString("business_id=")
|
||
|
builder.WriteString(fmt.Sprintf("%v", *v))
|
||
|
}
|
||
|
builder.WriteByte(')')
|
||
|
return builder.String()
|
||
|
}
|
||
|
|
||
|
// BusinessConfigs is a parsable slice of BusinessConfig.
|
||
|
type BusinessConfigs []*BusinessConfig
|