fix: api descript
This commit is contained in:
@@ -0,0 +1,289 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"juwan-backend/app/shop/rpc/internal/models/shops"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
|
||||
// Shops is the model entity for the Shops schema.
|
||||
type Shops struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int64 `json:"id,omitempty"`
|
||||
// OwnerID holds the value of the "owner_id" field.
|
||||
OwnerID int64 `json:"owner_id,omitempty"`
|
||||
// Name holds the value of the "name" field.
|
||||
Name string `json:"name,omitempty"`
|
||||
// Banner holds the value of the "banner" field.
|
||||
Banner *string `json:"banner,omitempty"`
|
||||
// Description holds the value of the "description" field.
|
||||
Description *string `json:"description,omitempty"`
|
||||
// Rating holds the value of the "rating" field.
|
||||
Rating decimal.Decimal `json:"rating,omitempty"`
|
||||
// TotalOrders holds the value of the "total_orders" field.
|
||||
TotalOrders int `json:"total_orders,omitempty"`
|
||||
// PlayerCount holds the value of the "player_count" field.
|
||||
PlayerCount int `json:"player_count,omitempty"`
|
||||
// CommissionType holds the value of the "commission_type" field.
|
||||
CommissionType string `json:"commission_type,omitempty"`
|
||||
// CommissionValue holds the value of the "commission_value" field.
|
||||
CommissionValue decimal.Decimal `json:"commission_value,omitempty"`
|
||||
// AllowMultiShop holds the value of the "allow_multi_shop" field.
|
||||
AllowMultiShop bool `json:"allow_multi_shop,omitempty"`
|
||||
// AllowIndependentOrders holds the value of the "allow_independent_orders" field.
|
||||
AllowIndependentOrders bool `json:"allow_independent_orders,omitempty"`
|
||||
// DispatchMode holds the value of the "dispatch_mode" field.
|
||||
DispatchMode string `json:"dispatch_mode,omitempty"`
|
||||
// Announcements holds the value of the "announcements" field.
|
||||
Announcements []string `json:"announcements,omitempty"`
|
||||
// TemplateConfig holds the value of the "template_config" field.
|
||||
TemplateConfig map[string]interface{} `json:"template_config,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"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*Shops) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case shops.FieldAnnouncements, shops.FieldTemplateConfig:
|
||||
values[i] = new([]byte)
|
||||
case shops.FieldRating, shops.FieldCommissionValue:
|
||||
values[i] = new(decimal.Decimal)
|
||||
case shops.FieldAllowMultiShop, shops.FieldAllowIndependentOrders:
|
||||
values[i] = new(sql.NullBool)
|
||||
case shops.FieldID, shops.FieldOwnerID, shops.FieldTotalOrders, shops.FieldPlayerCount:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case shops.FieldName, shops.FieldBanner, shops.FieldDescription, shops.FieldCommissionType, shops.FieldDispatchMode:
|
||||
values[i] = new(sql.NullString)
|
||||
case shops.FieldCreatedAt, shops.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 Shops fields.
|
||||
func (_m *Shops) 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 shops.FieldID:
|
||||
value, ok := values[i].(*sql.NullInt64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
_m.ID = int64(value.Int64)
|
||||
case shops.FieldOwnerID:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field owner_id", values[i])
|
||||
} else if value.Valid {
|
||||
_m.OwnerID = value.Int64
|
||||
}
|
||||
case shops.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 shops.FieldBanner:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field banner", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Banner = new(string)
|
||||
*_m.Banner = value.String
|
||||
}
|
||||
case shops.FieldDescription:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field description", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Description = new(string)
|
||||
*_m.Description = value.String
|
||||
}
|
||||
case shops.FieldRating:
|
||||
if value, ok := values[i].(*decimal.Decimal); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field rating", values[i])
|
||||
} else if value != nil {
|
||||
_m.Rating = *value
|
||||
}
|
||||
case shops.FieldTotalOrders:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field total_orders", values[i])
|
||||
} else if value.Valid {
|
||||
_m.TotalOrders = int(value.Int64)
|
||||
}
|
||||
case shops.FieldPlayerCount:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field player_count", values[i])
|
||||
} else if value.Valid {
|
||||
_m.PlayerCount = int(value.Int64)
|
||||
}
|
||||
case shops.FieldCommissionType:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field commission_type", values[i])
|
||||
} else if value.Valid {
|
||||
_m.CommissionType = value.String
|
||||
}
|
||||
case shops.FieldCommissionValue:
|
||||
if value, ok := values[i].(*decimal.Decimal); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field commission_value", values[i])
|
||||
} else if value != nil {
|
||||
_m.CommissionValue = *value
|
||||
}
|
||||
case shops.FieldAllowMultiShop:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field allow_multi_shop", values[i])
|
||||
} else if value.Valid {
|
||||
_m.AllowMultiShop = value.Bool
|
||||
}
|
||||
case shops.FieldAllowIndependentOrders:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field allow_independent_orders", values[i])
|
||||
} else if value.Valid {
|
||||
_m.AllowIndependentOrders = value.Bool
|
||||
}
|
||||
case shops.FieldDispatchMode:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field dispatch_mode", values[i])
|
||||
} else if value.Valid {
|
||||
_m.DispatchMode = value.String
|
||||
}
|
||||
case shops.FieldAnnouncements:
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field announcements", values[i])
|
||||
} else if value != nil && len(*value) > 0 {
|
||||
if err := json.Unmarshal(*value, &_m.Announcements); err != nil {
|
||||
return fmt.Errorf("unmarshal field announcements: %w", err)
|
||||
}
|
||||
}
|
||||
case shops.FieldTemplateConfig:
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field template_config", values[i])
|
||||
} else if value != nil && len(*value) > 0 {
|
||||
if err := json.Unmarshal(*value, &_m.TemplateConfig); err != nil {
|
||||
return fmt.Errorf("unmarshal field template_config: %w", err)
|
||||
}
|
||||
}
|
||||
case shops.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 shops.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 Shops.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (_m *Shops) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Shops.
|
||||
// Note that you need to call Shops.Unwrap() before calling this method if this Shops
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (_m *Shops) Update() *ShopsUpdateOne {
|
||||
return NewShopsClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the Shops 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 *Shops) Unwrap() *Shops {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("models: Shops is not a transactional entity")
|
||||
}
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (_m *Shops) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Shops(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("owner_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.OwnerID))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("name=")
|
||||
builder.WriteString(_m.Name)
|
||||
builder.WriteString(", ")
|
||||
if v := _m.Banner; v != nil {
|
||||
builder.WriteString("banner=")
|
||||
builder.WriteString(*v)
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
if v := _m.Description; v != nil {
|
||||
builder.WriteString("description=")
|
||||
builder.WriteString(*v)
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("rating=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Rating))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("total_orders=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.TotalOrders))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("player_count=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.PlayerCount))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("commission_type=")
|
||||
builder.WriteString(_m.CommissionType)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("commission_value=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.CommissionValue))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("allow_multi_shop=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.AllowMultiShop))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("allow_independent_orders=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.AllowIndependentOrders))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("dispatch_mode=")
|
||||
builder.WriteString(_m.DispatchMode)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("announcements=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Announcements))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("template_config=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.TemplateConfig))
|
||||
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()
|
||||
}
|
||||
|
||||
// ShopsSlice is a parsable slice of Shops.
|
||||
type ShopsSlice []*Shops
|
||||
Reference in New Issue
Block a user