Files
2024-06-14 09:40:50 -04:00

253 lines
9.2 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"fmt"
"registry-backend/ent/publisher"
"registry-backend/ent/schema"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// Publisher is the model entity for the Publisher schema.
type Publisher struct {
config `json:"-"`
// ID of the ent.
// The unique identifier of the publisher. Cannot be changed.
ID string `json:"id,omitempty"`
// CreateTime holds the value of the "create_time" field.
CreateTime time.Time `json:"create_time,omitempty"`
// UpdateTime holds the value of the "update_time" field.
UpdateTime time.Time `json:"update_time,omitempty"`
// The publicly visible name of the publisher.
Name string `json:"name,omitempty"`
// Description holds the value of the "description" field.
Description string `json:"description,omitempty"`
// Website holds the value of the "website" field.
Website string `json:"website,omitempty"`
// SupportEmail holds the value of the "support_email" field.
SupportEmail string `json:"support_email,omitempty"`
// SourceCodeRepo holds the value of the "source_code_repo" field.
SourceCodeRepo string `json:"source_code_repo,omitempty"`
// LogoURL holds the value of the "logo_url" field.
LogoURL string `json:"logo_url,omitempty"`
// Status holds the value of the "status" field.
Status schema.PublisherStatusType `json:"status,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the PublisherQuery when eager-loading is set.
Edges PublisherEdges `json:"edges"`
selectValues sql.SelectValues
}
// PublisherEdges holds the relations/edges for other nodes in the graph.
type PublisherEdges struct {
// PublisherPermissions holds the value of the publisher_permissions edge.
PublisherPermissions []*PublisherPermission `json:"publisher_permissions,omitempty"`
// Nodes holds the value of the nodes edge.
Nodes []*Node `json:"nodes,omitempty"`
// PersonalAccessTokens holds the value of the personal_access_tokens edge.
PersonalAccessTokens []*PersonalAccessToken `json:"personal_access_tokens,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [3]bool
}
// PublisherPermissionsOrErr returns the PublisherPermissions value or an error if the edge
// was not loaded in eager-loading.
func (e PublisherEdges) PublisherPermissionsOrErr() ([]*PublisherPermission, error) {
if e.loadedTypes[0] {
return e.PublisherPermissions, nil
}
return nil, &NotLoadedError{edge: "publisher_permissions"}
}
// NodesOrErr returns the Nodes value or an error if the edge
// was not loaded in eager-loading.
func (e PublisherEdges) NodesOrErr() ([]*Node, error) {
if e.loadedTypes[1] {
return e.Nodes, nil
}
return nil, &NotLoadedError{edge: "nodes"}
}
// PersonalAccessTokensOrErr returns the PersonalAccessTokens value or an error if the edge
// was not loaded in eager-loading.
func (e PublisherEdges) PersonalAccessTokensOrErr() ([]*PersonalAccessToken, error) {
if e.loadedTypes[2] {
return e.PersonalAccessTokens, nil
}
return nil, &NotLoadedError{edge: "personal_access_tokens"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Publisher) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case publisher.FieldID, publisher.FieldName, publisher.FieldDescription, publisher.FieldWebsite, publisher.FieldSupportEmail, publisher.FieldSourceCodeRepo, publisher.FieldLogoURL, publisher.FieldStatus:
values[i] = new(sql.NullString)
case publisher.FieldCreateTime, publisher.FieldUpdateTime:
values[i] = new(sql.NullTime)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the Publisher fields.
func (pu *Publisher) 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 publisher.FieldID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field id", values[i])
} else if value.Valid {
pu.ID = value.String
}
case publisher.FieldCreateTime:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field create_time", values[i])
} else if value.Valid {
pu.CreateTime = value.Time
}
case publisher.FieldUpdateTime:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field update_time", values[i])
} else if value.Valid {
pu.UpdateTime = value.Time
}
case publisher.FieldName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field name", values[i])
} else if value.Valid {
pu.Name = value.String
}
case publisher.FieldDescription:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field description", values[i])
} else if value.Valid {
pu.Description = value.String
}
case publisher.FieldWebsite:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field website", values[i])
} else if value.Valid {
pu.Website = value.String
}
case publisher.FieldSupportEmail:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field support_email", values[i])
} else if value.Valid {
pu.SupportEmail = value.String
}
case publisher.FieldSourceCodeRepo:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field source_code_repo", values[i])
} else if value.Valid {
pu.SourceCodeRepo = value.String
}
case publisher.FieldLogoURL:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field logo_url", values[i])
} else if value.Valid {
pu.LogoURL = value.String
}
case publisher.FieldStatus:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field status", values[i])
} else if value.Valid {
pu.Status = schema.PublisherStatusType(value.String)
}
default:
pu.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the Publisher.
// This includes values selected through modifiers, order, etc.
func (pu *Publisher) Value(name string) (ent.Value, error) {
return pu.selectValues.Get(name)
}
// QueryPublisherPermissions queries the "publisher_permissions" edge of the Publisher entity.
func (pu *Publisher) QueryPublisherPermissions() *PublisherPermissionQuery {
return NewPublisherClient(pu.config).QueryPublisherPermissions(pu)
}
// QueryNodes queries the "nodes" edge of the Publisher entity.
func (pu *Publisher) QueryNodes() *NodeQuery {
return NewPublisherClient(pu.config).QueryNodes(pu)
}
// QueryPersonalAccessTokens queries the "personal_access_tokens" edge of the Publisher entity.
func (pu *Publisher) QueryPersonalAccessTokens() *PersonalAccessTokenQuery {
return NewPublisherClient(pu.config).QueryPersonalAccessTokens(pu)
}
// Update returns a builder for updating this Publisher.
// Note that you need to call Publisher.Unwrap() before calling this method if this Publisher
// was returned from a transaction, and the transaction was committed or rolled back.
func (pu *Publisher) Update() *PublisherUpdateOne {
return NewPublisherClient(pu.config).UpdateOne(pu)
}
// Unwrap unwraps the Publisher 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 (pu *Publisher) Unwrap() *Publisher {
_tx, ok := pu.config.driver.(*txDriver)
if !ok {
panic("ent: Publisher is not a transactional entity")
}
pu.config.driver = _tx.drv
return pu
}
// String implements the fmt.Stringer.
func (pu *Publisher) String() string {
var builder strings.Builder
builder.WriteString("Publisher(")
builder.WriteString(fmt.Sprintf("id=%v, ", pu.ID))
builder.WriteString("create_time=")
builder.WriteString(pu.CreateTime.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("update_time=")
builder.WriteString(pu.UpdateTime.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("name=")
builder.WriteString(pu.Name)
builder.WriteString(", ")
builder.WriteString("description=")
builder.WriteString(pu.Description)
builder.WriteString(", ")
builder.WriteString("website=")
builder.WriteString(pu.Website)
builder.WriteString(", ")
builder.WriteString("support_email=")
builder.WriteString(pu.SupportEmail)
builder.WriteString(", ")
builder.WriteString("source_code_repo=")
builder.WriteString(pu.SourceCodeRepo)
builder.WriteString(", ")
builder.WriteString("logo_url=")
builder.WriteString(pu.LogoURL)
builder.WriteString(", ")
builder.WriteString("status=")
builder.WriteString(fmt.Sprintf("%v", pu.Status))
builder.WriteByte(')')
return builder.String()
}
// Publishers is a parsable slice of Publisher.
type Publishers []*Publisher