setting.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "fmt"
  5. "strings"
  6. "time"
  7. "entgo.io/ent"
  8. "entgo.io/ent/dialect/sql"
  9. "github.com/Wei-Shaw/sub2api/ent/setting"
  10. )
  11. // Setting is the model entity for the Setting schema.
  12. type Setting struct {
  13. config `json:"-"`
  14. // ID of the ent.
  15. ID int64 `json:"id,omitempty"`
  16. // Key holds the value of the "key" field.
  17. Key string `json:"key,omitempty"`
  18. // Value holds the value of the "value" field.
  19. Value string `json:"value,omitempty"`
  20. // UpdatedAt holds the value of the "updated_at" field.
  21. UpdatedAt time.Time `json:"updated_at,omitempty"`
  22. selectValues sql.SelectValues
  23. }
  24. // scanValues returns the types for scanning values from sql.Rows.
  25. func (*Setting) scanValues(columns []string) ([]any, error) {
  26. values := make([]any, len(columns))
  27. for i := range columns {
  28. switch columns[i] {
  29. case setting.FieldID:
  30. values[i] = new(sql.NullInt64)
  31. case setting.FieldKey, setting.FieldValue:
  32. values[i] = new(sql.NullString)
  33. case setting.FieldUpdatedAt:
  34. values[i] = new(sql.NullTime)
  35. default:
  36. values[i] = new(sql.UnknownType)
  37. }
  38. }
  39. return values, nil
  40. }
  41. // assignValues assigns the values that were returned from sql.Rows (after scanning)
  42. // to the Setting fields.
  43. func (_m *Setting) assignValues(columns []string, values []any) error {
  44. if m, n := len(values), len(columns); m < n {
  45. return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
  46. }
  47. for i := range columns {
  48. switch columns[i] {
  49. case setting.FieldID:
  50. value, ok := values[i].(*sql.NullInt64)
  51. if !ok {
  52. return fmt.Errorf("unexpected type %T for field id", value)
  53. }
  54. _m.ID = int64(value.Int64)
  55. case setting.FieldKey:
  56. if value, ok := values[i].(*sql.NullString); !ok {
  57. return fmt.Errorf("unexpected type %T for field key", values[i])
  58. } else if value.Valid {
  59. _m.Key = value.String
  60. }
  61. case setting.FieldValue:
  62. if value, ok := values[i].(*sql.NullString); !ok {
  63. return fmt.Errorf("unexpected type %T for field value", values[i])
  64. } else if value.Valid {
  65. _m.Value = value.String
  66. }
  67. case setting.FieldUpdatedAt:
  68. if value, ok := values[i].(*sql.NullTime); !ok {
  69. return fmt.Errorf("unexpected type %T for field updated_at", values[i])
  70. } else if value.Valid {
  71. _m.UpdatedAt = value.Time
  72. }
  73. default:
  74. _m.selectValues.Set(columns[i], values[i])
  75. }
  76. }
  77. return nil
  78. }
  79. // GetValue returns the ent.Value that was dynamically selected and assigned to the Setting.
  80. // This includes values selected through modifiers, order, etc.
  81. func (_m *Setting) GetValue(name string) (ent.Value, error) {
  82. return _m.selectValues.Get(name)
  83. }
  84. // Update returns a builder for updating this Setting.
  85. // Note that you need to call Setting.Unwrap() before calling this method if this Setting
  86. // was returned from a transaction, and the transaction was committed or rolled back.
  87. func (_m *Setting) Update() *SettingUpdateOne {
  88. return NewSettingClient(_m.config).UpdateOne(_m)
  89. }
  90. // Unwrap unwraps the Setting entity that was returned from a transaction after it was closed,
  91. // so that all future queries will be executed through the driver which created the transaction.
  92. func (_m *Setting) Unwrap() *Setting {
  93. _tx, ok := _m.config.driver.(*txDriver)
  94. if !ok {
  95. panic("ent: Setting is not a transactional entity")
  96. }
  97. _m.config.driver = _tx.drv
  98. return _m
  99. }
  100. // String implements the fmt.Stringer.
  101. func (_m *Setting) String() string {
  102. var builder strings.Builder
  103. builder.WriteString("Setting(")
  104. builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
  105. builder.WriteString("key=")
  106. builder.WriteString(_m.Key)
  107. builder.WriteString(", ")
  108. builder.WriteString("value=")
  109. builder.WriteString(_m.Value)
  110. builder.WriteString(", ")
  111. builder.WriteString("updated_at=")
  112. builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
  113. builder.WriteByte(')')
  114. return builder.String()
  115. }
  116. // Settings is a parsable slice of Setting.
  117. type Settings []*Setting