// Code generated by ent, DO NOT EDIT. package ent import ( "bj_power_mes/ent/workpiecebind" "fmt" "strings" "time" "entgo.io/ent" "entgo.io/ent/dialect/sql" ) // WorkpieceBind is the model entity for the WorkpieceBind schema. type WorkpieceBind struct { config `json:"-"` // ID of the ent. ID int `json:"id,omitempty"` // 工件SN Sn string `json:"sn,omitempty"` // 工单号 OrderNo string `json:"orderNo,omitempty"` // 装配工序 1~12 ProcessCode int `json:"processCode,omitempty"` // 绑定工位 StationNo string `json:"stationNo,omitempty"` // 物料编码 MaterialCode string `json:"materialCode,omitempty"` // 物料名称 MaterialName string `json:"materialName,omitempty"` // 规格 Spec string `json:"spec,omitempty"` // 单位 Unit string `json:"unit,omitempty"` // ManageMode holds the value of the "manageMode" field. ManageMode string `json:"manageMode,omitempty"` // 绑定值:批次号 或 SN BindValue string `json:"bindValue,omitempty"` // BindType holds the value of the "bindType" field. BindType string `json:"bindType,omitempty"` // 操作人 Operator string `json:"operator,omitempty"` // 绑定时间 CreatedAt time.Time `json:"createdAt,omitempty"` selectValues sql.SelectValues } // scanValues returns the types for scanning values from sql.Rows. func (*WorkpieceBind) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case workpiecebind.FieldID, workpiecebind.FieldProcessCode: values[i] = new(sql.NullInt64) case workpiecebind.FieldSn, workpiecebind.FieldOrderNo, workpiecebind.FieldStationNo, workpiecebind.FieldMaterialCode, workpiecebind.FieldMaterialName, workpiecebind.FieldSpec, workpiecebind.FieldUnit, workpiecebind.FieldManageMode, workpiecebind.FieldBindValue, workpiecebind.FieldBindType, workpiecebind.FieldOperator: values[i] = new(sql.NullString) case workpiecebind.FieldCreatedAt: 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 WorkpieceBind fields. func (_m *WorkpieceBind) 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 workpiecebind.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 workpiecebind.FieldSn: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field sn", values[i]) } else if value.Valid { _m.Sn = value.String } case workpiecebind.FieldOrderNo: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field orderNo", values[i]) } else if value.Valid { _m.OrderNo = value.String } case workpiecebind.FieldProcessCode: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field processCode", values[i]) } else if value.Valid { _m.ProcessCode = int(value.Int64) } case workpiecebind.FieldStationNo: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field stationNo", values[i]) } else if value.Valid { _m.StationNo = value.String } case workpiecebind.FieldMaterialCode: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field materialCode", values[i]) } else if value.Valid { _m.MaterialCode = value.String } case workpiecebind.FieldMaterialName: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field materialName", values[i]) } else if value.Valid { _m.MaterialName = value.String } case workpiecebind.FieldSpec: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field spec", values[i]) } else if value.Valid { _m.Spec = value.String } case workpiecebind.FieldUnit: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field unit", values[i]) } else if value.Valid { _m.Unit = value.String } case workpiecebind.FieldManageMode: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field manageMode", values[i]) } else if value.Valid { _m.ManageMode = value.String } case workpiecebind.FieldBindValue: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field bindValue", values[i]) } else if value.Valid { _m.BindValue = value.String } case workpiecebind.FieldBindType: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field bindType", values[i]) } else if value.Valid { _m.BindType = value.String } case workpiecebind.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 workpiecebind.FieldCreatedAt: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field createdAt", values[i]) } else if value.Valid { _m.CreatedAt = 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 WorkpieceBind. // This includes values selected through modifiers, order, etc. func (_m *WorkpieceBind) Value(name string) (ent.Value, error) { return _m.selectValues.Get(name) } // Update returns a builder for updating this WorkpieceBind. // Note that you need to call WorkpieceBind.Unwrap() before calling this method if this WorkpieceBind // was returned from a transaction, and the transaction was committed or rolled back. func (_m *WorkpieceBind) Update() *WorkpieceBindUpdateOne { return NewWorkpieceBindClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the WorkpieceBind 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 *WorkpieceBind) Unwrap() *WorkpieceBind { _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: WorkpieceBind is not a transactional entity") } _m.config.driver = _tx.drv return _m } // String implements the fmt.Stringer. func (_m *WorkpieceBind) String() string { var builder strings.Builder builder.WriteString("WorkpieceBind(") builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("sn=") builder.WriteString(_m.Sn) builder.WriteString(", ") builder.WriteString("orderNo=") builder.WriteString(_m.OrderNo) builder.WriteString(", ") builder.WriteString("processCode=") builder.WriteString(fmt.Sprintf("%v", _m.ProcessCode)) builder.WriteString(", ") builder.WriteString("stationNo=") builder.WriteString(_m.StationNo) builder.WriteString(", ") builder.WriteString("materialCode=") builder.WriteString(_m.MaterialCode) builder.WriteString(", ") builder.WriteString("materialName=") builder.WriteString(_m.MaterialName) builder.WriteString(", ") builder.WriteString("spec=") builder.WriteString(_m.Spec) builder.WriteString(", ") builder.WriteString("unit=") builder.WriteString(_m.Unit) builder.WriteString(", ") builder.WriteString("manageMode=") builder.WriteString(_m.ManageMode) builder.WriteString(", ") builder.WriteString("bindValue=") builder.WriteString(_m.BindValue) builder.WriteString(", ") builder.WriteString("bindType=") builder.WriteString(_m.BindType) builder.WriteString(", ") builder.WriteString("operator=") builder.WriteString(_m.Operator) builder.WriteString(", ") builder.WriteString("createdAt=") builder.WriteString(_m.CreatedAt.Format(time.ANSIC)) builder.WriteByte(')') return builder.String() } // WorkpieceBinds is a parsable slice of WorkpieceBind. type WorkpieceBinds []*WorkpieceBind