Init V4 community edition (#2265)
* Init V4 community edition * Init V4 community edition
This commit is contained in:
212
ent/directlink.go
Normal file
212
ent/directlink.go
Normal file
@@ -0,0 +1,212 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package ent
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"github.com/cloudreve/Cloudreve/v4/ent/directlink"
|
||||
"github.com/cloudreve/Cloudreve/v4/ent/file"
|
||||
)
|
||||
|
||||
// DirectLink is the model entity for the DirectLink schema.
|
||||
type DirectLink struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// CreatedAt holds the value of the "created_at" field.
|
||||
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||
// UpdatedAt holds the value of the "updated_at" field.
|
||||
UpdatedAt time.Time `json:"updated_at,omitempty"`
|
||||
// DeletedAt holds the value of the "deleted_at" field.
|
||||
DeletedAt *time.Time `json:"deleted_at,omitempty"`
|
||||
// Name holds the value of the "name" field.
|
||||
Name string `json:"name,omitempty"`
|
||||
// Downloads holds the value of the "downloads" field.
|
||||
Downloads int `json:"downloads,omitempty"`
|
||||
// FileID holds the value of the "file_id" field.
|
||||
FileID int `json:"file_id,omitempty"`
|
||||
// Speed holds the value of the "speed" field.
|
||||
Speed int `json:"speed,omitempty"`
|
||||
// Edges holds the relations/edges for other nodes in the graph.
|
||||
// The values are being populated by the DirectLinkQuery when eager-loading is set.
|
||||
Edges DirectLinkEdges `json:"edges"`
|
||||
selectValues sql.SelectValues
|
||||
}
|
||||
|
||||
// DirectLinkEdges holds the relations/edges for other nodes in the graph.
|
||||
type DirectLinkEdges struct {
|
||||
// File holds the value of the file edge.
|
||||
File *File `json:"file,omitempty"`
|
||||
// loadedTypes holds the information for reporting if a
|
||||
// type was loaded (or requested) in eager-loading or not.
|
||||
loadedTypes [1]bool
|
||||
}
|
||||
|
||||
// FileOrErr returns the File value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e DirectLinkEdges) FileOrErr() (*File, error) {
|
||||
if e.loadedTypes[0] {
|
||||
if e.File == nil {
|
||||
// Edge was loaded but was not found.
|
||||
return nil, &NotFoundError{label: file.Label}
|
||||
}
|
||||
return e.File, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "file"}
|
||||
}
|
||||
|
||||
// scanValues returns the types for scanning values from sql.Rows.
|
||||
func (*DirectLink) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case directlink.FieldID, directlink.FieldDownloads, directlink.FieldFileID, directlink.FieldSpeed:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case directlink.FieldName:
|
||||
values[i] = new(sql.NullString)
|
||||
case directlink.FieldCreatedAt, directlink.FieldUpdatedAt, directlink.FieldDeletedAt:
|
||||
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 DirectLink fields.
|
||||
func (dl *DirectLink) 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 directlink.FieldID:
|
||||
value, ok := values[i].(*sql.NullInt64)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
dl.ID = int(value.Int64)
|
||||
case directlink.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 {
|
||||
dl.CreatedAt = value.Time
|
||||
}
|
||||
case directlink.FieldUpdatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
|
||||
} else if value.Valid {
|
||||
dl.UpdatedAt = value.Time
|
||||
}
|
||||
case directlink.FieldDeletedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
|
||||
} else if value.Valid {
|
||||
dl.DeletedAt = new(time.Time)
|
||||
*dl.DeletedAt = value.Time
|
||||
}
|
||||
case directlink.FieldName:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field name", values[i])
|
||||
} else if value.Valid {
|
||||
dl.Name = value.String
|
||||
}
|
||||
case directlink.FieldDownloads:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field downloads", values[i])
|
||||
} else if value.Valid {
|
||||
dl.Downloads = int(value.Int64)
|
||||
}
|
||||
case directlink.FieldFileID:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field file_id", values[i])
|
||||
} else if value.Valid {
|
||||
dl.FileID = int(value.Int64)
|
||||
}
|
||||
case directlink.FieldSpeed:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field speed", values[i])
|
||||
} else if value.Valid {
|
||||
dl.Speed = int(value.Int64)
|
||||
}
|
||||
default:
|
||||
dl.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the DirectLink.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (dl *DirectLink) Value(name string) (ent.Value, error) {
|
||||
return dl.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryFile queries the "file" edge of the DirectLink entity.
|
||||
func (dl *DirectLink) QueryFile() *FileQuery {
|
||||
return NewDirectLinkClient(dl.config).QueryFile(dl)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this DirectLink.
|
||||
// Note that you need to call DirectLink.Unwrap() before calling this method if this DirectLink
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (dl *DirectLink) Update() *DirectLinkUpdateOne {
|
||||
return NewDirectLinkClient(dl.config).UpdateOne(dl)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the DirectLink 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 (dl *DirectLink) Unwrap() *DirectLink {
|
||||
_tx, ok := dl.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: DirectLink is not a transactional entity")
|
||||
}
|
||||
dl.config.driver = _tx.drv
|
||||
return dl
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (dl *DirectLink) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("DirectLink(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", dl.ID))
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(dl.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("updated_at=")
|
||||
builder.WriteString(dl.UpdatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
if v := dl.DeletedAt; v != nil {
|
||||
builder.WriteString("deleted_at=")
|
||||
builder.WriteString(v.Format(time.ANSIC))
|
||||
}
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("name=")
|
||||
builder.WriteString(dl.Name)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("downloads=")
|
||||
builder.WriteString(fmt.Sprintf("%v", dl.Downloads))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("file_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", dl.FileID))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("speed=")
|
||||
builder.WriteString(fmt.Sprintf("%v", dl.Speed))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
// SetFile manually set the edge as loaded state.
|
||||
func (e *DirectLink) SetFile(v *File) {
|
||||
e.Edges.File = v
|
||||
e.Edges.loadedTypes[0] = true
|
||||
}
|
||||
|
||||
// DirectLinks is a parsable slice of DirectLink.
|
||||
type DirectLinks []*DirectLink
|
||||
Reference in New Issue
Block a user