172 lines
5.9 KiB
Go
172 lines
5.9 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|||
|
|
|
||
|
|
package ent
|
||
|
|
|
||
|
|
import (
|
||
|
|
"bj_power_mes/ent/stationterminalevent"
|
||
|
|
"fmt"
|
||
|
|
"strings"
|
||
|
|
|
||
|
|
"entgo.io/ent"
|
||
|
|
"entgo.io/ent/dialect/sql"
|
||
|
|
)
|
||
|
|
|
||
|
|
// StationTerminalEvent 工位终端状态变化流水(只增)。
|
||
|
|
type StationTerminalEvent struct {
|
||
|
|
config `json:"-"`
|
||
|
|
// ID of the ent.
|
||
|
|
ID int `json:"id,omitempty"`
|
||
|
|
// 工位号
|
||
|
|
StationNo int `json:"stationNo,omitempty"`
|
||
|
|
// 事件:stream_on/stream_off/login/logout/pause/resume/heartbeat
|
||
|
|
Event string `json:"event,omitempty"`
|
||
|
|
// 事件后登录态
|
||
|
|
LoggedIn bool `json:"loggedIn,omitempty"`
|
||
|
|
// 事件后开机态
|
||
|
|
Powered bool `json:"powered,omitempty"`
|
||
|
|
// 操作人
|
||
|
|
Operator string `json:"operator,omitempty"`
|
||
|
|
// 补充说明
|
||
|
|
Detail string `json:"detail,omitempty"`
|
||
|
|
// 事件时间 unix秒
|
||
|
|
CreatedAt int64 `json:"createdAt,omitempty"`
|
||
|
|
selectValues sql.SelectValues
|
||
|
|
}
|
||
|
|
|
||
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
||
|
|
func (*StationTerminalEvent) scanValues(columns []string) ([]any, error) {
|
||
|
|
values := make([]any, len(columns))
|
||
|
|
for i := range columns {
|
||
|
|
switch columns[i] {
|
||
|
|
case stationterminalevent.FieldLoggedIn, stationterminalevent.FieldPowered:
|
||
|
|
values[i] = new(sql.NullBool)
|
||
|
|
case stationterminalevent.FieldID, stationterminalevent.FieldStationNo, stationterminalevent.FieldCreatedAt:
|
||
|
|
values[i] = new(sql.NullInt64)
|
||
|
|
case stationterminalevent.FieldEvent, stationterminalevent.FieldOperator, stationterminalevent.FieldDetail:
|
||
|
|
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 StationTerminalEvent fields.
|
||
|
|
func (_m *StationTerminalEvent) 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 stationterminalevent.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 stationterminalevent.FieldStationNo:
|
||
|
|
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)
|
||
|
|
}
|
||
|
|
case stationterminalevent.FieldEvent:
|
||
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||
|
|
return fmt.Errorf("unexpected type %T for field event", values[i])
|
||
|
|
} else if value.Valid {
|
||
|
|
_m.Event = value.String
|
||
|
|
}
|
||
|
|
case stationterminalevent.FieldLoggedIn:
|
||
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
||
|
|
return fmt.Errorf("unexpected type %T for field loggedIn", values[i])
|
||
|
|
} else if value.Valid {
|
||
|
|
_m.LoggedIn = value.Bool
|
||
|
|
}
|
||
|
|
case stationterminalevent.FieldPowered:
|
||
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
||
|
|
return fmt.Errorf("unexpected type %T for field powered", values[i])
|
||
|
|
} else if value.Valid {
|
||
|
|
_m.Powered = value.Bool
|
||
|
|
}
|
||
|
|
case stationterminalevent.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 stationterminalevent.FieldDetail:
|
||
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
||
|
|
return fmt.Errorf("unexpected type %T for field detail", values[i])
|
||
|
|
} else if value.Valid {
|
||
|
|
_m.Detail = value.String
|
||
|
|
}
|
||
|
|
case stationterminalevent.FieldCreatedAt:
|
||
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||
|
|
return fmt.Errorf("unexpected type %T for field createdAt", 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 StationTerminalEvent.
|
||
|
|
// This includes values selected through modifiers, order, etc.
|
||
|
|
func (_m *StationTerminalEvent) Value(name string) (ent.Value, error) {
|
||
|
|
return _m.selectValues.Get(name)
|
||
|
|
}
|
||
|
|
|
||
|
|
// Update returns a builder for updating this StationTerminalEvent.
|
||
|
|
// Note that you need to call StationTerminalEvent.Unwrap() before calling this method if this StationTerminalEvent
|
||
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
||
|
|
func (_m *StationTerminalEvent) Update() *StationTerminalEventUpdateOne {
|
||
|
|
return NewStationTerminalEventClient(_m.config).UpdateOne(_m)
|
||
|
|
}
|
||
|
|
|
||
|
|
// Unwrap unwraps the StationTerminalEvent 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 *StationTerminalEvent) Unwrap() *StationTerminalEvent {
|
||
|
|
_tx, ok := _m.config.driver.(*txDriver)
|
||
|
|
if !ok {
|
||
|
|
panic("ent: StationTerminalEvent is not a transactional entity")
|
||
|
|
}
|
||
|
|
_m.config.driver = _tx.drv
|
||
|
|
return _m
|
||
|
|
}
|
||
|
|
|
||
|
|
// String implements the fmt.Stringer.
|
||
|
|
func (_m *StationTerminalEvent) String() string {
|
||
|
|
var builder strings.Builder
|
||
|
|
builder.WriteString("StationTerminalEvent(")
|
||
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||
|
|
builder.WriteString("stationNo=")
|
||
|
|
builder.WriteString(fmt.Sprintf("%v", _m.StationNo))
|
||
|
|
builder.WriteString(", ")
|
||
|
|
builder.WriteString("event=")
|
||
|
|
builder.WriteString(_m.Event)
|
||
|
|
builder.WriteString(", ")
|
||
|
|
builder.WriteString("loggedIn=")
|
||
|
|
builder.WriteString(fmt.Sprintf("%v", _m.LoggedIn))
|
||
|
|
builder.WriteString(", ")
|
||
|
|
builder.WriteString("powered=")
|
||
|
|
builder.WriteString(fmt.Sprintf("%v", _m.Powered))
|
||
|
|
builder.WriteString(", ")
|
||
|
|
builder.WriteString("operator=")
|
||
|
|
builder.WriteString(_m.Operator)
|
||
|
|
builder.WriteString(", ")
|
||
|
|
builder.WriteString("detail=")
|
||
|
|
builder.WriteString(_m.Detail)
|
||
|
|
builder.WriteString(", ")
|
||
|
|
builder.WriteString("createdAt=")
|
||
|
|
builder.WriteString(fmt.Sprintf("%v", _m.CreatedAt))
|
||
|
|
builder.WriteByte(')')
|
||
|
|
return builder.String()
|
||
|
|
}
|
||
|
|
|
||
|
|
// StationTerminalEvents is a parsable slice of StationTerminalEvent.
|
||
|
|
type StationTerminalEvents []*StationTerminalEvent
|