contact_update.go 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "time"
  8. "wechat-api/ent/contact"
  9. "wechat-api/ent/labelrelationship"
  10. "wechat-api/ent/messagerecords"
  11. "wechat-api/ent/predicate"
  12. "entgo.io/ent/dialect/sql"
  13. "entgo.io/ent/dialect/sql/sqlgraph"
  14. "entgo.io/ent/schema/field"
  15. )
  16. // ContactUpdate is the builder for updating Contact entities.
  17. type ContactUpdate struct {
  18. config
  19. hooks []Hook
  20. mutation *ContactMutation
  21. }
  22. // Where appends a list predicates to the ContactUpdate builder.
  23. func (cu *ContactUpdate) Where(ps ...predicate.Contact) *ContactUpdate {
  24. cu.mutation.Where(ps...)
  25. return cu
  26. }
  27. // SetUpdatedAt sets the "updated_at" field.
  28. func (cu *ContactUpdate) SetUpdatedAt(t time.Time) *ContactUpdate {
  29. cu.mutation.SetUpdatedAt(t)
  30. return cu
  31. }
  32. // SetStatus sets the "status" field.
  33. func (cu *ContactUpdate) SetStatus(u uint8) *ContactUpdate {
  34. cu.mutation.ResetStatus()
  35. cu.mutation.SetStatus(u)
  36. return cu
  37. }
  38. // SetNillableStatus sets the "status" field if the given value is not nil.
  39. func (cu *ContactUpdate) SetNillableStatus(u *uint8) *ContactUpdate {
  40. if u != nil {
  41. cu.SetStatus(*u)
  42. }
  43. return cu
  44. }
  45. // AddStatus adds u to the "status" field.
  46. func (cu *ContactUpdate) AddStatus(u int8) *ContactUpdate {
  47. cu.mutation.AddStatus(u)
  48. return cu
  49. }
  50. // ClearStatus clears the value of the "status" field.
  51. func (cu *ContactUpdate) ClearStatus() *ContactUpdate {
  52. cu.mutation.ClearStatus()
  53. return cu
  54. }
  55. // SetDeletedAt sets the "deleted_at" field.
  56. func (cu *ContactUpdate) SetDeletedAt(t time.Time) *ContactUpdate {
  57. cu.mutation.SetDeletedAt(t)
  58. return cu
  59. }
  60. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  61. func (cu *ContactUpdate) SetNillableDeletedAt(t *time.Time) *ContactUpdate {
  62. if t != nil {
  63. cu.SetDeletedAt(*t)
  64. }
  65. return cu
  66. }
  67. // ClearDeletedAt clears the value of the "deleted_at" field.
  68. func (cu *ContactUpdate) ClearDeletedAt() *ContactUpdate {
  69. cu.mutation.ClearDeletedAt()
  70. return cu
  71. }
  72. // SetWxWxid sets the "wx_wxid" field.
  73. func (cu *ContactUpdate) SetWxWxid(s string) *ContactUpdate {
  74. cu.mutation.SetWxWxid(s)
  75. return cu
  76. }
  77. // SetNillableWxWxid sets the "wx_wxid" field if the given value is not nil.
  78. func (cu *ContactUpdate) SetNillableWxWxid(s *string) *ContactUpdate {
  79. if s != nil {
  80. cu.SetWxWxid(*s)
  81. }
  82. return cu
  83. }
  84. // SetType sets the "type" field.
  85. func (cu *ContactUpdate) SetType(i int) *ContactUpdate {
  86. cu.mutation.ResetType()
  87. cu.mutation.SetType(i)
  88. return cu
  89. }
  90. // SetNillableType sets the "type" field if the given value is not nil.
  91. func (cu *ContactUpdate) SetNillableType(i *int) *ContactUpdate {
  92. if i != nil {
  93. cu.SetType(*i)
  94. }
  95. return cu
  96. }
  97. // AddType adds i to the "type" field.
  98. func (cu *ContactUpdate) AddType(i int) *ContactUpdate {
  99. cu.mutation.AddType(i)
  100. return cu
  101. }
  102. // ClearType clears the value of the "type" field.
  103. func (cu *ContactUpdate) ClearType() *ContactUpdate {
  104. cu.mutation.ClearType()
  105. return cu
  106. }
  107. // SetWxid sets the "wxid" field.
  108. func (cu *ContactUpdate) SetWxid(s string) *ContactUpdate {
  109. cu.mutation.SetWxid(s)
  110. return cu
  111. }
  112. // SetNillableWxid sets the "wxid" field if the given value is not nil.
  113. func (cu *ContactUpdate) SetNillableWxid(s *string) *ContactUpdate {
  114. if s != nil {
  115. cu.SetWxid(*s)
  116. }
  117. return cu
  118. }
  119. // SetAccount sets the "account" field.
  120. func (cu *ContactUpdate) SetAccount(s string) *ContactUpdate {
  121. cu.mutation.SetAccount(s)
  122. return cu
  123. }
  124. // SetNillableAccount sets the "account" field if the given value is not nil.
  125. func (cu *ContactUpdate) SetNillableAccount(s *string) *ContactUpdate {
  126. if s != nil {
  127. cu.SetAccount(*s)
  128. }
  129. return cu
  130. }
  131. // SetNickname sets the "nickname" field.
  132. func (cu *ContactUpdate) SetNickname(s string) *ContactUpdate {
  133. cu.mutation.SetNickname(s)
  134. return cu
  135. }
  136. // SetNillableNickname sets the "nickname" field if the given value is not nil.
  137. func (cu *ContactUpdate) SetNillableNickname(s *string) *ContactUpdate {
  138. if s != nil {
  139. cu.SetNickname(*s)
  140. }
  141. return cu
  142. }
  143. // SetMarkname sets the "markname" field.
  144. func (cu *ContactUpdate) SetMarkname(s string) *ContactUpdate {
  145. cu.mutation.SetMarkname(s)
  146. return cu
  147. }
  148. // SetNillableMarkname sets the "markname" field if the given value is not nil.
  149. func (cu *ContactUpdate) SetNillableMarkname(s *string) *ContactUpdate {
  150. if s != nil {
  151. cu.SetMarkname(*s)
  152. }
  153. return cu
  154. }
  155. // SetHeadimg sets the "headimg" field.
  156. func (cu *ContactUpdate) SetHeadimg(s string) *ContactUpdate {
  157. cu.mutation.SetHeadimg(s)
  158. return cu
  159. }
  160. // SetNillableHeadimg sets the "headimg" field if the given value is not nil.
  161. func (cu *ContactUpdate) SetNillableHeadimg(s *string) *ContactUpdate {
  162. if s != nil {
  163. cu.SetHeadimg(*s)
  164. }
  165. return cu
  166. }
  167. // SetSex sets the "sex" field.
  168. func (cu *ContactUpdate) SetSex(i int) *ContactUpdate {
  169. cu.mutation.ResetSex()
  170. cu.mutation.SetSex(i)
  171. return cu
  172. }
  173. // SetNillableSex sets the "sex" field if the given value is not nil.
  174. func (cu *ContactUpdate) SetNillableSex(i *int) *ContactUpdate {
  175. if i != nil {
  176. cu.SetSex(*i)
  177. }
  178. return cu
  179. }
  180. // AddSex adds i to the "sex" field.
  181. func (cu *ContactUpdate) AddSex(i int) *ContactUpdate {
  182. cu.mutation.AddSex(i)
  183. return cu
  184. }
  185. // SetStarrole sets the "starrole" field.
  186. func (cu *ContactUpdate) SetStarrole(s string) *ContactUpdate {
  187. cu.mutation.SetStarrole(s)
  188. return cu
  189. }
  190. // SetNillableStarrole sets the "starrole" field if the given value is not nil.
  191. func (cu *ContactUpdate) SetNillableStarrole(s *string) *ContactUpdate {
  192. if s != nil {
  193. cu.SetStarrole(*s)
  194. }
  195. return cu
  196. }
  197. // SetDontseeit sets the "dontseeit" field.
  198. func (cu *ContactUpdate) SetDontseeit(i int) *ContactUpdate {
  199. cu.mutation.ResetDontseeit()
  200. cu.mutation.SetDontseeit(i)
  201. return cu
  202. }
  203. // SetNillableDontseeit sets the "dontseeit" field if the given value is not nil.
  204. func (cu *ContactUpdate) SetNillableDontseeit(i *int) *ContactUpdate {
  205. if i != nil {
  206. cu.SetDontseeit(*i)
  207. }
  208. return cu
  209. }
  210. // AddDontseeit adds i to the "dontseeit" field.
  211. func (cu *ContactUpdate) AddDontseeit(i int) *ContactUpdate {
  212. cu.mutation.AddDontseeit(i)
  213. return cu
  214. }
  215. // SetDontseeme sets the "dontseeme" field.
  216. func (cu *ContactUpdate) SetDontseeme(i int) *ContactUpdate {
  217. cu.mutation.ResetDontseeme()
  218. cu.mutation.SetDontseeme(i)
  219. return cu
  220. }
  221. // SetNillableDontseeme sets the "dontseeme" field if the given value is not nil.
  222. func (cu *ContactUpdate) SetNillableDontseeme(i *int) *ContactUpdate {
  223. if i != nil {
  224. cu.SetDontseeme(*i)
  225. }
  226. return cu
  227. }
  228. // AddDontseeme adds i to the "dontseeme" field.
  229. func (cu *ContactUpdate) AddDontseeme(i int) *ContactUpdate {
  230. cu.mutation.AddDontseeme(i)
  231. return cu
  232. }
  233. // SetLag sets the "lag" field.
  234. func (cu *ContactUpdate) SetLag(s string) *ContactUpdate {
  235. cu.mutation.SetLag(s)
  236. return cu
  237. }
  238. // SetNillableLag sets the "lag" field if the given value is not nil.
  239. func (cu *ContactUpdate) SetNillableLag(s *string) *ContactUpdate {
  240. if s != nil {
  241. cu.SetLag(*s)
  242. }
  243. return cu
  244. }
  245. // SetGid sets the "gid" field.
  246. func (cu *ContactUpdate) SetGid(s string) *ContactUpdate {
  247. cu.mutation.SetGid(s)
  248. return cu
  249. }
  250. // SetNillableGid sets the "gid" field if the given value is not nil.
  251. func (cu *ContactUpdate) SetNillableGid(s *string) *ContactUpdate {
  252. if s != nil {
  253. cu.SetGid(*s)
  254. }
  255. return cu
  256. }
  257. // SetGname sets the "gname" field.
  258. func (cu *ContactUpdate) SetGname(s string) *ContactUpdate {
  259. cu.mutation.SetGname(s)
  260. return cu
  261. }
  262. // SetNillableGname sets the "gname" field if the given value is not nil.
  263. func (cu *ContactUpdate) SetNillableGname(s *string) *ContactUpdate {
  264. if s != nil {
  265. cu.SetGname(*s)
  266. }
  267. return cu
  268. }
  269. // SetV3 sets the "v3" field.
  270. func (cu *ContactUpdate) SetV3(s string) *ContactUpdate {
  271. cu.mutation.SetV3(s)
  272. return cu
  273. }
  274. // SetNillableV3 sets the "v3" field if the given value is not nil.
  275. func (cu *ContactUpdate) SetNillableV3(s *string) *ContactUpdate {
  276. if s != nil {
  277. cu.SetV3(*s)
  278. }
  279. return cu
  280. }
  281. // SetOrganizationID sets the "organization_id" field.
  282. func (cu *ContactUpdate) SetOrganizationID(u uint64) *ContactUpdate {
  283. cu.mutation.ResetOrganizationID()
  284. cu.mutation.SetOrganizationID(u)
  285. return cu
  286. }
  287. // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
  288. func (cu *ContactUpdate) SetNillableOrganizationID(u *uint64) *ContactUpdate {
  289. if u != nil {
  290. cu.SetOrganizationID(*u)
  291. }
  292. return cu
  293. }
  294. // AddOrganizationID adds u to the "organization_id" field.
  295. func (cu *ContactUpdate) AddOrganizationID(u int64) *ContactUpdate {
  296. cu.mutation.AddOrganizationID(u)
  297. return cu
  298. }
  299. // ClearOrganizationID clears the value of the "organization_id" field.
  300. func (cu *ContactUpdate) ClearOrganizationID() *ContactUpdate {
  301. cu.mutation.ClearOrganizationID()
  302. return cu
  303. }
  304. // SetCtype sets the "ctype" field.
  305. func (cu *ContactUpdate) SetCtype(u uint64) *ContactUpdate {
  306. cu.mutation.ResetCtype()
  307. cu.mutation.SetCtype(u)
  308. return cu
  309. }
  310. // SetNillableCtype sets the "ctype" field if the given value is not nil.
  311. func (cu *ContactUpdate) SetNillableCtype(u *uint64) *ContactUpdate {
  312. if u != nil {
  313. cu.SetCtype(*u)
  314. }
  315. return cu
  316. }
  317. // AddCtype adds u to the "ctype" field.
  318. func (cu *ContactUpdate) AddCtype(u int64) *ContactUpdate {
  319. cu.mutation.AddCtype(u)
  320. return cu
  321. }
  322. // SetCage sets the "cage" field.
  323. func (cu *ContactUpdate) SetCage(i int) *ContactUpdate {
  324. cu.mutation.ResetCage()
  325. cu.mutation.SetCage(i)
  326. return cu
  327. }
  328. // SetNillableCage sets the "cage" field if the given value is not nil.
  329. func (cu *ContactUpdate) SetNillableCage(i *int) *ContactUpdate {
  330. if i != nil {
  331. cu.SetCage(*i)
  332. }
  333. return cu
  334. }
  335. // AddCage adds i to the "cage" field.
  336. func (cu *ContactUpdate) AddCage(i int) *ContactUpdate {
  337. cu.mutation.AddCage(i)
  338. return cu
  339. }
  340. // SetCname sets the "cname" field.
  341. func (cu *ContactUpdate) SetCname(s string) *ContactUpdate {
  342. cu.mutation.SetCname(s)
  343. return cu
  344. }
  345. // SetNillableCname sets the "cname" field if the given value is not nil.
  346. func (cu *ContactUpdate) SetNillableCname(s *string) *ContactUpdate {
  347. if s != nil {
  348. cu.SetCname(*s)
  349. }
  350. return cu
  351. }
  352. // SetCarea sets the "carea" field.
  353. func (cu *ContactUpdate) SetCarea(s string) *ContactUpdate {
  354. cu.mutation.SetCarea(s)
  355. return cu
  356. }
  357. // SetNillableCarea sets the "carea" field if the given value is not nil.
  358. func (cu *ContactUpdate) SetNillableCarea(s *string) *ContactUpdate {
  359. if s != nil {
  360. cu.SetCarea(*s)
  361. }
  362. return cu
  363. }
  364. // SetCbirthday sets the "cbirthday" field.
  365. func (cu *ContactUpdate) SetCbirthday(s string) *ContactUpdate {
  366. cu.mutation.SetCbirthday(s)
  367. return cu
  368. }
  369. // SetNillableCbirthday sets the "cbirthday" field if the given value is not nil.
  370. func (cu *ContactUpdate) SetNillableCbirthday(s *string) *ContactUpdate {
  371. if s != nil {
  372. cu.SetCbirthday(*s)
  373. }
  374. return cu
  375. }
  376. // SetCbirtharea sets the "cbirtharea" field.
  377. func (cu *ContactUpdate) SetCbirtharea(s string) *ContactUpdate {
  378. cu.mutation.SetCbirtharea(s)
  379. return cu
  380. }
  381. // SetNillableCbirtharea sets the "cbirtharea" field if the given value is not nil.
  382. func (cu *ContactUpdate) SetNillableCbirtharea(s *string) *ContactUpdate {
  383. if s != nil {
  384. cu.SetCbirtharea(*s)
  385. }
  386. return cu
  387. }
  388. // SetCidcardNo sets the "cidcard_no" field.
  389. func (cu *ContactUpdate) SetCidcardNo(s string) *ContactUpdate {
  390. cu.mutation.SetCidcardNo(s)
  391. return cu
  392. }
  393. // SetNillableCidcardNo sets the "cidcard_no" field if the given value is not nil.
  394. func (cu *ContactUpdate) SetNillableCidcardNo(s *string) *ContactUpdate {
  395. if s != nil {
  396. cu.SetCidcardNo(*s)
  397. }
  398. return cu
  399. }
  400. // SetCtitle sets the "ctitle" field.
  401. func (cu *ContactUpdate) SetCtitle(s string) *ContactUpdate {
  402. cu.mutation.SetCtitle(s)
  403. return cu
  404. }
  405. // SetNillableCtitle sets the "ctitle" field if the given value is not nil.
  406. func (cu *ContactUpdate) SetNillableCtitle(s *string) *ContactUpdate {
  407. if s != nil {
  408. cu.SetCtitle(*s)
  409. }
  410. return cu
  411. }
  412. // SetCc sets the "cc" field.
  413. func (cu *ContactUpdate) SetCc(s string) *ContactUpdate {
  414. cu.mutation.SetCc(s)
  415. return cu
  416. }
  417. // SetNillableCc sets the "cc" field if the given value is not nil.
  418. func (cu *ContactUpdate) SetNillableCc(s *string) *ContactUpdate {
  419. if s != nil {
  420. cu.SetCc(*s)
  421. }
  422. return cu
  423. }
  424. // SetPhone sets the "phone" field.
  425. func (cu *ContactUpdate) SetPhone(s string) *ContactUpdate {
  426. cu.mutation.SetPhone(s)
  427. return cu
  428. }
  429. // SetNillablePhone sets the "phone" field if the given value is not nil.
  430. func (cu *ContactUpdate) SetNillablePhone(s *string) *ContactUpdate {
  431. if s != nil {
  432. cu.SetPhone(*s)
  433. }
  434. return cu
  435. }
  436. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by IDs.
  437. func (cu *ContactUpdate) AddContactRelationshipIDs(ids ...uint64) *ContactUpdate {
  438. cu.mutation.AddContactRelationshipIDs(ids...)
  439. return cu
  440. }
  441. // AddContactRelationships adds the "contact_relationships" edges to the LabelRelationship entity.
  442. func (cu *ContactUpdate) AddContactRelationships(l ...*LabelRelationship) *ContactUpdate {
  443. ids := make([]uint64, len(l))
  444. for i := range l {
  445. ids[i] = l[i].ID
  446. }
  447. return cu.AddContactRelationshipIDs(ids...)
  448. }
  449. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by IDs.
  450. func (cu *ContactUpdate) AddContactMessageIDs(ids ...uint64) *ContactUpdate {
  451. cu.mutation.AddContactMessageIDs(ids...)
  452. return cu
  453. }
  454. // AddContactMessages adds the "contact_messages" edges to the MessageRecords entity.
  455. func (cu *ContactUpdate) AddContactMessages(m ...*MessageRecords) *ContactUpdate {
  456. ids := make([]uint64, len(m))
  457. for i := range m {
  458. ids[i] = m[i].ID
  459. }
  460. return cu.AddContactMessageIDs(ids...)
  461. }
  462. // Mutation returns the ContactMutation object of the builder.
  463. func (cu *ContactUpdate) Mutation() *ContactMutation {
  464. return cu.mutation
  465. }
  466. // ClearContactRelationships clears all "contact_relationships" edges to the LabelRelationship entity.
  467. func (cu *ContactUpdate) ClearContactRelationships() *ContactUpdate {
  468. cu.mutation.ClearContactRelationships()
  469. return cu
  470. }
  471. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to LabelRelationship entities by IDs.
  472. func (cu *ContactUpdate) RemoveContactRelationshipIDs(ids ...uint64) *ContactUpdate {
  473. cu.mutation.RemoveContactRelationshipIDs(ids...)
  474. return cu
  475. }
  476. // RemoveContactRelationships removes "contact_relationships" edges to LabelRelationship entities.
  477. func (cu *ContactUpdate) RemoveContactRelationships(l ...*LabelRelationship) *ContactUpdate {
  478. ids := make([]uint64, len(l))
  479. for i := range l {
  480. ids[i] = l[i].ID
  481. }
  482. return cu.RemoveContactRelationshipIDs(ids...)
  483. }
  484. // ClearContactMessages clears all "contact_messages" edges to the MessageRecords entity.
  485. func (cu *ContactUpdate) ClearContactMessages() *ContactUpdate {
  486. cu.mutation.ClearContactMessages()
  487. return cu
  488. }
  489. // RemoveContactMessageIDs removes the "contact_messages" edge to MessageRecords entities by IDs.
  490. func (cu *ContactUpdate) RemoveContactMessageIDs(ids ...uint64) *ContactUpdate {
  491. cu.mutation.RemoveContactMessageIDs(ids...)
  492. return cu
  493. }
  494. // RemoveContactMessages removes "contact_messages" edges to MessageRecords entities.
  495. func (cu *ContactUpdate) RemoveContactMessages(m ...*MessageRecords) *ContactUpdate {
  496. ids := make([]uint64, len(m))
  497. for i := range m {
  498. ids[i] = m[i].ID
  499. }
  500. return cu.RemoveContactMessageIDs(ids...)
  501. }
  502. // Save executes the query and returns the number of nodes affected by the update operation.
  503. func (cu *ContactUpdate) Save(ctx context.Context) (int, error) {
  504. if err := cu.defaults(); err != nil {
  505. return 0, err
  506. }
  507. return withHooks(ctx, cu.sqlSave, cu.mutation, cu.hooks)
  508. }
  509. // SaveX is like Save, but panics if an error occurs.
  510. func (cu *ContactUpdate) SaveX(ctx context.Context) int {
  511. affected, err := cu.Save(ctx)
  512. if err != nil {
  513. panic(err)
  514. }
  515. return affected
  516. }
  517. // Exec executes the query.
  518. func (cu *ContactUpdate) Exec(ctx context.Context) error {
  519. _, err := cu.Save(ctx)
  520. return err
  521. }
  522. // ExecX is like Exec, but panics if an error occurs.
  523. func (cu *ContactUpdate) ExecX(ctx context.Context) {
  524. if err := cu.Exec(ctx); err != nil {
  525. panic(err)
  526. }
  527. }
  528. // defaults sets the default values of the builder before save.
  529. func (cu *ContactUpdate) defaults() error {
  530. if _, ok := cu.mutation.UpdatedAt(); !ok {
  531. if contact.UpdateDefaultUpdatedAt == nil {
  532. return fmt.Errorf("ent: uninitialized contact.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
  533. }
  534. v := contact.UpdateDefaultUpdatedAt()
  535. cu.mutation.SetUpdatedAt(v)
  536. }
  537. return nil
  538. }
  539. func (cu *ContactUpdate) sqlSave(ctx context.Context) (n int, err error) {
  540. _spec := sqlgraph.NewUpdateSpec(contact.Table, contact.Columns, sqlgraph.NewFieldSpec(contact.FieldID, field.TypeUint64))
  541. if ps := cu.mutation.predicates; len(ps) > 0 {
  542. _spec.Predicate = func(selector *sql.Selector) {
  543. for i := range ps {
  544. ps[i](selector)
  545. }
  546. }
  547. }
  548. if value, ok := cu.mutation.UpdatedAt(); ok {
  549. _spec.SetField(contact.FieldUpdatedAt, field.TypeTime, value)
  550. }
  551. if value, ok := cu.mutation.Status(); ok {
  552. _spec.SetField(contact.FieldStatus, field.TypeUint8, value)
  553. }
  554. if value, ok := cu.mutation.AddedStatus(); ok {
  555. _spec.AddField(contact.FieldStatus, field.TypeUint8, value)
  556. }
  557. if cu.mutation.StatusCleared() {
  558. _spec.ClearField(contact.FieldStatus, field.TypeUint8)
  559. }
  560. if value, ok := cu.mutation.DeletedAt(); ok {
  561. _spec.SetField(contact.FieldDeletedAt, field.TypeTime, value)
  562. }
  563. if cu.mutation.DeletedAtCleared() {
  564. _spec.ClearField(contact.FieldDeletedAt, field.TypeTime)
  565. }
  566. if value, ok := cu.mutation.WxWxid(); ok {
  567. _spec.SetField(contact.FieldWxWxid, field.TypeString, value)
  568. }
  569. if value, ok := cu.mutation.GetType(); ok {
  570. _spec.SetField(contact.FieldType, field.TypeInt, value)
  571. }
  572. if value, ok := cu.mutation.AddedType(); ok {
  573. _spec.AddField(contact.FieldType, field.TypeInt, value)
  574. }
  575. if cu.mutation.TypeCleared() {
  576. _spec.ClearField(contact.FieldType, field.TypeInt)
  577. }
  578. if value, ok := cu.mutation.Wxid(); ok {
  579. _spec.SetField(contact.FieldWxid, field.TypeString, value)
  580. }
  581. if value, ok := cu.mutation.Account(); ok {
  582. _spec.SetField(contact.FieldAccount, field.TypeString, value)
  583. }
  584. if value, ok := cu.mutation.Nickname(); ok {
  585. _spec.SetField(contact.FieldNickname, field.TypeString, value)
  586. }
  587. if value, ok := cu.mutation.Markname(); ok {
  588. _spec.SetField(contact.FieldMarkname, field.TypeString, value)
  589. }
  590. if value, ok := cu.mutation.Headimg(); ok {
  591. _spec.SetField(contact.FieldHeadimg, field.TypeString, value)
  592. }
  593. if value, ok := cu.mutation.Sex(); ok {
  594. _spec.SetField(contact.FieldSex, field.TypeInt, value)
  595. }
  596. if value, ok := cu.mutation.AddedSex(); ok {
  597. _spec.AddField(contact.FieldSex, field.TypeInt, value)
  598. }
  599. if value, ok := cu.mutation.Starrole(); ok {
  600. _spec.SetField(contact.FieldStarrole, field.TypeString, value)
  601. }
  602. if value, ok := cu.mutation.Dontseeit(); ok {
  603. _spec.SetField(contact.FieldDontseeit, field.TypeInt, value)
  604. }
  605. if value, ok := cu.mutation.AddedDontseeit(); ok {
  606. _spec.AddField(contact.FieldDontseeit, field.TypeInt, value)
  607. }
  608. if value, ok := cu.mutation.Dontseeme(); ok {
  609. _spec.SetField(contact.FieldDontseeme, field.TypeInt, value)
  610. }
  611. if value, ok := cu.mutation.AddedDontseeme(); ok {
  612. _spec.AddField(contact.FieldDontseeme, field.TypeInt, value)
  613. }
  614. if value, ok := cu.mutation.Lag(); ok {
  615. _spec.SetField(contact.FieldLag, field.TypeString, value)
  616. }
  617. if value, ok := cu.mutation.Gid(); ok {
  618. _spec.SetField(contact.FieldGid, field.TypeString, value)
  619. }
  620. if value, ok := cu.mutation.Gname(); ok {
  621. _spec.SetField(contact.FieldGname, field.TypeString, value)
  622. }
  623. if value, ok := cu.mutation.V3(); ok {
  624. _spec.SetField(contact.FieldV3, field.TypeString, value)
  625. }
  626. if value, ok := cu.mutation.OrganizationID(); ok {
  627. _spec.SetField(contact.FieldOrganizationID, field.TypeUint64, value)
  628. }
  629. if value, ok := cu.mutation.AddedOrganizationID(); ok {
  630. _spec.AddField(contact.FieldOrganizationID, field.TypeUint64, value)
  631. }
  632. if cu.mutation.OrganizationIDCleared() {
  633. _spec.ClearField(contact.FieldOrganizationID, field.TypeUint64)
  634. }
  635. if value, ok := cu.mutation.Ctype(); ok {
  636. _spec.SetField(contact.FieldCtype, field.TypeUint64, value)
  637. }
  638. if value, ok := cu.mutation.AddedCtype(); ok {
  639. _spec.AddField(contact.FieldCtype, field.TypeUint64, value)
  640. }
  641. if value, ok := cu.mutation.Cage(); ok {
  642. _spec.SetField(contact.FieldCage, field.TypeInt, value)
  643. }
  644. if value, ok := cu.mutation.AddedCage(); ok {
  645. _spec.AddField(contact.FieldCage, field.TypeInt, value)
  646. }
  647. if value, ok := cu.mutation.Cname(); ok {
  648. _spec.SetField(contact.FieldCname, field.TypeString, value)
  649. }
  650. if value, ok := cu.mutation.Carea(); ok {
  651. _spec.SetField(contact.FieldCarea, field.TypeString, value)
  652. }
  653. if value, ok := cu.mutation.Cbirthday(); ok {
  654. _spec.SetField(contact.FieldCbirthday, field.TypeString, value)
  655. }
  656. if value, ok := cu.mutation.Cbirtharea(); ok {
  657. _spec.SetField(contact.FieldCbirtharea, field.TypeString, value)
  658. }
  659. if value, ok := cu.mutation.CidcardNo(); ok {
  660. _spec.SetField(contact.FieldCidcardNo, field.TypeString, value)
  661. }
  662. if value, ok := cu.mutation.Ctitle(); ok {
  663. _spec.SetField(contact.FieldCtitle, field.TypeString, value)
  664. }
  665. if value, ok := cu.mutation.Cc(); ok {
  666. _spec.SetField(contact.FieldCc, field.TypeString, value)
  667. }
  668. if value, ok := cu.mutation.Phone(); ok {
  669. _spec.SetField(contact.FieldPhone, field.TypeString, value)
  670. }
  671. if cu.mutation.ContactRelationshipsCleared() {
  672. edge := &sqlgraph.EdgeSpec{
  673. Rel: sqlgraph.O2M,
  674. Inverse: false,
  675. Table: contact.ContactRelationshipsTable,
  676. Columns: []string{contact.ContactRelationshipsColumn},
  677. Bidi: false,
  678. Target: &sqlgraph.EdgeTarget{
  679. IDSpec: sqlgraph.NewFieldSpec(labelrelationship.FieldID, field.TypeUint64),
  680. },
  681. }
  682. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  683. }
  684. if nodes := cu.mutation.RemovedContactRelationshipsIDs(); len(nodes) > 0 && !cu.mutation.ContactRelationshipsCleared() {
  685. edge := &sqlgraph.EdgeSpec{
  686. Rel: sqlgraph.O2M,
  687. Inverse: false,
  688. Table: contact.ContactRelationshipsTable,
  689. Columns: []string{contact.ContactRelationshipsColumn},
  690. Bidi: false,
  691. Target: &sqlgraph.EdgeTarget{
  692. IDSpec: sqlgraph.NewFieldSpec(labelrelationship.FieldID, field.TypeUint64),
  693. },
  694. }
  695. for _, k := range nodes {
  696. edge.Target.Nodes = append(edge.Target.Nodes, k)
  697. }
  698. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  699. }
  700. if nodes := cu.mutation.ContactRelationshipsIDs(); len(nodes) > 0 {
  701. edge := &sqlgraph.EdgeSpec{
  702. Rel: sqlgraph.O2M,
  703. Inverse: false,
  704. Table: contact.ContactRelationshipsTable,
  705. Columns: []string{contact.ContactRelationshipsColumn},
  706. Bidi: false,
  707. Target: &sqlgraph.EdgeTarget{
  708. IDSpec: sqlgraph.NewFieldSpec(labelrelationship.FieldID, field.TypeUint64),
  709. },
  710. }
  711. for _, k := range nodes {
  712. edge.Target.Nodes = append(edge.Target.Nodes, k)
  713. }
  714. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  715. }
  716. if cu.mutation.ContactMessagesCleared() {
  717. edge := &sqlgraph.EdgeSpec{
  718. Rel: sqlgraph.O2M,
  719. Inverse: false,
  720. Table: contact.ContactMessagesTable,
  721. Columns: []string{contact.ContactMessagesColumn},
  722. Bidi: false,
  723. Target: &sqlgraph.EdgeTarget{
  724. IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
  725. },
  726. }
  727. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  728. }
  729. if nodes := cu.mutation.RemovedContactMessagesIDs(); len(nodes) > 0 && !cu.mutation.ContactMessagesCleared() {
  730. edge := &sqlgraph.EdgeSpec{
  731. Rel: sqlgraph.O2M,
  732. Inverse: false,
  733. Table: contact.ContactMessagesTable,
  734. Columns: []string{contact.ContactMessagesColumn},
  735. Bidi: false,
  736. Target: &sqlgraph.EdgeTarget{
  737. IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
  738. },
  739. }
  740. for _, k := range nodes {
  741. edge.Target.Nodes = append(edge.Target.Nodes, k)
  742. }
  743. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  744. }
  745. if nodes := cu.mutation.ContactMessagesIDs(); len(nodes) > 0 {
  746. edge := &sqlgraph.EdgeSpec{
  747. Rel: sqlgraph.O2M,
  748. Inverse: false,
  749. Table: contact.ContactMessagesTable,
  750. Columns: []string{contact.ContactMessagesColumn},
  751. Bidi: false,
  752. Target: &sqlgraph.EdgeTarget{
  753. IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
  754. },
  755. }
  756. for _, k := range nodes {
  757. edge.Target.Nodes = append(edge.Target.Nodes, k)
  758. }
  759. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  760. }
  761. if n, err = sqlgraph.UpdateNodes(ctx, cu.driver, _spec); err != nil {
  762. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  763. err = &NotFoundError{contact.Label}
  764. } else if sqlgraph.IsConstraintError(err) {
  765. err = &ConstraintError{msg: err.Error(), wrap: err}
  766. }
  767. return 0, err
  768. }
  769. cu.mutation.done = true
  770. return n, nil
  771. }
  772. // ContactUpdateOne is the builder for updating a single Contact entity.
  773. type ContactUpdateOne struct {
  774. config
  775. fields []string
  776. hooks []Hook
  777. mutation *ContactMutation
  778. }
  779. // SetUpdatedAt sets the "updated_at" field.
  780. func (cuo *ContactUpdateOne) SetUpdatedAt(t time.Time) *ContactUpdateOne {
  781. cuo.mutation.SetUpdatedAt(t)
  782. return cuo
  783. }
  784. // SetStatus sets the "status" field.
  785. func (cuo *ContactUpdateOne) SetStatus(u uint8) *ContactUpdateOne {
  786. cuo.mutation.ResetStatus()
  787. cuo.mutation.SetStatus(u)
  788. return cuo
  789. }
  790. // SetNillableStatus sets the "status" field if the given value is not nil.
  791. func (cuo *ContactUpdateOne) SetNillableStatus(u *uint8) *ContactUpdateOne {
  792. if u != nil {
  793. cuo.SetStatus(*u)
  794. }
  795. return cuo
  796. }
  797. // AddStatus adds u to the "status" field.
  798. func (cuo *ContactUpdateOne) AddStatus(u int8) *ContactUpdateOne {
  799. cuo.mutation.AddStatus(u)
  800. return cuo
  801. }
  802. // ClearStatus clears the value of the "status" field.
  803. func (cuo *ContactUpdateOne) ClearStatus() *ContactUpdateOne {
  804. cuo.mutation.ClearStatus()
  805. return cuo
  806. }
  807. // SetDeletedAt sets the "deleted_at" field.
  808. func (cuo *ContactUpdateOne) SetDeletedAt(t time.Time) *ContactUpdateOne {
  809. cuo.mutation.SetDeletedAt(t)
  810. return cuo
  811. }
  812. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  813. func (cuo *ContactUpdateOne) SetNillableDeletedAt(t *time.Time) *ContactUpdateOne {
  814. if t != nil {
  815. cuo.SetDeletedAt(*t)
  816. }
  817. return cuo
  818. }
  819. // ClearDeletedAt clears the value of the "deleted_at" field.
  820. func (cuo *ContactUpdateOne) ClearDeletedAt() *ContactUpdateOne {
  821. cuo.mutation.ClearDeletedAt()
  822. return cuo
  823. }
  824. // SetWxWxid sets the "wx_wxid" field.
  825. func (cuo *ContactUpdateOne) SetWxWxid(s string) *ContactUpdateOne {
  826. cuo.mutation.SetWxWxid(s)
  827. return cuo
  828. }
  829. // SetNillableWxWxid sets the "wx_wxid" field if the given value is not nil.
  830. func (cuo *ContactUpdateOne) SetNillableWxWxid(s *string) *ContactUpdateOne {
  831. if s != nil {
  832. cuo.SetWxWxid(*s)
  833. }
  834. return cuo
  835. }
  836. // SetType sets the "type" field.
  837. func (cuo *ContactUpdateOne) SetType(i int) *ContactUpdateOne {
  838. cuo.mutation.ResetType()
  839. cuo.mutation.SetType(i)
  840. return cuo
  841. }
  842. // SetNillableType sets the "type" field if the given value is not nil.
  843. func (cuo *ContactUpdateOne) SetNillableType(i *int) *ContactUpdateOne {
  844. if i != nil {
  845. cuo.SetType(*i)
  846. }
  847. return cuo
  848. }
  849. // AddType adds i to the "type" field.
  850. func (cuo *ContactUpdateOne) AddType(i int) *ContactUpdateOne {
  851. cuo.mutation.AddType(i)
  852. return cuo
  853. }
  854. // ClearType clears the value of the "type" field.
  855. func (cuo *ContactUpdateOne) ClearType() *ContactUpdateOne {
  856. cuo.mutation.ClearType()
  857. return cuo
  858. }
  859. // SetWxid sets the "wxid" field.
  860. func (cuo *ContactUpdateOne) SetWxid(s string) *ContactUpdateOne {
  861. cuo.mutation.SetWxid(s)
  862. return cuo
  863. }
  864. // SetNillableWxid sets the "wxid" field if the given value is not nil.
  865. func (cuo *ContactUpdateOne) SetNillableWxid(s *string) *ContactUpdateOne {
  866. if s != nil {
  867. cuo.SetWxid(*s)
  868. }
  869. return cuo
  870. }
  871. // SetAccount sets the "account" field.
  872. func (cuo *ContactUpdateOne) SetAccount(s string) *ContactUpdateOne {
  873. cuo.mutation.SetAccount(s)
  874. return cuo
  875. }
  876. // SetNillableAccount sets the "account" field if the given value is not nil.
  877. func (cuo *ContactUpdateOne) SetNillableAccount(s *string) *ContactUpdateOne {
  878. if s != nil {
  879. cuo.SetAccount(*s)
  880. }
  881. return cuo
  882. }
  883. // SetNickname sets the "nickname" field.
  884. func (cuo *ContactUpdateOne) SetNickname(s string) *ContactUpdateOne {
  885. cuo.mutation.SetNickname(s)
  886. return cuo
  887. }
  888. // SetNillableNickname sets the "nickname" field if the given value is not nil.
  889. func (cuo *ContactUpdateOne) SetNillableNickname(s *string) *ContactUpdateOne {
  890. if s != nil {
  891. cuo.SetNickname(*s)
  892. }
  893. return cuo
  894. }
  895. // SetMarkname sets the "markname" field.
  896. func (cuo *ContactUpdateOne) SetMarkname(s string) *ContactUpdateOne {
  897. cuo.mutation.SetMarkname(s)
  898. return cuo
  899. }
  900. // SetNillableMarkname sets the "markname" field if the given value is not nil.
  901. func (cuo *ContactUpdateOne) SetNillableMarkname(s *string) *ContactUpdateOne {
  902. if s != nil {
  903. cuo.SetMarkname(*s)
  904. }
  905. return cuo
  906. }
  907. // SetHeadimg sets the "headimg" field.
  908. func (cuo *ContactUpdateOne) SetHeadimg(s string) *ContactUpdateOne {
  909. cuo.mutation.SetHeadimg(s)
  910. return cuo
  911. }
  912. // SetNillableHeadimg sets the "headimg" field if the given value is not nil.
  913. func (cuo *ContactUpdateOne) SetNillableHeadimg(s *string) *ContactUpdateOne {
  914. if s != nil {
  915. cuo.SetHeadimg(*s)
  916. }
  917. return cuo
  918. }
  919. // SetSex sets the "sex" field.
  920. func (cuo *ContactUpdateOne) SetSex(i int) *ContactUpdateOne {
  921. cuo.mutation.ResetSex()
  922. cuo.mutation.SetSex(i)
  923. return cuo
  924. }
  925. // SetNillableSex sets the "sex" field if the given value is not nil.
  926. func (cuo *ContactUpdateOne) SetNillableSex(i *int) *ContactUpdateOne {
  927. if i != nil {
  928. cuo.SetSex(*i)
  929. }
  930. return cuo
  931. }
  932. // AddSex adds i to the "sex" field.
  933. func (cuo *ContactUpdateOne) AddSex(i int) *ContactUpdateOne {
  934. cuo.mutation.AddSex(i)
  935. return cuo
  936. }
  937. // SetStarrole sets the "starrole" field.
  938. func (cuo *ContactUpdateOne) SetStarrole(s string) *ContactUpdateOne {
  939. cuo.mutation.SetStarrole(s)
  940. return cuo
  941. }
  942. // SetNillableStarrole sets the "starrole" field if the given value is not nil.
  943. func (cuo *ContactUpdateOne) SetNillableStarrole(s *string) *ContactUpdateOne {
  944. if s != nil {
  945. cuo.SetStarrole(*s)
  946. }
  947. return cuo
  948. }
  949. // SetDontseeit sets the "dontseeit" field.
  950. func (cuo *ContactUpdateOne) SetDontseeit(i int) *ContactUpdateOne {
  951. cuo.mutation.ResetDontseeit()
  952. cuo.mutation.SetDontseeit(i)
  953. return cuo
  954. }
  955. // SetNillableDontseeit sets the "dontseeit" field if the given value is not nil.
  956. func (cuo *ContactUpdateOne) SetNillableDontseeit(i *int) *ContactUpdateOne {
  957. if i != nil {
  958. cuo.SetDontseeit(*i)
  959. }
  960. return cuo
  961. }
  962. // AddDontseeit adds i to the "dontseeit" field.
  963. func (cuo *ContactUpdateOne) AddDontseeit(i int) *ContactUpdateOne {
  964. cuo.mutation.AddDontseeit(i)
  965. return cuo
  966. }
  967. // SetDontseeme sets the "dontseeme" field.
  968. func (cuo *ContactUpdateOne) SetDontseeme(i int) *ContactUpdateOne {
  969. cuo.mutation.ResetDontseeme()
  970. cuo.mutation.SetDontseeme(i)
  971. return cuo
  972. }
  973. // SetNillableDontseeme sets the "dontseeme" field if the given value is not nil.
  974. func (cuo *ContactUpdateOne) SetNillableDontseeme(i *int) *ContactUpdateOne {
  975. if i != nil {
  976. cuo.SetDontseeme(*i)
  977. }
  978. return cuo
  979. }
  980. // AddDontseeme adds i to the "dontseeme" field.
  981. func (cuo *ContactUpdateOne) AddDontseeme(i int) *ContactUpdateOne {
  982. cuo.mutation.AddDontseeme(i)
  983. return cuo
  984. }
  985. // SetLag sets the "lag" field.
  986. func (cuo *ContactUpdateOne) SetLag(s string) *ContactUpdateOne {
  987. cuo.mutation.SetLag(s)
  988. return cuo
  989. }
  990. // SetNillableLag sets the "lag" field if the given value is not nil.
  991. func (cuo *ContactUpdateOne) SetNillableLag(s *string) *ContactUpdateOne {
  992. if s != nil {
  993. cuo.SetLag(*s)
  994. }
  995. return cuo
  996. }
  997. // SetGid sets the "gid" field.
  998. func (cuo *ContactUpdateOne) SetGid(s string) *ContactUpdateOne {
  999. cuo.mutation.SetGid(s)
  1000. return cuo
  1001. }
  1002. // SetNillableGid sets the "gid" field if the given value is not nil.
  1003. func (cuo *ContactUpdateOne) SetNillableGid(s *string) *ContactUpdateOne {
  1004. if s != nil {
  1005. cuo.SetGid(*s)
  1006. }
  1007. return cuo
  1008. }
  1009. // SetGname sets the "gname" field.
  1010. func (cuo *ContactUpdateOne) SetGname(s string) *ContactUpdateOne {
  1011. cuo.mutation.SetGname(s)
  1012. return cuo
  1013. }
  1014. // SetNillableGname sets the "gname" field if the given value is not nil.
  1015. func (cuo *ContactUpdateOne) SetNillableGname(s *string) *ContactUpdateOne {
  1016. if s != nil {
  1017. cuo.SetGname(*s)
  1018. }
  1019. return cuo
  1020. }
  1021. // SetV3 sets the "v3" field.
  1022. func (cuo *ContactUpdateOne) SetV3(s string) *ContactUpdateOne {
  1023. cuo.mutation.SetV3(s)
  1024. return cuo
  1025. }
  1026. // SetNillableV3 sets the "v3" field if the given value is not nil.
  1027. func (cuo *ContactUpdateOne) SetNillableV3(s *string) *ContactUpdateOne {
  1028. if s != nil {
  1029. cuo.SetV3(*s)
  1030. }
  1031. return cuo
  1032. }
  1033. // SetOrganizationID sets the "organization_id" field.
  1034. func (cuo *ContactUpdateOne) SetOrganizationID(u uint64) *ContactUpdateOne {
  1035. cuo.mutation.ResetOrganizationID()
  1036. cuo.mutation.SetOrganizationID(u)
  1037. return cuo
  1038. }
  1039. // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
  1040. func (cuo *ContactUpdateOne) SetNillableOrganizationID(u *uint64) *ContactUpdateOne {
  1041. if u != nil {
  1042. cuo.SetOrganizationID(*u)
  1043. }
  1044. return cuo
  1045. }
  1046. // AddOrganizationID adds u to the "organization_id" field.
  1047. func (cuo *ContactUpdateOne) AddOrganizationID(u int64) *ContactUpdateOne {
  1048. cuo.mutation.AddOrganizationID(u)
  1049. return cuo
  1050. }
  1051. // ClearOrganizationID clears the value of the "organization_id" field.
  1052. func (cuo *ContactUpdateOne) ClearOrganizationID() *ContactUpdateOne {
  1053. cuo.mutation.ClearOrganizationID()
  1054. return cuo
  1055. }
  1056. // SetCtype sets the "ctype" field.
  1057. func (cuo *ContactUpdateOne) SetCtype(u uint64) *ContactUpdateOne {
  1058. cuo.mutation.ResetCtype()
  1059. cuo.mutation.SetCtype(u)
  1060. return cuo
  1061. }
  1062. // SetNillableCtype sets the "ctype" field if the given value is not nil.
  1063. func (cuo *ContactUpdateOne) SetNillableCtype(u *uint64) *ContactUpdateOne {
  1064. if u != nil {
  1065. cuo.SetCtype(*u)
  1066. }
  1067. return cuo
  1068. }
  1069. // AddCtype adds u to the "ctype" field.
  1070. func (cuo *ContactUpdateOne) AddCtype(u int64) *ContactUpdateOne {
  1071. cuo.mutation.AddCtype(u)
  1072. return cuo
  1073. }
  1074. // SetCage sets the "cage" field.
  1075. func (cuo *ContactUpdateOne) SetCage(i int) *ContactUpdateOne {
  1076. cuo.mutation.ResetCage()
  1077. cuo.mutation.SetCage(i)
  1078. return cuo
  1079. }
  1080. // SetNillableCage sets the "cage" field if the given value is not nil.
  1081. func (cuo *ContactUpdateOne) SetNillableCage(i *int) *ContactUpdateOne {
  1082. if i != nil {
  1083. cuo.SetCage(*i)
  1084. }
  1085. return cuo
  1086. }
  1087. // AddCage adds i to the "cage" field.
  1088. func (cuo *ContactUpdateOne) AddCage(i int) *ContactUpdateOne {
  1089. cuo.mutation.AddCage(i)
  1090. return cuo
  1091. }
  1092. // SetCname sets the "cname" field.
  1093. func (cuo *ContactUpdateOne) SetCname(s string) *ContactUpdateOne {
  1094. cuo.mutation.SetCname(s)
  1095. return cuo
  1096. }
  1097. // SetNillableCname sets the "cname" field if the given value is not nil.
  1098. func (cuo *ContactUpdateOne) SetNillableCname(s *string) *ContactUpdateOne {
  1099. if s != nil {
  1100. cuo.SetCname(*s)
  1101. }
  1102. return cuo
  1103. }
  1104. // SetCarea sets the "carea" field.
  1105. func (cuo *ContactUpdateOne) SetCarea(s string) *ContactUpdateOne {
  1106. cuo.mutation.SetCarea(s)
  1107. return cuo
  1108. }
  1109. // SetNillableCarea sets the "carea" field if the given value is not nil.
  1110. func (cuo *ContactUpdateOne) SetNillableCarea(s *string) *ContactUpdateOne {
  1111. if s != nil {
  1112. cuo.SetCarea(*s)
  1113. }
  1114. return cuo
  1115. }
  1116. // SetCbirthday sets the "cbirthday" field.
  1117. func (cuo *ContactUpdateOne) SetCbirthday(s string) *ContactUpdateOne {
  1118. cuo.mutation.SetCbirthday(s)
  1119. return cuo
  1120. }
  1121. // SetNillableCbirthday sets the "cbirthday" field if the given value is not nil.
  1122. func (cuo *ContactUpdateOne) SetNillableCbirthday(s *string) *ContactUpdateOne {
  1123. if s != nil {
  1124. cuo.SetCbirthday(*s)
  1125. }
  1126. return cuo
  1127. }
  1128. // SetCbirtharea sets the "cbirtharea" field.
  1129. func (cuo *ContactUpdateOne) SetCbirtharea(s string) *ContactUpdateOne {
  1130. cuo.mutation.SetCbirtharea(s)
  1131. return cuo
  1132. }
  1133. // SetNillableCbirtharea sets the "cbirtharea" field if the given value is not nil.
  1134. func (cuo *ContactUpdateOne) SetNillableCbirtharea(s *string) *ContactUpdateOne {
  1135. if s != nil {
  1136. cuo.SetCbirtharea(*s)
  1137. }
  1138. return cuo
  1139. }
  1140. // SetCidcardNo sets the "cidcard_no" field.
  1141. func (cuo *ContactUpdateOne) SetCidcardNo(s string) *ContactUpdateOne {
  1142. cuo.mutation.SetCidcardNo(s)
  1143. return cuo
  1144. }
  1145. // SetNillableCidcardNo sets the "cidcard_no" field if the given value is not nil.
  1146. func (cuo *ContactUpdateOne) SetNillableCidcardNo(s *string) *ContactUpdateOne {
  1147. if s != nil {
  1148. cuo.SetCidcardNo(*s)
  1149. }
  1150. return cuo
  1151. }
  1152. // SetCtitle sets the "ctitle" field.
  1153. func (cuo *ContactUpdateOne) SetCtitle(s string) *ContactUpdateOne {
  1154. cuo.mutation.SetCtitle(s)
  1155. return cuo
  1156. }
  1157. // SetNillableCtitle sets the "ctitle" field if the given value is not nil.
  1158. func (cuo *ContactUpdateOne) SetNillableCtitle(s *string) *ContactUpdateOne {
  1159. if s != nil {
  1160. cuo.SetCtitle(*s)
  1161. }
  1162. return cuo
  1163. }
  1164. // SetCc sets the "cc" field.
  1165. func (cuo *ContactUpdateOne) SetCc(s string) *ContactUpdateOne {
  1166. cuo.mutation.SetCc(s)
  1167. return cuo
  1168. }
  1169. // SetNillableCc sets the "cc" field if the given value is not nil.
  1170. func (cuo *ContactUpdateOne) SetNillableCc(s *string) *ContactUpdateOne {
  1171. if s != nil {
  1172. cuo.SetCc(*s)
  1173. }
  1174. return cuo
  1175. }
  1176. // SetPhone sets the "phone" field.
  1177. func (cuo *ContactUpdateOne) SetPhone(s string) *ContactUpdateOne {
  1178. cuo.mutation.SetPhone(s)
  1179. return cuo
  1180. }
  1181. // SetNillablePhone sets the "phone" field if the given value is not nil.
  1182. func (cuo *ContactUpdateOne) SetNillablePhone(s *string) *ContactUpdateOne {
  1183. if s != nil {
  1184. cuo.SetPhone(*s)
  1185. }
  1186. return cuo
  1187. }
  1188. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by IDs.
  1189. func (cuo *ContactUpdateOne) AddContactRelationshipIDs(ids ...uint64) *ContactUpdateOne {
  1190. cuo.mutation.AddContactRelationshipIDs(ids...)
  1191. return cuo
  1192. }
  1193. // AddContactRelationships adds the "contact_relationships" edges to the LabelRelationship entity.
  1194. func (cuo *ContactUpdateOne) AddContactRelationships(l ...*LabelRelationship) *ContactUpdateOne {
  1195. ids := make([]uint64, len(l))
  1196. for i := range l {
  1197. ids[i] = l[i].ID
  1198. }
  1199. return cuo.AddContactRelationshipIDs(ids...)
  1200. }
  1201. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by IDs.
  1202. func (cuo *ContactUpdateOne) AddContactMessageIDs(ids ...uint64) *ContactUpdateOne {
  1203. cuo.mutation.AddContactMessageIDs(ids...)
  1204. return cuo
  1205. }
  1206. // AddContactMessages adds the "contact_messages" edges to the MessageRecords entity.
  1207. func (cuo *ContactUpdateOne) AddContactMessages(m ...*MessageRecords) *ContactUpdateOne {
  1208. ids := make([]uint64, len(m))
  1209. for i := range m {
  1210. ids[i] = m[i].ID
  1211. }
  1212. return cuo.AddContactMessageIDs(ids...)
  1213. }
  1214. // Mutation returns the ContactMutation object of the builder.
  1215. func (cuo *ContactUpdateOne) Mutation() *ContactMutation {
  1216. return cuo.mutation
  1217. }
  1218. // ClearContactRelationships clears all "contact_relationships" edges to the LabelRelationship entity.
  1219. func (cuo *ContactUpdateOne) ClearContactRelationships() *ContactUpdateOne {
  1220. cuo.mutation.ClearContactRelationships()
  1221. return cuo
  1222. }
  1223. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to LabelRelationship entities by IDs.
  1224. func (cuo *ContactUpdateOne) RemoveContactRelationshipIDs(ids ...uint64) *ContactUpdateOne {
  1225. cuo.mutation.RemoveContactRelationshipIDs(ids...)
  1226. return cuo
  1227. }
  1228. // RemoveContactRelationships removes "contact_relationships" edges to LabelRelationship entities.
  1229. func (cuo *ContactUpdateOne) RemoveContactRelationships(l ...*LabelRelationship) *ContactUpdateOne {
  1230. ids := make([]uint64, len(l))
  1231. for i := range l {
  1232. ids[i] = l[i].ID
  1233. }
  1234. return cuo.RemoveContactRelationshipIDs(ids...)
  1235. }
  1236. // ClearContactMessages clears all "contact_messages" edges to the MessageRecords entity.
  1237. func (cuo *ContactUpdateOne) ClearContactMessages() *ContactUpdateOne {
  1238. cuo.mutation.ClearContactMessages()
  1239. return cuo
  1240. }
  1241. // RemoveContactMessageIDs removes the "contact_messages" edge to MessageRecords entities by IDs.
  1242. func (cuo *ContactUpdateOne) RemoveContactMessageIDs(ids ...uint64) *ContactUpdateOne {
  1243. cuo.mutation.RemoveContactMessageIDs(ids...)
  1244. return cuo
  1245. }
  1246. // RemoveContactMessages removes "contact_messages" edges to MessageRecords entities.
  1247. func (cuo *ContactUpdateOne) RemoveContactMessages(m ...*MessageRecords) *ContactUpdateOne {
  1248. ids := make([]uint64, len(m))
  1249. for i := range m {
  1250. ids[i] = m[i].ID
  1251. }
  1252. return cuo.RemoveContactMessageIDs(ids...)
  1253. }
  1254. // Where appends a list predicates to the ContactUpdate builder.
  1255. func (cuo *ContactUpdateOne) Where(ps ...predicate.Contact) *ContactUpdateOne {
  1256. cuo.mutation.Where(ps...)
  1257. return cuo
  1258. }
  1259. // Select allows selecting one or more fields (columns) of the returned entity.
  1260. // The default is selecting all fields defined in the entity schema.
  1261. func (cuo *ContactUpdateOne) Select(field string, fields ...string) *ContactUpdateOne {
  1262. cuo.fields = append([]string{field}, fields...)
  1263. return cuo
  1264. }
  1265. // Save executes the query and returns the updated Contact entity.
  1266. func (cuo *ContactUpdateOne) Save(ctx context.Context) (*Contact, error) {
  1267. if err := cuo.defaults(); err != nil {
  1268. return nil, err
  1269. }
  1270. return withHooks(ctx, cuo.sqlSave, cuo.mutation, cuo.hooks)
  1271. }
  1272. // SaveX is like Save, but panics if an error occurs.
  1273. func (cuo *ContactUpdateOne) SaveX(ctx context.Context) *Contact {
  1274. node, err := cuo.Save(ctx)
  1275. if err != nil {
  1276. panic(err)
  1277. }
  1278. return node
  1279. }
  1280. // Exec executes the query on the entity.
  1281. func (cuo *ContactUpdateOne) Exec(ctx context.Context) error {
  1282. _, err := cuo.Save(ctx)
  1283. return err
  1284. }
  1285. // ExecX is like Exec, but panics if an error occurs.
  1286. func (cuo *ContactUpdateOne) ExecX(ctx context.Context) {
  1287. if err := cuo.Exec(ctx); err != nil {
  1288. panic(err)
  1289. }
  1290. }
  1291. // defaults sets the default values of the builder before save.
  1292. func (cuo *ContactUpdateOne) defaults() error {
  1293. if _, ok := cuo.mutation.UpdatedAt(); !ok {
  1294. if contact.UpdateDefaultUpdatedAt == nil {
  1295. return fmt.Errorf("ent: uninitialized contact.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
  1296. }
  1297. v := contact.UpdateDefaultUpdatedAt()
  1298. cuo.mutation.SetUpdatedAt(v)
  1299. }
  1300. return nil
  1301. }
  1302. func (cuo *ContactUpdateOne) sqlSave(ctx context.Context) (_node *Contact, err error) {
  1303. _spec := sqlgraph.NewUpdateSpec(contact.Table, contact.Columns, sqlgraph.NewFieldSpec(contact.FieldID, field.TypeUint64))
  1304. id, ok := cuo.mutation.ID()
  1305. if !ok {
  1306. return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Contact.id" for update`)}
  1307. }
  1308. _spec.Node.ID.Value = id
  1309. if fields := cuo.fields; len(fields) > 0 {
  1310. _spec.Node.Columns = make([]string, 0, len(fields))
  1311. _spec.Node.Columns = append(_spec.Node.Columns, contact.FieldID)
  1312. for _, f := range fields {
  1313. if !contact.ValidColumn(f) {
  1314. return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
  1315. }
  1316. if f != contact.FieldID {
  1317. _spec.Node.Columns = append(_spec.Node.Columns, f)
  1318. }
  1319. }
  1320. }
  1321. if ps := cuo.mutation.predicates; len(ps) > 0 {
  1322. _spec.Predicate = func(selector *sql.Selector) {
  1323. for i := range ps {
  1324. ps[i](selector)
  1325. }
  1326. }
  1327. }
  1328. if value, ok := cuo.mutation.UpdatedAt(); ok {
  1329. _spec.SetField(contact.FieldUpdatedAt, field.TypeTime, value)
  1330. }
  1331. if value, ok := cuo.mutation.Status(); ok {
  1332. _spec.SetField(contact.FieldStatus, field.TypeUint8, value)
  1333. }
  1334. if value, ok := cuo.mutation.AddedStatus(); ok {
  1335. _spec.AddField(contact.FieldStatus, field.TypeUint8, value)
  1336. }
  1337. if cuo.mutation.StatusCleared() {
  1338. _spec.ClearField(contact.FieldStatus, field.TypeUint8)
  1339. }
  1340. if value, ok := cuo.mutation.DeletedAt(); ok {
  1341. _spec.SetField(contact.FieldDeletedAt, field.TypeTime, value)
  1342. }
  1343. if cuo.mutation.DeletedAtCleared() {
  1344. _spec.ClearField(contact.FieldDeletedAt, field.TypeTime)
  1345. }
  1346. if value, ok := cuo.mutation.WxWxid(); ok {
  1347. _spec.SetField(contact.FieldWxWxid, field.TypeString, value)
  1348. }
  1349. if value, ok := cuo.mutation.GetType(); ok {
  1350. _spec.SetField(contact.FieldType, field.TypeInt, value)
  1351. }
  1352. if value, ok := cuo.mutation.AddedType(); ok {
  1353. _spec.AddField(contact.FieldType, field.TypeInt, value)
  1354. }
  1355. if cuo.mutation.TypeCleared() {
  1356. _spec.ClearField(contact.FieldType, field.TypeInt)
  1357. }
  1358. if value, ok := cuo.mutation.Wxid(); ok {
  1359. _spec.SetField(contact.FieldWxid, field.TypeString, value)
  1360. }
  1361. if value, ok := cuo.mutation.Account(); ok {
  1362. _spec.SetField(contact.FieldAccount, field.TypeString, value)
  1363. }
  1364. if value, ok := cuo.mutation.Nickname(); ok {
  1365. _spec.SetField(contact.FieldNickname, field.TypeString, value)
  1366. }
  1367. if value, ok := cuo.mutation.Markname(); ok {
  1368. _spec.SetField(contact.FieldMarkname, field.TypeString, value)
  1369. }
  1370. if value, ok := cuo.mutation.Headimg(); ok {
  1371. _spec.SetField(contact.FieldHeadimg, field.TypeString, value)
  1372. }
  1373. if value, ok := cuo.mutation.Sex(); ok {
  1374. _spec.SetField(contact.FieldSex, field.TypeInt, value)
  1375. }
  1376. if value, ok := cuo.mutation.AddedSex(); ok {
  1377. _spec.AddField(contact.FieldSex, field.TypeInt, value)
  1378. }
  1379. if value, ok := cuo.mutation.Starrole(); ok {
  1380. _spec.SetField(contact.FieldStarrole, field.TypeString, value)
  1381. }
  1382. if value, ok := cuo.mutation.Dontseeit(); ok {
  1383. _spec.SetField(contact.FieldDontseeit, field.TypeInt, value)
  1384. }
  1385. if value, ok := cuo.mutation.AddedDontseeit(); ok {
  1386. _spec.AddField(contact.FieldDontseeit, field.TypeInt, value)
  1387. }
  1388. if value, ok := cuo.mutation.Dontseeme(); ok {
  1389. _spec.SetField(contact.FieldDontseeme, field.TypeInt, value)
  1390. }
  1391. if value, ok := cuo.mutation.AddedDontseeme(); ok {
  1392. _spec.AddField(contact.FieldDontseeme, field.TypeInt, value)
  1393. }
  1394. if value, ok := cuo.mutation.Lag(); ok {
  1395. _spec.SetField(contact.FieldLag, field.TypeString, value)
  1396. }
  1397. if value, ok := cuo.mutation.Gid(); ok {
  1398. _spec.SetField(contact.FieldGid, field.TypeString, value)
  1399. }
  1400. if value, ok := cuo.mutation.Gname(); ok {
  1401. _spec.SetField(contact.FieldGname, field.TypeString, value)
  1402. }
  1403. if value, ok := cuo.mutation.V3(); ok {
  1404. _spec.SetField(contact.FieldV3, field.TypeString, value)
  1405. }
  1406. if value, ok := cuo.mutation.OrganizationID(); ok {
  1407. _spec.SetField(contact.FieldOrganizationID, field.TypeUint64, value)
  1408. }
  1409. if value, ok := cuo.mutation.AddedOrganizationID(); ok {
  1410. _spec.AddField(contact.FieldOrganizationID, field.TypeUint64, value)
  1411. }
  1412. if cuo.mutation.OrganizationIDCleared() {
  1413. _spec.ClearField(contact.FieldOrganizationID, field.TypeUint64)
  1414. }
  1415. if value, ok := cuo.mutation.Ctype(); ok {
  1416. _spec.SetField(contact.FieldCtype, field.TypeUint64, value)
  1417. }
  1418. if value, ok := cuo.mutation.AddedCtype(); ok {
  1419. _spec.AddField(contact.FieldCtype, field.TypeUint64, value)
  1420. }
  1421. if value, ok := cuo.mutation.Cage(); ok {
  1422. _spec.SetField(contact.FieldCage, field.TypeInt, value)
  1423. }
  1424. if value, ok := cuo.mutation.AddedCage(); ok {
  1425. _spec.AddField(contact.FieldCage, field.TypeInt, value)
  1426. }
  1427. if value, ok := cuo.mutation.Cname(); ok {
  1428. _spec.SetField(contact.FieldCname, field.TypeString, value)
  1429. }
  1430. if value, ok := cuo.mutation.Carea(); ok {
  1431. _spec.SetField(contact.FieldCarea, field.TypeString, value)
  1432. }
  1433. if value, ok := cuo.mutation.Cbirthday(); ok {
  1434. _spec.SetField(contact.FieldCbirthday, field.TypeString, value)
  1435. }
  1436. if value, ok := cuo.mutation.Cbirtharea(); ok {
  1437. _spec.SetField(contact.FieldCbirtharea, field.TypeString, value)
  1438. }
  1439. if value, ok := cuo.mutation.CidcardNo(); ok {
  1440. _spec.SetField(contact.FieldCidcardNo, field.TypeString, value)
  1441. }
  1442. if value, ok := cuo.mutation.Ctitle(); ok {
  1443. _spec.SetField(contact.FieldCtitle, field.TypeString, value)
  1444. }
  1445. if value, ok := cuo.mutation.Cc(); ok {
  1446. _spec.SetField(contact.FieldCc, field.TypeString, value)
  1447. }
  1448. if value, ok := cuo.mutation.Phone(); ok {
  1449. _spec.SetField(contact.FieldPhone, field.TypeString, value)
  1450. }
  1451. if cuo.mutation.ContactRelationshipsCleared() {
  1452. edge := &sqlgraph.EdgeSpec{
  1453. Rel: sqlgraph.O2M,
  1454. Inverse: false,
  1455. Table: contact.ContactRelationshipsTable,
  1456. Columns: []string{contact.ContactRelationshipsColumn},
  1457. Bidi: false,
  1458. Target: &sqlgraph.EdgeTarget{
  1459. IDSpec: sqlgraph.NewFieldSpec(labelrelationship.FieldID, field.TypeUint64),
  1460. },
  1461. }
  1462. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1463. }
  1464. if nodes := cuo.mutation.RemovedContactRelationshipsIDs(); len(nodes) > 0 && !cuo.mutation.ContactRelationshipsCleared() {
  1465. edge := &sqlgraph.EdgeSpec{
  1466. Rel: sqlgraph.O2M,
  1467. Inverse: false,
  1468. Table: contact.ContactRelationshipsTable,
  1469. Columns: []string{contact.ContactRelationshipsColumn},
  1470. Bidi: false,
  1471. Target: &sqlgraph.EdgeTarget{
  1472. IDSpec: sqlgraph.NewFieldSpec(labelrelationship.FieldID, field.TypeUint64),
  1473. },
  1474. }
  1475. for _, k := range nodes {
  1476. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1477. }
  1478. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1479. }
  1480. if nodes := cuo.mutation.ContactRelationshipsIDs(); len(nodes) > 0 {
  1481. edge := &sqlgraph.EdgeSpec{
  1482. Rel: sqlgraph.O2M,
  1483. Inverse: false,
  1484. Table: contact.ContactRelationshipsTable,
  1485. Columns: []string{contact.ContactRelationshipsColumn},
  1486. Bidi: false,
  1487. Target: &sqlgraph.EdgeTarget{
  1488. IDSpec: sqlgraph.NewFieldSpec(labelrelationship.FieldID, field.TypeUint64),
  1489. },
  1490. }
  1491. for _, k := range nodes {
  1492. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1493. }
  1494. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  1495. }
  1496. if cuo.mutation.ContactMessagesCleared() {
  1497. edge := &sqlgraph.EdgeSpec{
  1498. Rel: sqlgraph.O2M,
  1499. Inverse: false,
  1500. Table: contact.ContactMessagesTable,
  1501. Columns: []string{contact.ContactMessagesColumn},
  1502. Bidi: false,
  1503. Target: &sqlgraph.EdgeTarget{
  1504. IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
  1505. },
  1506. }
  1507. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1508. }
  1509. if nodes := cuo.mutation.RemovedContactMessagesIDs(); len(nodes) > 0 && !cuo.mutation.ContactMessagesCleared() {
  1510. edge := &sqlgraph.EdgeSpec{
  1511. Rel: sqlgraph.O2M,
  1512. Inverse: false,
  1513. Table: contact.ContactMessagesTable,
  1514. Columns: []string{contact.ContactMessagesColumn},
  1515. Bidi: false,
  1516. Target: &sqlgraph.EdgeTarget{
  1517. IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
  1518. },
  1519. }
  1520. for _, k := range nodes {
  1521. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1522. }
  1523. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1524. }
  1525. if nodes := cuo.mutation.ContactMessagesIDs(); len(nodes) > 0 {
  1526. edge := &sqlgraph.EdgeSpec{
  1527. Rel: sqlgraph.O2M,
  1528. Inverse: false,
  1529. Table: contact.ContactMessagesTable,
  1530. Columns: []string{contact.ContactMessagesColumn},
  1531. Bidi: false,
  1532. Target: &sqlgraph.EdgeTarget{
  1533. IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
  1534. },
  1535. }
  1536. for _, k := range nodes {
  1537. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1538. }
  1539. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  1540. }
  1541. _node = &Contact{config: cuo.config}
  1542. _spec.Assign = _node.assignValues
  1543. _spec.ScanValues = _node.scanValues
  1544. if err = sqlgraph.UpdateNode(ctx, cuo.driver, _spec); err != nil {
  1545. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  1546. err = &NotFoundError{contact.Label}
  1547. } else if sqlgraph.IsConstraintError(err) {
  1548. err = &ConstraintError{msg: err.Error(), wrap: err}
  1549. }
  1550. return nil, err
  1551. }
  1552. cuo.mutation.done = true
  1553. return _node, nil
  1554. }