Files

175 lines
6.2 KiB
Go

// Code generated by ent, DO NOT EDIT.
package db
import (
"fmt"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/chaitin/MonkeyCode/backend/consts"
"github.com/chaitin/MonkeyCode/backend/db/notifysendlog"
"github.com/google/uuid"
)
// NotifySendLog is the model entity for the NotifySendLog schema.
type NotifySendLog struct {
config `json:"-"`
// ID of the ent.
ID uuid.UUID `json:"id,omitempty"`
// SubscriptionID holds the value of the "subscription_id" field.
SubscriptionID uuid.UUID `json:"subscription_id,omitempty"`
// ChannelID holds the value of the "channel_id" field.
ChannelID uuid.UUID `json:"channel_id,omitempty"`
// EventType holds the value of the "event_type" field.
EventType consts.NotifyEventType `json:"event_type,omitempty"`
// EventRefID holds the value of the "event_ref_id" field.
EventRefID string `json:"event_ref_id,omitempty"`
// Status holds the value of the "status" field.
Status consts.NotifySendStatus `json:"status,omitempty"`
// Error holds the value of the "error" field.
Error string `json:"error,omitempty"`
// CreatedAt holds the value of the "created_at" field.
CreatedAt time.Time `json:"created_at,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*NotifySendLog) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case notifysendlog.FieldEventType, notifysendlog.FieldEventRefID, notifysendlog.FieldStatus, notifysendlog.FieldError:
values[i] = new(sql.NullString)
case notifysendlog.FieldCreatedAt:
values[i] = new(sql.NullTime)
case notifysendlog.FieldID, notifysendlog.FieldSubscriptionID, notifysendlog.FieldChannelID:
values[i] = new(uuid.UUID)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the NotifySendLog fields.
func (_m *NotifySendLog) 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 notifysendlog.FieldID:
if value, ok := values[i].(*uuid.UUID); !ok {
return fmt.Errorf("unexpected type %T for field id", values[i])
} else if value != nil {
_m.ID = *value
}
case notifysendlog.FieldSubscriptionID:
if value, ok := values[i].(*uuid.UUID); !ok {
return fmt.Errorf("unexpected type %T for field subscription_id", values[i])
} else if value != nil {
_m.SubscriptionID = *value
}
case notifysendlog.FieldChannelID:
if value, ok := values[i].(*uuid.UUID); !ok {
return fmt.Errorf("unexpected type %T for field channel_id", values[i])
} else if value != nil {
_m.ChannelID = *value
}
case notifysendlog.FieldEventType:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field event_type", values[i])
} else if value.Valid {
_m.EventType = consts.NotifyEventType(value.String)
}
case notifysendlog.FieldEventRefID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field event_ref_id", values[i])
} else if value.Valid {
_m.EventRefID = value.String
}
case notifysendlog.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 = consts.NotifySendStatus(value.String)
}
case notifysendlog.FieldError:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field error", values[i])
} else if value.Valid {
_m.Error = value.String
}
case notifysendlog.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
_m.CreatedAt = value.Time
}
default:
_m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the NotifySendLog.
// This includes values selected through modifiers, order, etc.
func (_m *NotifySendLog) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// Update returns a builder for updating this NotifySendLog.
// Note that you need to call NotifySendLog.Unwrap() before calling this method if this NotifySendLog
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *NotifySendLog) Update() *NotifySendLogUpdateOne {
return NewNotifySendLogClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the NotifySendLog 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 *NotifySendLog) Unwrap() *NotifySendLog {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("db: NotifySendLog is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *NotifySendLog) String() string {
var builder strings.Builder
builder.WriteString("NotifySendLog(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("subscription_id=")
builder.WriteString(fmt.Sprintf("%v", _m.SubscriptionID))
builder.WriteString(", ")
builder.WriteString("channel_id=")
builder.WriteString(fmt.Sprintf("%v", _m.ChannelID))
builder.WriteString(", ")
builder.WriteString("event_type=")
builder.WriteString(fmt.Sprintf("%v", _m.EventType))
builder.WriteString(", ")
builder.WriteString("event_ref_id=")
builder.WriteString(_m.EventRefID)
builder.WriteString(", ")
builder.WriteString("status=")
builder.WriteString(fmt.Sprintf("%v", _m.Status))
builder.WriteString(", ")
builder.WriteString("error=")
builder.WriteString(_m.Error)
builder.WriteString(", ")
builder.WriteString("created_at=")
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
builder.WriteByte(')')
return builder.String()
}
// NotifySendLogs is a parsable slice of NotifySendLog.
type NotifySendLogs []*NotifySendLog