contact_update.go 55 KB

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