| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "fmt"
- "strings"
- "time"
- "entgo.io/ent"
- "entgo.io/ent/dialect/sql"
- "github.com/Wei-Shaw/sub2api/ent/user"
- "github.com/Wei-Shaw/sub2api/ent/userplatformquota"
- )
- // UserPlatformQuota is the model entity for the UserPlatformQuota schema.
- type UserPlatformQuota struct {
- config `json:"-"`
- // ID of the ent.
- ID int64 `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"`
- // UserID holds the value of the "user_id" field.
- UserID int64 `json:"user_id,omitempty"`
- // Platform holds the value of the "platform" field.
- Platform string `json:"platform,omitempty"`
- // DailyLimitUsd holds the value of the "daily_limit_usd" field.
- DailyLimitUsd *float64 `json:"daily_limit_usd,omitempty"`
- // WeeklyLimitUsd holds the value of the "weekly_limit_usd" field.
- WeeklyLimitUsd *float64 `json:"weekly_limit_usd,omitempty"`
- // MonthlyLimitUsd holds the value of the "monthly_limit_usd" field.
- MonthlyLimitUsd *float64 `json:"monthly_limit_usd,omitempty"`
- // DailyUsageUsd holds the value of the "daily_usage_usd" field.
- DailyUsageUsd float64 `json:"daily_usage_usd,omitempty"`
- // WeeklyUsageUsd holds the value of the "weekly_usage_usd" field.
- WeeklyUsageUsd float64 `json:"weekly_usage_usd,omitempty"`
- // MonthlyUsageUsd holds the value of the "monthly_usage_usd" field.
- MonthlyUsageUsd float64 `json:"monthly_usage_usd,omitempty"`
- // DailyWindowStart holds the value of the "daily_window_start" field.
- DailyWindowStart *time.Time `json:"daily_window_start,omitempty"`
- // WeeklyWindowStart holds the value of the "weekly_window_start" field.
- WeeklyWindowStart *time.Time `json:"weekly_window_start,omitempty"`
- // MonthlyWindowStart holds the value of the "monthly_window_start" field.
- MonthlyWindowStart *time.Time `json:"monthly_window_start,omitempty"`
- // Edges holds the relations/edges for other nodes in the graph.
- // The values are being populated by the UserPlatformQuotaQuery when eager-loading is set.
- Edges UserPlatformQuotaEdges `json:"edges"`
- selectValues sql.SelectValues
- }
- // UserPlatformQuotaEdges holds the relations/edges for other nodes in the graph.
- type UserPlatformQuotaEdges struct {
- // User holds the value of the user edge.
- User *User `json:"user,omitempty"`
- // loadedTypes holds the information for reporting if a
- // type was loaded (or requested) in eager-loading or not.
- loadedTypes [1]bool
- }
- // UserOrErr returns the User value or an error if the edge
- // was not loaded in eager-loading, or loaded but was not found.
- func (e UserPlatformQuotaEdges) UserOrErr() (*User, error) {
- if e.User != nil {
- return e.User, nil
- } else if e.loadedTypes[0] {
- return nil, &NotFoundError{label: user.Label}
- }
- return nil, &NotLoadedError{edge: "user"}
- }
- // scanValues returns the types for scanning values from sql.Rows.
- func (*UserPlatformQuota) scanValues(columns []string) ([]any, error) {
- values := make([]any, len(columns))
- for i := range columns {
- switch columns[i] {
- case userplatformquota.FieldDailyLimitUsd, userplatformquota.FieldWeeklyLimitUsd, userplatformquota.FieldMonthlyLimitUsd, userplatformquota.FieldDailyUsageUsd, userplatformquota.FieldWeeklyUsageUsd, userplatformquota.FieldMonthlyUsageUsd:
- values[i] = new(sql.NullFloat64)
- case userplatformquota.FieldID, userplatformquota.FieldUserID:
- values[i] = new(sql.NullInt64)
- case userplatformquota.FieldPlatform:
- values[i] = new(sql.NullString)
- case userplatformquota.FieldCreatedAt, userplatformquota.FieldUpdatedAt, userplatformquota.FieldDeletedAt, userplatformquota.FieldDailyWindowStart, userplatformquota.FieldWeeklyWindowStart, userplatformquota.FieldMonthlyWindowStart:
- 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 UserPlatformQuota fields.
- func (_m *UserPlatformQuota) 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 userplatformquota.FieldID:
- value, ok := values[i].(*sql.NullInt64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field id", value)
- }
- _m.ID = int64(value.Int64)
- case userplatformquota.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 {
- _m.CreatedAt = value.Time
- }
- case userplatformquota.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 {
- _m.UpdatedAt = value.Time
- }
- case userplatformquota.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 {
- _m.DeletedAt = new(time.Time)
- *_m.DeletedAt = value.Time
- }
- case userplatformquota.FieldUserID:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field user_id", values[i])
- } else if value.Valid {
- _m.UserID = value.Int64
- }
- case userplatformquota.FieldPlatform:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field platform", values[i])
- } else if value.Valid {
- _m.Platform = value.String
- }
- case userplatformquota.FieldDailyLimitUsd:
- if value, ok := values[i].(*sql.NullFloat64); !ok {
- return fmt.Errorf("unexpected type %T for field daily_limit_usd", values[i])
- } else if value.Valid {
- _m.DailyLimitUsd = new(float64)
- *_m.DailyLimitUsd = value.Float64
- }
- case userplatformquota.FieldWeeklyLimitUsd:
- if value, ok := values[i].(*sql.NullFloat64); !ok {
- return fmt.Errorf("unexpected type %T for field weekly_limit_usd", values[i])
- } else if value.Valid {
- _m.WeeklyLimitUsd = new(float64)
- *_m.WeeklyLimitUsd = value.Float64
- }
- case userplatformquota.FieldMonthlyLimitUsd:
- if value, ok := values[i].(*sql.NullFloat64); !ok {
- return fmt.Errorf("unexpected type %T for field monthly_limit_usd", values[i])
- } else if value.Valid {
- _m.MonthlyLimitUsd = new(float64)
- *_m.MonthlyLimitUsd = value.Float64
- }
- case userplatformquota.FieldDailyUsageUsd:
- if value, ok := values[i].(*sql.NullFloat64); !ok {
- return fmt.Errorf("unexpected type %T for field daily_usage_usd", values[i])
- } else if value.Valid {
- _m.DailyUsageUsd = value.Float64
- }
- case userplatformquota.FieldWeeklyUsageUsd:
- if value, ok := values[i].(*sql.NullFloat64); !ok {
- return fmt.Errorf("unexpected type %T for field weekly_usage_usd", values[i])
- } else if value.Valid {
- _m.WeeklyUsageUsd = value.Float64
- }
- case userplatformquota.FieldMonthlyUsageUsd:
- if value, ok := values[i].(*sql.NullFloat64); !ok {
- return fmt.Errorf("unexpected type %T for field monthly_usage_usd", values[i])
- } else if value.Valid {
- _m.MonthlyUsageUsd = value.Float64
- }
- case userplatformquota.FieldDailyWindowStart:
- if value, ok := values[i].(*sql.NullTime); !ok {
- return fmt.Errorf("unexpected type %T for field daily_window_start", values[i])
- } else if value.Valid {
- _m.DailyWindowStart = new(time.Time)
- *_m.DailyWindowStart = value.Time
- }
- case userplatformquota.FieldWeeklyWindowStart:
- if value, ok := values[i].(*sql.NullTime); !ok {
- return fmt.Errorf("unexpected type %T for field weekly_window_start", values[i])
- } else if value.Valid {
- _m.WeeklyWindowStart = new(time.Time)
- *_m.WeeklyWindowStart = value.Time
- }
- case userplatformquota.FieldMonthlyWindowStart:
- if value, ok := values[i].(*sql.NullTime); !ok {
- return fmt.Errorf("unexpected type %T for field monthly_window_start", values[i])
- } else if value.Valid {
- _m.MonthlyWindowStart = new(time.Time)
- *_m.MonthlyWindowStart = value.Time
- }
- default:
- _m.selectValues.Set(columns[i], values[i])
- }
- }
- return nil
- }
- // Value returns the ent.Value that was dynamically selected and assigned to the UserPlatformQuota.
- // This includes values selected through modifiers, order, etc.
- func (_m *UserPlatformQuota) Value(name string) (ent.Value, error) {
- return _m.selectValues.Get(name)
- }
- // QueryUser queries the "user" edge of the UserPlatformQuota entity.
- func (_m *UserPlatformQuota) QueryUser() *UserQuery {
- return NewUserPlatformQuotaClient(_m.config).QueryUser(_m)
- }
- // Update returns a builder for updating this UserPlatformQuota.
- // Note that you need to call UserPlatformQuota.Unwrap() before calling this method if this UserPlatformQuota
- // was returned from a transaction, and the transaction was committed or rolled back.
- func (_m *UserPlatformQuota) Update() *UserPlatformQuotaUpdateOne {
- return NewUserPlatformQuotaClient(_m.config).UpdateOne(_m)
- }
- // Unwrap unwraps the UserPlatformQuota 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 (_m *UserPlatformQuota) Unwrap() *UserPlatformQuota {
- _tx, ok := _m.config.driver.(*txDriver)
- if !ok {
- panic("ent: UserPlatformQuota is not a transactional entity")
- }
- _m.config.driver = _tx.drv
- return _m
- }
- // String implements the fmt.Stringer.
- func (_m *UserPlatformQuota) String() string {
- var builder strings.Builder
- builder.WriteString("UserPlatformQuota(")
- builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
- builder.WriteString("created_at=")
- builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("updated_at=")
- builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- if v := _m.DeletedAt; v != nil {
- builder.WriteString("deleted_at=")
- builder.WriteString(v.Format(time.ANSIC))
- }
- builder.WriteString(", ")
- builder.WriteString("user_id=")
- builder.WriteString(fmt.Sprintf("%v", _m.UserID))
- builder.WriteString(", ")
- builder.WriteString("platform=")
- builder.WriteString(_m.Platform)
- builder.WriteString(", ")
- if v := _m.DailyLimitUsd; v != nil {
- builder.WriteString("daily_limit_usd=")
- builder.WriteString(fmt.Sprintf("%v", *v))
- }
- builder.WriteString(", ")
- if v := _m.WeeklyLimitUsd; v != nil {
- builder.WriteString("weekly_limit_usd=")
- builder.WriteString(fmt.Sprintf("%v", *v))
- }
- builder.WriteString(", ")
- if v := _m.MonthlyLimitUsd; v != nil {
- builder.WriteString("monthly_limit_usd=")
- builder.WriteString(fmt.Sprintf("%v", *v))
- }
- builder.WriteString(", ")
- builder.WriteString("daily_usage_usd=")
- builder.WriteString(fmt.Sprintf("%v", _m.DailyUsageUsd))
- builder.WriteString(", ")
- builder.WriteString("weekly_usage_usd=")
- builder.WriteString(fmt.Sprintf("%v", _m.WeeklyUsageUsd))
- builder.WriteString(", ")
- builder.WriteString("monthly_usage_usd=")
- builder.WriteString(fmt.Sprintf("%v", _m.MonthlyUsageUsd))
- builder.WriteString(", ")
- if v := _m.DailyWindowStart; v != nil {
- builder.WriteString("daily_window_start=")
- builder.WriteString(v.Format(time.ANSIC))
- }
- builder.WriteString(", ")
- if v := _m.WeeklyWindowStart; v != nil {
- builder.WriteString("weekly_window_start=")
- builder.WriteString(v.Format(time.ANSIC))
- }
- builder.WriteString(", ")
- if v := _m.MonthlyWindowStart; v != nil {
- builder.WriteString("monthly_window_start=")
- builder.WriteString(v.Format(time.ANSIC))
- }
- builder.WriteByte(')')
- return builder.String()
- }
- // UserPlatformQuotaSlice is a parsable slice of UserPlatformQuota.
- type UserPlatformQuotaSlice []*UserPlatformQuota
|