pushregistration.go 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "fmt"
  5. "strings"
  6. "time"
  7. "w303a/server/app/gate/internal/data/ent/pushregistration"
  8. "entgo.io/ent"
  9. "entgo.io/ent/dialect/sql"
  10. "github.com/google/uuid"
  11. )
  12. // PushRegistration is the model entity for the PushRegistration schema.
  13. type PushRegistration struct {
  14. config `json:"-"`
  15. // ID of the ent.
  16. // 用户ID
  17. ID uuid.UUID `json:"id,omitempty"`
  18. // 推送注册ID
  19. RegID string `json:"reg_id,omitempty"`
  20. // 注册平台 0: 默认(极光推送), 1: 华为推送, 2: 小米推送, 3: OPPO 推送, 4: VIVO 推送, 5: APNs 苹果推送
  21. RegistrantPlatformType int8 `json:"registrant_platform_type,omitempty"`
  22. // 语言
  23. Language string `json:"language,omitempty"`
  24. // 设备型号
  25. DeviceModel *string `json:"device_model,omitempty"`
  26. // 设备厂商
  27. DeviceManufacturer *string `json:"device_manufacturer,omitempty"`
  28. // 设备系统版本
  29. DeviceSystemVersion *string `json:"device_system_version,omitempty"`
  30. // 设备系统
  31. DeviceSystem *string `json:"device_system,omitempty"`
  32. // 创建时间
  33. CreatedAt time.Time `json:"created_at,omitempty"`
  34. // 更新时间
  35. UpdatedAt time.Time `json:"updated_at,omitempty"`
  36. selectValues sql.SelectValues
  37. }
  38. // scanValues returns the types for scanning values from sql.Rows.
  39. func (*PushRegistration) scanValues(columns []string) ([]any, error) {
  40. values := make([]any, len(columns))
  41. for i := range columns {
  42. switch columns[i] {
  43. case pushregistration.FieldRegistrantPlatformType:
  44. values[i] = new(sql.NullInt64)
  45. case pushregistration.FieldRegID, pushregistration.FieldLanguage, pushregistration.FieldDeviceModel, pushregistration.FieldDeviceManufacturer, pushregistration.FieldDeviceSystemVersion, pushregistration.FieldDeviceSystem:
  46. values[i] = new(sql.NullString)
  47. case pushregistration.FieldCreatedAt, pushregistration.FieldUpdatedAt:
  48. values[i] = new(sql.NullTime)
  49. case pushregistration.FieldID:
  50. values[i] = new(uuid.UUID)
  51. default:
  52. values[i] = new(sql.UnknownType)
  53. }
  54. }
  55. return values, nil
  56. }
  57. // assignValues assigns the values that were returned from sql.Rows (after scanning)
  58. // to the PushRegistration fields.
  59. func (pr *PushRegistration) assignValues(columns []string, values []any) error {
  60. if m, n := len(values), len(columns); m < n {
  61. return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
  62. }
  63. for i := range columns {
  64. switch columns[i] {
  65. case pushregistration.FieldID:
  66. if value, ok := values[i].(*uuid.UUID); !ok {
  67. return fmt.Errorf("unexpected type %T for field id", values[i])
  68. } else if value != nil {
  69. pr.ID = *value
  70. }
  71. case pushregistration.FieldRegID:
  72. if value, ok := values[i].(*sql.NullString); !ok {
  73. return fmt.Errorf("unexpected type %T for field reg_id", values[i])
  74. } else if value.Valid {
  75. pr.RegID = value.String
  76. }
  77. case pushregistration.FieldRegistrantPlatformType:
  78. if value, ok := values[i].(*sql.NullInt64); !ok {
  79. return fmt.Errorf("unexpected type %T for field registrant_platform_type", values[i])
  80. } else if value.Valid {
  81. pr.RegistrantPlatformType = int8(value.Int64)
  82. }
  83. case pushregistration.FieldLanguage:
  84. if value, ok := values[i].(*sql.NullString); !ok {
  85. return fmt.Errorf("unexpected type %T for field language", values[i])
  86. } else if value.Valid {
  87. pr.Language = value.String
  88. }
  89. case pushregistration.FieldDeviceModel:
  90. if value, ok := values[i].(*sql.NullString); !ok {
  91. return fmt.Errorf("unexpected type %T for field device_model", values[i])
  92. } else if value.Valid {
  93. pr.DeviceModel = new(string)
  94. *pr.DeviceModel = value.String
  95. }
  96. case pushregistration.FieldDeviceManufacturer:
  97. if value, ok := values[i].(*sql.NullString); !ok {
  98. return fmt.Errorf("unexpected type %T for field device_manufacturer", values[i])
  99. } else if value.Valid {
  100. pr.DeviceManufacturer = new(string)
  101. *pr.DeviceManufacturer = value.String
  102. }
  103. case pushregistration.FieldDeviceSystemVersion:
  104. if value, ok := values[i].(*sql.NullString); !ok {
  105. return fmt.Errorf("unexpected type %T for field device_system_version", values[i])
  106. } else if value.Valid {
  107. pr.DeviceSystemVersion = new(string)
  108. *pr.DeviceSystemVersion = value.String
  109. }
  110. case pushregistration.FieldDeviceSystem:
  111. if value, ok := values[i].(*sql.NullString); !ok {
  112. return fmt.Errorf("unexpected type %T for field device_system", values[i])
  113. } else if value.Valid {
  114. pr.DeviceSystem = new(string)
  115. *pr.DeviceSystem = value.String
  116. }
  117. case pushregistration.FieldCreatedAt:
  118. if value, ok := values[i].(*sql.NullTime); !ok {
  119. return fmt.Errorf("unexpected type %T for field created_at", values[i])
  120. } else if value.Valid {
  121. pr.CreatedAt = value.Time
  122. }
  123. case pushregistration.FieldUpdatedAt:
  124. if value, ok := values[i].(*sql.NullTime); !ok {
  125. return fmt.Errorf("unexpected type %T for field updated_at", values[i])
  126. } else if value.Valid {
  127. pr.UpdatedAt = value.Time
  128. }
  129. default:
  130. pr.selectValues.Set(columns[i], values[i])
  131. }
  132. }
  133. return nil
  134. }
  135. // Value returns the ent.Value that was dynamically selected and assigned to the PushRegistration.
  136. // This includes values selected through modifiers, order, etc.
  137. func (pr *PushRegistration) Value(name string) (ent.Value, error) {
  138. return pr.selectValues.Get(name)
  139. }
  140. // Update returns a builder for updating this PushRegistration.
  141. // Note that you need to call PushRegistration.Unwrap() before calling this method if this PushRegistration
  142. // was returned from a transaction, and the transaction was committed or rolled back.
  143. func (pr *PushRegistration) Update() *PushRegistrationUpdateOne {
  144. return NewPushRegistrationClient(pr.config).UpdateOne(pr)
  145. }
  146. // Unwrap unwraps the PushRegistration entity that was returned from a transaction after it was closed,
  147. // so that all future queries will be executed through the driver which created the transaction.
  148. func (pr *PushRegistration) Unwrap() *PushRegistration {
  149. _tx, ok := pr.config.driver.(*txDriver)
  150. if !ok {
  151. panic("ent: PushRegistration is not a transactional entity")
  152. }
  153. pr.config.driver = _tx.drv
  154. return pr
  155. }
  156. // String implements the fmt.Stringer.
  157. func (pr *PushRegistration) String() string {
  158. var builder strings.Builder
  159. builder.WriteString("PushRegistration(")
  160. builder.WriteString(fmt.Sprintf("id=%v, ", pr.ID))
  161. builder.WriteString("reg_id=")
  162. builder.WriteString(pr.RegID)
  163. builder.WriteString(", ")
  164. builder.WriteString("registrant_platform_type=")
  165. builder.WriteString(fmt.Sprintf("%v", pr.RegistrantPlatformType))
  166. builder.WriteString(", ")
  167. builder.WriteString("language=")
  168. builder.WriteString(pr.Language)
  169. builder.WriteString(", ")
  170. if v := pr.DeviceModel; v != nil {
  171. builder.WriteString("device_model=")
  172. builder.WriteString(*v)
  173. }
  174. builder.WriteString(", ")
  175. if v := pr.DeviceManufacturer; v != nil {
  176. builder.WriteString("device_manufacturer=")
  177. builder.WriteString(*v)
  178. }
  179. builder.WriteString(", ")
  180. if v := pr.DeviceSystemVersion; v != nil {
  181. builder.WriteString("device_system_version=")
  182. builder.WriteString(*v)
  183. }
  184. builder.WriteString(", ")
  185. if v := pr.DeviceSystem; v != nil {
  186. builder.WriteString("device_system=")
  187. builder.WriteString(*v)
  188. }
  189. builder.WriteString(", ")
  190. builder.WriteString("created_at=")
  191. builder.WriteString(pr.CreatedAt.Format(time.ANSIC))
  192. builder.WriteString(", ")
  193. builder.WriteString("updated_at=")
  194. builder.WriteString(pr.UpdatedAt.Format(time.ANSIC))
  195. builder.WriteByte(')')
  196. return builder.String()
  197. }
  198. // PushRegistrations is a parsable slice of PushRegistration.
  199. type PushRegistrations []*PushRegistration