Files
polaris/ent/notificationclient.go
2024-07-29 15:56:29 +08:00

139 lines
4.6 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"polaris/ent/notificationclient"
"strings"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// NotificationClient is the model entity for the NotificationClient schema.
type NotificationClient struct {
config `json:"-"`
// ID of the ent.
ID int `json:"id,omitempty"`
// Name holds the value of the "name" field.
Name string `json:"name,omitempty"`
// Service holds the value of the "service" field.
Service string `json:"service,omitempty"`
// Settings holds the value of the "settings" field.
Settings string `json:"settings,omitempty"`
// Enabled holds the value of the "enabled" field.
Enabled bool `json:"enabled,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*NotificationClient) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case notificationclient.FieldEnabled:
values[i] = new(sql.NullBool)
case notificationclient.FieldID:
values[i] = new(sql.NullInt64)
case notificationclient.FieldName, notificationclient.FieldService, notificationclient.FieldSettings:
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 NotificationClient fields.
func (nc *NotificationClient) 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 notificationclient.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
nc.ID = int(value.Int64)
case notificationclient.FieldName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field name", values[i])
} else if value.Valid {
nc.Name = value.String
}
case notificationclient.FieldService:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field service", values[i])
} else if value.Valid {
nc.Service = value.String
}
case notificationclient.FieldSettings:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field settings", values[i])
} else if value.Valid {
nc.Settings = value.String
}
case notificationclient.FieldEnabled:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field enabled", values[i])
} else if value.Valid {
nc.Enabled = value.Bool
}
default:
nc.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the NotificationClient.
// This includes values selected through modifiers, order, etc.
func (nc *NotificationClient) Value(name string) (ent.Value, error) {
return nc.selectValues.Get(name)
}
// Update returns a builder for updating this NotificationClient.
// Note that you need to call NotificationClient.Unwrap() before calling this method if this NotificationClient
// was returned from a transaction, and the transaction was committed or rolled back.
func (nc *NotificationClient) Update() *NotificationClientUpdateOne {
return NewNotificationClientClient(nc.config).UpdateOne(nc)
}
// Unwrap unwraps the NotificationClient 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 (nc *NotificationClient) Unwrap() *NotificationClient {
_tx, ok := nc.config.driver.(*txDriver)
if !ok {
panic("ent: NotificationClient is not a transactional entity")
}
nc.config.driver = _tx.drv
return nc
}
// String implements the fmt.Stringer.
func (nc *NotificationClient) String() string {
var builder strings.Builder
builder.WriteString("NotificationClient(")
builder.WriteString(fmt.Sprintf("id=%v, ", nc.ID))
builder.WriteString("name=")
builder.WriteString(nc.Name)
builder.WriteString(", ")
builder.WriteString("service=")
builder.WriteString(nc.Service)
builder.WriteString(", ")
builder.WriteString("settings=")
builder.WriteString(nc.Settings)
builder.WriteString(", ")
builder.WriteString("enabled=")
builder.WriteString(fmt.Sprintf("%v", nc.Enabled))
builder.WriteByte(')')
return builder.String()
}
// NotificationClients is a parsable slice of NotificationClient.
type NotificationClients []*NotificationClient