Something went wrong. Try again.
Self-hosted file management and sharing system, supports multiple storage providers. forked from tdvorak.tngl.sh/cloudreve
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249// 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/giftcode" "github.com/cloudreve/Cloudreve/v4/ent/user")
// GiftCode is the model entity for the GiftCode schema.type GiftCode 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"` // Code holds the value of the "code" field. Code string `json:"code,omitempty"` // Type holds the value of the "type" field. Type giftcode.Type `json:"type,omitempty"` // Amount holds the value of the "amount" field. Amount int64 `json:"amount,omitempty"` // Duration holds the value of the "duration" field. Duration int64 `json:"duration,omitempty"` // UsedByID holds the value of the "used_by_id" field. UsedByID int `json:"used_by_id,omitempty"` // UsedAt holds the value of the "used_at" field. UsedAt *time.Time `json:"used_at,omitempty"` // Des holds the value of the "des" field. Des string `json:"des,omitempty"` // Edges holds the relations/edges for other nodes in the graph. // The values are being populated by the GiftCodeQuery when eager-loading is set. Edges GiftCodeEdges `json:"edges"` selectValues sql.SelectValues}
// GiftCodeEdges holds the relations/edges for other nodes in the graph.type GiftCodeEdges struct { // Redeemer holds the value of the redeemer edge. Redeemer *User `json:"redeemer,omitempty"` // loadedTypes holds the information for reporting if a // type was loaded (or requested) in eager-loading or not. loadedTypes [1]bool}
// RedeemerOrErr returns the Redeemer value or an error if the edge// was not loaded in eager-loading, or loaded but was not found.func (e GiftCodeEdges) RedeemerOrErr() (*User, error) { if e.loadedTypes[0] { if e.Redeemer == nil { // Edge was loaded but was not found. return nil, &NotFoundError{label: user.Label} } return e.Redeemer, nil } return nil, &NotLoadedError{edge: "redeemer"}}
// scanValues returns the types for scanning values from sql.Rows.func (*GiftCode) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case giftcode.FieldID, giftcode.FieldAmount, giftcode.FieldDuration, giftcode.FieldUsedByID: values[i] = new(sql.NullInt64) case giftcode.FieldCode, giftcode.FieldType, giftcode.FieldDes: values[i] = new(sql.NullString) case giftcode.FieldCreatedAt, giftcode.FieldUpdatedAt, giftcode.FieldDeletedAt, giftcode.FieldUsedAt: 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 GiftCode fields.func (gc *GiftCode) 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 giftcode.FieldID: value, ok := values[i].(*sql.NullInt64) if !ok { return fmt.Errorf("unexpected type %T for field id", value) } gc.ID = int(value.Int64) case giftcode.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 { gc.CreatedAt = value.Time } case giftcode.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 { gc.UpdatedAt = value.Time } case giftcode.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 { gc.DeletedAt = new(time.Time) *gc.DeletedAt = value.Time } case giftcode.FieldCode: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field code", values[i]) } else if value.Valid { gc.Code = value.String } case giftcode.FieldType: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field type", values[i]) } else if value.Valid { gc.Type = giftcode.Type(value.String) } case giftcode.FieldAmount: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field amount", values[i]) } else if value.Valid { gc.Amount = value.Int64 } case giftcode.FieldDuration: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field duration", values[i]) } else if value.Valid { gc.Duration = value.Int64 } case giftcode.FieldUsedByID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field used_by_id", values[i]) } else if value.Valid { gc.UsedByID = int(value.Int64) } case giftcode.FieldUsedAt: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field used_at", values[i]) } else if value.Valid { gc.UsedAt = new(time.Time) *gc.UsedAt = value.Time } case giftcode.FieldDes: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field des", values[i]) } else if value.Valid { gc.Des = value.String } default: gc.selectValues.Set(columns[i], values[i]) } } return nil}
// Value returns the ent.Value that was dynamically selected and assigned to the GiftCode.// This includes values selected through modifiers, order, etc.func (gc *GiftCode) Value(name string) (ent.Value, error) { return gc.selectValues.Get(name)}
// QueryRedeemer queries the "redeemer" edge of the GiftCode entity.func (gc *GiftCode) QueryRedeemer() *UserQuery { return NewGiftCodeClient(gc.config).QueryRedeemer(gc)}
// Update returns a builder for updating this GiftCode.// Note that you need to call GiftCode.Unwrap() before calling this method if this GiftCode// was returned from a transaction, and the transaction was committed or rolled back.func (gc *GiftCode) Update() *GiftCodeUpdateOne { return NewGiftCodeClient(gc.config).UpdateOne(gc)}
// Unwrap unwraps the GiftCode 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 (gc *GiftCode) Unwrap() *GiftCode { _tx, ok := gc.config.driver.(*txDriver) if !ok { panic("ent: GiftCode is not a transactional entity") } gc.config.driver = _tx.drv return gc}
// String implements the fmt.Stringer.func (gc *GiftCode) String() string { var builder strings.Builder builder.WriteString("GiftCode(") builder.WriteString(fmt.Sprintf("id=%v, ", gc.ID)) builder.WriteString("created_at=") builder.WriteString(gc.CreatedAt.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("updated_at=") builder.WriteString(gc.UpdatedAt.Format(time.ANSIC)) builder.WriteString(", ") if v := gc.DeletedAt; v != nil { builder.WriteString("deleted_at=") builder.WriteString(v.Format(time.ANSIC)) } builder.WriteString(", ") builder.WriteString("code=") builder.WriteString(gc.Code) builder.WriteString(", ") builder.WriteString("type=") builder.WriteString(fmt.Sprintf("%v", gc.Type)) builder.WriteString(", ") builder.WriteString("amount=") builder.WriteString(fmt.Sprintf("%v", gc.Amount)) builder.WriteString(", ") builder.WriteString("duration=") builder.WriteString(fmt.Sprintf("%v", gc.Duration)) builder.WriteString(", ") builder.WriteString("used_by_id=") builder.WriteString(fmt.Sprintf("%v", gc.UsedByID)) builder.WriteString(", ") if v := gc.UsedAt; v != nil { builder.WriteString("used_at=") builder.WriteString(v.Format(time.ANSIC)) } builder.WriteString(", ") builder.WriteString("des=") builder.WriteString(gc.Des) builder.WriteByte(')') return builder.String()}
// SetRedeemer manually set the edge as loaded state.func (e *GiftCode) SetRedeemer(v *User) { e.Edges.Redeemer = v e.Edges.loadedTypes[0] = true}
// GiftCodes is a parsable slice of GiftCode.type GiftCodes []*GiftCode