contact_update.go 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822
  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. // SetCsex sets the "csex" field.
  323. func (cu *ContactUpdate) SetCsex(i int) *ContactUpdate {
  324. cu.mutation.ResetCsex()
  325. cu.mutation.SetCsex(i)
  326. return cu
  327. }
  328. // SetNillableCsex sets the "csex" field if the given value is not nil.
  329. func (cu *ContactUpdate) SetNillableCsex(i *int) *ContactUpdate {
  330. if i != nil {
  331. cu.SetCsex(*i)
  332. }
  333. return cu
  334. }
  335. // AddCsex adds i to the "csex" field.
  336. func (cu *ContactUpdate) AddCsex(i int) *ContactUpdate {
  337. cu.mutation.AddCsex(i)
  338. return cu
  339. }
  340. // SetCage sets the "cage" field.
  341. func (cu *ContactUpdate) SetCage(i int) *ContactUpdate {
  342. cu.mutation.ResetCage()
  343. cu.mutation.SetCage(i)
  344. return cu
  345. }
  346. // SetNillableCage sets the "cage" field if the given value is not nil.
  347. func (cu *ContactUpdate) SetNillableCage(i *int) *ContactUpdate {
  348. if i != nil {
  349. cu.SetCage(*i)
  350. }
  351. return cu
  352. }
  353. // AddCage adds i to the "cage" field.
  354. func (cu *ContactUpdate) AddCage(i int) *ContactUpdate {
  355. cu.mutation.AddCage(i)
  356. return cu
  357. }
  358. // SetCname sets the "cname" field.
  359. func (cu *ContactUpdate) SetCname(s string) *ContactUpdate {
  360. cu.mutation.SetCname(s)
  361. return cu
  362. }
  363. // SetNillableCname sets the "cname" field if the given value is not nil.
  364. func (cu *ContactUpdate) SetNillableCname(s *string) *ContactUpdate {
  365. if s != nil {
  366. cu.SetCname(*s)
  367. }
  368. return cu
  369. }
  370. // SetCarea sets the "carea" field.
  371. func (cu *ContactUpdate) SetCarea(s string) *ContactUpdate {
  372. cu.mutation.SetCarea(s)
  373. return cu
  374. }
  375. // SetNillableCarea sets the "carea" field if the given value is not nil.
  376. func (cu *ContactUpdate) SetNillableCarea(s *string) *ContactUpdate {
  377. if s != nil {
  378. cu.SetCarea(*s)
  379. }
  380. return cu
  381. }
  382. // SetCmobile sets the "cmobile" field.
  383. func (cu *ContactUpdate) SetCmobile(s string) *ContactUpdate {
  384. cu.mutation.SetCmobile(s)
  385. return cu
  386. }
  387. // SetNillableCmobile sets the "cmobile" field if the given value is not nil.
  388. func (cu *ContactUpdate) SetNillableCmobile(s *string) *ContactUpdate {
  389. if s != nil {
  390. cu.SetCmobile(*s)
  391. }
  392. return cu
  393. }
  394. // SetCbirthday sets the "cbirthday" field.
  395. func (cu *ContactUpdate) SetCbirthday(s string) *ContactUpdate {
  396. cu.mutation.SetCbirthday(s)
  397. return cu
  398. }
  399. // SetNillableCbirthday sets the "cbirthday" field if the given value is not nil.
  400. func (cu *ContactUpdate) SetNillableCbirthday(s *string) *ContactUpdate {
  401. if s != nil {
  402. cu.SetCbirthday(*s)
  403. }
  404. return cu
  405. }
  406. // SetCbirtharea sets the "cbirtharea" field.
  407. func (cu *ContactUpdate) SetCbirtharea(s string) *ContactUpdate {
  408. cu.mutation.SetCbirtharea(s)
  409. return cu
  410. }
  411. // SetNillableCbirtharea sets the "cbirtharea" field if the given value is not nil.
  412. func (cu *ContactUpdate) SetNillableCbirtharea(s *string) *ContactUpdate {
  413. if s != nil {
  414. cu.SetCbirtharea(*s)
  415. }
  416. return cu
  417. }
  418. // SetCidcardNo sets the "cidcard_no" field.
  419. func (cu *ContactUpdate) SetCidcardNo(s string) *ContactUpdate {
  420. cu.mutation.SetCidcardNo(s)
  421. return cu
  422. }
  423. // SetNillableCidcardNo sets the "cidcard_no" field if the given value is not nil.
  424. func (cu *ContactUpdate) SetNillableCidcardNo(s *string) *ContactUpdate {
  425. if s != nil {
  426. cu.SetCidcardNo(*s)
  427. }
  428. return cu
  429. }
  430. // SetCtitle sets the "ctitle" field.
  431. func (cu *ContactUpdate) SetCtitle(s string) *ContactUpdate {
  432. cu.mutation.SetCtitle(s)
  433. return cu
  434. }
  435. // SetNillableCtitle sets the "ctitle" field if the given value is not nil.
  436. func (cu *ContactUpdate) SetNillableCtitle(s *string) *ContactUpdate {
  437. if s != nil {
  438. cu.SetCtitle(*s)
  439. }
  440. return cu
  441. }
  442. // SetCc sets the "cc" field.
  443. func (cu *ContactUpdate) SetCc(s string) *ContactUpdate {
  444. cu.mutation.SetCc(s)
  445. return cu
  446. }
  447. // SetNillableCc sets the "cc" field if the given value is not nil.
  448. func (cu *ContactUpdate) SetNillableCc(s *string) *ContactUpdate {
  449. if s != nil {
  450. cu.SetCc(*s)
  451. }
  452. return cu
  453. }
  454. // SetPhone sets the "phone" field.
  455. func (cu *ContactUpdate) SetPhone(s string) *ContactUpdate {
  456. cu.mutation.SetPhone(s)
  457. return cu
  458. }
  459. // SetNillablePhone sets the "phone" field if the given value is not nil.
  460. func (cu *ContactUpdate) SetNillablePhone(s *string) *ContactUpdate {
  461. if s != nil {
  462. cu.SetPhone(*s)
  463. }
  464. return cu
  465. }
  466. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by IDs.
  467. func (cu *ContactUpdate) AddContactRelationshipIDs(ids ...uint64) *ContactUpdate {
  468. cu.mutation.AddContactRelationshipIDs(ids...)
  469. return cu
  470. }
  471. // AddContactRelationships adds the "contact_relationships" edges to the LabelRelationship entity.
  472. func (cu *ContactUpdate) AddContactRelationships(l ...*LabelRelationship) *ContactUpdate {
  473. ids := make([]uint64, len(l))
  474. for i := range l {
  475. ids[i] = l[i].ID
  476. }
  477. return cu.AddContactRelationshipIDs(ids...)
  478. }
  479. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by IDs.
  480. func (cu *ContactUpdate) AddContactMessageIDs(ids ...uint64) *ContactUpdate {
  481. cu.mutation.AddContactMessageIDs(ids...)
  482. return cu
  483. }
  484. // AddContactMessages adds the "contact_messages" edges to the MessageRecords entity.
  485. func (cu *ContactUpdate) AddContactMessages(m ...*MessageRecords) *ContactUpdate {
  486. ids := make([]uint64, len(m))
  487. for i := range m {
  488. ids[i] = m[i].ID
  489. }
  490. return cu.AddContactMessageIDs(ids...)
  491. }
  492. // Mutation returns the ContactMutation object of the builder.
  493. func (cu *ContactUpdate) Mutation() *ContactMutation {
  494. return cu.mutation
  495. }
  496. // ClearContactRelationships clears all "contact_relationships" edges to the LabelRelationship entity.
  497. func (cu *ContactUpdate) ClearContactRelationships() *ContactUpdate {
  498. cu.mutation.ClearContactRelationships()
  499. return cu
  500. }
  501. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to LabelRelationship entities by IDs.
  502. func (cu *ContactUpdate) RemoveContactRelationshipIDs(ids ...uint64) *ContactUpdate {
  503. cu.mutation.RemoveContactRelationshipIDs(ids...)
  504. return cu
  505. }
  506. // RemoveContactRelationships removes "contact_relationships" edges to LabelRelationship entities.
  507. func (cu *ContactUpdate) RemoveContactRelationships(l ...*LabelRelationship) *ContactUpdate {
  508. ids := make([]uint64, len(l))
  509. for i := range l {
  510. ids[i] = l[i].ID
  511. }
  512. return cu.RemoveContactRelationshipIDs(ids...)
  513. }
  514. // ClearContactMessages clears all "contact_messages" edges to the MessageRecords entity.
  515. func (cu *ContactUpdate) ClearContactMessages() *ContactUpdate {
  516. cu.mutation.ClearContactMessages()
  517. return cu
  518. }
  519. // RemoveContactMessageIDs removes the "contact_messages" edge to MessageRecords entities by IDs.
  520. func (cu *ContactUpdate) RemoveContactMessageIDs(ids ...uint64) *ContactUpdate {
  521. cu.mutation.RemoveContactMessageIDs(ids...)
  522. return cu
  523. }
  524. // RemoveContactMessages removes "contact_messages" edges to MessageRecords entities.
  525. func (cu *ContactUpdate) RemoveContactMessages(m ...*MessageRecords) *ContactUpdate {
  526. ids := make([]uint64, len(m))
  527. for i := range m {
  528. ids[i] = m[i].ID
  529. }
  530. return cu.RemoveContactMessageIDs(ids...)
  531. }
  532. // Save executes the query and returns the number of nodes affected by the update operation.
  533. func (cu *ContactUpdate) Save(ctx context.Context) (int, error) {
  534. if err := cu.defaults(); err != nil {
  535. return 0, err
  536. }
  537. return withHooks(ctx, cu.sqlSave, cu.mutation, cu.hooks)
  538. }
  539. // SaveX is like Save, but panics if an error occurs.
  540. func (cu *ContactUpdate) SaveX(ctx context.Context) int {
  541. affected, err := cu.Save(ctx)
  542. if err != nil {
  543. panic(err)
  544. }
  545. return affected
  546. }
  547. // Exec executes the query.
  548. func (cu *ContactUpdate) Exec(ctx context.Context) error {
  549. _, err := cu.Save(ctx)
  550. return err
  551. }
  552. // ExecX is like Exec, but panics if an error occurs.
  553. func (cu *ContactUpdate) ExecX(ctx context.Context) {
  554. if err := cu.Exec(ctx); err != nil {
  555. panic(err)
  556. }
  557. }
  558. // defaults sets the default values of the builder before save.
  559. func (cu *ContactUpdate) defaults() error {
  560. if _, ok := cu.mutation.UpdatedAt(); !ok {
  561. if contact.UpdateDefaultUpdatedAt == nil {
  562. return fmt.Errorf("ent: uninitialized contact.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
  563. }
  564. v := contact.UpdateDefaultUpdatedAt()
  565. cu.mutation.SetUpdatedAt(v)
  566. }
  567. return nil
  568. }
  569. func (cu *ContactUpdate) sqlSave(ctx context.Context) (n int, err error) {
  570. _spec := sqlgraph.NewUpdateSpec(contact.Table, contact.Columns, sqlgraph.NewFieldSpec(contact.FieldID, field.TypeUint64))
  571. if ps := cu.mutation.predicates; len(ps) > 0 {
  572. _spec.Predicate = func(selector *sql.Selector) {
  573. for i := range ps {
  574. ps[i](selector)
  575. }
  576. }
  577. }
  578. if value, ok := cu.mutation.UpdatedAt(); ok {
  579. _spec.SetField(contact.FieldUpdatedAt, field.TypeTime, value)
  580. }
  581. if value, ok := cu.mutation.Status(); ok {
  582. _spec.SetField(contact.FieldStatus, field.TypeUint8, value)
  583. }
  584. if value, ok := cu.mutation.AddedStatus(); ok {
  585. _spec.AddField(contact.FieldStatus, field.TypeUint8, value)
  586. }
  587. if cu.mutation.StatusCleared() {
  588. _spec.ClearField(contact.FieldStatus, field.TypeUint8)
  589. }
  590. if value, ok := cu.mutation.DeletedAt(); ok {
  591. _spec.SetField(contact.FieldDeletedAt, field.TypeTime, value)
  592. }
  593. if cu.mutation.DeletedAtCleared() {
  594. _spec.ClearField(contact.FieldDeletedAt, field.TypeTime)
  595. }
  596. if value, ok := cu.mutation.WxWxid(); ok {
  597. _spec.SetField(contact.FieldWxWxid, field.TypeString, value)
  598. }
  599. if value, ok := cu.mutation.GetType(); ok {
  600. _spec.SetField(contact.FieldType, field.TypeInt, value)
  601. }
  602. if value, ok := cu.mutation.AddedType(); ok {
  603. _spec.AddField(contact.FieldType, field.TypeInt, value)
  604. }
  605. if cu.mutation.TypeCleared() {
  606. _spec.ClearField(contact.FieldType, field.TypeInt)
  607. }
  608. if value, ok := cu.mutation.Wxid(); ok {
  609. _spec.SetField(contact.FieldWxid, field.TypeString, value)
  610. }
  611. if value, ok := cu.mutation.Account(); ok {
  612. _spec.SetField(contact.FieldAccount, field.TypeString, value)
  613. }
  614. if value, ok := cu.mutation.Nickname(); ok {
  615. _spec.SetField(contact.FieldNickname, field.TypeString, value)
  616. }
  617. if value, ok := cu.mutation.Markname(); ok {
  618. _spec.SetField(contact.FieldMarkname, field.TypeString, value)
  619. }
  620. if value, ok := cu.mutation.Headimg(); ok {
  621. _spec.SetField(contact.FieldHeadimg, field.TypeString, value)
  622. }
  623. if value, ok := cu.mutation.Sex(); ok {
  624. _spec.SetField(contact.FieldSex, field.TypeInt, value)
  625. }
  626. if value, ok := cu.mutation.AddedSex(); ok {
  627. _spec.AddField(contact.FieldSex, field.TypeInt, value)
  628. }
  629. if value, ok := cu.mutation.Starrole(); ok {
  630. _spec.SetField(contact.FieldStarrole, field.TypeString, value)
  631. }
  632. if value, ok := cu.mutation.Dontseeit(); ok {
  633. _spec.SetField(contact.FieldDontseeit, field.TypeInt, value)
  634. }
  635. if value, ok := cu.mutation.AddedDontseeit(); ok {
  636. _spec.AddField(contact.FieldDontseeit, field.TypeInt, value)
  637. }
  638. if value, ok := cu.mutation.Dontseeme(); ok {
  639. _spec.SetField(contact.FieldDontseeme, field.TypeInt, value)
  640. }
  641. if value, ok := cu.mutation.AddedDontseeme(); ok {
  642. _spec.AddField(contact.FieldDontseeme, field.TypeInt, value)
  643. }
  644. if value, ok := cu.mutation.Lag(); ok {
  645. _spec.SetField(contact.FieldLag, field.TypeString, value)
  646. }
  647. if value, ok := cu.mutation.Gid(); ok {
  648. _spec.SetField(contact.FieldGid, field.TypeString, value)
  649. }
  650. if value, ok := cu.mutation.Gname(); ok {
  651. _spec.SetField(contact.FieldGname, field.TypeString, value)
  652. }
  653. if value, ok := cu.mutation.V3(); ok {
  654. _spec.SetField(contact.FieldV3, field.TypeString, value)
  655. }
  656. if value, ok := cu.mutation.OrganizationID(); ok {
  657. _spec.SetField(contact.FieldOrganizationID, field.TypeUint64, value)
  658. }
  659. if value, ok := cu.mutation.AddedOrganizationID(); ok {
  660. _spec.AddField(contact.FieldOrganizationID, field.TypeUint64, value)
  661. }
  662. if cu.mutation.OrganizationIDCleared() {
  663. _spec.ClearField(contact.FieldOrganizationID, field.TypeUint64)
  664. }
  665. if value, ok := cu.mutation.Ctype(); ok {
  666. _spec.SetField(contact.FieldCtype, field.TypeUint64, value)
  667. }
  668. if value, ok := cu.mutation.AddedCtype(); ok {
  669. _spec.AddField(contact.FieldCtype, field.TypeUint64, value)
  670. }
  671. if value, ok := cu.mutation.Csex(); ok {
  672. _spec.SetField(contact.FieldCsex, field.TypeInt, value)
  673. }
  674. if value, ok := cu.mutation.AddedCsex(); ok {
  675. _spec.AddField(contact.FieldCsex, field.TypeInt, value)
  676. }
  677. if value, ok := cu.mutation.Cage(); ok {
  678. _spec.SetField(contact.FieldCage, field.TypeInt, value)
  679. }
  680. if value, ok := cu.mutation.AddedCage(); ok {
  681. _spec.AddField(contact.FieldCage, field.TypeInt, value)
  682. }
  683. if value, ok := cu.mutation.Cname(); ok {
  684. _spec.SetField(contact.FieldCname, field.TypeString, value)
  685. }
  686. if value, ok := cu.mutation.Carea(); ok {
  687. _spec.SetField(contact.FieldCarea, field.TypeString, value)
  688. }
  689. if value, ok := cu.mutation.Cmobile(); ok {
  690. _spec.SetField(contact.FieldCmobile, field.TypeString, value)
  691. }
  692. if value, ok := cu.mutation.Cbirthday(); ok {
  693. _spec.SetField(contact.FieldCbirthday, field.TypeString, value)
  694. }
  695. if value, ok := cu.mutation.Cbirtharea(); ok {
  696. _spec.SetField(contact.FieldCbirtharea, field.TypeString, value)
  697. }
  698. if value, ok := cu.mutation.CidcardNo(); ok {
  699. _spec.SetField(contact.FieldCidcardNo, field.TypeString, value)
  700. }
  701. if value, ok := cu.mutation.Ctitle(); ok {
  702. _spec.SetField(contact.FieldCtitle, field.TypeString, value)
  703. }
  704. if value, ok := cu.mutation.Cc(); ok {
  705. _spec.SetField(contact.FieldCc, field.TypeString, value)
  706. }
  707. if value, ok := cu.mutation.Phone(); ok {
  708. _spec.SetField(contact.FieldPhone, field.TypeString, value)
  709. }
  710. if cu.mutation.ContactRelationshipsCleared() {
  711. edge := &sqlgraph.EdgeSpec{
  712. Rel: sqlgraph.O2M,
  713. Inverse: false,
  714. Table: contact.ContactRelationshipsTable,
  715. Columns: []string{contact.ContactRelationshipsColumn},
  716. Bidi: false,
  717. Target: &sqlgraph.EdgeTarget{
  718. IDSpec: sqlgraph.NewFieldSpec(labelrelationship.FieldID, field.TypeUint64),
  719. },
  720. }
  721. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  722. }
  723. if nodes := cu.mutation.RemovedContactRelationshipsIDs(); len(nodes) > 0 && !cu.mutation.ContactRelationshipsCleared() {
  724. edge := &sqlgraph.EdgeSpec{
  725. Rel: sqlgraph.O2M,
  726. Inverse: false,
  727. Table: contact.ContactRelationshipsTable,
  728. Columns: []string{contact.ContactRelationshipsColumn},
  729. Bidi: false,
  730. Target: &sqlgraph.EdgeTarget{
  731. IDSpec: sqlgraph.NewFieldSpec(labelrelationship.FieldID, field.TypeUint64),
  732. },
  733. }
  734. for _, k := range nodes {
  735. edge.Target.Nodes = append(edge.Target.Nodes, k)
  736. }
  737. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  738. }
  739. if nodes := cu.mutation.ContactRelationshipsIDs(); len(nodes) > 0 {
  740. edge := &sqlgraph.EdgeSpec{
  741. Rel: sqlgraph.O2M,
  742. Inverse: false,
  743. Table: contact.ContactRelationshipsTable,
  744. Columns: []string{contact.ContactRelationshipsColumn},
  745. Bidi: false,
  746. Target: &sqlgraph.EdgeTarget{
  747. IDSpec: sqlgraph.NewFieldSpec(labelrelationship.FieldID, field.TypeUint64),
  748. },
  749. }
  750. for _, k := range nodes {
  751. edge.Target.Nodes = append(edge.Target.Nodes, k)
  752. }
  753. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  754. }
  755. if cu.mutation.ContactMessagesCleared() {
  756. edge := &sqlgraph.EdgeSpec{
  757. Rel: sqlgraph.O2M,
  758. Inverse: false,
  759. Table: contact.ContactMessagesTable,
  760. Columns: []string{contact.ContactMessagesColumn},
  761. Bidi: false,
  762. Target: &sqlgraph.EdgeTarget{
  763. IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
  764. },
  765. }
  766. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  767. }
  768. if nodes := cu.mutation.RemovedContactMessagesIDs(); len(nodes) > 0 && !cu.mutation.ContactMessagesCleared() {
  769. edge := &sqlgraph.EdgeSpec{
  770. Rel: sqlgraph.O2M,
  771. Inverse: false,
  772. Table: contact.ContactMessagesTable,
  773. Columns: []string{contact.ContactMessagesColumn},
  774. Bidi: false,
  775. Target: &sqlgraph.EdgeTarget{
  776. IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
  777. },
  778. }
  779. for _, k := range nodes {
  780. edge.Target.Nodes = append(edge.Target.Nodes, k)
  781. }
  782. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  783. }
  784. if nodes := cu.mutation.ContactMessagesIDs(); len(nodes) > 0 {
  785. edge := &sqlgraph.EdgeSpec{
  786. Rel: sqlgraph.O2M,
  787. Inverse: false,
  788. Table: contact.ContactMessagesTable,
  789. Columns: []string{contact.ContactMessagesColumn},
  790. Bidi: false,
  791. Target: &sqlgraph.EdgeTarget{
  792. IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
  793. },
  794. }
  795. for _, k := range nodes {
  796. edge.Target.Nodes = append(edge.Target.Nodes, k)
  797. }
  798. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  799. }
  800. if n, err = sqlgraph.UpdateNodes(ctx, cu.driver, _spec); err != nil {
  801. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  802. err = &NotFoundError{contact.Label}
  803. } else if sqlgraph.IsConstraintError(err) {
  804. err = &ConstraintError{msg: err.Error(), wrap: err}
  805. }
  806. return 0, err
  807. }
  808. cu.mutation.done = true
  809. return n, nil
  810. }
  811. // ContactUpdateOne is the builder for updating a single Contact entity.
  812. type ContactUpdateOne struct {
  813. config
  814. fields []string
  815. hooks []Hook
  816. mutation *ContactMutation
  817. }
  818. // SetUpdatedAt sets the "updated_at" field.
  819. func (cuo *ContactUpdateOne) SetUpdatedAt(t time.Time) *ContactUpdateOne {
  820. cuo.mutation.SetUpdatedAt(t)
  821. return cuo
  822. }
  823. // SetStatus sets the "status" field.
  824. func (cuo *ContactUpdateOne) SetStatus(u uint8) *ContactUpdateOne {
  825. cuo.mutation.ResetStatus()
  826. cuo.mutation.SetStatus(u)
  827. return cuo
  828. }
  829. // SetNillableStatus sets the "status" field if the given value is not nil.
  830. func (cuo *ContactUpdateOne) SetNillableStatus(u *uint8) *ContactUpdateOne {
  831. if u != nil {
  832. cuo.SetStatus(*u)
  833. }
  834. return cuo
  835. }
  836. // AddStatus adds u to the "status" field.
  837. func (cuo *ContactUpdateOne) AddStatus(u int8) *ContactUpdateOne {
  838. cuo.mutation.AddStatus(u)
  839. return cuo
  840. }
  841. // ClearStatus clears the value of the "status" field.
  842. func (cuo *ContactUpdateOne) ClearStatus() *ContactUpdateOne {
  843. cuo.mutation.ClearStatus()
  844. return cuo
  845. }
  846. // SetDeletedAt sets the "deleted_at" field.
  847. func (cuo *ContactUpdateOne) SetDeletedAt(t time.Time) *ContactUpdateOne {
  848. cuo.mutation.SetDeletedAt(t)
  849. return cuo
  850. }
  851. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  852. func (cuo *ContactUpdateOne) SetNillableDeletedAt(t *time.Time) *ContactUpdateOne {
  853. if t != nil {
  854. cuo.SetDeletedAt(*t)
  855. }
  856. return cuo
  857. }
  858. // ClearDeletedAt clears the value of the "deleted_at" field.
  859. func (cuo *ContactUpdateOne) ClearDeletedAt() *ContactUpdateOne {
  860. cuo.mutation.ClearDeletedAt()
  861. return cuo
  862. }
  863. // SetWxWxid sets the "wx_wxid" field.
  864. func (cuo *ContactUpdateOne) SetWxWxid(s string) *ContactUpdateOne {
  865. cuo.mutation.SetWxWxid(s)
  866. return cuo
  867. }
  868. // SetNillableWxWxid sets the "wx_wxid" field if the given value is not nil.
  869. func (cuo *ContactUpdateOne) SetNillableWxWxid(s *string) *ContactUpdateOne {
  870. if s != nil {
  871. cuo.SetWxWxid(*s)
  872. }
  873. return cuo
  874. }
  875. // SetType sets the "type" field.
  876. func (cuo *ContactUpdateOne) SetType(i int) *ContactUpdateOne {
  877. cuo.mutation.ResetType()
  878. cuo.mutation.SetType(i)
  879. return cuo
  880. }
  881. // SetNillableType sets the "type" field if the given value is not nil.
  882. func (cuo *ContactUpdateOne) SetNillableType(i *int) *ContactUpdateOne {
  883. if i != nil {
  884. cuo.SetType(*i)
  885. }
  886. return cuo
  887. }
  888. // AddType adds i to the "type" field.
  889. func (cuo *ContactUpdateOne) AddType(i int) *ContactUpdateOne {
  890. cuo.mutation.AddType(i)
  891. return cuo
  892. }
  893. // ClearType clears the value of the "type" field.
  894. func (cuo *ContactUpdateOne) ClearType() *ContactUpdateOne {
  895. cuo.mutation.ClearType()
  896. return cuo
  897. }
  898. // SetWxid sets the "wxid" field.
  899. func (cuo *ContactUpdateOne) SetWxid(s string) *ContactUpdateOne {
  900. cuo.mutation.SetWxid(s)
  901. return cuo
  902. }
  903. // SetNillableWxid sets the "wxid" field if the given value is not nil.
  904. func (cuo *ContactUpdateOne) SetNillableWxid(s *string) *ContactUpdateOne {
  905. if s != nil {
  906. cuo.SetWxid(*s)
  907. }
  908. return cuo
  909. }
  910. // SetAccount sets the "account" field.
  911. func (cuo *ContactUpdateOne) SetAccount(s string) *ContactUpdateOne {
  912. cuo.mutation.SetAccount(s)
  913. return cuo
  914. }
  915. // SetNillableAccount sets the "account" field if the given value is not nil.
  916. func (cuo *ContactUpdateOne) SetNillableAccount(s *string) *ContactUpdateOne {
  917. if s != nil {
  918. cuo.SetAccount(*s)
  919. }
  920. return cuo
  921. }
  922. // SetNickname sets the "nickname" field.
  923. func (cuo *ContactUpdateOne) SetNickname(s string) *ContactUpdateOne {
  924. cuo.mutation.SetNickname(s)
  925. return cuo
  926. }
  927. // SetNillableNickname sets the "nickname" field if the given value is not nil.
  928. func (cuo *ContactUpdateOne) SetNillableNickname(s *string) *ContactUpdateOne {
  929. if s != nil {
  930. cuo.SetNickname(*s)
  931. }
  932. return cuo
  933. }
  934. // SetMarkname sets the "markname" field.
  935. func (cuo *ContactUpdateOne) SetMarkname(s string) *ContactUpdateOne {
  936. cuo.mutation.SetMarkname(s)
  937. return cuo
  938. }
  939. // SetNillableMarkname sets the "markname" field if the given value is not nil.
  940. func (cuo *ContactUpdateOne) SetNillableMarkname(s *string) *ContactUpdateOne {
  941. if s != nil {
  942. cuo.SetMarkname(*s)
  943. }
  944. return cuo
  945. }
  946. // SetHeadimg sets the "headimg" field.
  947. func (cuo *ContactUpdateOne) SetHeadimg(s string) *ContactUpdateOne {
  948. cuo.mutation.SetHeadimg(s)
  949. return cuo
  950. }
  951. // SetNillableHeadimg sets the "headimg" field if the given value is not nil.
  952. func (cuo *ContactUpdateOne) SetNillableHeadimg(s *string) *ContactUpdateOne {
  953. if s != nil {
  954. cuo.SetHeadimg(*s)
  955. }
  956. return cuo
  957. }
  958. // SetSex sets the "sex" field.
  959. func (cuo *ContactUpdateOne) SetSex(i int) *ContactUpdateOne {
  960. cuo.mutation.ResetSex()
  961. cuo.mutation.SetSex(i)
  962. return cuo
  963. }
  964. // SetNillableSex sets the "sex" field if the given value is not nil.
  965. func (cuo *ContactUpdateOne) SetNillableSex(i *int) *ContactUpdateOne {
  966. if i != nil {
  967. cuo.SetSex(*i)
  968. }
  969. return cuo
  970. }
  971. // AddSex adds i to the "sex" field.
  972. func (cuo *ContactUpdateOne) AddSex(i int) *ContactUpdateOne {
  973. cuo.mutation.AddSex(i)
  974. return cuo
  975. }
  976. // SetStarrole sets the "starrole" field.
  977. func (cuo *ContactUpdateOne) SetStarrole(s string) *ContactUpdateOne {
  978. cuo.mutation.SetStarrole(s)
  979. return cuo
  980. }
  981. // SetNillableStarrole sets the "starrole" field if the given value is not nil.
  982. func (cuo *ContactUpdateOne) SetNillableStarrole(s *string) *ContactUpdateOne {
  983. if s != nil {
  984. cuo.SetStarrole(*s)
  985. }
  986. return cuo
  987. }
  988. // SetDontseeit sets the "dontseeit" field.
  989. func (cuo *ContactUpdateOne) SetDontseeit(i int) *ContactUpdateOne {
  990. cuo.mutation.ResetDontseeit()
  991. cuo.mutation.SetDontseeit(i)
  992. return cuo
  993. }
  994. // SetNillableDontseeit sets the "dontseeit" field if the given value is not nil.
  995. func (cuo *ContactUpdateOne) SetNillableDontseeit(i *int) *ContactUpdateOne {
  996. if i != nil {
  997. cuo.SetDontseeit(*i)
  998. }
  999. return cuo
  1000. }
  1001. // AddDontseeit adds i to the "dontseeit" field.
  1002. func (cuo *ContactUpdateOne) AddDontseeit(i int) *ContactUpdateOne {
  1003. cuo.mutation.AddDontseeit(i)
  1004. return cuo
  1005. }
  1006. // SetDontseeme sets the "dontseeme" field.
  1007. func (cuo *ContactUpdateOne) SetDontseeme(i int) *ContactUpdateOne {
  1008. cuo.mutation.ResetDontseeme()
  1009. cuo.mutation.SetDontseeme(i)
  1010. return cuo
  1011. }
  1012. // SetNillableDontseeme sets the "dontseeme" field if the given value is not nil.
  1013. func (cuo *ContactUpdateOne) SetNillableDontseeme(i *int) *ContactUpdateOne {
  1014. if i != nil {
  1015. cuo.SetDontseeme(*i)
  1016. }
  1017. return cuo
  1018. }
  1019. // AddDontseeme adds i to the "dontseeme" field.
  1020. func (cuo *ContactUpdateOne) AddDontseeme(i int) *ContactUpdateOne {
  1021. cuo.mutation.AddDontseeme(i)
  1022. return cuo
  1023. }
  1024. // SetLag sets the "lag" field.
  1025. func (cuo *ContactUpdateOne) SetLag(s string) *ContactUpdateOne {
  1026. cuo.mutation.SetLag(s)
  1027. return cuo
  1028. }
  1029. // SetNillableLag sets the "lag" field if the given value is not nil.
  1030. func (cuo *ContactUpdateOne) SetNillableLag(s *string) *ContactUpdateOne {
  1031. if s != nil {
  1032. cuo.SetLag(*s)
  1033. }
  1034. return cuo
  1035. }
  1036. // SetGid sets the "gid" field.
  1037. func (cuo *ContactUpdateOne) SetGid(s string) *ContactUpdateOne {
  1038. cuo.mutation.SetGid(s)
  1039. return cuo
  1040. }
  1041. // SetNillableGid sets the "gid" field if the given value is not nil.
  1042. func (cuo *ContactUpdateOne) SetNillableGid(s *string) *ContactUpdateOne {
  1043. if s != nil {
  1044. cuo.SetGid(*s)
  1045. }
  1046. return cuo
  1047. }
  1048. // SetGname sets the "gname" field.
  1049. func (cuo *ContactUpdateOne) SetGname(s string) *ContactUpdateOne {
  1050. cuo.mutation.SetGname(s)
  1051. return cuo
  1052. }
  1053. // SetNillableGname sets the "gname" field if the given value is not nil.
  1054. func (cuo *ContactUpdateOne) SetNillableGname(s *string) *ContactUpdateOne {
  1055. if s != nil {
  1056. cuo.SetGname(*s)
  1057. }
  1058. return cuo
  1059. }
  1060. // SetV3 sets the "v3" field.
  1061. func (cuo *ContactUpdateOne) SetV3(s string) *ContactUpdateOne {
  1062. cuo.mutation.SetV3(s)
  1063. return cuo
  1064. }
  1065. // SetNillableV3 sets the "v3" field if the given value is not nil.
  1066. func (cuo *ContactUpdateOne) SetNillableV3(s *string) *ContactUpdateOne {
  1067. if s != nil {
  1068. cuo.SetV3(*s)
  1069. }
  1070. return cuo
  1071. }
  1072. // SetOrganizationID sets the "organization_id" field.
  1073. func (cuo *ContactUpdateOne) SetOrganizationID(u uint64) *ContactUpdateOne {
  1074. cuo.mutation.ResetOrganizationID()
  1075. cuo.mutation.SetOrganizationID(u)
  1076. return cuo
  1077. }
  1078. // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
  1079. func (cuo *ContactUpdateOne) SetNillableOrganizationID(u *uint64) *ContactUpdateOne {
  1080. if u != nil {
  1081. cuo.SetOrganizationID(*u)
  1082. }
  1083. return cuo
  1084. }
  1085. // AddOrganizationID adds u to the "organization_id" field.
  1086. func (cuo *ContactUpdateOne) AddOrganizationID(u int64) *ContactUpdateOne {
  1087. cuo.mutation.AddOrganizationID(u)
  1088. return cuo
  1089. }
  1090. // ClearOrganizationID clears the value of the "organization_id" field.
  1091. func (cuo *ContactUpdateOne) ClearOrganizationID() *ContactUpdateOne {
  1092. cuo.mutation.ClearOrganizationID()
  1093. return cuo
  1094. }
  1095. // SetCtype sets the "ctype" field.
  1096. func (cuo *ContactUpdateOne) SetCtype(u uint64) *ContactUpdateOne {
  1097. cuo.mutation.ResetCtype()
  1098. cuo.mutation.SetCtype(u)
  1099. return cuo
  1100. }
  1101. // SetNillableCtype sets the "ctype" field if the given value is not nil.
  1102. func (cuo *ContactUpdateOne) SetNillableCtype(u *uint64) *ContactUpdateOne {
  1103. if u != nil {
  1104. cuo.SetCtype(*u)
  1105. }
  1106. return cuo
  1107. }
  1108. // AddCtype adds u to the "ctype" field.
  1109. func (cuo *ContactUpdateOne) AddCtype(u int64) *ContactUpdateOne {
  1110. cuo.mutation.AddCtype(u)
  1111. return cuo
  1112. }
  1113. // SetCsex sets the "csex" field.
  1114. func (cuo *ContactUpdateOne) SetCsex(i int) *ContactUpdateOne {
  1115. cuo.mutation.ResetCsex()
  1116. cuo.mutation.SetCsex(i)
  1117. return cuo
  1118. }
  1119. // SetNillableCsex sets the "csex" field if the given value is not nil.
  1120. func (cuo *ContactUpdateOne) SetNillableCsex(i *int) *ContactUpdateOne {
  1121. if i != nil {
  1122. cuo.SetCsex(*i)
  1123. }
  1124. return cuo
  1125. }
  1126. // AddCsex adds i to the "csex" field.
  1127. func (cuo *ContactUpdateOne) AddCsex(i int) *ContactUpdateOne {
  1128. cuo.mutation.AddCsex(i)
  1129. return cuo
  1130. }
  1131. // SetCage sets the "cage" field.
  1132. func (cuo *ContactUpdateOne) SetCage(i int) *ContactUpdateOne {
  1133. cuo.mutation.ResetCage()
  1134. cuo.mutation.SetCage(i)
  1135. return cuo
  1136. }
  1137. // SetNillableCage sets the "cage" field if the given value is not nil.
  1138. func (cuo *ContactUpdateOne) SetNillableCage(i *int) *ContactUpdateOne {
  1139. if i != nil {
  1140. cuo.SetCage(*i)
  1141. }
  1142. return cuo
  1143. }
  1144. // AddCage adds i to the "cage" field.
  1145. func (cuo *ContactUpdateOne) AddCage(i int) *ContactUpdateOne {
  1146. cuo.mutation.AddCage(i)
  1147. return cuo
  1148. }
  1149. // SetCname sets the "cname" field.
  1150. func (cuo *ContactUpdateOne) SetCname(s string) *ContactUpdateOne {
  1151. cuo.mutation.SetCname(s)
  1152. return cuo
  1153. }
  1154. // SetNillableCname sets the "cname" field if the given value is not nil.
  1155. func (cuo *ContactUpdateOne) SetNillableCname(s *string) *ContactUpdateOne {
  1156. if s != nil {
  1157. cuo.SetCname(*s)
  1158. }
  1159. return cuo
  1160. }
  1161. // SetCarea sets the "carea" field.
  1162. func (cuo *ContactUpdateOne) SetCarea(s string) *ContactUpdateOne {
  1163. cuo.mutation.SetCarea(s)
  1164. return cuo
  1165. }
  1166. // SetNillableCarea sets the "carea" field if the given value is not nil.
  1167. func (cuo *ContactUpdateOne) SetNillableCarea(s *string) *ContactUpdateOne {
  1168. if s != nil {
  1169. cuo.SetCarea(*s)
  1170. }
  1171. return cuo
  1172. }
  1173. // SetCmobile sets the "cmobile" field.
  1174. func (cuo *ContactUpdateOne) SetCmobile(s string) *ContactUpdateOne {
  1175. cuo.mutation.SetCmobile(s)
  1176. return cuo
  1177. }
  1178. // SetNillableCmobile sets the "cmobile" field if the given value is not nil.
  1179. func (cuo *ContactUpdateOne) SetNillableCmobile(s *string) *ContactUpdateOne {
  1180. if s != nil {
  1181. cuo.SetCmobile(*s)
  1182. }
  1183. return cuo
  1184. }
  1185. // SetCbirthday sets the "cbirthday" field.
  1186. func (cuo *ContactUpdateOne) SetCbirthday(s string) *ContactUpdateOne {
  1187. cuo.mutation.SetCbirthday(s)
  1188. return cuo
  1189. }
  1190. // SetNillableCbirthday sets the "cbirthday" field if the given value is not nil.
  1191. func (cuo *ContactUpdateOne) SetNillableCbirthday(s *string) *ContactUpdateOne {
  1192. if s != nil {
  1193. cuo.SetCbirthday(*s)
  1194. }
  1195. return cuo
  1196. }
  1197. // SetCbirtharea sets the "cbirtharea" field.
  1198. func (cuo *ContactUpdateOne) SetCbirtharea(s string) *ContactUpdateOne {
  1199. cuo.mutation.SetCbirtharea(s)
  1200. return cuo
  1201. }
  1202. // SetNillableCbirtharea sets the "cbirtharea" field if the given value is not nil.
  1203. func (cuo *ContactUpdateOne) SetNillableCbirtharea(s *string) *ContactUpdateOne {
  1204. if s != nil {
  1205. cuo.SetCbirtharea(*s)
  1206. }
  1207. return cuo
  1208. }
  1209. // SetCidcardNo sets the "cidcard_no" field.
  1210. func (cuo *ContactUpdateOne) SetCidcardNo(s string) *ContactUpdateOne {
  1211. cuo.mutation.SetCidcardNo(s)
  1212. return cuo
  1213. }
  1214. // SetNillableCidcardNo sets the "cidcard_no" field if the given value is not nil.
  1215. func (cuo *ContactUpdateOne) SetNillableCidcardNo(s *string) *ContactUpdateOne {
  1216. if s != nil {
  1217. cuo.SetCidcardNo(*s)
  1218. }
  1219. return cuo
  1220. }
  1221. // SetCtitle sets the "ctitle" field.
  1222. func (cuo *ContactUpdateOne) SetCtitle(s string) *ContactUpdateOne {
  1223. cuo.mutation.SetCtitle(s)
  1224. return cuo
  1225. }
  1226. // SetNillableCtitle sets the "ctitle" field if the given value is not nil.
  1227. func (cuo *ContactUpdateOne) SetNillableCtitle(s *string) *ContactUpdateOne {
  1228. if s != nil {
  1229. cuo.SetCtitle(*s)
  1230. }
  1231. return cuo
  1232. }
  1233. // SetCc sets the "cc" field.
  1234. func (cuo *ContactUpdateOne) SetCc(s string) *ContactUpdateOne {
  1235. cuo.mutation.SetCc(s)
  1236. return cuo
  1237. }
  1238. // SetNillableCc sets the "cc" field if the given value is not nil.
  1239. func (cuo *ContactUpdateOne) SetNillableCc(s *string) *ContactUpdateOne {
  1240. if s != nil {
  1241. cuo.SetCc(*s)
  1242. }
  1243. return cuo
  1244. }
  1245. // SetPhone sets the "phone" field.
  1246. func (cuo *ContactUpdateOne) SetPhone(s string) *ContactUpdateOne {
  1247. cuo.mutation.SetPhone(s)
  1248. return cuo
  1249. }
  1250. // SetNillablePhone sets the "phone" field if the given value is not nil.
  1251. func (cuo *ContactUpdateOne) SetNillablePhone(s *string) *ContactUpdateOne {
  1252. if s != nil {
  1253. cuo.SetPhone(*s)
  1254. }
  1255. return cuo
  1256. }
  1257. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by IDs.
  1258. func (cuo *ContactUpdateOne) AddContactRelationshipIDs(ids ...uint64) *ContactUpdateOne {
  1259. cuo.mutation.AddContactRelationshipIDs(ids...)
  1260. return cuo
  1261. }
  1262. // AddContactRelationships adds the "contact_relationships" edges to the LabelRelationship entity.
  1263. func (cuo *ContactUpdateOne) AddContactRelationships(l ...*LabelRelationship) *ContactUpdateOne {
  1264. ids := make([]uint64, len(l))
  1265. for i := range l {
  1266. ids[i] = l[i].ID
  1267. }
  1268. return cuo.AddContactRelationshipIDs(ids...)
  1269. }
  1270. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by IDs.
  1271. func (cuo *ContactUpdateOne) AddContactMessageIDs(ids ...uint64) *ContactUpdateOne {
  1272. cuo.mutation.AddContactMessageIDs(ids...)
  1273. return cuo
  1274. }
  1275. // AddContactMessages adds the "contact_messages" edges to the MessageRecords entity.
  1276. func (cuo *ContactUpdateOne) AddContactMessages(m ...*MessageRecords) *ContactUpdateOne {
  1277. ids := make([]uint64, len(m))
  1278. for i := range m {
  1279. ids[i] = m[i].ID
  1280. }
  1281. return cuo.AddContactMessageIDs(ids...)
  1282. }
  1283. // Mutation returns the ContactMutation object of the builder.
  1284. func (cuo *ContactUpdateOne) Mutation() *ContactMutation {
  1285. return cuo.mutation
  1286. }
  1287. // ClearContactRelationships clears all "contact_relationships" edges to the LabelRelationship entity.
  1288. func (cuo *ContactUpdateOne) ClearContactRelationships() *ContactUpdateOne {
  1289. cuo.mutation.ClearContactRelationships()
  1290. return cuo
  1291. }
  1292. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to LabelRelationship entities by IDs.
  1293. func (cuo *ContactUpdateOne) RemoveContactRelationshipIDs(ids ...uint64) *ContactUpdateOne {
  1294. cuo.mutation.RemoveContactRelationshipIDs(ids...)
  1295. return cuo
  1296. }
  1297. // RemoveContactRelationships removes "contact_relationships" edges to LabelRelationship entities.
  1298. func (cuo *ContactUpdateOne) RemoveContactRelationships(l ...*LabelRelationship) *ContactUpdateOne {
  1299. ids := make([]uint64, len(l))
  1300. for i := range l {
  1301. ids[i] = l[i].ID
  1302. }
  1303. return cuo.RemoveContactRelationshipIDs(ids...)
  1304. }
  1305. // ClearContactMessages clears all "contact_messages" edges to the MessageRecords entity.
  1306. func (cuo *ContactUpdateOne) ClearContactMessages() *ContactUpdateOne {
  1307. cuo.mutation.ClearContactMessages()
  1308. return cuo
  1309. }
  1310. // RemoveContactMessageIDs removes the "contact_messages" edge to MessageRecords entities by IDs.
  1311. func (cuo *ContactUpdateOne) RemoveContactMessageIDs(ids ...uint64) *ContactUpdateOne {
  1312. cuo.mutation.RemoveContactMessageIDs(ids...)
  1313. return cuo
  1314. }
  1315. // RemoveContactMessages removes "contact_messages" edges to MessageRecords entities.
  1316. func (cuo *ContactUpdateOne) RemoveContactMessages(m ...*MessageRecords) *ContactUpdateOne {
  1317. ids := make([]uint64, len(m))
  1318. for i := range m {
  1319. ids[i] = m[i].ID
  1320. }
  1321. return cuo.RemoveContactMessageIDs(ids...)
  1322. }
  1323. // Where appends a list predicates to the ContactUpdate builder.
  1324. func (cuo *ContactUpdateOne) Where(ps ...predicate.Contact) *ContactUpdateOne {
  1325. cuo.mutation.Where(ps...)
  1326. return cuo
  1327. }
  1328. // Select allows selecting one or more fields (columns) of the returned entity.
  1329. // The default is selecting all fields defined in the entity schema.
  1330. func (cuo *ContactUpdateOne) Select(field string, fields ...string) *ContactUpdateOne {
  1331. cuo.fields = append([]string{field}, fields...)
  1332. return cuo
  1333. }
  1334. // Save executes the query and returns the updated Contact entity.
  1335. func (cuo *ContactUpdateOne) Save(ctx context.Context) (*Contact, error) {
  1336. if err := cuo.defaults(); err != nil {
  1337. return nil, err
  1338. }
  1339. return withHooks(ctx, cuo.sqlSave, cuo.mutation, cuo.hooks)
  1340. }
  1341. // SaveX is like Save, but panics if an error occurs.
  1342. func (cuo *ContactUpdateOne) SaveX(ctx context.Context) *Contact {
  1343. node, err := cuo.Save(ctx)
  1344. if err != nil {
  1345. panic(err)
  1346. }
  1347. return node
  1348. }
  1349. // Exec executes the query on the entity.
  1350. func (cuo *ContactUpdateOne) Exec(ctx context.Context) error {
  1351. _, err := cuo.Save(ctx)
  1352. return err
  1353. }
  1354. // ExecX is like Exec, but panics if an error occurs.
  1355. func (cuo *ContactUpdateOne) ExecX(ctx context.Context) {
  1356. if err := cuo.Exec(ctx); err != nil {
  1357. panic(err)
  1358. }
  1359. }
  1360. // defaults sets the default values of the builder before save.
  1361. func (cuo *ContactUpdateOne) defaults() error {
  1362. if _, ok := cuo.mutation.UpdatedAt(); !ok {
  1363. if contact.UpdateDefaultUpdatedAt == nil {
  1364. return fmt.Errorf("ent: uninitialized contact.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
  1365. }
  1366. v := contact.UpdateDefaultUpdatedAt()
  1367. cuo.mutation.SetUpdatedAt(v)
  1368. }
  1369. return nil
  1370. }
  1371. func (cuo *ContactUpdateOne) sqlSave(ctx context.Context) (_node *Contact, err error) {
  1372. _spec := sqlgraph.NewUpdateSpec(contact.Table, contact.Columns, sqlgraph.NewFieldSpec(contact.FieldID, field.TypeUint64))
  1373. id, ok := cuo.mutation.ID()
  1374. if !ok {
  1375. return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Contact.id" for update`)}
  1376. }
  1377. _spec.Node.ID.Value = id
  1378. if fields := cuo.fields; len(fields) > 0 {
  1379. _spec.Node.Columns = make([]string, 0, len(fields))
  1380. _spec.Node.Columns = append(_spec.Node.Columns, contact.FieldID)
  1381. for _, f := range fields {
  1382. if !contact.ValidColumn(f) {
  1383. return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
  1384. }
  1385. if f != contact.FieldID {
  1386. _spec.Node.Columns = append(_spec.Node.Columns, f)
  1387. }
  1388. }
  1389. }
  1390. if ps := cuo.mutation.predicates; len(ps) > 0 {
  1391. _spec.Predicate = func(selector *sql.Selector) {
  1392. for i := range ps {
  1393. ps[i](selector)
  1394. }
  1395. }
  1396. }
  1397. if value, ok := cuo.mutation.UpdatedAt(); ok {
  1398. _spec.SetField(contact.FieldUpdatedAt, field.TypeTime, value)
  1399. }
  1400. if value, ok := cuo.mutation.Status(); ok {
  1401. _spec.SetField(contact.FieldStatus, field.TypeUint8, value)
  1402. }
  1403. if value, ok := cuo.mutation.AddedStatus(); ok {
  1404. _spec.AddField(contact.FieldStatus, field.TypeUint8, value)
  1405. }
  1406. if cuo.mutation.StatusCleared() {
  1407. _spec.ClearField(contact.FieldStatus, field.TypeUint8)
  1408. }
  1409. if value, ok := cuo.mutation.DeletedAt(); ok {
  1410. _spec.SetField(contact.FieldDeletedAt, field.TypeTime, value)
  1411. }
  1412. if cuo.mutation.DeletedAtCleared() {
  1413. _spec.ClearField(contact.FieldDeletedAt, field.TypeTime)
  1414. }
  1415. if value, ok := cuo.mutation.WxWxid(); ok {
  1416. _spec.SetField(contact.FieldWxWxid, field.TypeString, value)
  1417. }
  1418. if value, ok := cuo.mutation.GetType(); ok {
  1419. _spec.SetField(contact.FieldType, field.TypeInt, value)
  1420. }
  1421. if value, ok := cuo.mutation.AddedType(); ok {
  1422. _spec.AddField(contact.FieldType, field.TypeInt, value)
  1423. }
  1424. if cuo.mutation.TypeCleared() {
  1425. _spec.ClearField(contact.FieldType, field.TypeInt)
  1426. }
  1427. if value, ok := cuo.mutation.Wxid(); ok {
  1428. _spec.SetField(contact.FieldWxid, field.TypeString, value)
  1429. }
  1430. if value, ok := cuo.mutation.Account(); ok {
  1431. _spec.SetField(contact.FieldAccount, field.TypeString, value)
  1432. }
  1433. if value, ok := cuo.mutation.Nickname(); ok {
  1434. _spec.SetField(contact.FieldNickname, field.TypeString, value)
  1435. }
  1436. if value, ok := cuo.mutation.Markname(); ok {
  1437. _spec.SetField(contact.FieldMarkname, field.TypeString, value)
  1438. }
  1439. if value, ok := cuo.mutation.Headimg(); ok {
  1440. _spec.SetField(contact.FieldHeadimg, field.TypeString, value)
  1441. }
  1442. if value, ok := cuo.mutation.Sex(); ok {
  1443. _spec.SetField(contact.FieldSex, field.TypeInt, value)
  1444. }
  1445. if value, ok := cuo.mutation.AddedSex(); ok {
  1446. _spec.AddField(contact.FieldSex, field.TypeInt, value)
  1447. }
  1448. if value, ok := cuo.mutation.Starrole(); ok {
  1449. _spec.SetField(contact.FieldStarrole, field.TypeString, value)
  1450. }
  1451. if value, ok := cuo.mutation.Dontseeit(); ok {
  1452. _spec.SetField(contact.FieldDontseeit, field.TypeInt, value)
  1453. }
  1454. if value, ok := cuo.mutation.AddedDontseeit(); ok {
  1455. _spec.AddField(contact.FieldDontseeit, field.TypeInt, value)
  1456. }
  1457. if value, ok := cuo.mutation.Dontseeme(); ok {
  1458. _spec.SetField(contact.FieldDontseeme, field.TypeInt, value)
  1459. }
  1460. if value, ok := cuo.mutation.AddedDontseeme(); ok {
  1461. _spec.AddField(contact.FieldDontseeme, field.TypeInt, value)
  1462. }
  1463. if value, ok := cuo.mutation.Lag(); ok {
  1464. _spec.SetField(contact.FieldLag, field.TypeString, value)
  1465. }
  1466. if value, ok := cuo.mutation.Gid(); ok {
  1467. _spec.SetField(contact.FieldGid, field.TypeString, value)
  1468. }
  1469. if value, ok := cuo.mutation.Gname(); ok {
  1470. _spec.SetField(contact.FieldGname, field.TypeString, value)
  1471. }
  1472. if value, ok := cuo.mutation.V3(); ok {
  1473. _spec.SetField(contact.FieldV3, field.TypeString, value)
  1474. }
  1475. if value, ok := cuo.mutation.OrganizationID(); ok {
  1476. _spec.SetField(contact.FieldOrganizationID, field.TypeUint64, value)
  1477. }
  1478. if value, ok := cuo.mutation.AddedOrganizationID(); ok {
  1479. _spec.AddField(contact.FieldOrganizationID, field.TypeUint64, value)
  1480. }
  1481. if cuo.mutation.OrganizationIDCleared() {
  1482. _spec.ClearField(contact.FieldOrganizationID, field.TypeUint64)
  1483. }
  1484. if value, ok := cuo.mutation.Ctype(); ok {
  1485. _spec.SetField(contact.FieldCtype, field.TypeUint64, value)
  1486. }
  1487. if value, ok := cuo.mutation.AddedCtype(); ok {
  1488. _spec.AddField(contact.FieldCtype, field.TypeUint64, value)
  1489. }
  1490. if value, ok := cuo.mutation.Csex(); ok {
  1491. _spec.SetField(contact.FieldCsex, field.TypeInt, value)
  1492. }
  1493. if value, ok := cuo.mutation.AddedCsex(); ok {
  1494. _spec.AddField(contact.FieldCsex, field.TypeInt, value)
  1495. }
  1496. if value, ok := cuo.mutation.Cage(); ok {
  1497. _spec.SetField(contact.FieldCage, field.TypeInt, value)
  1498. }
  1499. if value, ok := cuo.mutation.AddedCage(); ok {
  1500. _spec.AddField(contact.FieldCage, field.TypeInt, value)
  1501. }
  1502. if value, ok := cuo.mutation.Cname(); ok {
  1503. _spec.SetField(contact.FieldCname, field.TypeString, value)
  1504. }
  1505. if value, ok := cuo.mutation.Carea(); ok {
  1506. _spec.SetField(contact.FieldCarea, field.TypeString, value)
  1507. }
  1508. if value, ok := cuo.mutation.Cmobile(); ok {
  1509. _spec.SetField(contact.FieldCmobile, field.TypeString, value)
  1510. }
  1511. if value, ok := cuo.mutation.Cbirthday(); ok {
  1512. _spec.SetField(contact.FieldCbirthday, field.TypeString, value)
  1513. }
  1514. if value, ok := cuo.mutation.Cbirtharea(); ok {
  1515. _spec.SetField(contact.FieldCbirtharea, field.TypeString, value)
  1516. }
  1517. if value, ok := cuo.mutation.CidcardNo(); ok {
  1518. _spec.SetField(contact.FieldCidcardNo, field.TypeString, value)
  1519. }
  1520. if value, ok := cuo.mutation.Ctitle(); ok {
  1521. _spec.SetField(contact.FieldCtitle, field.TypeString, value)
  1522. }
  1523. if value, ok := cuo.mutation.Cc(); ok {
  1524. _spec.SetField(contact.FieldCc, field.TypeString, value)
  1525. }
  1526. if value, ok := cuo.mutation.Phone(); ok {
  1527. _spec.SetField(contact.FieldPhone, field.TypeString, value)
  1528. }
  1529. if cuo.mutation.ContactRelationshipsCleared() {
  1530. edge := &sqlgraph.EdgeSpec{
  1531. Rel: sqlgraph.O2M,
  1532. Inverse: false,
  1533. Table: contact.ContactRelationshipsTable,
  1534. Columns: []string{contact.ContactRelationshipsColumn},
  1535. Bidi: false,
  1536. Target: &sqlgraph.EdgeTarget{
  1537. IDSpec: sqlgraph.NewFieldSpec(labelrelationship.FieldID, field.TypeUint64),
  1538. },
  1539. }
  1540. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1541. }
  1542. if nodes := cuo.mutation.RemovedContactRelationshipsIDs(); len(nodes) > 0 && !cuo.mutation.ContactRelationshipsCleared() {
  1543. edge := &sqlgraph.EdgeSpec{
  1544. Rel: sqlgraph.O2M,
  1545. Inverse: false,
  1546. Table: contact.ContactRelationshipsTable,
  1547. Columns: []string{contact.ContactRelationshipsColumn},
  1548. Bidi: false,
  1549. Target: &sqlgraph.EdgeTarget{
  1550. IDSpec: sqlgraph.NewFieldSpec(labelrelationship.FieldID, field.TypeUint64),
  1551. },
  1552. }
  1553. for _, k := range nodes {
  1554. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1555. }
  1556. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1557. }
  1558. if nodes := cuo.mutation.ContactRelationshipsIDs(); len(nodes) > 0 {
  1559. edge := &sqlgraph.EdgeSpec{
  1560. Rel: sqlgraph.O2M,
  1561. Inverse: false,
  1562. Table: contact.ContactRelationshipsTable,
  1563. Columns: []string{contact.ContactRelationshipsColumn},
  1564. Bidi: false,
  1565. Target: &sqlgraph.EdgeTarget{
  1566. IDSpec: sqlgraph.NewFieldSpec(labelrelationship.FieldID, field.TypeUint64),
  1567. },
  1568. }
  1569. for _, k := range nodes {
  1570. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1571. }
  1572. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  1573. }
  1574. if cuo.mutation.ContactMessagesCleared() {
  1575. edge := &sqlgraph.EdgeSpec{
  1576. Rel: sqlgraph.O2M,
  1577. Inverse: false,
  1578. Table: contact.ContactMessagesTable,
  1579. Columns: []string{contact.ContactMessagesColumn},
  1580. Bidi: false,
  1581. Target: &sqlgraph.EdgeTarget{
  1582. IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
  1583. },
  1584. }
  1585. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1586. }
  1587. if nodes := cuo.mutation.RemovedContactMessagesIDs(); len(nodes) > 0 && !cuo.mutation.ContactMessagesCleared() {
  1588. edge := &sqlgraph.EdgeSpec{
  1589. Rel: sqlgraph.O2M,
  1590. Inverse: false,
  1591. Table: contact.ContactMessagesTable,
  1592. Columns: []string{contact.ContactMessagesColumn},
  1593. Bidi: false,
  1594. Target: &sqlgraph.EdgeTarget{
  1595. IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
  1596. },
  1597. }
  1598. for _, k := range nodes {
  1599. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1600. }
  1601. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  1602. }
  1603. if nodes := cuo.mutation.ContactMessagesIDs(); len(nodes) > 0 {
  1604. edge := &sqlgraph.EdgeSpec{
  1605. Rel: sqlgraph.O2M,
  1606. Inverse: false,
  1607. Table: contact.ContactMessagesTable,
  1608. Columns: []string{contact.ContactMessagesColumn},
  1609. Bidi: false,
  1610. Target: &sqlgraph.EdgeTarget{
  1611. IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
  1612. },
  1613. }
  1614. for _, k := range nodes {
  1615. edge.Target.Nodes = append(edge.Target.Nodes, k)
  1616. }
  1617. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  1618. }
  1619. _node = &Contact{config: cuo.config}
  1620. _spec.Assign = _node.assignValues
  1621. _spec.ScanValues = _node.scanValues
  1622. if err = sqlgraph.UpdateNode(ctx, cuo.driver, _spec); err != nil {
  1623. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  1624. err = &NotFoundError{contact.Label}
  1625. } else if sqlgraph.IsConstraintError(err) {
  1626. err = &ConstraintError{msg: err.Error(), wrap: err}
  1627. }
  1628. return nil, err
  1629. }
  1630. cuo.mutation.done = true
  1631. return _node, nil
  1632. }