whatsappchannel.go 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "fmt"
  5. "strings"
  6. "time"
  7. "wechat-api/ent/whatsappchannel"
  8. "entgo.io/ent"
  9. "entgo.io/ent/dialect/sql"
  10. )
  11. // WhatsappChannel is the model entity for the WhatsappChannel schema.
  12. type WhatsappChannel struct {
  13. config `json:"-"`
  14. // ID of the ent.
  15. ID uint64 `json:"id,omitempty"`
  16. // Create Time | 创建日期
  17. CreatedAt time.Time `json:"created_at,omitempty"`
  18. // Update Time | 修改日期
  19. UpdatedAt time.Time `json:"updated_at,omitempty"`
  20. // Status 1: normal 2: ban | 状态 1 正常 2 禁用
  21. Status uint8 `json:"status,omitempty"`
  22. // Delete Time | 删除日期
  23. DeletedAt time.Time `json:"deleted_at,omitempty"`
  24. // ak
  25. Ak string `json:"ak,omitempty"`
  26. // 端口号
  27. Sk string `json:"sk,omitempty"`
  28. // 通道ID
  29. WaID string `json:"wa_id,omitempty"`
  30. // 通道名
  31. WaName string `json:"wa_name,omitempty"`
  32. // WABA ID
  33. WabaID uint64 `json:"waba_id,omitempty"`
  34. // 商业平台ID
  35. BusinessID uint64 `json:"business_id,omitempty"`
  36. // 机构 ID
  37. OrganizationID uint64 `json:"organization_id,omitempty"`
  38. // 认证主体
  39. VerifyAccount string `json:"verify_account,omitempty"`
  40. selectValues sql.SelectValues
  41. }
  42. // scanValues returns the types for scanning values from sql.Rows.
  43. func (*WhatsappChannel) scanValues(columns []string) ([]any, error) {
  44. values := make([]any, len(columns))
  45. for i := range columns {
  46. switch columns[i] {
  47. case whatsappchannel.FieldID, whatsappchannel.FieldStatus, whatsappchannel.FieldWabaID, whatsappchannel.FieldBusinessID, whatsappchannel.FieldOrganizationID:
  48. values[i] = new(sql.NullInt64)
  49. case whatsappchannel.FieldAk, whatsappchannel.FieldSk, whatsappchannel.FieldWaID, whatsappchannel.FieldWaName, whatsappchannel.FieldVerifyAccount:
  50. values[i] = new(sql.NullString)
  51. case whatsappchannel.FieldCreatedAt, whatsappchannel.FieldUpdatedAt, whatsappchannel.FieldDeletedAt:
  52. values[i] = new(sql.NullTime)
  53. default:
  54. values[i] = new(sql.UnknownType)
  55. }
  56. }
  57. return values, nil
  58. }
  59. // assignValues assigns the values that were returned from sql.Rows (after scanning)
  60. // to the WhatsappChannel fields.
  61. func (wc *WhatsappChannel) assignValues(columns []string, values []any) error {
  62. if m, n := len(values), len(columns); m < n {
  63. return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
  64. }
  65. for i := range columns {
  66. switch columns[i] {
  67. case whatsappchannel.FieldID:
  68. value, ok := values[i].(*sql.NullInt64)
  69. if !ok {
  70. return fmt.Errorf("unexpected type %T for field id", value)
  71. }
  72. wc.ID = uint64(value.Int64)
  73. case whatsappchannel.FieldCreatedAt:
  74. if value, ok := values[i].(*sql.NullTime); !ok {
  75. return fmt.Errorf("unexpected type %T for field created_at", values[i])
  76. } else if value.Valid {
  77. wc.CreatedAt = value.Time
  78. }
  79. case whatsappchannel.FieldUpdatedAt:
  80. if value, ok := values[i].(*sql.NullTime); !ok {
  81. return fmt.Errorf("unexpected type %T for field updated_at", values[i])
  82. } else if value.Valid {
  83. wc.UpdatedAt = value.Time
  84. }
  85. case whatsappchannel.FieldStatus:
  86. if value, ok := values[i].(*sql.NullInt64); !ok {
  87. return fmt.Errorf("unexpected type %T for field status", values[i])
  88. } else if value.Valid {
  89. wc.Status = uint8(value.Int64)
  90. }
  91. case whatsappchannel.FieldDeletedAt:
  92. if value, ok := values[i].(*sql.NullTime); !ok {
  93. return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
  94. } else if value.Valid {
  95. wc.DeletedAt = value.Time
  96. }
  97. case whatsappchannel.FieldAk:
  98. if value, ok := values[i].(*sql.NullString); !ok {
  99. return fmt.Errorf("unexpected type %T for field ak", values[i])
  100. } else if value.Valid {
  101. wc.Ak = value.String
  102. }
  103. case whatsappchannel.FieldSk:
  104. if value, ok := values[i].(*sql.NullString); !ok {
  105. return fmt.Errorf("unexpected type %T for field sk", values[i])
  106. } else if value.Valid {
  107. wc.Sk = value.String
  108. }
  109. case whatsappchannel.FieldWaID:
  110. if value, ok := values[i].(*sql.NullString); !ok {
  111. return fmt.Errorf("unexpected type %T for field wa_id", values[i])
  112. } else if value.Valid {
  113. wc.WaID = value.String
  114. }
  115. case whatsappchannel.FieldWaName:
  116. if value, ok := values[i].(*sql.NullString); !ok {
  117. return fmt.Errorf("unexpected type %T for field wa_name", values[i])
  118. } else if value.Valid {
  119. wc.WaName = value.String
  120. }
  121. case whatsappchannel.FieldWabaID:
  122. if value, ok := values[i].(*sql.NullInt64); !ok {
  123. return fmt.Errorf("unexpected type %T for field waba_id", values[i])
  124. } else if value.Valid {
  125. wc.WabaID = uint64(value.Int64)
  126. }
  127. case whatsappchannel.FieldBusinessID:
  128. if value, ok := values[i].(*sql.NullInt64); !ok {
  129. return fmt.Errorf("unexpected type %T for field business_id", values[i])
  130. } else if value.Valid {
  131. wc.BusinessID = uint64(value.Int64)
  132. }
  133. case whatsappchannel.FieldOrganizationID:
  134. if value, ok := values[i].(*sql.NullInt64); !ok {
  135. return fmt.Errorf("unexpected type %T for field organization_id", values[i])
  136. } else if value.Valid {
  137. wc.OrganizationID = uint64(value.Int64)
  138. }
  139. case whatsappchannel.FieldVerifyAccount:
  140. if value, ok := values[i].(*sql.NullString); !ok {
  141. return fmt.Errorf("unexpected type %T for field verify_account", values[i])
  142. } else if value.Valid {
  143. wc.VerifyAccount = value.String
  144. }
  145. default:
  146. wc.selectValues.Set(columns[i], values[i])
  147. }
  148. }
  149. return nil
  150. }
  151. // Value returns the ent.Value that was dynamically selected and assigned to the WhatsappChannel.
  152. // This includes values selected through modifiers, order, etc.
  153. func (wc *WhatsappChannel) Value(name string) (ent.Value, error) {
  154. return wc.selectValues.Get(name)
  155. }
  156. // Update returns a builder for updating this WhatsappChannel.
  157. // Note that you need to call WhatsappChannel.Unwrap() before calling this method if this WhatsappChannel
  158. // was returned from a transaction, and the transaction was committed or rolled back.
  159. func (wc *WhatsappChannel) Update() *WhatsappChannelUpdateOne {
  160. return NewWhatsappChannelClient(wc.config).UpdateOne(wc)
  161. }
  162. // Unwrap unwraps the WhatsappChannel entity that was returned from a transaction after it was closed,
  163. // so that all future queries will be executed through the driver which created the transaction.
  164. func (wc *WhatsappChannel) Unwrap() *WhatsappChannel {
  165. _tx, ok := wc.config.driver.(*txDriver)
  166. if !ok {
  167. panic("ent: WhatsappChannel is not a transactional entity")
  168. }
  169. wc.config.driver = _tx.drv
  170. return wc
  171. }
  172. // String implements the fmt.Stringer.
  173. func (wc *WhatsappChannel) String() string {
  174. var builder strings.Builder
  175. builder.WriteString("WhatsappChannel(")
  176. builder.WriteString(fmt.Sprintf("id=%v, ", wc.ID))
  177. builder.WriteString("created_at=")
  178. builder.WriteString(wc.CreatedAt.Format(time.ANSIC))
  179. builder.WriteString(", ")
  180. builder.WriteString("updated_at=")
  181. builder.WriteString(wc.UpdatedAt.Format(time.ANSIC))
  182. builder.WriteString(", ")
  183. builder.WriteString("status=")
  184. builder.WriteString(fmt.Sprintf("%v", wc.Status))
  185. builder.WriteString(", ")
  186. builder.WriteString("deleted_at=")
  187. builder.WriteString(wc.DeletedAt.Format(time.ANSIC))
  188. builder.WriteString(", ")
  189. builder.WriteString("ak=")
  190. builder.WriteString(wc.Ak)
  191. builder.WriteString(", ")
  192. builder.WriteString("sk=")
  193. builder.WriteString(wc.Sk)
  194. builder.WriteString(", ")
  195. builder.WriteString("wa_id=")
  196. builder.WriteString(wc.WaID)
  197. builder.WriteString(", ")
  198. builder.WriteString("wa_name=")
  199. builder.WriteString(wc.WaName)
  200. builder.WriteString(", ")
  201. builder.WriteString("waba_id=")
  202. builder.WriteString(fmt.Sprintf("%v", wc.WabaID))
  203. builder.WriteString(", ")
  204. builder.WriteString("business_id=")
  205. builder.WriteString(fmt.Sprintf("%v", wc.BusinessID))
  206. builder.WriteString(", ")
  207. builder.WriteString("organization_id=")
  208. builder.WriteString(fmt.Sprintf("%v", wc.OrganizationID))
  209. builder.WriteString(", ")
  210. builder.WriteString("verify_account=")
  211. builder.WriteString(wc.VerifyAccount)
  212. builder.WriteByte(')')
  213. return builder.String()
  214. }
  215. // WhatsappChannels is a parsable slice of WhatsappChannel.
  216. type WhatsappChannels []*WhatsappChannel