// Code generated by ent, DO NOT EDIT. package ent import ( "bj_power_wms/ent/produciblesnapshot" "fmt" "strings" "entgo.io/ent" "entgo.io/ent/dialect/sql" ) // ProducibleSnapshot is the model entity for the ProducibleSnapshot schema. type ProducibleSnapshot struct { config `json:"-"` // ID of the ent. ID int `json:"id,omitempty"` // 产品编号 ProductCode string `json:"productCode,omitempty"` // 产品名称 ProductName string `json:"productName,omitempty"` // 可生产套数=min(各物料可用量/单台用量) ProducibleQty int `json:"producibleQty,omitempty"` // 短板物料描述(如 SCR-M4-12缺20) ShortText string `json:"shortText,omitempty"` // MES 计算时间(unix 秒) ComputedAt int64 `json:"computedAt,omitempty"` // 同步到 WMS 时间(unix 秒) SyncedAt int64 `json:"syncedAt,omitempty"` selectValues sql.SelectValues } // scanValues returns the types for scanning values from sql.Rows. func (*ProducibleSnapshot) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case produciblesnapshot.FieldID, produciblesnapshot.FieldProducibleQty, produciblesnapshot.FieldComputedAt, produciblesnapshot.FieldSyncedAt: values[i] = new(sql.NullInt64) case produciblesnapshot.FieldProductCode, produciblesnapshot.FieldProductName, produciblesnapshot.FieldShortText: 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 ProducibleSnapshot fields. func (_m *ProducibleSnapshot) 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 produciblesnapshot.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 produciblesnapshot.FieldProductCode: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field product_code", values[i]) } else if value.Valid { _m.ProductCode = value.String } case produciblesnapshot.FieldProductName: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field product_name", values[i]) } else if value.Valid { _m.ProductName = value.String } case produciblesnapshot.FieldProducibleQty: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field producible_qty", values[i]) } else if value.Valid { _m.ProducibleQty = int(value.Int64) } case produciblesnapshot.FieldShortText: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field short_text", values[i]) } else if value.Valid { _m.ShortText = value.String } case produciblesnapshot.FieldComputedAt: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field computed_at", values[i]) } else if value.Valid { _m.ComputedAt = value.Int64 } case produciblesnapshot.FieldSyncedAt: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field synced_at", values[i]) } else if value.Valid { _m.SyncedAt = 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 ProducibleSnapshot. // This includes values selected through modifiers, order, etc. func (_m *ProducibleSnapshot) Value(name string) (ent.Value, error) { return _m.selectValues.Get(name) } // Update returns a builder for updating this ProducibleSnapshot. // Note that you need to call ProducibleSnapshot.Unwrap() before calling this method if this ProducibleSnapshot // was returned from a transaction, and the transaction was committed or rolled back. func (_m *ProducibleSnapshot) Update() *ProducibleSnapshotUpdateOne { return NewProducibleSnapshotClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the ProducibleSnapshot 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 *ProducibleSnapshot) Unwrap() *ProducibleSnapshot { _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: ProducibleSnapshot is not a transactional entity") } _m.config.driver = _tx.drv return _m } // String implements the fmt.Stringer. func (_m *ProducibleSnapshot) String() string { var builder strings.Builder builder.WriteString("ProducibleSnapshot(") builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("product_code=") builder.WriteString(_m.ProductCode) builder.WriteString(", ") builder.WriteString("product_name=") builder.WriteString(_m.ProductName) builder.WriteString(", ") builder.WriteString("producible_qty=") builder.WriteString(fmt.Sprintf("%v", _m.ProducibleQty)) builder.WriteString(", ") builder.WriteString("short_text=") builder.WriteString(_m.ShortText) builder.WriteString(", ") builder.WriteString("computed_at=") builder.WriteString(fmt.Sprintf("%v", _m.ComputedAt)) builder.WriteString(", ") builder.WriteString("synced_at=") builder.WriteString(fmt.Sprintf("%v", _m.SyncedAt)) builder.WriteByte(')') return builder.String() } // ProducibleSnapshots is a parsable slice of ProducibleSnapshot. type ProducibleSnapshots []*ProducibleSnapshot