wx.go 8.9 KB

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