authidentitychannel.go 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "encoding/json"
  5. "fmt"
  6. "strings"
  7. "time"
  8. "entgo.io/ent"
  9. "entgo.io/ent/dialect/sql"
  10. "github.com/Wei-Shaw/sub2api/ent/authidentity"
  11. "github.com/Wei-Shaw/sub2api/ent/authidentitychannel"
  12. )
  13. // AuthIdentityChannel is the model entity for the AuthIdentityChannel schema.
  14. type AuthIdentityChannel struct {
  15. config `json:"-"`
  16. // ID of the ent.
  17. ID int64 `json:"id,omitempty"`
  18. // CreatedAt holds the value of the "created_at" field.
  19. CreatedAt time.Time `json:"created_at,omitempty"`
  20. // UpdatedAt holds the value of the "updated_at" field.
  21. UpdatedAt time.Time `json:"updated_at,omitempty"`
  22. // IdentityID holds the value of the "identity_id" field.
  23. IdentityID int64 `json:"identity_id,omitempty"`
  24. // ProviderType holds the value of the "provider_type" field.
  25. ProviderType string `json:"provider_type,omitempty"`
  26. // ProviderKey holds the value of the "provider_key" field.
  27. ProviderKey string `json:"provider_key,omitempty"`
  28. // Channel holds the value of the "channel" field.
  29. Channel string `json:"channel,omitempty"`
  30. // ChannelAppID holds the value of the "channel_app_id" field.
  31. ChannelAppID string `json:"channel_app_id,omitempty"`
  32. // ChannelSubject holds the value of the "channel_subject" field.
  33. ChannelSubject string `json:"channel_subject,omitempty"`
  34. // Metadata holds the value of the "metadata" field.
  35. Metadata map[string]interface{} `json:"metadata,omitempty"`
  36. // Edges holds the relations/edges for other nodes in the graph.
  37. // The values are being populated by the AuthIdentityChannelQuery when eager-loading is set.
  38. Edges AuthIdentityChannelEdges `json:"edges"`
  39. selectValues sql.SelectValues
  40. }
  41. // AuthIdentityChannelEdges holds the relations/edges for other nodes in the graph.
  42. type AuthIdentityChannelEdges struct {
  43. // Identity holds the value of the identity edge.
  44. Identity *AuthIdentity `json:"identity,omitempty"`
  45. // loadedTypes holds the information for reporting if a
  46. // type was loaded (or requested) in eager-loading or not.
  47. loadedTypes [1]bool
  48. }
  49. // IdentityOrErr returns the Identity value or an error if the edge
  50. // was not loaded in eager-loading, or loaded but was not found.
  51. func (e AuthIdentityChannelEdges) IdentityOrErr() (*AuthIdentity, error) {
  52. if e.Identity != nil {
  53. return e.Identity, nil
  54. } else if e.loadedTypes[0] {
  55. return nil, &NotFoundError{label: authidentity.Label}
  56. }
  57. return nil, &NotLoadedError{edge: "identity"}
  58. }
  59. // scanValues returns the types for scanning values from sql.Rows.
  60. func (*AuthIdentityChannel) scanValues(columns []string) ([]any, error) {
  61. values := make([]any, len(columns))
  62. for i := range columns {
  63. switch columns[i] {
  64. case authidentitychannel.FieldMetadata:
  65. values[i] = new([]byte)
  66. case authidentitychannel.FieldID, authidentitychannel.FieldIdentityID:
  67. values[i] = new(sql.NullInt64)
  68. case authidentitychannel.FieldProviderType, authidentitychannel.FieldProviderKey, authidentitychannel.FieldChannel, authidentitychannel.FieldChannelAppID, authidentitychannel.FieldChannelSubject:
  69. values[i] = new(sql.NullString)
  70. case authidentitychannel.FieldCreatedAt, authidentitychannel.FieldUpdatedAt:
  71. values[i] = new(sql.NullTime)
  72. default:
  73. values[i] = new(sql.UnknownType)
  74. }
  75. }
  76. return values, nil
  77. }
  78. // assignValues assigns the values that were returned from sql.Rows (after scanning)
  79. // to the AuthIdentityChannel fields.
  80. func (_m *AuthIdentityChannel) assignValues(columns []string, values []any) error {
  81. if m, n := len(values), len(columns); m < n {
  82. return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
  83. }
  84. for i := range columns {
  85. switch columns[i] {
  86. case authidentitychannel.FieldID:
  87. value, ok := values[i].(*sql.NullInt64)
  88. if !ok {
  89. return fmt.Errorf("unexpected type %T for field id", value)
  90. }
  91. _m.ID = int64(value.Int64)
  92. case authidentitychannel.FieldCreatedAt:
  93. if value, ok := values[i].(*sql.NullTime); !ok {
  94. return fmt.Errorf("unexpected type %T for field created_at", values[i])
  95. } else if value.Valid {
  96. _m.CreatedAt = value.Time
  97. }
  98. case authidentitychannel.FieldUpdatedAt:
  99. if value, ok := values[i].(*sql.NullTime); !ok {
  100. return fmt.Errorf("unexpected type %T for field updated_at", values[i])
  101. } else if value.Valid {
  102. _m.UpdatedAt = value.Time
  103. }
  104. case authidentitychannel.FieldIdentityID:
  105. if value, ok := values[i].(*sql.NullInt64); !ok {
  106. return fmt.Errorf("unexpected type %T for field identity_id", values[i])
  107. } else if value.Valid {
  108. _m.IdentityID = value.Int64
  109. }
  110. case authidentitychannel.FieldProviderType:
  111. if value, ok := values[i].(*sql.NullString); !ok {
  112. return fmt.Errorf("unexpected type %T for field provider_type", values[i])
  113. } else if value.Valid {
  114. _m.ProviderType = value.String
  115. }
  116. case authidentitychannel.FieldProviderKey:
  117. if value, ok := values[i].(*sql.NullString); !ok {
  118. return fmt.Errorf("unexpected type %T for field provider_key", values[i])
  119. } else if value.Valid {
  120. _m.ProviderKey = value.String
  121. }
  122. case authidentitychannel.FieldChannel:
  123. if value, ok := values[i].(*sql.NullString); !ok {
  124. return fmt.Errorf("unexpected type %T for field channel", values[i])
  125. } else if value.Valid {
  126. _m.Channel = value.String
  127. }
  128. case authidentitychannel.FieldChannelAppID:
  129. if value, ok := values[i].(*sql.NullString); !ok {
  130. return fmt.Errorf("unexpected type %T for field channel_app_id", values[i])
  131. } else if value.Valid {
  132. _m.ChannelAppID = value.String
  133. }
  134. case authidentitychannel.FieldChannelSubject:
  135. if value, ok := values[i].(*sql.NullString); !ok {
  136. return fmt.Errorf("unexpected type %T for field channel_subject", values[i])
  137. } else if value.Valid {
  138. _m.ChannelSubject = value.String
  139. }
  140. case authidentitychannel.FieldMetadata:
  141. if value, ok := values[i].(*[]byte); !ok {
  142. return fmt.Errorf("unexpected type %T for field metadata", values[i])
  143. } else if value != nil && len(*value) > 0 {
  144. if err := json.Unmarshal(*value, &_m.Metadata); err != nil {
  145. return fmt.Errorf("unmarshal field metadata: %w", err)
  146. }
  147. }
  148. default:
  149. _m.selectValues.Set(columns[i], values[i])
  150. }
  151. }
  152. return nil
  153. }
  154. // Value returns the ent.Value that was dynamically selected and assigned to the AuthIdentityChannel.
  155. // This includes values selected through modifiers, order, etc.
  156. func (_m *AuthIdentityChannel) Value(name string) (ent.Value, error) {
  157. return _m.selectValues.Get(name)
  158. }
  159. // QueryIdentity queries the "identity" edge of the AuthIdentityChannel entity.
  160. func (_m *AuthIdentityChannel) QueryIdentity() *AuthIdentityQuery {
  161. return NewAuthIdentityChannelClient(_m.config).QueryIdentity(_m)
  162. }
  163. // Update returns a builder for updating this AuthIdentityChannel.
  164. // Note that you need to call AuthIdentityChannel.Unwrap() before calling this method if this AuthIdentityChannel
  165. // was returned from a transaction, and the transaction was committed or rolled back.
  166. func (_m *AuthIdentityChannel) Update() *AuthIdentityChannelUpdateOne {
  167. return NewAuthIdentityChannelClient(_m.config).UpdateOne(_m)
  168. }
  169. // Unwrap unwraps the AuthIdentityChannel entity that was returned from a transaction after it was closed,
  170. // so that all future queries will be executed through the driver which created the transaction.
  171. func (_m *AuthIdentityChannel) Unwrap() *AuthIdentityChannel {
  172. _tx, ok := _m.config.driver.(*txDriver)
  173. if !ok {
  174. panic("ent: AuthIdentityChannel is not a transactional entity")
  175. }
  176. _m.config.driver = _tx.drv
  177. return _m
  178. }
  179. // String implements the fmt.Stringer.
  180. func (_m *AuthIdentityChannel) String() string {
  181. var builder strings.Builder
  182. builder.WriteString("AuthIdentityChannel(")
  183. builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
  184. builder.WriteString("created_at=")
  185. builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
  186. builder.WriteString(", ")
  187. builder.WriteString("updated_at=")
  188. builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
  189. builder.WriteString(", ")
  190. builder.WriteString("identity_id=")
  191. builder.WriteString(fmt.Sprintf("%v", _m.IdentityID))
  192. builder.WriteString(", ")
  193. builder.WriteString("provider_type=")
  194. builder.WriteString(_m.ProviderType)
  195. builder.WriteString(", ")
  196. builder.WriteString("provider_key=")
  197. builder.WriteString(_m.ProviderKey)
  198. builder.WriteString(", ")
  199. builder.WriteString("channel=")
  200. builder.WriteString(_m.Channel)
  201. builder.WriteString(", ")
  202. builder.WriteString("channel_app_id=")
  203. builder.WriteString(_m.ChannelAppID)
  204. builder.WriteString(", ")
  205. builder.WriteString("channel_subject=")
  206. builder.WriteString(_m.ChannelSubject)
  207. builder.WriteString(", ")
  208. builder.WriteString("metadata=")
  209. builder.WriteString(fmt.Sprintf("%v", _m.Metadata))
  210. builder.WriteByte(')')
  211. return builder.String()
  212. }
  213. // AuthIdentityChannels is a parsable slice of AuthIdentityChannel.
  214. type AuthIdentityChannels []*AuthIdentityChannel