// Code generated by ent, DO NOT EDIT. package ent import ( "bj_power_wms/ent/alert" "fmt" "strings" "entgo.io/ent" "entgo.io/ent/dialect/sql" ) // Alert 预警实例:扫描器按规则产生,用户标记已读闭环 type Alert struct { config `json:"-"` // ID of the ent. ID int `json:"id,omitempty"` // 关联规则编码(固定五类) RuleCode string `json:"ruleCode,omitempty"` // 级别 info/warning/error Level string `json:"level,omitempty"` // 预警标题 Title string `json:"title,omitempty"` // 预警内容 Content string `json:"content,omitempty"` // 关联对象(物料编码/批次/SN/库存行ID等) Target string `json:"target,omitempty"` // 状态 unread/read Status string `json:"status,omitempty"` // 创建时间 CreatedAt int64 `json:"createdAt,omitempty"` // 更新时间 UpdatedAt int64 `json:"updatedAt,omitempty"` selectValues sql.SelectValues } // scanValues returns the types for scanning values from sql.Rows. func (*Alert) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case alert.FieldID, alert.FieldCreatedAt, alert.FieldUpdatedAt: values[i] = new(sql.NullInt64) case alert.FieldRuleCode, alert.FieldLevel, alert.FieldTitle, alert.FieldContent, alert.FieldTarget, alert.FieldStatus: 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 Alert fields. func (_m *Alert) 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 alert.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 alert.FieldRuleCode: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field rule_code", values[i]) } else if value.Valid { _m.RuleCode = value.String } case alert.FieldLevel: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field level", values[i]) } else if value.Valid { _m.Level = value.String } case alert.FieldTitle: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field title", values[i]) } else if value.Valid { _m.Title = value.String } case alert.FieldContent: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field content", values[i]) } else if value.Valid { _m.Content = value.String } case alert.FieldTarget: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field target", values[i]) } else if value.Valid { _m.Target = value.String } case alert.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 alert.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 alert.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 Alert. // This includes values selected through modifiers, order, etc. func (_m *Alert) Value(name string) (ent.Value, error) { return _m.selectValues.Get(name) } // Update returns a builder for updating this Alert. // Note that you need to call Alert.Unwrap() before calling this method if this Alert // was returned from a transaction, and the transaction was committed or rolled back. func (_m *Alert) Update() *AlertUpdateOne { return NewAlertClient(_m.config).UpdateOne(_m) } // Unwrap unwraps the Alert 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 *Alert) Unwrap() *Alert { _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: Alert is not a transactional entity") } _m.config.driver = _tx.drv return _m } // String implements the fmt.Stringer. func (_m *Alert) String() string { var builder strings.Builder builder.WriteString("Alert(") builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("rule_code=") builder.WriteString(_m.RuleCode) builder.WriteString(", ") builder.WriteString("level=") builder.WriteString(_m.Level) builder.WriteString(", ") builder.WriteString("title=") builder.WriteString(_m.Title) builder.WriteString(", ") builder.WriteString("content=") builder.WriteString(_m.Content) builder.WriteString(", ") builder.WriteString("target=") builder.WriteString(_m.Target) builder.WriteString(", ") builder.WriteString("status=") builder.WriteString(_m.Status) 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() } // Alerts is a parsable slice of Alert. type Alerts []*Alert