mirror of
https://github.com/simon-ding/polaris.git
synced 2026-02-06 23:21:00 +08:00
217 lines
7.4 KiB
Go
217 lines
7.4 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"fmt"
|
|
"polaris/ent/history"
|
|
"strings"
|
|
"time"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
)
|
|
|
|
// History is the model entity for the History schema.
|
|
type History struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID int `json:"id,omitempty"`
|
|
// MediaID holds the value of the "media_id" field.
|
|
MediaID int `json:"media_id,omitempty"`
|
|
// EpisodeID holds the value of the "episode_id" field.
|
|
EpisodeID int `json:"episode_id,omitempty"`
|
|
// SourceTitle holds the value of the "source_title" field.
|
|
SourceTitle string `json:"source_title,omitempty"`
|
|
// Date holds the value of the "date" field.
|
|
Date time.Time `json:"date,omitempty"`
|
|
// TargetDir holds the value of the "target_dir" field.
|
|
TargetDir string `json:"target_dir,omitempty"`
|
|
// Size holds the value of the "size" field.
|
|
Size int `json:"size,omitempty"`
|
|
// DownloadClientID holds the value of the "download_client_id" field.
|
|
DownloadClientID int `json:"download_client_id,omitempty"`
|
|
// IndexerID holds the value of the "indexer_id" field.
|
|
IndexerID int `json:"indexer_id,omitempty"`
|
|
// Link holds the value of the "link" field.
|
|
Link string `json:"link,omitempty"`
|
|
// Status holds the value of the "status" field.
|
|
Status history.Status `json:"status,omitempty"`
|
|
// Saved holds the value of the "saved" field.
|
|
Saved string `json:"saved,omitempty"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*History) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case history.FieldID, history.FieldMediaID, history.FieldEpisodeID, history.FieldSize, history.FieldDownloadClientID, history.FieldIndexerID:
|
|
values[i] = new(sql.NullInt64)
|
|
case history.FieldSourceTitle, history.FieldTargetDir, history.FieldLink, history.FieldStatus, history.FieldSaved:
|
|
values[i] = new(sql.NullString)
|
|
case history.FieldDate:
|
|
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 History fields.
|
|
func (h *History) 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 history.FieldID:
|
|
value, ok := values[i].(*sql.NullInt64)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", value)
|
|
}
|
|
h.ID = int(value.Int64)
|
|
case history.FieldMediaID:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field media_id", values[i])
|
|
} else if value.Valid {
|
|
h.MediaID = int(value.Int64)
|
|
}
|
|
case history.FieldEpisodeID:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field episode_id", values[i])
|
|
} else if value.Valid {
|
|
h.EpisodeID = int(value.Int64)
|
|
}
|
|
case history.FieldSourceTitle:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field source_title", values[i])
|
|
} else if value.Valid {
|
|
h.SourceTitle = value.String
|
|
}
|
|
case history.FieldDate:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field date", values[i])
|
|
} else if value.Valid {
|
|
h.Date = value.Time
|
|
}
|
|
case history.FieldTargetDir:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field target_dir", values[i])
|
|
} else if value.Valid {
|
|
h.TargetDir = value.String
|
|
}
|
|
case history.FieldSize:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field size", values[i])
|
|
} else if value.Valid {
|
|
h.Size = int(value.Int64)
|
|
}
|
|
case history.FieldDownloadClientID:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field download_client_id", values[i])
|
|
} else if value.Valid {
|
|
h.DownloadClientID = int(value.Int64)
|
|
}
|
|
case history.FieldIndexerID:
|
|
if value, ok := values[i].(*sql.NullInt64); !ok {
|
|
return fmt.Errorf("unexpected type %T for field indexer_id", values[i])
|
|
} else if value.Valid {
|
|
h.IndexerID = int(value.Int64)
|
|
}
|
|
case history.FieldLink:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field link", values[i])
|
|
} else if value.Valid {
|
|
h.Link = value.String
|
|
}
|
|
case history.FieldStatus:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field status", values[i])
|
|
} else if value.Valid {
|
|
h.Status = history.Status(value.String)
|
|
}
|
|
case history.FieldSaved:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field saved", values[i])
|
|
} else if value.Valid {
|
|
h.Saved = value.String
|
|
}
|
|
default:
|
|
h.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the History.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (h *History) Value(name string) (ent.Value, error) {
|
|
return h.selectValues.Get(name)
|
|
}
|
|
|
|
// Update returns a builder for updating this History.
|
|
// Note that you need to call History.Unwrap() before calling this method if this History
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (h *History) Update() *HistoryUpdateOne {
|
|
return NewHistoryClient(h.config).UpdateOne(h)
|
|
}
|
|
|
|
// Unwrap unwraps the History 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 (h *History) Unwrap() *History {
|
|
_tx, ok := h.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: History is not a transactional entity")
|
|
}
|
|
h.config.driver = _tx.drv
|
|
return h
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (h *History) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("History(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", h.ID))
|
|
builder.WriteString("media_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", h.MediaID))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("episode_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", h.EpisodeID))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("source_title=")
|
|
builder.WriteString(h.SourceTitle)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("date=")
|
|
builder.WriteString(h.Date.Format(time.ANSIC))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("target_dir=")
|
|
builder.WriteString(h.TargetDir)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("size=")
|
|
builder.WriteString(fmt.Sprintf("%v", h.Size))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("download_client_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", h.DownloadClientID))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("indexer_id=")
|
|
builder.WriteString(fmt.Sprintf("%v", h.IndexerID))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("link=")
|
|
builder.WriteString(h.Link)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("status=")
|
|
builder.WriteString(fmt.Sprintf("%v", h.Status))
|
|
builder.WriteString(", ")
|
|
builder.WriteString("saved=")
|
|
builder.WriteString(h.Saved)
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// Histories is a parsable slice of History.
|
|
type Histories []*History
|