// Code generated by ent, DO NOT EDIT. package ent import ( "bj_power_wms/ent/inspectionrecord" "fmt" "strings" "entgo.io/ent" "entgo.io/ent/dialect/sql" ) // InspectionRecord is the model entity for the InspectionRecord schema. type InspectionRecord struct { config `json:"-"` // ID of the ent. ID int `json:"id,omitempty"` // BATCH/SN TargetType string `json:"targetType,omitempty"` // 批次号或 SN TargetID string `json:"targetId,omitempty"` // 物料编码 MaterialCode string `json:"materialCode,omitempty"` // 来料检/过程检/成品检 InspectionType string `json:"inspectionType,omitempty"` // 未检/合格/不合格 Status string `json:"status,omitempty"` // 实测值(部分检验项) ResultValue string `json:"resultValue,omitempty"` // 检验数量(抽检件数) InspectQty int `json:"inspectQty,omitempty"` // 合格数量(≤检验数量) PassQty int `json:"passQty,omitempty"` // 检测说明(检验项目/方法) CheckDesc string `json:"checkDesc,omitempty"` // 不合格原因(不合格时必填) FailReason string `json:"failReason,omitempty"` // 检验人 Inspector string `json:"inspector,omitempty"` // 备注 Remark string `json:"remark,omitempty"` // CreatedAt holds the value of the "created_at" field. CreatedAt int64 `json:"createdAt,omitempty"` // UpdatedAt holds the value of the "updated_at" field. UpdatedAt int64 `json:"updatedAt,omitempty"` selectValues sql.SelectValues } // scanValues returns the types for scanning values from sql.Rows. func (*InspectionRecord) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case inspectionrecord.FieldID, inspectionrecord.FieldInspectQty, inspectionrecord.FieldPassQty, inspectionrecord.FieldCreatedAt, inspectionrecord.FieldUpdatedAt: values[i] = new(sql.NullInt64) case inspectionrecord.FieldTargetType, inspectionrecord.FieldTargetID, inspectionrecord.FieldMaterialCode, inspectionrecord.FieldInspectionType, inspectionrecord.FieldStatus, inspectionrecord.FieldResultValue, inspectionrecord.FieldCheckDesc, inspectionrecord.FieldFailReason, inspectionrecord.FieldInspector, inspectionrecord.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 InspectionRecord fields. func (_m *InspectionRecord) 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 inspectionrecord.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 inspectionrecord.FieldTargetType: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field target_type", values[i]) } else if value.Valid { _m.TargetType = value.String } case inspectionrecord.FieldTargetID: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field target_id", values[i]) } else if value.Valid { _m.TargetID = value.String } case inspectionrecord.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 inspectionrecord.FieldInspectionType: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field inspection_type", values[i]) } else if value.Valid { _m.InspectionType = value.String } case inspectionrecord.FieldStatus: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field status", values[i]) } else if value.Valid { _m.Status = value.String } case inspectionrecord.FieldResultValue: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field result_value", values[i]) } else if value.Valid { _m.ResultValue = value.String } case inspectionrecord.FieldInspectQty: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field inspect_qty", values[i]) } else if value.Valid { _m.InspectQty = int(value.Int64) } case inspectionrecord.FieldPassQty: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field pass_qty", values[i]) } else if value.Valid { _m.PassQty = int(value.Int64) } case inspectionrecord.FieldCheckDesc: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field check_desc", values[i]) } else if value.Valid { _m.CheckDesc = value.String } case inspectionrecord.FieldFailReason: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field fail_reason", values[i]) } else if value.Valid { _m.FailReason = value.String } case inspectionrecord.FieldInspector: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field inspector", values[i]) } else if value.Valid { _m.Inspector = value.String } case inspectionrecord.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 inspectionrecord.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 } case inspectionrecord.FieldUpdatedAt: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field updated_at", values[i]) } else if value.Valid { _m.UpdatedAt = 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 InspectionRecord. // This includes values selected through modifiers, order, etc. func (_m *InspectionRecord) Value(name string) (ent.Value, error) { return _m.selectValues.Get(name) } // Update returns a builder for updating this InspectionRecord. // Note that you need to call InspectionRecord.Unwrap() before calling this method if this InspectionRecord // was returned from a transaction, and the transaction was committed or rolled back. func (_m *InspectionRecord) Update() *InspectionRecordUpdateOne { return NewInspectionRecordClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the InspectionRecord 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 *InspectionRecord) Unwrap() *InspectionRecord { _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: InspectionRecord is not a transactional entity") } _m.config.driver = _tx.drv return _m } // String implements the fmt.Stringer. func (_m *InspectionRecord) String() string { var builder strings.Builder builder.WriteString("InspectionRecord(") builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("target_type=") builder.WriteString(_m.TargetType) builder.WriteString(", ") builder.WriteString("target_id=") builder.WriteString(_m.TargetID) builder.WriteString(", ") builder.WriteString("material_code=") builder.WriteString(_m.MaterialCode) builder.WriteString(", ") builder.WriteString("inspection_type=") builder.WriteString(_m.InspectionType) builder.WriteString(", ") builder.WriteString("status=") builder.WriteString(_m.Status) builder.WriteString(", ") builder.WriteString("result_value=") builder.WriteString(_m.ResultValue) builder.WriteString(", ") builder.WriteString("inspect_qty=") builder.WriteString(fmt.Sprintf("%v", _m.InspectQty)) builder.WriteString(", ") builder.WriteString("pass_qty=") builder.WriteString(fmt.Sprintf("%v", _m.PassQty)) builder.WriteString(", ") builder.WriteString("check_desc=") builder.WriteString(_m.CheckDesc) builder.WriteString(", ") builder.WriteString("fail_reason=") builder.WriteString(_m.FailReason) builder.WriteString(", ") builder.WriteString("inspector=") builder.WriteString(_m.Inspector) builder.WriteString(", ") builder.WriteString("remark=") builder.WriteString(_m.Remark) builder.WriteString(", ") builder.WriteString("created_at=") builder.WriteString(fmt.Sprintf("%v", _m.CreatedAt)) builder.WriteString(", ") builder.WriteString("updated_at=") builder.WriteString(fmt.Sprintf("%v", _m.UpdatedAt)) builder.WriteByte(')') return builder.String() } // InspectionRecords is a parsable slice of InspectionRecord. type InspectionRecords []*InspectionRecord