// Code generated by ent, DO NOT EDIT. package ent import ( "bj_power_wms/ent/inspectiondisposalitem" "fmt" "strings" "entgo.io/ent" "entgo.io/ent/dialect/sql" ) // InspectionDisposalItem 不合格品处置明细(按数量分退货/返修/报废) type InspectionDisposalItem struct { config `json:"-"` // ID of the ent. ID int `json:"id,omitempty"` // 父检验记录ID(inspection_records.id) RecordID int64 `json:"recordId,omitempty"` // 处置方式 RETURN/REWORK/SCRAP DisposeType string `json:"disposeType,omitempty"` // 本行处置数量(合计=记录不合格数) Qty int `json:"qty,omitempty"` // 处置备注(非必填;退货物流信息也填此处) Remark string `json:"remark,omitempty"` // 操作人 Operator string `json:"operator,omitempty"` // CreatedAt holds the value of the "created_at" field. CreatedAt int64 `json:"createdAt,omitempty"` selectValues sql.SelectValues } // scanValues returns the types for scanning values from sql.Rows. func (*InspectionDisposalItem) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case inspectiondisposalitem.FieldID, inspectiondisposalitem.FieldRecordID, inspectiondisposalitem.FieldQty, inspectiondisposalitem.FieldCreatedAt: values[i] = new(sql.NullInt64) case inspectiondisposalitem.FieldDisposeType, inspectiondisposalitem.FieldRemark, inspectiondisposalitem.FieldOperator: 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 InspectionDisposalItem fields. func (_m *InspectionDisposalItem) 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 inspectiondisposalitem.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 inspectiondisposalitem.FieldRecordID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field record_id", values[i]) } else if value.Valid { _m.RecordID = value.Int64 } case inspectiondisposalitem.FieldDisposeType: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field dispose_type", values[i]) } else if value.Valid { _m.DisposeType = value.String } case inspectiondisposalitem.FieldQty: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field qty", values[i]) } else if value.Valid { _m.Qty = int(value.Int64) } case inspectiondisposalitem.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 inspectiondisposalitem.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 inspectiondisposalitem.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 InspectionDisposalItem. // This includes values selected through modifiers, order, etc. func (_m *InspectionDisposalItem) Value(name string) (ent.Value, error) { return _m.selectValues.Get(name) } // Update returns a builder for updating this InspectionDisposalItem. // Note that you need to call InspectionDisposalItem.Unwrap() before calling this method if this InspectionDisposalItem // was returned from a transaction, and the transaction was committed or rolled back. func (_m *InspectionDisposalItem) Update() *InspectionDisposalItemUpdateOne { return NewInspectionDisposalItemClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the InspectionDisposalItem 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 *InspectionDisposalItem) Unwrap() *InspectionDisposalItem { _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: InspectionDisposalItem is not a transactional entity") } _m.config.driver = _tx.drv return _m } // String implements the fmt.Stringer. func (_m *InspectionDisposalItem) String() string { var builder strings.Builder builder.WriteString("InspectionDisposalItem(") builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("record_id=") builder.WriteString(fmt.Sprintf("%v", _m.RecordID)) builder.WriteString(", ") builder.WriteString("dispose_type=") builder.WriteString(_m.DisposeType) builder.WriteString(", ") builder.WriteString("qty=") builder.WriteString(fmt.Sprintf("%v", _m.Qty)) builder.WriteString(", ") builder.WriteString("remark=") builder.WriteString(_m.Remark) builder.WriteString(", ") builder.WriteString("operator=") builder.WriteString(_m.Operator) builder.WriteString(", ") builder.WriteString("created_at=") builder.WriteString(fmt.Sprintf("%v", _m.CreatedAt)) builder.WriteByte(')') return builder.String() } // InspectionDisposalItems is a parsable slice of InspectionDisposalItem. type InspectionDisposalItems []*InspectionDisposalItem