285 lines
9.6 KiB
Go
285 lines
9.6 KiB
Go
// Code generated by entc, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"time"
|
|
|
|
"code.icod.de/postfix/manager/ent/domain"
|
|
"entgo.io/ent/dialect/sql"
|
|
)
|
|
|
|
// Domain is the model entity for the Domain schema.
|
|
type Domain struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID int64 `json:"id,omitempty"`
|
|
// Created holds the value of the "created" field.
|
|
Created time.Time `json:"created,omitempty"`
|
|
// Modified holds the value of the "modified" field.
|
|
Modified *time.Time `json:"modified,omitempty"`
|
|
// Domain holds the value of the "domain" field.
|
|
Domain string `json:"domain,omitempty"`
|
|
// Description holds the value of the "description" field.
|
|
Description *string `json:"description,omitempty"`
|
|
// MaxAliases holds the value of the "max_aliases" field.
|
|
MaxAliases int64 `json:"max_aliases,omitempty"`
|
|
// MaxMailboxes holds the value of the "max_mailboxes" field.
|
|
MaxMailboxes int64 `json:"max_mailboxes,omitempty"`
|
|
// MaxQuota holds the value of the "max_quota" field.
|
|
MaxQuota int64 `json:"max_quota,omitempty"`
|
|
// Quota holds the value of the "quota" field.
|
|
Quota int64 `json:"quota,omitempty"`
|
|
// Transport holds the value of the "transport" field.
|
|
Transport string `json:"transport,omitempty"`
|
|
// BackupMx holds the value of the "backup_mx" field.
|
|
BackupMx bool `json:"backup_mx,omitempty"`
|
|
// Active holds the value of the "active" field.
|
|
Active bool `json:"active,omitempty"`
|
|
// Edges holds the relations/edges for other nodes in the graph.
|
|
// The values are being populated by the DomainQuery when eager-loading is set.
|
|
Edges DomainEdges `json:"edges"`
|
|
}
|
|
|
|
// DomainEdges holds the relations/edges for other nodes in the graph.
|
|
type DomainEdges struct {
|
|
// Mailboxes holds the value of the mailboxes edge.
|
|
Mailboxes []*Mailbox `json:"mailboxes,omitempty"`
|
|
// Aliases holds the value of the aliases edge.
|
|
Aliases []*Alias `json:"aliases,omitempty"`
|
|
// Logs holds the value of the logs edge.
|
|
Logs []*Logentry `json:"logs,omitempty"`
|
|
// Accounts holds the value of the accounts edge.
|
|
Accounts []*Account `json:"accounts,omitempty"`
|
|
// loadedTypes holds the information for reporting if a
|
|
// type was loaded (or requested) in eager-loading or not.
|
|
loadedTypes [4]bool
|
|
}
|
|
|
|
// MailboxesOrErr returns the Mailboxes value or an error if the edge
|
|
// was not loaded in eager-loading.
|
|
func (e DomainEdges) MailboxesOrErr() ([]*Mailbox, error) {
|
|
if e.loadedTypes[0] {
|
|
return e.Mailboxes, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "mailboxes"}
|
|
}
|
|
|
|
// AliasesOrErr returns the Aliases value or an error if the edge
|
|
// was not loaded in eager-loading.
|
|
func (e DomainEdges) AliasesOrErr() ([]*Alias, error) {
|
|
if e.loadedTypes[1] {
|
|
return e.Aliases, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "aliases"}
|
|
}
|
|
|
|
// LogsOrErr returns the Logs value or an error if the edge
|
|
// was not loaded in eager-loading.
|
|
func (e DomainEdges) LogsOrErr() ([]*Logentry, error) {
|
|
if e.loadedTypes[2] {
|
|
return e.Logs, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "logs"}
|
|
}
|
|
|
|
// AccountsOrErr returns the Accounts value or an error if the edge
|
|
// was not loaded in eager-loading.
|
|
func (e DomainEdges) AccountsOrErr() ([]*Account, error) {
|
|
if e.loadedTypes[3] {
|
|
return e.Accounts, nil
|
|
}
|
|
return nil, &NotLoadedError{edge: "accounts"}
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*Domain) scanValues(columns []string) ([]interface{}, error) {
|
|
values := make([]interface{}, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case domain.FieldBackupMx, domain.FieldActive:
|
|
values[i] = new(sql.NullBool)
|
|
case domain.FieldID, domain.FieldMaxAliases, domain.FieldMaxMailboxes, domain.FieldMaxQuota, domain.FieldQuota:
|
|
values[i] = new(sql.NullInt64)
|
|
case domain.FieldDomain, domain.FieldDescription, domain.FieldTransport:
|
|
values[i] = new(sql.NullString)
|
|
case domain.FieldCreated, domain.FieldModified:
|
|
values[i] = new(sql.NullTime)
|
|
default:
|
|
return nil, fmt.Errorf("unexpected column %q for type Domain", columns[i])
|
|
}
|
|
}
|
|
return values, nil
|
|
}
|
|
|
|
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
|
// to the Domain fields.
|
|
func (d *Domain) assignValues(columns []string, values []interface{}) 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 domain.FieldID:
|
|
value, ok := values[i].(*sql.NullInt64)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", value)
|
|
}
|
|
d.ID = int64(value.Int64)
|
|
case domain.FieldCreated:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field created", values[i])
|
|
} else if value.Valid {
|
|
d.Created = value.Time
|
|
}
|
|
case domain.FieldModified:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field modified", values[i])
|
|
} else if value.Valid {
|
|
d.Modified = new(time.Time)
|
|
*d.Modified = value.Time
|
|
}
|
|
case domain.FieldDomain:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field domain", values[i])
|
|
} else if value.Valid {
|
|
d.Domain = value.String
|
|
}
|
|
case domain.FieldDescription:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field description", values[i])
|
|
} else if value.Valid {
|
|
d.Description = new(string)
|
|
*d.Description = value.String
|
|
}
|
|
case domain.FieldMaxAliases:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field max_aliases", values[i])
|
|
} else if value.Valid {
|
|
d.MaxAliases = value.Int64
|
|
}
|
|
case domain.FieldMaxMailboxes:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field max_mailboxes", values[i])
|
|
} else if value.Valid {
|
|
d.MaxMailboxes = value.Int64
|
|
}
|
|
case domain.FieldMaxQuota:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field max_quota", values[i])
|
|
} else if value.Valid {
|
|
d.MaxQuota = value.Int64
|
|
}
|
|
case domain.FieldQuota:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field quota", values[i])
|
|
} else if value.Valid {
|
|
d.Quota = value.Int64
|
|
}
|
|
case domain.FieldTransport:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field transport", values[i])
|
|
} else if value.Valid {
|
|
d.Transport = value.String
|
|
}
|
|
case domain.FieldBackupMx:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field backup_mx", values[i])
|
|
} else if value.Valid {
|
|
d.BackupMx = value.Bool
|
|
}
|
|
case domain.FieldActive:
|
|
if value, ok := values[i].(*sql.NullBool); !ok {
|
|
return fmt.Errorf("unexpected type %T for field active", values[i])
|
|
} else if value.Valid {
|
|
d.Active = value.Bool
|
|
}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// QueryMailboxes queries the "mailboxes" edge of the Domain entity.
|
|
func (d *Domain) QueryMailboxes() *MailboxQuery {
|
|
return (&DomainClient{config: d.config}).QueryMailboxes(d)
|
|
}
|
|
|
|
// QueryAliases queries the "aliases" edge of the Domain entity.
|
|
func (d *Domain) QueryAliases() *AliasQuery {
|
|
return (&DomainClient{config: d.config}).QueryAliases(d)
|
|
}
|
|
|
|
// QueryLogs queries the "logs" edge of the Domain entity.
|
|
func (d *Domain) QueryLogs() *LogentryQuery {
|
|
return (&DomainClient{config: d.config}).QueryLogs(d)
|
|
}
|
|
|
|
// QueryAccounts queries the "accounts" edge of the Domain entity.
|
|
func (d *Domain) QueryAccounts() *AccountQuery {
|
|
return (&DomainClient{config: d.config}).QueryAccounts(d)
|
|
}
|
|
|
|
// Update returns a builder for updating this Domain.
|
|
// Note that you need to call Domain.Unwrap() before calling this method if this Domain
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (d *Domain) Update() *DomainUpdateOne {
|
|
return (&DomainClient{config: d.config}).UpdateOne(d)
|
|
}
|
|
|
|
// Unwrap unwraps the Domain 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 (d *Domain) Unwrap() *Domain {
|
|
tx, ok := d.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: Domain is not a transactional entity")
|
|
}
|
|
d.config.driver = tx.drv
|
|
return d
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (d *Domain) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("Domain(")
|
|
builder.WriteString(fmt.Sprintf("id=%v", d.ID))
|
|
builder.WriteString(", created=")
|
|
builder.WriteString(d.Created.Format(time.ANSIC))
|
|
if v := d.Modified; v != nil {
|
|
builder.WriteString(", modified=")
|
|
builder.WriteString(v.Format(time.ANSIC))
|
|
}
|
|
builder.WriteString(", domain=")
|
|
builder.WriteString(d.Domain)
|
|
if v := d.Description; v != nil {
|
|
builder.WriteString(", description=")
|
|
builder.WriteString(*v)
|
|
}
|
|
builder.WriteString(", max_aliases=")
|
|
builder.WriteString(fmt.Sprintf("%v", d.MaxAliases))
|
|
builder.WriteString(", max_mailboxes=")
|
|
builder.WriteString(fmt.Sprintf("%v", d.MaxMailboxes))
|
|
builder.WriteString(", max_quota=")
|
|
builder.WriteString(fmt.Sprintf("%v", d.MaxQuota))
|
|
builder.WriteString(", quota=")
|
|
builder.WriteString(fmt.Sprintf("%v", d.Quota))
|
|
builder.WriteString(", transport=")
|
|
builder.WriteString(d.Transport)
|
|
builder.WriteString(", backup_mx=")
|
|
builder.WriteString(fmt.Sprintf("%v", d.BackupMx))
|
|
builder.WriteString(", active=")
|
|
builder.WriteString(fmt.Sprintf("%v", d.Active))
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// Domains is a parsable slice of Domain.
|
|
type Domains []*Domain
|
|
|
|
func (d Domains) config(cfg config) {
|
|
for _i := range d {
|
|
d[_i].config = cfg
|
|
}
|
|
}
|