Files
bj_power/bj_power_wms/ent/packagebox.go
T

170 lines
5.4 KiB
Go
Raw Normal View History

2026-08-27 19:50:57 +08:00
// Code generated by ent, DO NOT EDIT.
package ent
import (
"bj_power_wms/ent/packagebox"
"fmt"
"strings"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// PackageBox is the model entity for the PackageBox schema.
type PackageBox struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// 箱号
BoxNo string `json:"box_no,omitempty"`
// 箱内 SN 列表
SnList string `json:"sn_list,omitempty"`
// 物料编码
MaterialCode string `json:"material_code,omitempty"`
// 箱内数量
Quantity int `json:"quantity,omitempty"`
// 包装人
Operator string `json:"operator,omitempty"`
// 备注
Remark string `json:"remark,omitempty"`
// CreatedAt holds the value of the "created_at" field.
CreatedAt int64 `json:"created_at,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*PackageBox) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case packagebox.FieldID, packagebox.FieldQuantity, packagebox.FieldCreatedAt:
values[i] = new(sql.NullInt64)
case packagebox.FieldBoxNo, packagebox.FieldSnList, packagebox.FieldMaterialCode, packagebox.FieldOperator, packagebox.FieldRemark:
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 PackageBox fields.
func (_m *PackageBox) 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 packagebox.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 packagebox.FieldBoxNo:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field box_no", values[i])
} else if value.Valid {
_m.BoxNo = value.String
}
case packagebox.FieldSnList:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field sn_list", values[i])
} else if value.Valid {
_m.SnList = value.String
}
case packagebox.FieldMaterialCode:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field material_code", values[i])
} else if value.Valid {
_m.MaterialCode = value.String
}
case packagebox.FieldQuantity:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field quantity", values[i])
} else if value.Valid {
_m.Quantity = int(value.Int64)
}
case packagebox.FieldOperator:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field operator", values[i])
} else if value.Valid {
_m.Operator = value.String
}
case packagebox.FieldRemark:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field remark", values[i])
} else if value.Valid {
_m.Remark = value.String
}
case packagebox.FieldCreatedAt:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
_m.CreatedAt = value.Int64
}
default:
_m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the PackageBox.
// This includes values selected through modifiers, order, etc.
func (_m *PackageBox) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// Update returns a builder for updating this PackageBox.
// Note that you need to call PackageBox.Unwrap() before calling this method if this PackageBox
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *PackageBox) Update() *PackageBoxUpdateOne {
return NewPackageBoxClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the PackageBox 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 *PackageBox) Unwrap() *PackageBox {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: PackageBox is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *PackageBox) String() string {
var builder strings.Builder
builder.WriteString("PackageBox(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("box_no=")
builder.WriteString(_m.BoxNo)
builder.WriteString(", ")
builder.WriteString("sn_list=")
builder.WriteString(_m.SnList)
builder.WriteString(", ")
builder.WriteString("material_code=")
builder.WriteString(_m.MaterialCode)
builder.WriteString(", ")
builder.WriteString("quantity=")
builder.WriteString(fmt.Sprintf("%v", _m.Quantity))
builder.WriteString(", ")
builder.WriteString("operator=")
builder.WriteString(_m.Operator)
builder.WriteString(", ")
builder.WriteString("remark=")
builder.WriteString(_m.Remark)
builder.WriteString(", ")
builder.WriteString("created_at=")
builder.WriteString(fmt.Sprintf("%v", _m.CreatedAt))
builder.WriteByte(')')
return builder.String()
}
// PackageBoxes is a parsable slice of PackageBox.
type PackageBoxes []*PackageBox