contact.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  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. // ContactFields holds the value of the contact_fields edge.
  86. ContactFields []*ContactField `json:"contact_fields,omitempty"`
  87. // ContactMessages holds the value of the contact_messages edge.
  88. ContactMessages []*MessageRecords `json:"contact_messages,omitempty"`
  89. // loadedTypes holds the information for reporting if a
  90. // type was loaded (or requested) in eager-loading or not.
  91. loadedTypes [3]bool
  92. }
  93. // ContactRelationshipsOrErr returns the ContactRelationships value or an error if the edge
  94. // was not loaded in eager-loading.
  95. func (e ContactEdges) ContactRelationshipsOrErr() ([]*LabelRelationship, error) {
  96. if e.loadedTypes[0] {
  97. return e.ContactRelationships, nil
  98. }
  99. return nil, &NotLoadedError{edge: "contact_relationships"}
  100. }
  101. // ContactFieldsOrErr returns the ContactFields value or an error if the edge
  102. // was not loaded in eager-loading.
  103. func (e ContactEdges) ContactFieldsOrErr() ([]*ContactField, error) {
  104. if e.loadedTypes[1] {
  105. return e.ContactFields, nil
  106. }
  107. return nil, &NotLoadedError{edge: "contact_fields"}
  108. }
  109. // ContactMessagesOrErr returns the ContactMessages value or an error if the edge
  110. // was not loaded in eager-loading.
  111. func (e ContactEdges) ContactMessagesOrErr() ([]*MessageRecords, error) {
  112. if e.loadedTypes[2] {
  113. return e.ContactMessages, nil
  114. }
  115. return nil, &NotLoadedError{edge: "contact_messages"}
  116. }
  117. // scanValues returns the types for scanning values from sql.Rows.
  118. func (*Contact) scanValues(columns []string) ([]any, error) {
  119. values := make([]any, len(columns))
  120. for i := range columns {
  121. switch columns[i] {
  122. case contact.FieldID, contact.FieldStatus, contact.FieldType, contact.FieldSex, contact.FieldDontseeit, contact.FieldDontseeme, contact.FieldOrganizationID, contact.FieldCtype, contact.FieldCage:
  123. values[i] = new(sql.NullInt64)
  124. 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:
  125. values[i] = new(sql.NullString)
  126. case contact.FieldCreatedAt, contact.FieldUpdatedAt, contact.FieldDeletedAt:
  127. values[i] = new(sql.NullTime)
  128. default:
  129. values[i] = new(sql.UnknownType)
  130. }
  131. }
  132. return values, nil
  133. }
  134. // assignValues assigns the values that were returned from sql.Rows (after scanning)
  135. // to the Contact fields.
  136. func (c *Contact) assignValues(columns []string, values []any) error {
  137. if m, n := len(values), len(columns); m < n {
  138. return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
  139. }
  140. for i := range columns {
  141. switch columns[i] {
  142. case contact.FieldID:
  143. value, ok := values[i].(*sql.NullInt64)
  144. if !ok {
  145. return fmt.Errorf("unexpected type %T for field id", value)
  146. }
  147. c.ID = uint64(value.Int64)
  148. case contact.FieldCreatedAt:
  149. if value, ok := values[i].(*sql.NullTime); !ok {
  150. return fmt.Errorf("unexpected type %T for field created_at", values[i])
  151. } else if value.Valid {
  152. c.CreatedAt = value.Time
  153. }
  154. case contact.FieldUpdatedAt:
  155. if value, ok := values[i].(*sql.NullTime); !ok {
  156. return fmt.Errorf("unexpected type %T for field updated_at", values[i])
  157. } else if value.Valid {
  158. c.UpdatedAt = value.Time
  159. }
  160. case contact.FieldStatus:
  161. if value, ok := values[i].(*sql.NullInt64); !ok {
  162. return fmt.Errorf("unexpected type %T for field status", values[i])
  163. } else if value.Valid {
  164. c.Status = uint8(value.Int64)
  165. }
  166. case contact.FieldDeletedAt:
  167. if value, ok := values[i].(*sql.NullTime); !ok {
  168. return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
  169. } else if value.Valid {
  170. c.DeletedAt = value.Time
  171. }
  172. case contact.FieldWxWxid:
  173. if value, ok := values[i].(*sql.NullString); !ok {
  174. return fmt.Errorf("unexpected type %T for field wx_wxid", values[i])
  175. } else if value.Valid {
  176. c.WxWxid = value.String
  177. }
  178. case contact.FieldType:
  179. if value, ok := values[i].(*sql.NullInt64); !ok {
  180. return fmt.Errorf("unexpected type %T for field type", values[i])
  181. } else if value.Valid {
  182. c.Type = int(value.Int64)
  183. }
  184. case contact.FieldWxid:
  185. if value, ok := values[i].(*sql.NullString); !ok {
  186. return fmt.Errorf("unexpected type %T for field wxid", values[i])
  187. } else if value.Valid {
  188. c.Wxid = value.String
  189. }
  190. case contact.FieldAccount:
  191. if value, ok := values[i].(*sql.NullString); !ok {
  192. return fmt.Errorf("unexpected type %T for field account", values[i])
  193. } else if value.Valid {
  194. c.Account = value.String
  195. }
  196. case contact.FieldNickname:
  197. if value, ok := values[i].(*sql.NullString); !ok {
  198. return fmt.Errorf("unexpected type %T for field nickname", values[i])
  199. } else if value.Valid {
  200. c.Nickname = value.String
  201. }
  202. case contact.FieldMarkname:
  203. if value, ok := values[i].(*sql.NullString); !ok {
  204. return fmt.Errorf("unexpected type %T for field markname", values[i])
  205. } else if value.Valid {
  206. c.Markname = value.String
  207. }
  208. case contact.FieldHeadimg:
  209. if value, ok := values[i].(*sql.NullString); !ok {
  210. return fmt.Errorf("unexpected type %T for field headimg", values[i])
  211. } else if value.Valid {
  212. c.Headimg = value.String
  213. }
  214. case contact.FieldSex:
  215. if value, ok := values[i].(*sql.NullInt64); !ok {
  216. return fmt.Errorf("unexpected type %T for field sex", values[i])
  217. } else if value.Valid {
  218. c.Sex = int(value.Int64)
  219. }
  220. case contact.FieldStarrole:
  221. if value, ok := values[i].(*sql.NullString); !ok {
  222. return fmt.Errorf("unexpected type %T for field starrole", values[i])
  223. } else if value.Valid {
  224. c.Starrole = value.String
  225. }
  226. case contact.FieldDontseeit:
  227. if value, ok := values[i].(*sql.NullInt64); !ok {
  228. return fmt.Errorf("unexpected type %T for field dontseeit", values[i])
  229. } else if value.Valid {
  230. c.Dontseeit = int(value.Int64)
  231. }
  232. case contact.FieldDontseeme:
  233. if value, ok := values[i].(*sql.NullInt64); !ok {
  234. return fmt.Errorf("unexpected type %T for field dontseeme", values[i])
  235. } else if value.Valid {
  236. c.Dontseeme = int(value.Int64)
  237. }
  238. case contact.FieldLag:
  239. if value, ok := values[i].(*sql.NullString); !ok {
  240. return fmt.Errorf("unexpected type %T for field lag", values[i])
  241. } else if value.Valid {
  242. c.Lag = value.String
  243. }
  244. case contact.FieldGid:
  245. if value, ok := values[i].(*sql.NullString); !ok {
  246. return fmt.Errorf("unexpected type %T for field gid", values[i])
  247. } else if value.Valid {
  248. c.Gid = value.String
  249. }
  250. case contact.FieldGname:
  251. if value, ok := values[i].(*sql.NullString); !ok {
  252. return fmt.Errorf("unexpected type %T for field gname", values[i])
  253. } else if value.Valid {
  254. c.Gname = value.String
  255. }
  256. case contact.FieldV3:
  257. if value, ok := values[i].(*sql.NullString); !ok {
  258. return fmt.Errorf("unexpected type %T for field v3", values[i])
  259. } else if value.Valid {
  260. c.V3 = value.String
  261. }
  262. case contact.FieldOrganizationID:
  263. if value, ok := values[i].(*sql.NullInt64); !ok {
  264. return fmt.Errorf("unexpected type %T for field organization_id", values[i])
  265. } else if value.Valid {
  266. c.OrganizationID = uint64(value.Int64)
  267. }
  268. case contact.FieldCtype:
  269. if value, ok := values[i].(*sql.NullInt64); !ok {
  270. return fmt.Errorf("unexpected type %T for field ctype", values[i])
  271. } else if value.Valid {
  272. c.Ctype = uint64(value.Int64)
  273. }
  274. case contact.FieldCage:
  275. if value, ok := values[i].(*sql.NullInt64); !ok {
  276. return fmt.Errorf("unexpected type %T for field cage", values[i])
  277. } else if value.Valid {
  278. c.Cage = int(value.Int64)
  279. }
  280. case contact.FieldCname:
  281. if value, ok := values[i].(*sql.NullString); !ok {
  282. return fmt.Errorf("unexpected type %T for field cname", values[i])
  283. } else if value.Valid {
  284. c.Cname = value.String
  285. }
  286. case contact.FieldCarea:
  287. if value, ok := values[i].(*sql.NullString); !ok {
  288. return fmt.Errorf("unexpected type %T for field carea", values[i])
  289. } else if value.Valid {
  290. c.Carea = value.String
  291. }
  292. case contact.FieldCbirthday:
  293. if value, ok := values[i].(*sql.NullString); !ok {
  294. return fmt.Errorf("unexpected type %T for field cbirthday", values[i])
  295. } else if value.Valid {
  296. c.Cbirthday = value.String
  297. }
  298. case contact.FieldCbirtharea:
  299. if value, ok := values[i].(*sql.NullString); !ok {
  300. return fmt.Errorf("unexpected type %T for field cbirtharea", values[i])
  301. } else if value.Valid {
  302. c.Cbirtharea = value.String
  303. }
  304. case contact.FieldCidcardNo:
  305. if value, ok := values[i].(*sql.NullString); !ok {
  306. return fmt.Errorf("unexpected type %T for field cidcard_no", values[i])
  307. } else if value.Valid {
  308. c.CidcardNo = value.String
  309. }
  310. case contact.FieldCtitle:
  311. if value, ok := values[i].(*sql.NullString); !ok {
  312. return fmt.Errorf("unexpected type %T for field ctitle", values[i])
  313. } else if value.Valid {
  314. c.Ctitle = value.String
  315. }
  316. case contact.FieldCc:
  317. if value, ok := values[i].(*sql.NullString); !ok {
  318. return fmt.Errorf("unexpected type %T for field cc", values[i])
  319. } else if value.Valid {
  320. c.Cc = value.String
  321. }
  322. case contact.FieldPhone:
  323. if value, ok := values[i].(*sql.NullString); !ok {
  324. return fmt.Errorf("unexpected type %T for field phone", values[i])
  325. } else if value.Valid {
  326. c.Phone = value.String
  327. }
  328. default:
  329. c.selectValues.Set(columns[i], values[i])
  330. }
  331. }
  332. return nil
  333. }
  334. // Value returns the ent.Value that was dynamically selected and assigned to the Contact.
  335. // This includes values selected through modifiers, order, etc.
  336. func (c *Contact) Value(name string) (ent.Value, error) {
  337. return c.selectValues.Get(name)
  338. }
  339. // QueryContactRelationships queries the "contact_relationships" edge of the Contact entity.
  340. func (c *Contact) QueryContactRelationships() *LabelRelationshipQuery {
  341. return NewContactClient(c.config).QueryContactRelationships(c)
  342. }
  343. // QueryContactFields queries the "contact_fields" edge of the Contact entity.
  344. func (c *Contact) QueryContactFields() *ContactFieldQuery {
  345. return NewContactClient(c.config).QueryContactFields(c)
  346. }
  347. // QueryContactMessages queries the "contact_messages" edge of the Contact entity.
  348. func (c *Contact) QueryContactMessages() *MessageRecordsQuery {
  349. return NewContactClient(c.config).QueryContactMessages(c)
  350. }
  351. // Update returns a builder for updating this Contact.
  352. // Note that you need to call Contact.Unwrap() before calling this method if this Contact
  353. // was returned from a transaction, and the transaction was committed or rolled back.
  354. func (c *Contact) Update() *ContactUpdateOne {
  355. return NewContactClient(c.config).UpdateOne(c)
  356. }
  357. // Unwrap unwraps the Contact entity that was returned from a transaction after it was closed,
  358. // so that all future queries will be executed through the driver which created the transaction.
  359. func (c *Contact) Unwrap() *Contact {
  360. _tx, ok := c.config.driver.(*txDriver)
  361. if !ok {
  362. panic("ent: Contact is not a transactional entity")
  363. }
  364. c.config.driver = _tx.drv
  365. return c
  366. }
  367. // String implements the fmt.Stringer.
  368. func (c *Contact) String() string {
  369. var builder strings.Builder
  370. builder.WriteString("Contact(")
  371. builder.WriteString(fmt.Sprintf("id=%v, ", c.ID))
  372. builder.WriteString("created_at=")
  373. builder.WriteString(c.CreatedAt.Format(time.ANSIC))
  374. builder.WriteString(", ")
  375. builder.WriteString("updated_at=")
  376. builder.WriteString(c.UpdatedAt.Format(time.ANSIC))
  377. builder.WriteString(", ")
  378. builder.WriteString("status=")
  379. builder.WriteString(fmt.Sprintf("%v", c.Status))
  380. builder.WriteString(", ")
  381. builder.WriteString("deleted_at=")
  382. builder.WriteString(c.DeletedAt.Format(time.ANSIC))
  383. builder.WriteString(", ")
  384. builder.WriteString("wx_wxid=")
  385. builder.WriteString(c.WxWxid)
  386. builder.WriteString(", ")
  387. builder.WriteString("type=")
  388. builder.WriteString(fmt.Sprintf("%v", c.Type))
  389. builder.WriteString(", ")
  390. builder.WriteString("wxid=")
  391. builder.WriteString(c.Wxid)
  392. builder.WriteString(", ")
  393. builder.WriteString("account=")
  394. builder.WriteString(c.Account)
  395. builder.WriteString(", ")
  396. builder.WriteString("nickname=")
  397. builder.WriteString(c.Nickname)
  398. builder.WriteString(", ")
  399. builder.WriteString("markname=")
  400. builder.WriteString(c.Markname)
  401. builder.WriteString(", ")
  402. builder.WriteString("headimg=")
  403. builder.WriteString(c.Headimg)
  404. builder.WriteString(", ")
  405. builder.WriteString("sex=")
  406. builder.WriteString(fmt.Sprintf("%v", c.Sex))
  407. builder.WriteString(", ")
  408. builder.WriteString("starrole=")
  409. builder.WriteString(c.Starrole)
  410. builder.WriteString(", ")
  411. builder.WriteString("dontseeit=")
  412. builder.WriteString(fmt.Sprintf("%v", c.Dontseeit))
  413. builder.WriteString(", ")
  414. builder.WriteString("dontseeme=")
  415. builder.WriteString(fmt.Sprintf("%v", c.Dontseeme))
  416. builder.WriteString(", ")
  417. builder.WriteString("lag=")
  418. builder.WriteString(c.Lag)
  419. builder.WriteString(", ")
  420. builder.WriteString("gid=")
  421. builder.WriteString(c.Gid)
  422. builder.WriteString(", ")
  423. builder.WriteString("gname=")
  424. builder.WriteString(c.Gname)
  425. builder.WriteString(", ")
  426. builder.WriteString("v3=")
  427. builder.WriteString(c.V3)
  428. builder.WriteString(", ")
  429. builder.WriteString("organization_id=")
  430. builder.WriteString(fmt.Sprintf("%v", c.OrganizationID))
  431. builder.WriteString(", ")
  432. builder.WriteString("ctype=")
  433. builder.WriteString(fmt.Sprintf("%v", c.Ctype))
  434. builder.WriteString(", ")
  435. builder.WriteString("cage=")
  436. builder.WriteString(fmt.Sprintf("%v", c.Cage))
  437. builder.WriteString(", ")
  438. builder.WriteString("cname=")
  439. builder.WriteString(c.Cname)
  440. builder.WriteString(", ")
  441. builder.WriteString("carea=")
  442. builder.WriteString(c.Carea)
  443. builder.WriteString(", ")
  444. builder.WriteString("cbirthday=")
  445. builder.WriteString(c.Cbirthday)
  446. builder.WriteString(", ")
  447. builder.WriteString("cbirtharea=")
  448. builder.WriteString(c.Cbirtharea)
  449. builder.WriteString(", ")
  450. builder.WriteString("cidcard_no=")
  451. builder.WriteString(c.CidcardNo)
  452. builder.WriteString(", ")
  453. builder.WriteString("ctitle=")
  454. builder.WriteString(c.Ctitle)
  455. builder.WriteString(", ")
  456. builder.WriteString("cc=")
  457. builder.WriteString(c.Cc)
  458. builder.WriteString(", ")
  459. builder.WriteString("phone=")
  460. builder.WriteString(c.Phone)
  461. builder.WriteByte(')')
  462. return builder.String()
  463. }
  464. // Contacts is a parsable slice of Contact.
  465. type Contacts []*Contact