contact.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "fmt"
  5. "strings"
  6. "time"
  7. "wechat-api/ent/contact"
  8. "entgo.io/ent"
  9. "entgo.io/ent/dialect/sql"
  10. )
  11. // Contact is the model entity for the Contact schema.
  12. type Contact 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. // 属主微信id
  25. WxWxid string `json:"wx_wxid,omitempty"`
  26. // 联系人类型:1好友,2群组,3公众号,4企业微信联系人
  27. Type int `json:"type,omitempty"`
  28. // 微信id 公众号微信ID
  29. Wxid string `json:"wxid,omitempty"`
  30. // 微信账号
  31. Account string `json:"account,omitempty"`
  32. // 微信昵称 群备注名称
  33. Nickname string `json:"nickname,omitempty"`
  34. // 备注名
  35. Markname string `json:"markname,omitempty"`
  36. // 头像
  37. Headimg string `json:"headimg,omitempty"`
  38. // 性别 0未知 1男 2女
  39. Sex int `json:"sex,omitempty"`
  40. // 星标 65/67=星标 1/3=未星标
  41. Starrole string `json:"starrole,omitempty"`
  42. // 不让他看我的朋友圈 0可以看 1不让看
  43. Dontseeit int `json:"dontseeit,omitempty"`
  44. // 不看他的朋友圈 0可以看 1不看 1=开启了不看他 128/129=仅聊天
  45. Dontseeme int `json:"dontseeme,omitempty"`
  46. // 所属标签id清单,多开会用逗号隔开
  47. Lag string `json:"lag,omitempty"`
  48. // 群组id
  49. Gid string `json:"gid,omitempty"`
  50. // 群组名称
  51. Gname string `json:"gname,omitempty"`
  52. // v3数据
  53. V3 string `json:"v3,omitempty"`
  54. // 机构 ID
  55. OrganizationID uint64 `json:"organization_id,omitempty"`
  56. // 内容类型:1-微信 2-whatsapp
  57. Ctype uint64 `json:"ctype,omitempty"`
  58. // 年龄
  59. Cage int `json:"cage,omitempty"`
  60. // 姓名
  61. Cname string `json:"cname,omitempty"`
  62. // 地区
  63. Carea string `json:"carea,omitempty"`
  64. // 出生日期
  65. Cbirthday string `json:"cbirthday,omitempty"`
  66. // 出生地
  67. Cbirtharea string `json:"cbirtharea,omitempty"`
  68. // 身份证号
  69. CidcardNo string `json:"cidcard_no,omitempty"`
  70. // 称呼
  71. Ctitle string `json:"ctitle,omitempty"`
  72. // 国家区号
  73. Cc string `json:"cc,omitempty"`
  74. // 手机号
  75. Phone string `json:"phone,omitempty"`
  76. // Edges holds the relations/edges for other nodes in the graph.
  77. // The values are being populated by the ContactQuery when eager-loading is set.
  78. Edges ContactEdges `json:"edges"`
  79. selectValues sql.SelectValues
  80. }
  81. // ContactEdges holds the relations/edges for other nodes in the graph.
  82. type ContactEdges struct {
  83. // ContactRelationships holds the value of the contact_relationships edge.
  84. ContactRelationships []*LabelRelationship `json:"contact_relationships,omitempty"`
  85. // ContactMessages holds the value of the contact_messages edge.
  86. ContactMessages []*MessageRecords `json:"contact_messages,omitempty"`
  87. // loadedTypes holds the information for reporting if a
  88. // type was loaded (or requested) in eager-loading or not.
  89. loadedTypes [2]bool
  90. }
  91. // ContactRelationshipsOrErr returns the ContactRelationships value or an error if the edge
  92. // was not loaded in eager-loading.
  93. func (e ContactEdges) ContactRelationshipsOrErr() ([]*LabelRelationship, error) {
  94. if e.loadedTypes[0] {
  95. return e.ContactRelationships, nil
  96. }
  97. return nil, &NotLoadedError{edge: "contact_relationships"}
  98. }
  99. // ContactMessagesOrErr returns the ContactMessages value or an error if the edge
  100. // was not loaded in eager-loading.
  101. func (e ContactEdges) ContactMessagesOrErr() ([]*MessageRecords, error) {
  102. if e.loadedTypes[1] {
  103. return e.ContactMessages, nil
  104. }
  105. return nil, &NotLoadedError{edge: "contact_messages"}
  106. }
  107. // scanValues returns the types for scanning values from sql.Rows.
  108. func (*Contact) scanValues(columns []string) ([]any, error) {
  109. values := make([]any, len(columns))
  110. for i := range columns {
  111. switch columns[i] {
  112. case contact.FieldID, contact.FieldStatus, contact.FieldType, contact.FieldSex, contact.FieldDontseeit, contact.FieldDontseeme, contact.FieldOrganizationID, contact.FieldCtype, contact.FieldCage:
  113. values[i] = new(sql.NullInt64)
  114. case contact.FieldWxWxid, contact.FieldWxid, contact.FieldAccount, contact.FieldNickname, contact.FieldMarkname, contact.FieldHeadimg, contact.FieldStarrole, contact.FieldLag, contact.FieldGid, contact.FieldGname, contact.FieldV3, contact.FieldCname, contact.FieldCarea, contact.FieldCbirthday, contact.FieldCbirtharea, contact.FieldCidcardNo, contact.FieldCtitle, contact.FieldCc, contact.FieldPhone:
  115. values[i] = new(sql.NullString)
  116. case contact.FieldCreatedAt, contact.FieldUpdatedAt, contact.FieldDeletedAt:
  117. values[i] = new(sql.NullTime)
  118. default:
  119. values[i] = new(sql.UnknownType)
  120. }
  121. }
  122. return values, nil
  123. }
  124. // assignValues assigns the values that were returned from sql.Rows (after scanning)
  125. // to the Contact fields.
  126. func (c *Contact) assignValues(columns []string, values []any) error {
  127. if m, n := len(values), len(columns); m < n {
  128. return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
  129. }
  130. for i := range columns {
  131. switch columns[i] {
  132. case contact.FieldID:
  133. value, ok := values[i].(*sql.NullInt64)
  134. if !ok {
  135. return fmt.Errorf("unexpected type %T for field id", value)
  136. }
  137. c.ID = uint64(value.Int64)
  138. case contact.FieldCreatedAt:
  139. if value, ok := values[i].(*sql.NullTime); !ok {
  140. return fmt.Errorf("unexpected type %T for field created_at", values[i])
  141. } else if value.Valid {
  142. c.CreatedAt = value.Time
  143. }
  144. case contact.FieldUpdatedAt:
  145. if value, ok := values[i].(*sql.NullTime); !ok {
  146. return fmt.Errorf("unexpected type %T for field updated_at", values[i])
  147. } else if value.Valid {
  148. c.UpdatedAt = value.Time
  149. }
  150. case contact.FieldStatus:
  151. if value, ok := values[i].(*sql.NullInt64); !ok {
  152. return fmt.Errorf("unexpected type %T for field status", values[i])
  153. } else if value.Valid {
  154. c.Status = uint8(value.Int64)
  155. }
  156. case contact.FieldDeletedAt:
  157. if value, ok := values[i].(*sql.NullTime); !ok {
  158. return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
  159. } else if value.Valid {
  160. c.DeletedAt = value.Time
  161. }
  162. case contact.FieldWxWxid:
  163. if value, ok := values[i].(*sql.NullString); !ok {
  164. return fmt.Errorf("unexpected type %T for field wx_wxid", values[i])
  165. } else if value.Valid {
  166. c.WxWxid = value.String
  167. }
  168. case contact.FieldType:
  169. if value, ok := values[i].(*sql.NullInt64); !ok {
  170. return fmt.Errorf("unexpected type %T for field type", values[i])
  171. } else if value.Valid {
  172. c.Type = int(value.Int64)
  173. }
  174. case contact.FieldWxid:
  175. if value, ok := values[i].(*sql.NullString); !ok {
  176. return fmt.Errorf("unexpected type %T for field wxid", values[i])
  177. } else if value.Valid {
  178. c.Wxid = value.String
  179. }
  180. case contact.FieldAccount:
  181. if value, ok := values[i].(*sql.NullString); !ok {
  182. return fmt.Errorf("unexpected type %T for field account", values[i])
  183. } else if value.Valid {
  184. c.Account = value.String
  185. }
  186. case contact.FieldNickname:
  187. if value, ok := values[i].(*sql.NullString); !ok {
  188. return fmt.Errorf("unexpected type %T for field nickname", values[i])
  189. } else if value.Valid {
  190. c.Nickname = value.String
  191. }
  192. case contact.FieldMarkname:
  193. if value, ok := values[i].(*sql.NullString); !ok {
  194. return fmt.Errorf("unexpected type %T for field markname", values[i])
  195. } else if value.Valid {
  196. c.Markname = value.String
  197. }
  198. case contact.FieldHeadimg:
  199. if value, ok := values[i].(*sql.NullString); !ok {
  200. return fmt.Errorf("unexpected type %T for field headimg", values[i])
  201. } else if value.Valid {
  202. c.Headimg = value.String
  203. }
  204. case contact.FieldSex:
  205. if value, ok := values[i].(*sql.NullInt64); !ok {
  206. return fmt.Errorf("unexpected type %T for field sex", values[i])
  207. } else if value.Valid {
  208. c.Sex = int(value.Int64)
  209. }
  210. case contact.FieldStarrole:
  211. if value, ok := values[i].(*sql.NullString); !ok {
  212. return fmt.Errorf("unexpected type %T for field starrole", values[i])
  213. } else if value.Valid {
  214. c.Starrole = value.String
  215. }
  216. case contact.FieldDontseeit:
  217. if value, ok := values[i].(*sql.NullInt64); !ok {
  218. return fmt.Errorf("unexpected type %T for field dontseeit", values[i])
  219. } else if value.Valid {
  220. c.Dontseeit = int(value.Int64)
  221. }
  222. case contact.FieldDontseeme:
  223. if value, ok := values[i].(*sql.NullInt64); !ok {
  224. return fmt.Errorf("unexpected type %T for field dontseeme", values[i])
  225. } else if value.Valid {
  226. c.Dontseeme = int(value.Int64)
  227. }
  228. case contact.FieldLag:
  229. if value, ok := values[i].(*sql.NullString); !ok {
  230. return fmt.Errorf("unexpected type %T for field lag", values[i])
  231. } else if value.Valid {
  232. c.Lag = value.String
  233. }
  234. case contact.FieldGid:
  235. if value, ok := values[i].(*sql.NullString); !ok {
  236. return fmt.Errorf("unexpected type %T for field gid", values[i])
  237. } else if value.Valid {
  238. c.Gid = value.String
  239. }
  240. case contact.FieldGname:
  241. if value, ok := values[i].(*sql.NullString); !ok {
  242. return fmt.Errorf("unexpected type %T for field gname", values[i])
  243. } else if value.Valid {
  244. c.Gname = value.String
  245. }
  246. case contact.FieldV3:
  247. if value, ok := values[i].(*sql.NullString); !ok {
  248. return fmt.Errorf("unexpected type %T for field v3", values[i])
  249. } else if value.Valid {
  250. c.V3 = value.String
  251. }
  252. case contact.FieldOrganizationID:
  253. if value, ok := values[i].(*sql.NullInt64); !ok {
  254. return fmt.Errorf("unexpected type %T for field organization_id", values[i])
  255. } else if value.Valid {
  256. c.OrganizationID = uint64(value.Int64)
  257. }
  258. case contact.FieldCtype:
  259. if value, ok := values[i].(*sql.NullInt64); !ok {
  260. return fmt.Errorf("unexpected type %T for field ctype", values[i])
  261. } else if value.Valid {
  262. c.Ctype = uint64(value.Int64)
  263. }
  264. case contact.FieldCage:
  265. if value, ok := values[i].(*sql.NullInt64); !ok {
  266. return fmt.Errorf("unexpected type %T for field cage", values[i])
  267. } else if value.Valid {
  268. c.Cage = int(value.Int64)
  269. }
  270. case contact.FieldCname:
  271. if value, ok := values[i].(*sql.NullString); !ok {
  272. return fmt.Errorf("unexpected type %T for field cname", values[i])
  273. } else if value.Valid {
  274. c.Cname = value.String
  275. }
  276. case contact.FieldCarea:
  277. if value, ok := values[i].(*sql.NullString); !ok {
  278. return fmt.Errorf("unexpected type %T for field carea", values[i])
  279. } else if value.Valid {
  280. c.Carea = value.String
  281. }
  282. case contact.FieldCbirthday:
  283. if value, ok := values[i].(*sql.NullString); !ok {
  284. return fmt.Errorf("unexpected type %T for field cbirthday", values[i])
  285. } else if value.Valid {
  286. c.Cbirthday = value.String
  287. }
  288. case contact.FieldCbirtharea:
  289. if value, ok := values[i].(*sql.NullString); !ok {
  290. return fmt.Errorf("unexpected type %T for field cbirtharea", values[i])
  291. } else if value.Valid {
  292. c.Cbirtharea = value.String
  293. }
  294. case contact.FieldCidcardNo:
  295. if value, ok := values[i].(*sql.NullString); !ok {
  296. return fmt.Errorf("unexpected type %T for field cidcard_no", values[i])
  297. } else if value.Valid {
  298. c.CidcardNo = value.String
  299. }
  300. case contact.FieldCtitle:
  301. if value, ok := values[i].(*sql.NullString); !ok {
  302. return fmt.Errorf("unexpected type %T for field ctitle", values[i])
  303. } else if value.Valid {
  304. c.Ctitle = value.String
  305. }
  306. case contact.FieldCc:
  307. if value, ok := values[i].(*sql.NullString); !ok {
  308. return fmt.Errorf("unexpected type %T for field cc", values[i])
  309. } else if value.Valid {
  310. c.Cc = value.String
  311. }
  312. case contact.FieldPhone:
  313. if value, ok := values[i].(*sql.NullString); !ok {
  314. return fmt.Errorf("unexpected type %T for field phone", values[i])
  315. } else if value.Valid {
  316. c.Phone = value.String
  317. }
  318. default:
  319. c.selectValues.Set(columns[i], values[i])
  320. }
  321. }
  322. return nil
  323. }
  324. // Value returns the ent.Value that was dynamically selected and assigned to the Contact.
  325. // This includes values selected through modifiers, order, etc.
  326. func (c *Contact) Value(name string) (ent.Value, error) {
  327. return c.selectValues.Get(name)
  328. }
  329. // QueryContactRelationships queries the "contact_relationships" edge of the Contact entity.
  330. func (c *Contact) QueryContactRelationships() *LabelRelationshipQuery {
  331. return NewContactClient(c.config).QueryContactRelationships(c)
  332. }
  333. // QueryContactMessages queries the "contact_messages" edge of the Contact entity.
  334. func (c *Contact) QueryContactMessages() *MessageRecordsQuery {
  335. return NewContactClient(c.config).QueryContactMessages(c)
  336. }
  337. // Update returns a builder for updating this Contact.
  338. // Note that you need to call Contact.Unwrap() before calling this method if this Contact
  339. // was returned from a transaction, and the transaction was committed or rolled back.
  340. func (c *Contact) Update() *ContactUpdateOne {
  341. return NewContactClient(c.config).UpdateOne(c)
  342. }
  343. // Unwrap unwraps the Contact entity that was returned from a transaction after it was closed,
  344. // so that all future queries will be executed through the driver which created the transaction.
  345. func (c *Contact) Unwrap() *Contact {
  346. _tx, ok := c.config.driver.(*txDriver)
  347. if !ok {
  348. panic("ent: Contact is not a transactional entity")
  349. }
  350. c.config.driver = _tx.drv
  351. return c
  352. }
  353. // String implements the fmt.Stringer.
  354. func (c *Contact) String() string {
  355. var builder strings.Builder
  356. builder.WriteString("Contact(")
  357. builder.WriteString(fmt.Sprintf("id=%v, ", c.ID))
  358. builder.WriteString("created_at=")
  359. builder.WriteString(c.CreatedAt.Format(time.ANSIC))
  360. builder.WriteString(", ")
  361. builder.WriteString("updated_at=")
  362. builder.WriteString(c.UpdatedAt.Format(time.ANSIC))
  363. builder.WriteString(", ")
  364. builder.WriteString("status=")
  365. builder.WriteString(fmt.Sprintf("%v", c.Status))
  366. builder.WriteString(", ")
  367. builder.WriteString("deleted_at=")
  368. builder.WriteString(c.DeletedAt.Format(time.ANSIC))
  369. builder.WriteString(", ")
  370. builder.WriteString("wx_wxid=")
  371. builder.WriteString(c.WxWxid)
  372. builder.WriteString(", ")
  373. builder.WriteString("type=")
  374. builder.WriteString(fmt.Sprintf("%v", c.Type))
  375. builder.WriteString(", ")
  376. builder.WriteString("wxid=")
  377. builder.WriteString(c.Wxid)
  378. builder.WriteString(", ")
  379. builder.WriteString("account=")
  380. builder.WriteString(c.Account)
  381. builder.WriteString(", ")
  382. builder.WriteString("nickname=")
  383. builder.WriteString(c.Nickname)
  384. builder.WriteString(", ")
  385. builder.WriteString("markname=")
  386. builder.WriteString(c.Markname)
  387. builder.WriteString(", ")
  388. builder.WriteString("headimg=")
  389. builder.WriteString(c.Headimg)
  390. builder.WriteString(", ")
  391. builder.WriteString("sex=")
  392. builder.WriteString(fmt.Sprintf("%v", c.Sex))
  393. builder.WriteString(", ")
  394. builder.WriteString("starrole=")
  395. builder.WriteString(c.Starrole)
  396. builder.WriteString(", ")
  397. builder.WriteString("dontseeit=")
  398. builder.WriteString(fmt.Sprintf("%v", c.Dontseeit))
  399. builder.WriteString(", ")
  400. builder.WriteString("dontseeme=")
  401. builder.WriteString(fmt.Sprintf("%v", c.Dontseeme))
  402. builder.WriteString(", ")
  403. builder.WriteString("lag=")
  404. builder.WriteString(c.Lag)
  405. builder.WriteString(", ")
  406. builder.WriteString("gid=")
  407. builder.WriteString(c.Gid)
  408. builder.WriteString(", ")
  409. builder.WriteString("gname=")
  410. builder.WriteString(c.Gname)
  411. builder.WriteString(", ")
  412. builder.WriteString("v3=")
  413. builder.WriteString(c.V3)
  414. builder.WriteString(", ")
  415. builder.WriteString("organization_id=")
  416. builder.WriteString(fmt.Sprintf("%v", c.OrganizationID))
  417. builder.WriteString(", ")
  418. builder.WriteString("ctype=")
  419. builder.WriteString(fmt.Sprintf("%v", c.Ctype))
  420. builder.WriteString(", ")
  421. builder.WriteString("cage=")
  422. builder.WriteString(fmt.Sprintf("%v", c.Cage))
  423. builder.WriteString(", ")
  424. builder.WriteString("cname=")
  425. builder.WriteString(c.Cname)
  426. builder.WriteString(", ")
  427. builder.WriteString("carea=")
  428. builder.WriteString(c.Carea)
  429. builder.WriteString(", ")
  430. builder.WriteString("cbirthday=")
  431. builder.WriteString(c.Cbirthday)
  432. builder.WriteString(", ")
  433. builder.WriteString("cbirtharea=")
  434. builder.WriteString(c.Cbirtharea)
  435. builder.WriteString(", ")
  436. builder.WriteString("cidcard_no=")
  437. builder.WriteString(c.CidcardNo)
  438. builder.WriteString(", ")
  439. builder.WriteString("ctitle=")
  440. builder.WriteString(c.Ctitle)
  441. builder.WriteString(", ")
  442. builder.WriteString("cc=")
  443. builder.WriteString(c.Cc)
  444. builder.WriteString(", ")
  445. builder.WriteString("phone=")
  446. builder.WriteString(c.Phone)
  447. builder.WriteByte(')')
  448. return builder.String()
  449. }
  450. // Contacts is a parsable slice of Contact.
  451. type Contacts []*Contact