wx.go 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "fmt"
  5. "strings"
  6. "time"
  7. "wechat-api/ent/server"
  8. "wechat-api/ent/wx"
  9. "entgo.io/ent"
  10. "entgo.io/ent/dialect/sql"
  11. )
  12. // Wx is the model entity for the Wx schema.
  13. type Wx struct {
  14. config `json:"-"`
  15. // ID of the ent.
  16. ID uint64 `json:"id,omitempty"`
  17. // Create Time | 创建日期
  18. CreatedAt time.Time `json:"created_at,omitempty"`
  19. // Update Time | 修改日期
  20. UpdatedAt time.Time `json:"updated_at,omitempty"`
  21. // Status 1: normal 2: ban | 状态 1 正常 2 禁用
  22. Status uint8 `json:"status,omitempty"`
  23. // Delete Time | 删除日期
  24. DeletedAt time.Time `json:"deleted_at,omitempty"`
  25. // 服务器id
  26. ServerID uint64 `json:"server_id,omitempty"`
  27. // 端口号
  28. Port string `json:"port,omitempty"`
  29. // 进程号
  30. ProcessID string `json:"process_id,omitempty"`
  31. // 回调地址
  32. Callback string `json:"callback,omitempty"`
  33. // 微信id
  34. Wxid string `json:"wxid,omitempty"`
  35. // 微信账号
  36. Account string `json:"account,omitempty"`
  37. // 微信昵称
  38. Nickname string `json:"nickname,omitempty"`
  39. // 手机号
  40. Tel string `json:"tel,omitempty"`
  41. // 微信头像
  42. HeadBig string `json:"head_big,omitempty"`
  43. // Edges holds the relations/edges for other nodes in the graph.
  44. // The values are being populated by the WxQuery when eager-loading is set.
  45. Edges WxEdges `json:"edges"`
  46. selectValues sql.SelectValues
  47. }
  48. // WxEdges holds the relations/edges for other nodes in the graph.
  49. type WxEdges struct {
  50. // Server holds the value of the server edge.
  51. Server *Server `json:"server,omitempty"`
  52. // loadedTypes holds the information for reporting if a
  53. // type was loaded (or requested) in eager-loading or not.
  54. loadedTypes [1]bool
  55. }
  56. // ServerOrErr returns the Server value or an error if the edge
  57. // was not loaded in eager-loading, or loaded but was not found.
  58. func (e WxEdges) ServerOrErr() (*Server, error) {
  59. if e.Server != nil {
  60. return e.Server, nil
  61. } else if e.loadedTypes[0] {
  62. return nil, &NotFoundError{label: server.Label}
  63. }
  64. return nil, &NotLoadedError{edge: "server"}
  65. }
  66. // scanValues returns the types for scanning values from sql.Rows.
  67. func (*Wx) scanValues(columns []string) ([]any, error) {
  68. values := make([]any, len(columns))
  69. for i := range columns {
  70. switch columns[i] {
  71. case wx.FieldID, wx.FieldStatus, wx.FieldServerID:
  72. values[i] = new(sql.NullInt64)
  73. case wx.FieldPort, wx.FieldProcessID, wx.FieldCallback, wx.FieldWxid, wx.FieldAccount, wx.FieldNickname, wx.FieldTel, wx.FieldHeadBig:
  74. values[i] = new(sql.NullString)
  75. case wx.FieldCreatedAt, wx.FieldUpdatedAt, wx.FieldDeletedAt:
  76. values[i] = new(sql.NullTime)
  77. default:
  78. values[i] = new(sql.UnknownType)
  79. }
  80. }
  81. return values, nil
  82. }
  83. // assignValues assigns the values that were returned from sql.Rows (after scanning)
  84. // to the Wx fields.
  85. func (w *Wx) assignValues(columns []string, values []any) error {
  86. if m, n := len(values), len(columns); m < n {
  87. return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
  88. }
  89. for i := range columns {
  90. switch columns[i] {
  91. case wx.FieldID:
  92. value, ok := values[i].(*sql.NullInt64)
  93. if !ok {
  94. return fmt.Errorf("unexpected type %T for field id", value)
  95. }
  96. w.ID = uint64(value.Int64)
  97. case wx.FieldCreatedAt:
  98. if value, ok := values[i].(*sql.NullTime); !ok {
  99. return fmt.Errorf("unexpected type %T for field created_at", values[i])
  100. } else if value.Valid {
  101. w.CreatedAt = value.Time
  102. }
  103. case wx.FieldUpdatedAt:
  104. if value, ok := values[i].(*sql.NullTime); !ok {
  105. return fmt.Errorf("unexpected type %T for field updated_at", values[i])
  106. } else if value.Valid {
  107. w.UpdatedAt = value.Time
  108. }
  109. case wx.FieldStatus:
  110. if value, ok := values[i].(*sql.NullInt64); !ok {
  111. return fmt.Errorf("unexpected type %T for field status", values[i])
  112. } else if value.Valid {
  113. w.Status = uint8(value.Int64)
  114. }
  115. case wx.FieldDeletedAt:
  116. if value, ok := values[i].(*sql.NullTime); !ok {
  117. return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
  118. } else if value.Valid {
  119. w.DeletedAt = value.Time
  120. }
  121. case wx.FieldServerID:
  122. if value, ok := values[i].(*sql.NullInt64); !ok {
  123. return fmt.Errorf("unexpected type %T for field server_id", values[i])
  124. } else if value.Valid {
  125. w.ServerID = uint64(value.Int64)
  126. }
  127. case wx.FieldPort:
  128. if value, ok := values[i].(*sql.NullString); !ok {
  129. return fmt.Errorf("unexpected type %T for field port", values[i])
  130. } else if value.Valid {
  131. w.Port = value.String
  132. }
  133. case wx.FieldProcessID:
  134. if value, ok := values[i].(*sql.NullString); !ok {
  135. return fmt.Errorf("unexpected type %T for field process_id", values[i])
  136. } else if value.Valid {
  137. w.ProcessID = value.String
  138. }
  139. case wx.FieldCallback:
  140. if value, ok := values[i].(*sql.NullString); !ok {
  141. return fmt.Errorf("unexpected type %T for field callback", values[i])
  142. } else if value.Valid {
  143. w.Callback = value.String
  144. }
  145. case wx.FieldWxid:
  146. if value, ok := values[i].(*sql.NullString); !ok {
  147. return fmt.Errorf("unexpected type %T for field wxid", values[i])
  148. } else if value.Valid {
  149. w.Wxid = value.String
  150. }
  151. case wx.FieldAccount:
  152. if value, ok := values[i].(*sql.NullString); !ok {
  153. return fmt.Errorf("unexpected type %T for field account", values[i])
  154. } else if value.Valid {
  155. w.Account = value.String
  156. }
  157. case wx.FieldNickname:
  158. if value, ok := values[i].(*sql.NullString); !ok {
  159. return fmt.Errorf("unexpected type %T for field nickname", values[i])
  160. } else if value.Valid {
  161. w.Nickname = value.String
  162. }
  163. case wx.FieldTel:
  164. if value, ok := values[i].(*sql.NullString); !ok {
  165. return fmt.Errorf("unexpected type %T for field tel", values[i])
  166. } else if value.Valid {
  167. w.Tel = value.String
  168. }
  169. case wx.FieldHeadBig:
  170. if value, ok := values[i].(*sql.NullString); !ok {
  171. return fmt.Errorf("unexpected type %T for field head_big", values[i])
  172. } else if value.Valid {
  173. w.HeadBig = value.String
  174. }
  175. default:
  176. w.selectValues.Set(columns[i], values[i])
  177. }
  178. }
  179. return nil
  180. }
  181. // Value returns the ent.Value that was dynamically selected and assigned to the Wx.
  182. // This includes values selected through modifiers, order, etc.
  183. func (w *Wx) Value(name string) (ent.Value, error) {
  184. return w.selectValues.Get(name)
  185. }
  186. // QueryServer queries the "server" edge of the Wx entity.
  187. func (w *Wx) QueryServer() *ServerQuery {
  188. return NewWxClient(w.config).QueryServer(w)
  189. }
  190. // Update returns a builder for updating this Wx.
  191. // Note that you need to call Wx.Unwrap() before calling this method if this Wx
  192. // was returned from a transaction, and the transaction was committed or rolled back.
  193. func (w *Wx) Update() *WxUpdateOne {
  194. return NewWxClient(w.config).UpdateOne(w)
  195. }
  196. // Unwrap unwraps the Wx entity that was returned from a transaction after it was closed,
  197. // so that all future queries will be executed through the driver which created the transaction.
  198. func (w *Wx) Unwrap() *Wx {
  199. _tx, ok := w.config.driver.(*txDriver)
  200. if !ok {
  201. panic("ent: Wx is not a transactional entity")
  202. }
  203. w.config.driver = _tx.drv
  204. return w
  205. }
  206. // String implements the fmt.Stringer.
  207. func (w *Wx) String() string {
  208. var builder strings.Builder
  209. builder.WriteString("Wx(")
  210. builder.WriteString(fmt.Sprintf("id=%v, ", w.ID))
  211. builder.WriteString("created_at=")
  212. builder.WriteString(w.CreatedAt.Format(time.ANSIC))
  213. builder.WriteString(", ")
  214. builder.WriteString("updated_at=")
  215. builder.WriteString(w.UpdatedAt.Format(time.ANSIC))
  216. builder.WriteString(", ")
  217. builder.WriteString("status=")
  218. builder.WriteString(fmt.Sprintf("%v", w.Status))
  219. builder.WriteString(", ")
  220. builder.WriteString("deleted_at=")
  221. builder.WriteString(w.DeletedAt.Format(time.ANSIC))
  222. builder.WriteString(", ")
  223. builder.WriteString("server_id=")
  224. builder.WriteString(fmt.Sprintf("%v", w.ServerID))
  225. builder.WriteString(", ")
  226. builder.WriteString("port=")
  227. builder.WriteString(w.Port)
  228. builder.WriteString(", ")
  229. builder.WriteString("process_id=")
  230. builder.WriteString(w.ProcessID)
  231. builder.WriteString(", ")
  232. builder.WriteString("callback=")
  233. builder.WriteString(w.Callback)
  234. builder.WriteString(", ")
  235. builder.WriteString("wxid=")
  236. builder.WriteString(w.Wxid)
  237. builder.WriteString(", ")
  238. builder.WriteString("account=")
  239. builder.WriteString(w.Account)
  240. builder.WriteString(", ")
  241. builder.WriteString("nickname=")
  242. builder.WriteString(w.Nickname)
  243. builder.WriteString(", ")
  244. builder.WriteString("tel=")
  245. builder.WriteString(w.Tel)
  246. builder.WriteString(", ")
  247. builder.WriteString("head_big=")
  248. builder.WriteString(w.HeadBig)
  249. builder.WriteByte(')')
  250. return builder.String()
  251. }
  252. // Wxes is a parsable slice of Wx.
  253. type Wxes []*Wx