2026-08-28 15:06:01 +08:00
|
|
|
// Code generated by ent, DO NOT EDIT.
|
|
|
|
|
|
|
|
|
|
package ent
|
|
|
|
|
|
|
|
|
|
import (
|
2026-09-22 11:32:29 +08:00
|
|
|
"bj_power_mes/ent/stationstate"
|
2026-08-28 15:06:01 +08:00
|
|
|
"fmt"
|
|
|
|
|
"strings"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"entgo.io/ent"
|
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
|
|
|
)
|
|
|
|
|
|
2026-09-22 11:32:29 +08:00
|
|
|
// StationState is the model entity for the StationState schema.
|
|
|
|
|
type StationState struct {
|
2026-08-28 15:06:01 +08:00
|
|
|
config `json:"-"`
|
|
|
|
|
// ID of the ent.
|
|
|
|
|
ID int `json:"id,omitempty"`
|
2026-09-22 11:32:29 +08:00
|
|
|
// 工位号
|
2026-08-28 15:06:01 +08:00
|
|
|
StationNo int `json:"stationNo,omitempty"`
|
2026-09-22 11:32:29 +08:00
|
|
|
// 生效日期 yyyy-MM-dd(只认当天)
|
|
|
|
|
Date string `json:"date,omitempty"`
|
|
|
|
|
// 是否停止接单
|
|
|
|
|
Paused bool `json:"paused,omitempty"`
|
|
|
|
|
// 停单原因(缺料/故障/其他)
|
|
|
|
|
Reason string `json:"reason,omitempty"`
|
|
|
|
|
// 操作人
|
2026-08-28 15:06:01 +08:00
|
|
|
Operator string `json:"operator,omitempty"`
|
|
|
|
|
// CreatedAt holds the value of the "createdAt" field.
|
2026-09-22 11:32:29 +08:00
|
|
|
CreatedAt time.Time `json:"createdAt,omitempty"`
|
|
|
|
|
// UpdatedAt holds the value of the "updatedAt" field.
|
|
|
|
|
UpdatedAt *time.Time `json:"updatedAt,omitempty"`
|
2026-08-28 15:06:01 +08:00
|
|
|
selectValues sql.SelectValues
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
2026-09-22 11:32:29 +08:00
|
|
|
func (*StationState) scanValues(columns []string) ([]any, error) {
|
2026-08-28 15:06:01 +08:00
|
|
|
values := make([]any, len(columns))
|
|
|
|
|
for i := range columns {
|
|
|
|
|
switch columns[i] {
|
2026-09-22 11:32:29 +08:00
|
|
|
case stationstate.FieldPaused:
|
|
|
|
|
values[i] = new(sql.NullBool)
|
|
|
|
|
case stationstate.FieldID, stationstate.FieldStationNo:
|
2026-08-28 15:06:01 +08:00
|
|
|
values[i] = new(sql.NullInt64)
|
2026-09-22 11:32:29 +08:00
|
|
|
case stationstate.FieldDate, stationstate.FieldReason, stationstate.FieldOperator:
|
2026-08-28 15:06:01 +08:00
|
|
|
values[i] = new(sql.NullString)
|
2026-09-22 11:32:29 +08:00
|
|
|
case stationstate.FieldCreatedAt, stationstate.FieldUpdatedAt:
|
2026-08-28 15:06:01 +08:00
|
|
|
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)
|
2026-09-22 11:32:29 +08:00
|
|
|
// to the StationState fields.
|
|
|
|
|
func (_m *StationState) assignValues(columns []string, values []any) error {
|
2026-08-28 15:06:01 +08:00
|
|
|
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] {
|
2026-09-22 11:32:29 +08:00
|
|
|
case stationstate.FieldID:
|
2026-08-28 15:06:01 +08:00
|
|
|
value, ok := values[i].(*sql.NullInt64)
|
|
|
|
|
if !ok {
|
|
|
|
|
return fmt.Errorf("unexpected type %T for field id", value)
|
|
|
|
|
}
|
|
|
|
|
_m.ID = int(value.Int64)
|
2026-09-22 11:32:29 +08:00
|
|
|
case stationstate.FieldStationNo:
|
2026-08-28 15:06:01 +08:00
|
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
|
|
|
return fmt.Errorf("unexpected type %T for field stationNo", values[i])
|
|
|
|
|
} else if value.Valid {
|
|
|
|
|
_m.StationNo = int(value.Int64)
|
|
|
|
|
}
|
2026-09-22 11:32:29 +08:00
|
|
|
case stationstate.FieldDate:
|
|
|
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
|
|
|
return fmt.Errorf("unexpected type %T for field date", values[i])
|
2026-08-28 15:06:01 +08:00
|
|
|
} else if value.Valid {
|
2026-09-22 11:32:29 +08:00
|
|
|
_m.Date = value.String
|
2026-08-28 15:06:01 +08:00
|
|
|
}
|
2026-09-22 11:32:29 +08:00
|
|
|
case stationstate.FieldPaused:
|
|
|
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
|
|
|
return fmt.Errorf("unexpected type %T for field paused", values[i])
|
2026-08-28 15:06:01 +08:00
|
|
|
} else if value.Valid {
|
2026-09-22 11:32:29 +08:00
|
|
|
_m.Paused = value.Bool
|
2026-08-28 15:06:01 +08:00
|
|
|
}
|
2026-09-22 11:32:29 +08:00
|
|
|
case stationstate.FieldReason:
|
2026-08-28 15:06:01 +08:00
|
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
2026-09-22 11:32:29 +08:00
|
|
|
return fmt.Errorf("unexpected type %T for field reason", values[i])
|
2026-08-28 15:06:01 +08:00
|
|
|
} else if value.Valid {
|
2026-09-22 11:32:29 +08:00
|
|
|
_m.Reason = value.String
|
2026-08-28 15:06:01 +08:00
|
|
|
}
|
2026-09-22 11:32:29 +08:00
|
|
|
case stationstate.FieldOperator:
|
2026-08-28 15:06:01 +08:00
|
|
|
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
|
|
|
|
|
}
|
2026-09-22 11:32:29 +08:00
|
|
|
case stationstate.FieldCreatedAt:
|
2026-08-28 15:06:01 +08:00
|
|
|
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
|
|
|
|
|
}
|
2026-09-22 11:32:29 +08:00
|
|
|
case stationstate.FieldUpdatedAt:
|
|
|
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
|
|
|
return fmt.Errorf("unexpected type %T for field updatedAt", values[i])
|
|
|
|
|
} else if value.Valid {
|
|
|
|
|
_m.UpdatedAt = new(time.Time)
|
|
|
|
|
*_m.UpdatedAt = value.Time
|
|
|
|
|
}
|
2026-08-28 15:06:01 +08:00
|
|
|
default:
|
|
|
|
|
_m.selectValues.Set(columns[i], values[i])
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-22 11:32:29 +08:00
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the StationState.
|
2026-08-28 15:06:01 +08:00
|
|
|
// This includes values selected through modifiers, order, etc.
|
2026-09-22 11:32:29 +08:00
|
|
|
func (_m *StationState) Value(name string) (ent.Value, error) {
|
2026-08-28 15:06:01 +08:00
|
|
|
return _m.selectValues.Get(name)
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-22 11:32:29 +08:00
|
|
|
// Update returns a builder for updating this StationState.
|
|
|
|
|
// Note that you need to call StationState.Unwrap() before calling this method if this StationState
|
2026-08-28 15:06:01 +08:00
|
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
2026-09-22 11:32:29 +08:00
|
|
|
func (_m *StationState) Update() *StationStateUpdateOne {
|
|
|
|
|
return NewStationStateClient(_m.config).UpdateOne(_m)
|
2026-08-28 15:06:01 +08:00
|
|
|
}
|
|
|
|
|
|
2026-09-22 11:32:29 +08:00
|
|
|
// Unwrap unwraps the StationState entity that was returned from a transaction after it was closed,
|
2026-08-28 15:06:01 +08:00
|
|
|
// so that all future queries will be executed through the driver which created the transaction.
|
2026-09-22 11:32:29 +08:00
|
|
|
func (_m *StationState) Unwrap() *StationState {
|
2026-08-28 15:06:01 +08:00
|
|
|
_tx, ok := _m.config.driver.(*txDriver)
|
|
|
|
|
if !ok {
|
2026-09-22 11:32:29 +08:00
|
|
|
panic("ent: StationState is not a transactional entity")
|
2026-08-28 15:06:01 +08:00
|
|
|
}
|
|
|
|
|
_m.config.driver = _tx.drv
|
|
|
|
|
return _m
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// String implements the fmt.Stringer.
|
2026-09-22 11:32:29 +08:00
|
|
|
func (_m *StationState) String() string {
|
2026-08-28 15:06:01 +08:00
|
|
|
var builder strings.Builder
|
2026-09-22 11:32:29 +08:00
|
|
|
builder.WriteString("StationState(")
|
2026-08-28 15:06:01 +08:00
|
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
|
|
|
|
builder.WriteString("stationNo=")
|
|
|
|
|
builder.WriteString(fmt.Sprintf("%v", _m.StationNo))
|
|
|
|
|
builder.WriteString(", ")
|
2026-09-22 11:32:29 +08:00
|
|
|
builder.WriteString("date=")
|
|
|
|
|
builder.WriteString(_m.Date)
|
2026-08-28 15:06:01 +08:00
|
|
|
builder.WriteString(", ")
|
2026-09-22 11:32:29 +08:00
|
|
|
builder.WriteString("paused=")
|
|
|
|
|
builder.WriteString(fmt.Sprintf("%v", _m.Paused))
|
2026-08-28 15:06:01 +08:00
|
|
|
builder.WriteString(", ")
|
2026-09-22 11:32:29 +08:00
|
|
|
builder.WriteString("reason=")
|
|
|
|
|
builder.WriteString(_m.Reason)
|
2026-08-28 15:06:01 +08:00
|
|
|
builder.WriteString(", ")
|
|
|
|
|
builder.WriteString("operator=")
|
|
|
|
|
builder.WriteString(_m.Operator)
|
|
|
|
|
builder.WriteString(", ")
|
|
|
|
|
builder.WriteString("createdAt=")
|
|
|
|
|
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
2026-09-22 11:32:29 +08:00
|
|
|
builder.WriteString(", ")
|
|
|
|
|
if v := _m.UpdatedAt; v != nil {
|
|
|
|
|
builder.WriteString("updatedAt=")
|
|
|
|
|
builder.WriteString(v.Format(time.ANSIC))
|
|
|
|
|
}
|
2026-08-28 15:06:01 +08:00
|
|
|
builder.WriteByte(')')
|
|
|
|
|
return builder.String()
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-22 11:32:29 +08:00
|
|
|
// StationStates is a parsable slice of StationState.
|
|
|
|
|
type StationStates []*StationState
|