contact_create.go 74 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683
  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. "entgo.io/ent/dialect/sql"
  13. "entgo.io/ent/dialect/sql/sqlgraph"
  14. "entgo.io/ent/schema/field"
  15. )
  16. // ContactCreate is the builder for creating a Contact entity.
  17. type ContactCreate struct {
  18. config
  19. mutation *ContactMutation
  20. hooks []Hook
  21. conflict []sql.ConflictOption
  22. }
  23. // SetCreatedAt sets the "created_at" field.
  24. func (cc *ContactCreate) SetCreatedAt(t time.Time) *ContactCreate {
  25. cc.mutation.SetCreatedAt(t)
  26. return cc
  27. }
  28. // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
  29. func (cc *ContactCreate) SetNillableCreatedAt(t *time.Time) *ContactCreate {
  30. if t != nil {
  31. cc.SetCreatedAt(*t)
  32. }
  33. return cc
  34. }
  35. // SetUpdatedAt sets the "updated_at" field.
  36. func (cc *ContactCreate) SetUpdatedAt(t time.Time) *ContactCreate {
  37. cc.mutation.SetUpdatedAt(t)
  38. return cc
  39. }
  40. // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
  41. func (cc *ContactCreate) SetNillableUpdatedAt(t *time.Time) *ContactCreate {
  42. if t != nil {
  43. cc.SetUpdatedAt(*t)
  44. }
  45. return cc
  46. }
  47. // SetStatus sets the "status" field.
  48. func (cc *ContactCreate) SetStatus(u uint8) *ContactCreate {
  49. cc.mutation.SetStatus(u)
  50. return cc
  51. }
  52. // SetNillableStatus sets the "status" field if the given value is not nil.
  53. func (cc *ContactCreate) SetNillableStatus(u *uint8) *ContactCreate {
  54. if u != nil {
  55. cc.SetStatus(*u)
  56. }
  57. return cc
  58. }
  59. // SetDeletedAt sets the "deleted_at" field.
  60. func (cc *ContactCreate) SetDeletedAt(t time.Time) *ContactCreate {
  61. cc.mutation.SetDeletedAt(t)
  62. return cc
  63. }
  64. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  65. func (cc *ContactCreate) SetNillableDeletedAt(t *time.Time) *ContactCreate {
  66. if t != nil {
  67. cc.SetDeletedAt(*t)
  68. }
  69. return cc
  70. }
  71. // SetWxWxid sets the "wx_wxid" field.
  72. func (cc *ContactCreate) SetWxWxid(s string) *ContactCreate {
  73. cc.mutation.SetWxWxid(s)
  74. return cc
  75. }
  76. // SetNillableWxWxid sets the "wx_wxid" field if the given value is not nil.
  77. func (cc *ContactCreate) SetNillableWxWxid(s *string) *ContactCreate {
  78. if s != nil {
  79. cc.SetWxWxid(*s)
  80. }
  81. return cc
  82. }
  83. // SetType sets the "type" field.
  84. func (cc *ContactCreate) SetType(i int) *ContactCreate {
  85. cc.mutation.SetType(i)
  86. return cc
  87. }
  88. // SetNillableType sets the "type" field if the given value is not nil.
  89. func (cc *ContactCreate) SetNillableType(i *int) *ContactCreate {
  90. if i != nil {
  91. cc.SetType(*i)
  92. }
  93. return cc
  94. }
  95. // SetWxid sets the "wxid" field.
  96. func (cc *ContactCreate) SetWxid(s string) *ContactCreate {
  97. cc.mutation.SetWxid(s)
  98. return cc
  99. }
  100. // SetNillableWxid sets the "wxid" field if the given value is not nil.
  101. func (cc *ContactCreate) SetNillableWxid(s *string) *ContactCreate {
  102. if s != nil {
  103. cc.SetWxid(*s)
  104. }
  105. return cc
  106. }
  107. // SetAccount sets the "account" field.
  108. func (cc *ContactCreate) SetAccount(s string) *ContactCreate {
  109. cc.mutation.SetAccount(s)
  110. return cc
  111. }
  112. // SetNillableAccount sets the "account" field if the given value is not nil.
  113. func (cc *ContactCreate) SetNillableAccount(s *string) *ContactCreate {
  114. if s != nil {
  115. cc.SetAccount(*s)
  116. }
  117. return cc
  118. }
  119. // SetNickname sets the "nickname" field.
  120. func (cc *ContactCreate) SetNickname(s string) *ContactCreate {
  121. cc.mutation.SetNickname(s)
  122. return cc
  123. }
  124. // SetNillableNickname sets the "nickname" field if the given value is not nil.
  125. func (cc *ContactCreate) SetNillableNickname(s *string) *ContactCreate {
  126. if s != nil {
  127. cc.SetNickname(*s)
  128. }
  129. return cc
  130. }
  131. // SetMarkname sets the "markname" field.
  132. func (cc *ContactCreate) SetMarkname(s string) *ContactCreate {
  133. cc.mutation.SetMarkname(s)
  134. return cc
  135. }
  136. // SetNillableMarkname sets the "markname" field if the given value is not nil.
  137. func (cc *ContactCreate) SetNillableMarkname(s *string) *ContactCreate {
  138. if s != nil {
  139. cc.SetMarkname(*s)
  140. }
  141. return cc
  142. }
  143. // SetHeadimg sets the "headimg" field.
  144. func (cc *ContactCreate) SetHeadimg(s string) *ContactCreate {
  145. cc.mutation.SetHeadimg(s)
  146. return cc
  147. }
  148. // SetNillableHeadimg sets the "headimg" field if the given value is not nil.
  149. func (cc *ContactCreate) SetNillableHeadimg(s *string) *ContactCreate {
  150. if s != nil {
  151. cc.SetHeadimg(*s)
  152. }
  153. return cc
  154. }
  155. // SetSex sets the "sex" field.
  156. func (cc *ContactCreate) SetSex(i int) *ContactCreate {
  157. cc.mutation.SetSex(i)
  158. return cc
  159. }
  160. // SetNillableSex sets the "sex" field if the given value is not nil.
  161. func (cc *ContactCreate) SetNillableSex(i *int) *ContactCreate {
  162. if i != nil {
  163. cc.SetSex(*i)
  164. }
  165. return cc
  166. }
  167. // SetStarrole sets the "starrole" field.
  168. func (cc *ContactCreate) SetStarrole(s string) *ContactCreate {
  169. cc.mutation.SetStarrole(s)
  170. return cc
  171. }
  172. // SetNillableStarrole sets the "starrole" field if the given value is not nil.
  173. func (cc *ContactCreate) SetNillableStarrole(s *string) *ContactCreate {
  174. if s != nil {
  175. cc.SetStarrole(*s)
  176. }
  177. return cc
  178. }
  179. // SetDontseeit sets the "dontseeit" field.
  180. func (cc *ContactCreate) SetDontseeit(i int) *ContactCreate {
  181. cc.mutation.SetDontseeit(i)
  182. return cc
  183. }
  184. // SetNillableDontseeit sets the "dontseeit" field if the given value is not nil.
  185. func (cc *ContactCreate) SetNillableDontseeit(i *int) *ContactCreate {
  186. if i != nil {
  187. cc.SetDontseeit(*i)
  188. }
  189. return cc
  190. }
  191. // SetDontseeme sets the "dontseeme" field.
  192. func (cc *ContactCreate) SetDontseeme(i int) *ContactCreate {
  193. cc.mutation.SetDontseeme(i)
  194. return cc
  195. }
  196. // SetNillableDontseeme sets the "dontseeme" field if the given value is not nil.
  197. func (cc *ContactCreate) SetNillableDontseeme(i *int) *ContactCreate {
  198. if i != nil {
  199. cc.SetDontseeme(*i)
  200. }
  201. return cc
  202. }
  203. // SetLag sets the "lag" field.
  204. func (cc *ContactCreate) SetLag(s string) *ContactCreate {
  205. cc.mutation.SetLag(s)
  206. return cc
  207. }
  208. // SetNillableLag sets the "lag" field if the given value is not nil.
  209. func (cc *ContactCreate) SetNillableLag(s *string) *ContactCreate {
  210. if s != nil {
  211. cc.SetLag(*s)
  212. }
  213. return cc
  214. }
  215. // SetGid sets the "gid" field.
  216. func (cc *ContactCreate) SetGid(s string) *ContactCreate {
  217. cc.mutation.SetGid(s)
  218. return cc
  219. }
  220. // SetNillableGid sets the "gid" field if the given value is not nil.
  221. func (cc *ContactCreate) SetNillableGid(s *string) *ContactCreate {
  222. if s != nil {
  223. cc.SetGid(*s)
  224. }
  225. return cc
  226. }
  227. // SetGname sets the "gname" field.
  228. func (cc *ContactCreate) SetGname(s string) *ContactCreate {
  229. cc.mutation.SetGname(s)
  230. return cc
  231. }
  232. // SetNillableGname sets the "gname" field if the given value is not nil.
  233. func (cc *ContactCreate) SetNillableGname(s *string) *ContactCreate {
  234. if s != nil {
  235. cc.SetGname(*s)
  236. }
  237. return cc
  238. }
  239. // SetV3 sets the "v3" field.
  240. func (cc *ContactCreate) SetV3(s string) *ContactCreate {
  241. cc.mutation.SetV3(s)
  242. return cc
  243. }
  244. // SetNillableV3 sets the "v3" field if the given value is not nil.
  245. func (cc *ContactCreate) SetNillableV3(s *string) *ContactCreate {
  246. if s != nil {
  247. cc.SetV3(*s)
  248. }
  249. return cc
  250. }
  251. // SetOrganizationID sets the "organization_id" field.
  252. func (cc *ContactCreate) SetOrganizationID(u uint64) *ContactCreate {
  253. cc.mutation.SetOrganizationID(u)
  254. return cc
  255. }
  256. // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
  257. func (cc *ContactCreate) SetNillableOrganizationID(u *uint64) *ContactCreate {
  258. if u != nil {
  259. cc.SetOrganizationID(*u)
  260. }
  261. return cc
  262. }
  263. // SetCtype sets the "ctype" field.
  264. func (cc *ContactCreate) SetCtype(u uint64) *ContactCreate {
  265. cc.mutation.SetCtype(u)
  266. return cc
  267. }
  268. // SetNillableCtype sets the "ctype" field if the given value is not nil.
  269. func (cc *ContactCreate) SetNillableCtype(u *uint64) *ContactCreate {
  270. if u != nil {
  271. cc.SetCtype(*u)
  272. }
  273. return cc
  274. }
  275. // SetCage sets the "cage" field.
  276. func (cc *ContactCreate) SetCage(i int) *ContactCreate {
  277. cc.mutation.SetCage(i)
  278. return cc
  279. }
  280. // SetNillableCage sets the "cage" field if the given value is not nil.
  281. func (cc *ContactCreate) SetNillableCage(i *int) *ContactCreate {
  282. if i != nil {
  283. cc.SetCage(*i)
  284. }
  285. return cc
  286. }
  287. // SetCname sets the "cname" field.
  288. func (cc *ContactCreate) SetCname(s string) *ContactCreate {
  289. cc.mutation.SetCname(s)
  290. return cc
  291. }
  292. // SetNillableCname sets the "cname" field if the given value is not nil.
  293. func (cc *ContactCreate) SetNillableCname(s *string) *ContactCreate {
  294. if s != nil {
  295. cc.SetCname(*s)
  296. }
  297. return cc
  298. }
  299. // SetCarea sets the "carea" field.
  300. func (cc *ContactCreate) SetCarea(s string) *ContactCreate {
  301. cc.mutation.SetCarea(s)
  302. return cc
  303. }
  304. // SetNillableCarea sets the "carea" field if the given value is not nil.
  305. func (cc *ContactCreate) SetNillableCarea(s *string) *ContactCreate {
  306. if s != nil {
  307. cc.SetCarea(*s)
  308. }
  309. return cc
  310. }
  311. // SetCbirthday sets the "cbirthday" field.
  312. func (cc *ContactCreate) SetCbirthday(s string) *ContactCreate {
  313. cc.mutation.SetCbirthday(s)
  314. return cc
  315. }
  316. // SetNillableCbirthday sets the "cbirthday" field if the given value is not nil.
  317. func (cc *ContactCreate) SetNillableCbirthday(s *string) *ContactCreate {
  318. if s != nil {
  319. cc.SetCbirthday(*s)
  320. }
  321. return cc
  322. }
  323. // SetCbirtharea sets the "cbirtharea" field.
  324. func (cc *ContactCreate) SetCbirtharea(s string) *ContactCreate {
  325. cc.mutation.SetCbirtharea(s)
  326. return cc
  327. }
  328. // SetNillableCbirtharea sets the "cbirtharea" field if the given value is not nil.
  329. func (cc *ContactCreate) SetNillableCbirtharea(s *string) *ContactCreate {
  330. if s != nil {
  331. cc.SetCbirtharea(*s)
  332. }
  333. return cc
  334. }
  335. // SetCidcardNo sets the "cidcard_no" field.
  336. func (cc *ContactCreate) SetCidcardNo(s string) *ContactCreate {
  337. cc.mutation.SetCidcardNo(s)
  338. return cc
  339. }
  340. // SetNillableCidcardNo sets the "cidcard_no" field if the given value is not nil.
  341. func (cc *ContactCreate) SetNillableCidcardNo(s *string) *ContactCreate {
  342. if s != nil {
  343. cc.SetCidcardNo(*s)
  344. }
  345. return cc
  346. }
  347. // SetCtitle sets the "ctitle" field.
  348. func (cc *ContactCreate) SetCtitle(s string) *ContactCreate {
  349. cc.mutation.SetCtitle(s)
  350. return cc
  351. }
  352. // SetNillableCtitle sets the "ctitle" field if the given value is not nil.
  353. func (cc *ContactCreate) SetNillableCtitle(s *string) *ContactCreate {
  354. if s != nil {
  355. cc.SetCtitle(*s)
  356. }
  357. return cc
  358. }
  359. // SetCc sets the "cc" field.
  360. func (cc *ContactCreate) SetCc(s string) *ContactCreate {
  361. cc.mutation.SetCc(s)
  362. return cc
  363. }
  364. // SetNillableCc sets the "cc" field if the given value is not nil.
  365. func (cc *ContactCreate) SetNillableCc(s *string) *ContactCreate {
  366. if s != nil {
  367. cc.SetCc(*s)
  368. }
  369. return cc
  370. }
  371. // SetPhone sets the "phone" field.
  372. func (cc *ContactCreate) SetPhone(s string) *ContactCreate {
  373. cc.mutation.SetPhone(s)
  374. return cc
  375. }
  376. // SetNillablePhone sets the "phone" field if the given value is not nil.
  377. func (cc *ContactCreate) SetNillablePhone(s *string) *ContactCreate {
  378. if s != nil {
  379. cc.SetPhone(*s)
  380. }
  381. return cc
  382. }
  383. // SetID sets the "id" field.
  384. func (cc *ContactCreate) SetID(u uint64) *ContactCreate {
  385. cc.mutation.SetID(u)
  386. return cc
  387. }
  388. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by IDs.
  389. func (cc *ContactCreate) AddContactRelationshipIDs(ids ...uint64) *ContactCreate {
  390. cc.mutation.AddContactRelationshipIDs(ids...)
  391. return cc
  392. }
  393. // AddContactRelationships adds the "contact_relationships" edges to the LabelRelationship entity.
  394. func (cc *ContactCreate) AddContactRelationships(l ...*LabelRelationship) *ContactCreate {
  395. ids := make([]uint64, len(l))
  396. for i := range l {
  397. ids[i] = l[i].ID
  398. }
  399. return cc.AddContactRelationshipIDs(ids...)
  400. }
  401. // AddContactFieldIDs adds the "contact_fields" edge to the ContactField entity by IDs.
  402. func (cc *ContactCreate) AddContactFieldIDs(ids ...uint64) *ContactCreate {
  403. cc.mutation.AddContactFieldIDs(ids...)
  404. return cc
  405. }
  406. // AddContactFields adds the "contact_fields" edges to the ContactField entity.
  407. func (cc *ContactCreate) AddContactFields(c ...*ContactField) *ContactCreate {
  408. ids := make([]uint64, len(c))
  409. for i := range c {
  410. ids[i] = c[i].ID
  411. }
  412. return cc.AddContactFieldIDs(ids...)
  413. }
  414. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by IDs.
  415. func (cc *ContactCreate) AddContactMessageIDs(ids ...uint64) *ContactCreate {
  416. cc.mutation.AddContactMessageIDs(ids...)
  417. return cc
  418. }
  419. // AddContactMessages adds the "contact_messages" edges to the MessageRecords entity.
  420. func (cc *ContactCreate) AddContactMessages(m ...*MessageRecords) *ContactCreate {
  421. ids := make([]uint64, len(m))
  422. for i := range m {
  423. ids[i] = m[i].ID
  424. }
  425. return cc.AddContactMessageIDs(ids...)
  426. }
  427. // Mutation returns the ContactMutation object of the builder.
  428. func (cc *ContactCreate) Mutation() *ContactMutation {
  429. return cc.mutation
  430. }
  431. // Save creates the Contact in the database.
  432. func (cc *ContactCreate) Save(ctx context.Context) (*Contact, error) {
  433. if err := cc.defaults(); err != nil {
  434. return nil, err
  435. }
  436. return withHooks(ctx, cc.sqlSave, cc.mutation, cc.hooks)
  437. }
  438. // SaveX calls Save and panics if Save returns an error.
  439. func (cc *ContactCreate) SaveX(ctx context.Context) *Contact {
  440. v, err := cc.Save(ctx)
  441. if err != nil {
  442. panic(err)
  443. }
  444. return v
  445. }
  446. // Exec executes the query.
  447. func (cc *ContactCreate) Exec(ctx context.Context) error {
  448. _, err := cc.Save(ctx)
  449. return err
  450. }
  451. // ExecX is like Exec, but panics if an error occurs.
  452. func (cc *ContactCreate) ExecX(ctx context.Context) {
  453. if err := cc.Exec(ctx); err != nil {
  454. panic(err)
  455. }
  456. }
  457. // defaults sets the default values of the builder before save.
  458. func (cc *ContactCreate) defaults() error {
  459. if _, ok := cc.mutation.CreatedAt(); !ok {
  460. if contact.DefaultCreatedAt == nil {
  461. return fmt.Errorf("ent: uninitialized contact.DefaultCreatedAt (forgotten import ent/runtime?)")
  462. }
  463. v := contact.DefaultCreatedAt()
  464. cc.mutation.SetCreatedAt(v)
  465. }
  466. if _, ok := cc.mutation.UpdatedAt(); !ok {
  467. if contact.DefaultUpdatedAt == nil {
  468. return fmt.Errorf("ent: uninitialized contact.DefaultUpdatedAt (forgotten import ent/runtime?)")
  469. }
  470. v := contact.DefaultUpdatedAt()
  471. cc.mutation.SetUpdatedAt(v)
  472. }
  473. if _, ok := cc.mutation.Status(); !ok {
  474. v := contact.DefaultStatus
  475. cc.mutation.SetStatus(v)
  476. }
  477. if _, ok := cc.mutation.WxWxid(); !ok {
  478. v := contact.DefaultWxWxid
  479. cc.mutation.SetWxWxid(v)
  480. }
  481. if _, ok := cc.mutation.GetType(); !ok {
  482. v := contact.DefaultType
  483. cc.mutation.SetType(v)
  484. }
  485. if _, ok := cc.mutation.Wxid(); !ok {
  486. v := contact.DefaultWxid
  487. cc.mutation.SetWxid(v)
  488. }
  489. if _, ok := cc.mutation.Account(); !ok {
  490. v := contact.DefaultAccount
  491. cc.mutation.SetAccount(v)
  492. }
  493. if _, ok := cc.mutation.Nickname(); !ok {
  494. v := contact.DefaultNickname
  495. cc.mutation.SetNickname(v)
  496. }
  497. if _, ok := cc.mutation.Markname(); !ok {
  498. v := contact.DefaultMarkname
  499. cc.mutation.SetMarkname(v)
  500. }
  501. if _, ok := cc.mutation.Headimg(); !ok {
  502. v := contact.DefaultHeadimg
  503. cc.mutation.SetHeadimg(v)
  504. }
  505. if _, ok := cc.mutation.Sex(); !ok {
  506. v := contact.DefaultSex
  507. cc.mutation.SetSex(v)
  508. }
  509. if _, ok := cc.mutation.Starrole(); !ok {
  510. v := contact.DefaultStarrole
  511. cc.mutation.SetStarrole(v)
  512. }
  513. if _, ok := cc.mutation.Dontseeit(); !ok {
  514. v := contact.DefaultDontseeit
  515. cc.mutation.SetDontseeit(v)
  516. }
  517. if _, ok := cc.mutation.Dontseeme(); !ok {
  518. v := contact.DefaultDontseeme
  519. cc.mutation.SetDontseeme(v)
  520. }
  521. if _, ok := cc.mutation.Lag(); !ok {
  522. v := contact.DefaultLag
  523. cc.mutation.SetLag(v)
  524. }
  525. if _, ok := cc.mutation.Gid(); !ok {
  526. v := contact.DefaultGid
  527. cc.mutation.SetGid(v)
  528. }
  529. if _, ok := cc.mutation.Gname(); !ok {
  530. v := contact.DefaultGname
  531. cc.mutation.SetGname(v)
  532. }
  533. if _, ok := cc.mutation.V3(); !ok {
  534. v := contact.DefaultV3
  535. cc.mutation.SetV3(v)
  536. }
  537. if _, ok := cc.mutation.OrganizationID(); !ok {
  538. v := contact.DefaultOrganizationID
  539. cc.mutation.SetOrganizationID(v)
  540. }
  541. if _, ok := cc.mutation.Ctype(); !ok {
  542. v := contact.DefaultCtype
  543. cc.mutation.SetCtype(v)
  544. }
  545. if _, ok := cc.mutation.Cage(); !ok {
  546. v := contact.DefaultCage
  547. cc.mutation.SetCage(v)
  548. }
  549. if _, ok := cc.mutation.Cname(); !ok {
  550. v := contact.DefaultCname
  551. cc.mutation.SetCname(v)
  552. }
  553. if _, ok := cc.mutation.Carea(); !ok {
  554. v := contact.DefaultCarea
  555. cc.mutation.SetCarea(v)
  556. }
  557. if _, ok := cc.mutation.Cbirthday(); !ok {
  558. v := contact.DefaultCbirthday
  559. cc.mutation.SetCbirthday(v)
  560. }
  561. if _, ok := cc.mutation.Cbirtharea(); !ok {
  562. v := contact.DefaultCbirtharea
  563. cc.mutation.SetCbirtharea(v)
  564. }
  565. if _, ok := cc.mutation.CidcardNo(); !ok {
  566. v := contact.DefaultCidcardNo
  567. cc.mutation.SetCidcardNo(v)
  568. }
  569. if _, ok := cc.mutation.Ctitle(); !ok {
  570. v := contact.DefaultCtitle
  571. cc.mutation.SetCtitle(v)
  572. }
  573. if _, ok := cc.mutation.Cc(); !ok {
  574. v := contact.DefaultCc
  575. cc.mutation.SetCc(v)
  576. }
  577. if _, ok := cc.mutation.Phone(); !ok {
  578. v := contact.DefaultPhone
  579. cc.mutation.SetPhone(v)
  580. }
  581. return nil
  582. }
  583. // check runs all checks and user-defined validators on the builder.
  584. func (cc *ContactCreate) check() error {
  585. if _, ok := cc.mutation.CreatedAt(); !ok {
  586. return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Contact.created_at"`)}
  587. }
  588. if _, ok := cc.mutation.UpdatedAt(); !ok {
  589. return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Contact.updated_at"`)}
  590. }
  591. if _, ok := cc.mutation.WxWxid(); !ok {
  592. return &ValidationError{Name: "wx_wxid", err: errors.New(`ent: missing required field "Contact.wx_wxid"`)}
  593. }
  594. if _, ok := cc.mutation.Wxid(); !ok {
  595. return &ValidationError{Name: "wxid", err: errors.New(`ent: missing required field "Contact.wxid"`)}
  596. }
  597. if _, ok := cc.mutation.Account(); !ok {
  598. return &ValidationError{Name: "account", err: errors.New(`ent: missing required field "Contact.account"`)}
  599. }
  600. if _, ok := cc.mutation.Nickname(); !ok {
  601. return &ValidationError{Name: "nickname", err: errors.New(`ent: missing required field "Contact.nickname"`)}
  602. }
  603. if _, ok := cc.mutation.Markname(); !ok {
  604. return &ValidationError{Name: "markname", err: errors.New(`ent: missing required field "Contact.markname"`)}
  605. }
  606. if _, ok := cc.mutation.Headimg(); !ok {
  607. return &ValidationError{Name: "headimg", err: errors.New(`ent: missing required field "Contact.headimg"`)}
  608. }
  609. if _, ok := cc.mutation.Sex(); !ok {
  610. return &ValidationError{Name: "sex", err: errors.New(`ent: missing required field "Contact.sex"`)}
  611. }
  612. if _, ok := cc.mutation.Starrole(); !ok {
  613. return &ValidationError{Name: "starrole", err: errors.New(`ent: missing required field "Contact.starrole"`)}
  614. }
  615. if _, ok := cc.mutation.Dontseeit(); !ok {
  616. return &ValidationError{Name: "dontseeit", err: errors.New(`ent: missing required field "Contact.dontseeit"`)}
  617. }
  618. if _, ok := cc.mutation.Dontseeme(); !ok {
  619. return &ValidationError{Name: "dontseeme", err: errors.New(`ent: missing required field "Contact.dontseeme"`)}
  620. }
  621. if _, ok := cc.mutation.Lag(); !ok {
  622. return &ValidationError{Name: "lag", err: errors.New(`ent: missing required field "Contact.lag"`)}
  623. }
  624. if _, ok := cc.mutation.Gid(); !ok {
  625. return &ValidationError{Name: "gid", err: errors.New(`ent: missing required field "Contact.gid"`)}
  626. }
  627. if _, ok := cc.mutation.Gname(); !ok {
  628. return &ValidationError{Name: "gname", err: errors.New(`ent: missing required field "Contact.gname"`)}
  629. }
  630. if _, ok := cc.mutation.V3(); !ok {
  631. return &ValidationError{Name: "v3", err: errors.New(`ent: missing required field "Contact.v3"`)}
  632. }
  633. if _, ok := cc.mutation.Ctype(); !ok {
  634. return &ValidationError{Name: "ctype", err: errors.New(`ent: missing required field "Contact.ctype"`)}
  635. }
  636. if _, ok := cc.mutation.Cage(); !ok {
  637. return &ValidationError{Name: "cage", err: errors.New(`ent: missing required field "Contact.cage"`)}
  638. }
  639. if _, ok := cc.mutation.Cname(); !ok {
  640. return &ValidationError{Name: "cname", err: errors.New(`ent: missing required field "Contact.cname"`)}
  641. }
  642. if _, ok := cc.mutation.Carea(); !ok {
  643. return &ValidationError{Name: "carea", err: errors.New(`ent: missing required field "Contact.carea"`)}
  644. }
  645. if _, ok := cc.mutation.Cbirthday(); !ok {
  646. return &ValidationError{Name: "cbirthday", err: errors.New(`ent: missing required field "Contact.cbirthday"`)}
  647. }
  648. if _, ok := cc.mutation.Cbirtharea(); !ok {
  649. return &ValidationError{Name: "cbirtharea", err: errors.New(`ent: missing required field "Contact.cbirtharea"`)}
  650. }
  651. if _, ok := cc.mutation.CidcardNo(); !ok {
  652. return &ValidationError{Name: "cidcard_no", err: errors.New(`ent: missing required field "Contact.cidcard_no"`)}
  653. }
  654. if _, ok := cc.mutation.Ctitle(); !ok {
  655. return &ValidationError{Name: "ctitle", err: errors.New(`ent: missing required field "Contact.ctitle"`)}
  656. }
  657. if _, ok := cc.mutation.Cc(); !ok {
  658. return &ValidationError{Name: "cc", err: errors.New(`ent: missing required field "Contact.cc"`)}
  659. }
  660. if _, ok := cc.mutation.Phone(); !ok {
  661. return &ValidationError{Name: "phone", err: errors.New(`ent: missing required field "Contact.phone"`)}
  662. }
  663. return nil
  664. }
  665. func (cc *ContactCreate) sqlSave(ctx context.Context) (*Contact, error) {
  666. if err := cc.check(); err != nil {
  667. return nil, err
  668. }
  669. _node, _spec := cc.createSpec()
  670. if err := sqlgraph.CreateNode(ctx, cc.driver, _spec); err != nil {
  671. if sqlgraph.IsConstraintError(err) {
  672. err = &ConstraintError{msg: err.Error(), wrap: err}
  673. }
  674. return nil, err
  675. }
  676. if _spec.ID.Value != _node.ID {
  677. id := _spec.ID.Value.(int64)
  678. _node.ID = uint64(id)
  679. }
  680. cc.mutation.id = &_node.ID
  681. cc.mutation.done = true
  682. return _node, nil
  683. }
  684. func (cc *ContactCreate) createSpec() (*Contact, *sqlgraph.CreateSpec) {
  685. var (
  686. _node = &Contact{config: cc.config}
  687. _spec = sqlgraph.NewCreateSpec(contact.Table, sqlgraph.NewFieldSpec(contact.FieldID, field.TypeUint64))
  688. )
  689. _spec.OnConflict = cc.conflict
  690. if id, ok := cc.mutation.ID(); ok {
  691. _node.ID = id
  692. _spec.ID.Value = id
  693. }
  694. if value, ok := cc.mutation.CreatedAt(); ok {
  695. _spec.SetField(contact.FieldCreatedAt, field.TypeTime, value)
  696. _node.CreatedAt = value
  697. }
  698. if value, ok := cc.mutation.UpdatedAt(); ok {
  699. _spec.SetField(contact.FieldUpdatedAt, field.TypeTime, value)
  700. _node.UpdatedAt = value
  701. }
  702. if value, ok := cc.mutation.Status(); ok {
  703. _spec.SetField(contact.FieldStatus, field.TypeUint8, value)
  704. _node.Status = value
  705. }
  706. if value, ok := cc.mutation.DeletedAt(); ok {
  707. _spec.SetField(contact.FieldDeletedAt, field.TypeTime, value)
  708. _node.DeletedAt = value
  709. }
  710. if value, ok := cc.mutation.WxWxid(); ok {
  711. _spec.SetField(contact.FieldWxWxid, field.TypeString, value)
  712. _node.WxWxid = value
  713. }
  714. if value, ok := cc.mutation.GetType(); ok {
  715. _spec.SetField(contact.FieldType, field.TypeInt, value)
  716. _node.Type = value
  717. }
  718. if value, ok := cc.mutation.Wxid(); ok {
  719. _spec.SetField(contact.FieldWxid, field.TypeString, value)
  720. _node.Wxid = value
  721. }
  722. if value, ok := cc.mutation.Account(); ok {
  723. _spec.SetField(contact.FieldAccount, field.TypeString, value)
  724. _node.Account = value
  725. }
  726. if value, ok := cc.mutation.Nickname(); ok {
  727. _spec.SetField(contact.FieldNickname, field.TypeString, value)
  728. _node.Nickname = value
  729. }
  730. if value, ok := cc.mutation.Markname(); ok {
  731. _spec.SetField(contact.FieldMarkname, field.TypeString, value)
  732. _node.Markname = value
  733. }
  734. if value, ok := cc.mutation.Headimg(); ok {
  735. _spec.SetField(contact.FieldHeadimg, field.TypeString, value)
  736. _node.Headimg = value
  737. }
  738. if value, ok := cc.mutation.Sex(); ok {
  739. _spec.SetField(contact.FieldSex, field.TypeInt, value)
  740. _node.Sex = value
  741. }
  742. if value, ok := cc.mutation.Starrole(); ok {
  743. _spec.SetField(contact.FieldStarrole, field.TypeString, value)
  744. _node.Starrole = value
  745. }
  746. if value, ok := cc.mutation.Dontseeit(); ok {
  747. _spec.SetField(contact.FieldDontseeit, field.TypeInt, value)
  748. _node.Dontseeit = value
  749. }
  750. if value, ok := cc.mutation.Dontseeme(); ok {
  751. _spec.SetField(contact.FieldDontseeme, field.TypeInt, value)
  752. _node.Dontseeme = value
  753. }
  754. if value, ok := cc.mutation.Lag(); ok {
  755. _spec.SetField(contact.FieldLag, field.TypeString, value)
  756. _node.Lag = value
  757. }
  758. if value, ok := cc.mutation.Gid(); ok {
  759. _spec.SetField(contact.FieldGid, field.TypeString, value)
  760. _node.Gid = value
  761. }
  762. if value, ok := cc.mutation.Gname(); ok {
  763. _spec.SetField(contact.FieldGname, field.TypeString, value)
  764. _node.Gname = value
  765. }
  766. if value, ok := cc.mutation.V3(); ok {
  767. _spec.SetField(contact.FieldV3, field.TypeString, value)
  768. _node.V3 = value
  769. }
  770. if value, ok := cc.mutation.OrganizationID(); ok {
  771. _spec.SetField(contact.FieldOrganizationID, field.TypeUint64, value)
  772. _node.OrganizationID = value
  773. }
  774. if value, ok := cc.mutation.Ctype(); ok {
  775. _spec.SetField(contact.FieldCtype, field.TypeUint64, value)
  776. _node.Ctype = value
  777. }
  778. if value, ok := cc.mutation.Cage(); ok {
  779. _spec.SetField(contact.FieldCage, field.TypeInt, value)
  780. _node.Cage = value
  781. }
  782. if value, ok := cc.mutation.Cname(); ok {
  783. _spec.SetField(contact.FieldCname, field.TypeString, value)
  784. _node.Cname = value
  785. }
  786. if value, ok := cc.mutation.Carea(); ok {
  787. _spec.SetField(contact.FieldCarea, field.TypeString, value)
  788. _node.Carea = value
  789. }
  790. if value, ok := cc.mutation.Cbirthday(); ok {
  791. _spec.SetField(contact.FieldCbirthday, field.TypeString, value)
  792. _node.Cbirthday = value
  793. }
  794. if value, ok := cc.mutation.Cbirtharea(); ok {
  795. _spec.SetField(contact.FieldCbirtharea, field.TypeString, value)
  796. _node.Cbirtharea = value
  797. }
  798. if value, ok := cc.mutation.CidcardNo(); ok {
  799. _spec.SetField(contact.FieldCidcardNo, field.TypeString, value)
  800. _node.CidcardNo = value
  801. }
  802. if value, ok := cc.mutation.Ctitle(); ok {
  803. _spec.SetField(contact.FieldCtitle, field.TypeString, value)
  804. _node.Ctitle = value
  805. }
  806. if value, ok := cc.mutation.Cc(); ok {
  807. _spec.SetField(contact.FieldCc, field.TypeString, value)
  808. _node.Cc = value
  809. }
  810. if value, ok := cc.mutation.Phone(); ok {
  811. _spec.SetField(contact.FieldPhone, field.TypeString, value)
  812. _node.Phone = value
  813. }
  814. if nodes := cc.mutation.ContactRelationshipsIDs(); len(nodes) > 0 {
  815. edge := &sqlgraph.EdgeSpec{
  816. Rel: sqlgraph.O2M,
  817. Inverse: false,
  818. Table: contact.ContactRelationshipsTable,
  819. Columns: []string{contact.ContactRelationshipsColumn},
  820. Bidi: false,
  821. Target: &sqlgraph.EdgeTarget{
  822. IDSpec: sqlgraph.NewFieldSpec(labelrelationship.FieldID, field.TypeUint64),
  823. },
  824. }
  825. for _, k := range nodes {
  826. edge.Target.Nodes = append(edge.Target.Nodes, k)
  827. }
  828. _spec.Edges = append(_spec.Edges, edge)
  829. }
  830. if nodes := cc.mutation.ContactFieldsIDs(); len(nodes) > 0 {
  831. edge := &sqlgraph.EdgeSpec{
  832. Rel: sqlgraph.O2M,
  833. Inverse: false,
  834. Table: contact.ContactFieldsTable,
  835. Columns: []string{contact.ContactFieldsColumn},
  836. Bidi: false,
  837. Target: &sqlgraph.EdgeTarget{
  838. IDSpec: sqlgraph.NewFieldSpec(contactfield.FieldID, field.TypeUint64),
  839. },
  840. }
  841. for _, k := range nodes {
  842. edge.Target.Nodes = append(edge.Target.Nodes, k)
  843. }
  844. _spec.Edges = append(_spec.Edges, edge)
  845. }
  846. if nodes := cc.mutation.ContactMessagesIDs(); len(nodes) > 0 {
  847. edge := &sqlgraph.EdgeSpec{
  848. Rel: sqlgraph.O2M,
  849. Inverse: false,
  850. Table: contact.ContactMessagesTable,
  851. Columns: []string{contact.ContactMessagesColumn},
  852. Bidi: false,
  853. Target: &sqlgraph.EdgeTarget{
  854. IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
  855. },
  856. }
  857. for _, k := range nodes {
  858. edge.Target.Nodes = append(edge.Target.Nodes, k)
  859. }
  860. _spec.Edges = append(_spec.Edges, edge)
  861. }
  862. return _node, _spec
  863. }
  864. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  865. // of the `INSERT` statement. For example:
  866. //
  867. // client.Contact.Create().
  868. // SetCreatedAt(v).
  869. // OnConflict(
  870. // // Update the row with the new values
  871. // // the was proposed for insertion.
  872. // sql.ResolveWithNewValues(),
  873. // ).
  874. // // Override some of the fields with custom
  875. // // update values.
  876. // Update(func(u *ent.ContactUpsert) {
  877. // SetCreatedAt(v+v).
  878. // }).
  879. // Exec(ctx)
  880. func (cc *ContactCreate) OnConflict(opts ...sql.ConflictOption) *ContactUpsertOne {
  881. cc.conflict = opts
  882. return &ContactUpsertOne{
  883. create: cc,
  884. }
  885. }
  886. // OnConflictColumns calls `OnConflict` and configures the columns
  887. // as conflict target. Using this option is equivalent to using:
  888. //
  889. // client.Contact.Create().
  890. // OnConflict(sql.ConflictColumns(columns...)).
  891. // Exec(ctx)
  892. func (cc *ContactCreate) OnConflictColumns(columns ...string) *ContactUpsertOne {
  893. cc.conflict = append(cc.conflict, sql.ConflictColumns(columns...))
  894. return &ContactUpsertOne{
  895. create: cc,
  896. }
  897. }
  898. type (
  899. // ContactUpsertOne is the builder for "upsert"-ing
  900. // one Contact node.
  901. ContactUpsertOne struct {
  902. create *ContactCreate
  903. }
  904. // ContactUpsert is the "OnConflict" setter.
  905. ContactUpsert struct {
  906. *sql.UpdateSet
  907. }
  908. )
  909. // SetUpdatedAt sets the "updated_at" field.
  910. func (u *ContactUpsert) SetUpdatedAt(v time.Time) *ContactUpsert {
  911. u.Set(contact.FieldUpdatedAt, v)
  912. return u
  913. }
  914. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  915. func (u *ContactUpsert) UpdateUpdatedAt() *ContactUpsert {
  916. u.SetExcluded(contact.FieldUpdatedAt)
  917. return u
  918. }
  919. // SetStatus sets the "status" field.
  920. func (u *ContactUpsert) SetStatus(v uint8) *ContactUpsert {
  921. u.Set(contact.FieldStatus, v)
  922. return u
  923. }
  924. // UpdateStatus sets the "status" field to the value that was provided on create.
  925. func (u *ContactUpsert) UpdateStatus() *ContactUpsert {
  926. u.SetExcluded(contact.FieldStatus)
  927. return u
  928. }
  929. // AddStatus adds v to the "status" field.
  930. func (u *ContactUpsert) AddStatus(v uint8) *ContactUpsert {
  931. u.Add(contact.FieldStatus, v)
  932. return u
  933. }
  934. // ClearStatus clears the value of the "status" field.
  935. func (u *ContactUpsert) ClearStatus() *ContactUpsert {
  936. u.SetNull(contact.FieldStatus)
  937. return u
  938. }
  939. // SetDeletedAt sets the "deleted_at" field.
  940. func (u *ContactUpsert) SetDeletedAt(v time.Time) *ContactUpsert {
  941. u.Set(contact.FieldDeletedAt, v)
  942. return u
  943. }
  944. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  945. func (u *ContactUpsert) UpdateDeletedAt() *ContactUpsert {
  946. u.SetExcluded(contact.FieldDeletedAt)
  947. return u
  948. }
  949. // ClearDeletedAt clears the value of the "deleted_at" field.
  950. func (u *ContactUpsert) ClearDeletedAt() *ContactUpsert {
  951. u.SetNull(contact.FieldDeletedAt)
  952. return u
  953. }
  954. // SetWxWxid sets the "wx_wxid" field.
  955. func (u *ContactUpsert) SetWxWxid(v string) *ContactUpsert {
  956. u.Set(contact.FieldWxWxid, v)
  957. return u
  958. }
  959. // UpdateWxWxid sets the "wx_wxid" field to the value that was provided on create.
  960. func (u *ContactUpsert) UpdateWxWxid() *ContactUpsert {
  961. u.SetExcluded(contact.FieldWxWxid)
  962. return u
  963. }
  964. // SetType sets the "type" field.
  965. func (u *ContactUpsert) SetType(v int) *ContactUpsert {
  966. u.Set(contact.FieldType, v)
  967. return u
  968. }
  969. // UpdateType sets the "type" field to the value that was provided on create.
  970. func (u *ContactUpsert) UpdateType() *ContactUpsert {
  971. u.SetExcluded(contact.FieldType)
  972. return u
  973. }
  974. // AddType adds v to the "type" field.
  975. func (u *ContactUpsert) AddType(v int) *ContactUpsert {
  976. u.Add(contact.FieldType, v)
  977. return u
  978. }
  979. // ClearType clears the value of the "type" field.
  980. func (u *ContactUpsert) ClearType() *ContactUpsert {
  981. u.SetNull(contact.FieldType)
  982. return u
  983. }
  984. // SetWxid sets the "wxid" field.
  985. func (u *ContactUpsert) SetWxid(v string) *ContactUpsert {
  986. u.Set(contact.FieldWxid, v)
  987. return u
  988. }
  989. // UpdateWxid sets the "wxid" field to the value that was provided on create.
  990. func (u *ContactUpsert) UpdateWxid() *ContactUpsert {
  991. u.SetExcluded(contact.FieldWxid)
  992. return u
  993. }
  994. // SetAccount sets the "account" field.
  995. func (u *ContactUpsert) SetAccount(v string) *ContactUpsert {
  996. u.Set(contact.FieldAccount, v)
  997. return u
  998. }
  999. // UpdateAccount sets the "account" field to the value that was provided on create.
  1000. func (u *ContactUpsert) UpdateAccount() *ContactUpsert {
  1001. u.SetExcluded(contact.FieldAccount)
  1002. return u
  1003. }
  1004. // SetNickname sets the "nickname" field.
  1005. func (u *ContactUpsert) SetNickname(v string) *ContactUpsert {
  1006. u.Set(contact.FieldNickname, v)
  1007. return u
  1008. }
  1009. // UpdateNickname sets the "nickname" field to the value that was provided on create.
  1010. func (u *ContactUpsert) UpdateNickname() *ContactUpsert {
  1011. u.SetExcluded(contact.FieldNickname)
  1012. return u
  1013. }
  1014. // SetMarkname sets the "markname" field.
  1015. func (u *ContactUpsert) SetMarkname(v string) *ContactUpsert {
  1016. u.Set(contact.FieldMarkname, v)
  1017. return u
  1018. }
  1019. // UpdateMarkname sets the "markname" field to the value that was provided on create.
  1020. func (u *ContactUpsert) UpdateMarkname() *ContactUpsert {
  1021. u.SetExcluded(contact.FieldMarkname)
  1022. return u
  1023. }
  1024. // SetHeadimg sets the "headimg" field.
  1025. func (u *ContactUpsert) SetHeadimg(v string) *ContactUpsert {
  1026. u.Set(contact.FieldHeadimg, v)
  1027. return u
  1028. }
  1029. // UpdateHeadimg sets the "headimg" field to the value that was provided on create.
  1030. func (u *ContactUpsert) UpdateHeadimg() *ContactUpsert {
  1031. u.SetExcluded(contact.FieldHeadimg)
  1032. return u
  1033. }
  1034. // SetSex sets the "sex" field.
  1035. func (u *ContactUpsert) SetSex(v int) *ContactUpsert {
  1036. u.Set(contact.FieldSex, v)
  1037. return u
  1038. }
  1039. // UpdateSex sets the "sex" field to the value that was provided on create.
  1040. func (u *ContactUpsert) UpdateSex() *ContactUpsert {
  1041. u.SetExcluded(contact.FieldSex)
  1042. return u
  1043. }
  1044. // AddSex adds v to the "sex" field.
  1045. func (u *ContactUpsert) AddSex(v int) *ContactUpsert {
  1046. u.Add(contact.FieldSex, v)
  1047. return u
  1048. }
  1049. // SetStarrole sets the "starrole" field.
  1050. func (u *ContactUpsert) SetStarrole(v string) *ContactUpsert {
  1051. u.Set(contact.FieldStarrole, v)
  1052. return u
  1053. }
  1054. // UpdateStarrole sets the "starrole" field to the value that was provided on create.
  1055. func (u *ContactUpsert) UpdateStarrole() *ContactUpsert {
  1056. u.SetExcluded(contact.FieldStarrole)
  1057. return u
  1058. }
  1059. // SetDontseeit sets the "dontseeit" field.
  1060. func (u *ContactUpsert) SetDontseeit(v int) *ContactUpsert {
  1061. u.Set(contact.FieldDontseeit, v)
  1062. return u
  1063. }
  1064. // UpdateDontseeit sets the "dontseeit" field to the value that was provided on create.
  1065. func (u *ContactUpsert) UpdateDontseeit() *ContactUpsert {
  1066. u.SetExcluded(contact.FieldDontseeit)
  1067. return u
  1068. }
  1069. // AddDontseeit adds v to the "dontseeit" field.
  1070. func (u *ContactUpsert) AddDontseeit(v int) *ContactUpsert {
  1071. u.Add(contact.FieldDontseeit, v)
  1072. return u
  1073. }
  1074. // SetDontseeme sets the "dontseeme" field.
  1075. func (u *ContactUpsert) SetDontseeme(v int) *ContactUpsert {
  1076. u.Set(contact.FieldDontseeme, v)
  1077. return u
  1078. }
  1079. // UpdateDontseeme sets the "dontseeme" field to the value that was provided on create.
  1080. func (u *ContactUpsert) UpdateDontseeme() *ContactUpsert {
  1081. u.SetExcluded(contact.FieldDontseeme)
  1082. return u
  1083. }
  1084. // AddDontseeme adds v to the "dontseeme" field.
  1085. func (u *ContactUpsert) AddDontseeme(v int) *ContactUpsert {
  1086. u.Add(contact.FieldDontseeme, v)
  1087. return u
  1088. }
  1089. // SetLag sets the "lag" field.
  1090. func (u *ContactUpsert) SetLag(v string) *ContactUpsert {
  1091. u.Set(contact.FieldLag, v)
  1092. return u
  1093. }
  1094. // UpdateLag sets the "lag" field to the value that was provided on create.
  1095. func (u *ContactUpsert) UpdateLag() *ContactUpsert {
  1096. u.SetExcluded(contact.FieldLag)
  1097. return u
  1098. }
  1099. // SetGid sets the "gid" field.
  1100. func (u *ContactUpsert) SetGid(v string) *ContactUpsert {
  1101. u.Set(contact.FieldGid, v)
  1102. return u
  1103. }
  1104. // UpdateGid sets the "gid" field to the value that was provided on create.
  1105. func (u *ContactUpsert) UpdateGid() *ContactUpsert {
  1106. u.SetExcluded(contact.FieldGid)
  1107. return u
  1108. }
  1109. // SetGname sets the "gname" field.
  1110. func (u *ContactUpsert) SetGname(v string) *ContactUpsert {
  1111. u.Set(contact.FieldGname, v)
  1112. return u
  1113. }
  1114. // UpdateGname sets the "gname" field to the value that was provided on create.
  1115. func (u *ContactUpsert) UpdateGname() *ContactUpsert {
  1116. u.SetExcluded(contact.FieldGname)
  1117. return u
  1118. }
  1119. // SetV3 sets the "v3" field.
  1120. func (u *ContactUpsert) SetV3(v string) *ContactUpsert {
  1121. u.Set(contact.FieldV3, v)
  1122. return u
  1123. }
  1124. // UpdateV3 sets the "v3" field to the value that was provided on create.
  1125. func (u *ContactUpsert) UpdateV3() *ContactUpsert {
  1126. u.SetExcluded(contact.FieldV3)
  1127. return u
  1128. }
  1129. // SetOrganizationID sets the "organization_id" field.
  1130. func (u *ContactUpsert) SetOrganizationID(v uint64) *ContactUpsert {
  1131. u.Set(contact.FieldOrganizationID, v)
  1132. return u
  1133. }
  1134. // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
  1135. func (u *ContactUpsert) UpdateOrganizationID() *ContactUpsert {
  1136. u.SetExcluded(contact.FieldOrganizationID)
  1137. return u
  1138. }
  1139. // AddOrganizationID adds v to the "organization_id" field.
  1140. func (u *ContactUpsert) AddOrganizationID(v uint64) *ContactUpsert {
  1141. u.Add(contact.FieldOrganizationID, v)
  1142. return u
  1143. }
  1144. // ClearOrganizationID clears the value of the "organization_id" field.
  1145. func (u *ContactUpsert) ClearOrganizationID() *ContactUpsert {
  1146. u.SetNull(contact.FieldOrganizationID)
  1147. return u
  1148. }
  1149. // SetCtype sets the "ctype" field.
  1150. func (u *ContactUpsert) SetCtype(v uint64) *ContactUpsert {
  1151. u.Set(contact.FieldCtype, v)
  1152. return u
  1153. }
  1154. // UpdateCtype sets the "ctype" field to the value that was provided on create.
  1155. func (u *ContactUpsert) UpdateCtype() *ContactUpsert {
  1156. u.SetExcluded(contact.FieldCtype)
  1157. return u
  1158. }
  1159. // AddCtype adds v to the "ctype" field.
  1160. func (u *ContactUpsert) AddCtype(v uint64) *ContactUpsert {
  1161. u.Add(contact.FieldCtype, v)
  1162. return u
  1163. }
  1164. // SetCage sets the "cage" field.
  1165. func (u *ContactUpsert) SetCage(v int) *ContactUpsert {
  1166. u.Set(contact.FieldCage, v)
  1167. return u
  1168. }
  1169. // UpdateCage sets the "cage" field to the value that was provided on create.
  1170. func (u *ContactUpsert) UpdateCage() *ContactUpsert {
  1171. u.SetExcluded(contact.FieldCage)
  1172. return u
  1173. }
  1174. // AddCage adds v to the "cage" field.
  1175. func (u *ContactUpsert) AddCage(v int) *ContactUpsert {
  1176. u.Add(contact.FieldCage, v)
  1177. return u
  1178. }
  1179. // SetCname sets the "cname" field.
  1180. func (u *ContactUpsert) SetCname(v string) *ContactUpsert {
  1181. u.Set(contact.FieldCname, v)
  1182. return u
  1183. }
  1184. // UpdateCname sets the "cname" field to the value that was provided on create.
  1185. func (u *ContactUpsert) UpdateCname() *ContactUpsert {
  1186. u.SetExcluded(contact.FieldCname)
  1187. return u
  1188. }
  1189. // SetCarea sets the "carea" field.
  1190. func (u *ContactUpsert) SetCarea(v string) *ContactUpsert {
  1191. u.Set(contact.FieldCarea, v)
  1192. return u
  1193. }
  1194. // UpdateCarea sets the "carea" field to the value that was provided on create.
  1195. func (u *ContactUpsert) UpdateCarea() *ContactUpsert {
  1196. u.SetExcluded(contact.FieldCarea)
  1197. return u
  1198. }
  1199. // SetCbirthday sets the "cbirthday" field.
  1200. func (u *ContactUpsert) SetCbirthday(v string) *ContactUpsert {
  1201. u.Set(contact.FieldCbirthday, v)
  1202. return u
  1203. }
  1204. // UpdateCbirthday sets the "cbirthday" field to the value that was provided on create.
  1205. func (u *ContactUpsert) UpdateCbirthday() *ContactUpsert {
  1206. u.SetExcluded(contact.FieldCbirthday)
  1207. return u
  1208. }
  1209. // SetCbirtharea sets the "cbirtharea" field.
  1210. func (u *ContactUpsert) SetCbirtharea(v string) *ContactUpsert {
  1211. u.Set(contact.FieldCbirtharea, v)
  1212. return u
  1213. }
  1214. // UpdateCbirtharea sets the "cbirtharea" field to the value that was provided on create.
  1215. func (u *ContactUpsert) UpdateCbirtharea() *ContactUpsert {
  1216. u.SetExcluded(contact.FieldCbirtharea)
  1217. return u
  1218. }
  1219. // SetCidcardNo sets the "cidcard_no" field.
  1220. func (u *ContactUpsert) SetCidcardNo(v string) *ContactUpsert {
  1221. u.Set(contact.FieldCidcardNo, v)
  1222. return u
  1223. }
  1224. // UpdateCidcardNo sets the "cidcard_no" field to the value that was provided on create.
  1225. func (u *ContactUpsert) UpdateCidcardNo() *ContactUpsert {
  1226. u.SetExcluded(contact.FieldCidcardNo)
  1227. return u
  1228. }
  1229. // SetCtitle sets the "ctitle" field.
  1230. func (u *ContactUpsert) SetCtitle(v string) *ContactUpsert {
  1231. u.Set(contact.FieldCtitle, v)
  1232. return u
  1233. }
  1234. // UpdateCtitle sets the "ctitle" field to the value that was provided on create.
  1235. func (u *ContactUpsert) UpdateCtitle() *ContactUpsert {
  1236. u.SetExcluded(contact.FieldCtitle)
  1237. return u
  1238. }
  1239. // SetCc sets the "cc" field.
  1240. func (u *ContactUpsert) SetCc(v string) *ContactUpsert {
  1241. u.Set(contact.FieldCc, v)
  1242. return u
  1243. }
  1244. // UpdateCc sets the "cc" field to the value that was provided on create.
  1245. func (u *ContactUpsert) UpdateCc() *ContactUpsert {
  1246. u.SetExcluded(contact.FieldCc)
  1247. return u
  1248. }
  1249. // SetPhone sets the "phone" field.
  1250. func (u *ContactUpsert) SetPhone(v string) *ContactUpsert {
  1251. u.Set(contact.FieldPhone, v)
  1252. return u
  1253. }
  1254. // UpdatePhone sets the "phone" field to the value that was provided on create.
  1255. func (u *ContactUpsert) UpdatePhone() *ContactUpsert {
  1256. u.SetExcluded(contact.FieldPhone)
  1257. return u
  1258. }
  1259. // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
  1260. // Using this option is equivalent to using:
  1261. //
  1262. // client.Contact.Create().
  1263. // OnConflict(
  1264. // sql.ResolveWithNewValues(),
  1265. // sql.ResolveWith(func(u *sql.UpdateSet) {
  1266. // u.SetIgnore(contact.FieldID)
  1267. // }),
  1268. // ).
  1269. // Exec(ctx)
  1270. func (u *ContactUpsertOne) UpdateNewValues() *ContactUpsertOne {
  1271. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  1272. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  1273. if _, exists := u.create.mutation.ID(); exists {
  1274. s.SetIgnore(contact.FieldID)
  1275. }
  1276. if _, exists := u.create.mutation.CreatedAt(); exists {
  1277. s.SetIgnore(contact.FieldCreatedAt)
  1278. }
  1279. }))
  1280. return u
  1281. }
  1282. // Ignore sets each column to itself in case of conflict.
  1283. // Using this option is equivalent to using:
  1284. //
  1285. // client.Contact.Create().
  1286. // OnConflict(sql.ResolveWithIgnore()).
  1287. // Exec(ctx)
  1288. func (u *ContactUpsertOne) Ignore() *ContactUpsertOne {
  1289. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  1290. return u
  1291. }
  1292. // DoNothing configures the conflict_action to `DO NOTHING`.
  1293. // Supported only by SQLite and PostgreSQL.
  1294. func (u *ContactUpsertOne) DoNothing() *ContactUpsertOne {
  1295. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  1296. return u
  1297. }
  1298. // Update allows overriding fields `UPDATE` values. See the ContactCreate.OnConflict
  1299. // documentation for more info.
  1300. func (u *ContactUpsertOne) Update(set func(*ContactUpsert)) *ContactUpsertOne {
  1301. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  1302. set(&ContactUpsert{UpdateSet: update})
  1303. }))
  1304. return u
  1305. }
  1306. // SetUpdatedAt sets the "updated_at" field.
  1307. func (u *ContactUpsertOne) SetUpdatedAt(v time.Time) *ContactUpsertOne {
  1308. return u.Update(func(s *ContactUpsert) {
  1309. s.SetUpdatedAt(v)
  1310. })
  1311. }
  1312. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  1313. func (u *ContactUpsertOne) UpdateUpdatedAt() *ContactUpsertOne {
  1314. return u.Update(func(s *ContactUpsert) {
  1315. s.UpdateUpdatedAt()
  1316. })
  1317. }
  1318. // SetStatus sets the "status" field.
  1319. func (u *ContactUpsertOne) SetStatus(v uint8) *ContactUpsertOne {
  1320. return u.Update(func(s *ContactUpsert) {
  1321. s.SetStatus(v)
  1322. })
  1323. }
  1324. // AddStatus adds v to the "status" field.
  1325. func (u *ContactUpsertOne) AddStatus(v uint8) *ContactUpsertOne {
  1326. return u.Update(func(s *ContactUpsert) {
  1327. s.AddStatus(v)
  1328. })
  1329. }
  1330. // UpdateStatus sets the "status" field to the value that was provided on create.
  1331. func (u *ContactUpsertOne) UpdateStatus() *ContactUpsertOne {
  1332. return u.Update(func(s *ContactUpsert) {
  1333. s.UpdateStatus()
  1334. })
  1335. }
  1336. // ClearStatus clears the value of the "status" field.
  1337. func (u *ContactUpsertOne) ClearStatus() *ContactUpsertOne {
  1338. return u.Update(func(s *ContactUpsert) {
  1339. s.ClearStatus()
  1340. })
  1341. }
  1342. // SetDeletedAt sets the "deleted_at" field.
  1343. func (u *ContactUpsertOne) SetDeletedAt(v time.Time) *ContactUpsertOne {
  1344. return u.Update(func(s *ContactUpsert) {
  1345. s.SetDeletedAt(v)
  1346. })
  1347. }
  1348. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  1349. func (u *ContactUpsertOne) UpdateDeletedAt() *ContactUpsertOne {
  1350. return u.Update(func(s *ContactUpsert) {
  1351. s.UpdateDeletedAt()
  1352. })
  1353. }
  1354. // ClearDeletedAt clears the value of the "deleted_at" field.
  1355. func (u *ContactUpsertOne) ClearDeletedAt() *ContactUpsertOne {
  1356. return u.Update(func(s *ContactUpsert) {
  1357. s.ClearDeletedAt()
  1358. })
  1359. }
  1360. // SetWxWxid sets the "wx_wxid" field.
  1361. func (u *ContactUpsertOne) SetWxWxid(v string) *ContactUpsertOne {
  1362. return u.Update(func(s *ContactUpsert) {
  1363. s.SetWxWxid(v)
  1364. })
  1365. }
  1366. // UpdateWxWxid sets the "wx_wxid" field to the value that was provided on create.
  1367. func (u *ContactUpsertOne) UpdateWxWxid() *ContactUpsertOne {
  1368. return u.Update(func(s *ContactUpsert) {
  1369. s.UpdateWxWxid()
  1370. })
  1371. }
  1372. // SetType sets the "type" field.
  1373. func (u *ContactUpsertOne) SetType(v int) *ContactUpsertOne {
  1374. return u.Update(func(s *ContactUpsert) {
  1375. s.SetType(v)
  1376. })
  1377. }
  1378. // AddType adds v to the "type" field.
  1379. func (u *ContactUpsertOne) AddType(v int) *ContactUpsertOne {
  1380. return u.Update(func(s *ContactUpsert) {
  1381. s.AddType(v)
  1382. })
  1383. }
  1384. // UpdateType sets the "type" field to the value that was provided on create.
  1385. func (u *ContactUpsertOne) UpdateType() *ContactUpsertOne {
  1386. return u.Update(func(s *ContactUpsert) {
  1387. s.UpdateType()
  1388. })
  1389. }
  1390. // ClearType clears the value of the "type" field.
  1391. func (u *ContactUpsertOne) ClearType() *ContactUpsertOne {
  1392. return u.Update(func(s *ContactUpsert) {
  1393. s.ClearType()
  1394. })
  1395. }
  1396. // SetWxid sets the "wxid" field.
  1397. func (u *ContactUpsertOne) SetWxid(v string) *ContactUpsertOne {
  1398. return u.Update(func(s *ContactUpsert) {
  1399. s.SetWxid(v)
  1400. })
  1401. }
  1402. // UpdateWxid sets the "wxid" field to the value that was provided on create.
  1403. func (u *ContactUpsertOne) UpdateWxid() *ContactUpsertOne {
  1404. return u.Update(func(s *ContactUpsert) {
  1405. s.UpdateWxid()
  1406. })
  1407. }
  1408. // SetAccount sets the "account" field.
  1409. func (u *ContactUpsertOne) SetAccount(v string) *ContactUpsertOne {
  1410. return u.Update(func(s *ContactUpsert) {
  1411. s.SetAccount(v)
  1412. })
  1413. }
  1414. // UpdateAccount sets the "account" field to the value that was provided on create.
  1415. func (u *ContactUpsertOne) UpdateAccount() *ContactUpsertOne {
  1416. return u.Update(func(s *ContactUpsert) {
  1417. s.UpdateAccount()
  1418. })
  1419. }
  1420. // SetNickname sets the "nickname" field.
  1421. func (u *ContactUpsertOne) SetNickname(v string) *ContactUpsertOne {
  1422. return u.Update(func(s *ContactUpsert) {
  1423. s.SetNickname(v)
  1424. })
  1425. }
  1426. // UpdateNickname sets the "nickname" field to the value that was provided on create.
  1427. func (u *ContactUpsertOne) UpdateNickname() *ContactUpsertOne {
  1428. return u.Update(func(s *ContactUpsert) {
  1429. s.UpdateNickname()
  1430. })
  1431. }
  1432. // SetMarkname sets the "markname" field.
  1433. func (u *ContactUpsertOne) SetMarkname(v string) *ContactUpsertOne {
  1434. return u.Update(func(s *ContactUpsert) {
  1435. s.SetMarkname(v)
  1436. })
  1437. }
  1438. // UpdateMarkname sets the "markname" field to the value that was provided on create.
  1439. func (u *ContactUpsertOne) UpdateMarkname() *ContactUpsertOne {
  1440. return u.Update(func(s *ContactUpsert) {
  1441. s.UpdateMarkname()
  1442. })
  1443. }
  1444. // SetHeadimg sets the "headimg" field.
  1445. func (u *ContactUpsertOne) SetHeadimg(v string) *ContactUpsertOne {
  1446. return u.Update(func(s *ContactUpsert) {
  1447. s.SetHeadimg(v)
  1448. })
  1449. }
  1450. // UpdateHeadimg sets the "headimg" field to the value that was provided on create.
  1451. func (u *ContactUpsertOne) UpdateHeadimg() *ContactUpsertOne {
  1452. return u.Update(func(s *ContactUpsert) {
  1453. s.UpdateHeadimg()
  1454. })
  1455. }
  1456. // SetSex sets the "sex" field.
  1457. func (u *ContactUpsertOne) SetSex(v int) *ContactUpsertOne {
  1458. return u.Update(func(s *ContactUpsert) {
  1459. s.SetSex(v)
  1460. })
  1461. }
  1462. // AddSex adds v to the "sex" field.
  1463. func (u *ContactUpsertOne) AddSex(v int) *ContactUpsertOne {
  1464. return u.Update(func(s *ContactUpsert) {
  1465. s.AddSex(v)
  1466. })
  1467. }
  1468. // UpdateSex sets the "sex" field to the value that was provided on create.
  1469. func (u *ContactUpsertOne) UpdateSex() *ContactUpsertOne {
  1470. return u.Update(func(s *ContactUpsert) {
  1471. s.UpdateSex()
  1472. })
  1473. }
  1474. // SetStarrole sets the "starrole" field.
  1475. func (u *ContactUpsertOne) SetStarrole(v string) *ContactUpsertOne {
  1476. return u.Update(func(s *ContactUpsert) {
  1477. s.SetStarrole(v)
  1478. })
  1479. }
  1480. // UpdateStarrole sets the "starrole" field to the value that was provided on create.
  1481. func (u *ContactUpsertOne) UpdateStarrole() *ContactUpsertOne {
  1482. return u.Update(func(s *ContactUpsert) {
  1483. s.UpdateStarrole()
  1484. })
  1485. }
  1486. // SetDontseeit sets the "dontseeit" field.
  1487. func (u *ContactUpsertOne) SetDontseeit(v int) *ContactUpsertOne {
  1488. return u.Update(func(s *ContactUpsert) {
  1489. s.SetDontseeit(v)
  1490. })
  1491. }
  1492. // AddDontseeit adds v to the "dontseeit" field.
  1493. func (u *ContactUpsertOne) AddDontseeit(v int) *ContactUpsertOne {
  1494. return u.Update(func(s *ContactUpsert) {
  1495. s.AddDontseeit(v)
  1496. })
  1497. }
  1498. // UpdateDontseeit sets the "dontseeit" field to the value that was provided on create.
  1499. func (u *ContactUpsertOne) UpdateDontseeit() *ContactUpsertOne {
  1500. return u.Update(func(s *ContactUpsert) {
  1501. s.UpdateDontseeit()
  1502. })
  1503. }
  1504. // SetDontseeme sets the "dontseeme" field.
  1505. func (u *ContactUpsertOne) SetDontseeme(v int) *ContactUpsertOne {
  1506. return u.Update(func(s *ContactUpsert) {
  1507. s.SetDontseeme(v)
  1508. })
  1509. }
  1510. // AddDontseeme adds v to the "dontseeme" field.
  1511. func (u *ContactUpsertOne) AddDontseeme(v int) *ContactUpsertOne {
  1512. return u.Update(func(s *ContactUpsert) {
  1513. s.AddDontseeme(v)
  1514. })
  1515. }
  1516. // UpdateDontseeme sets the "dontseeme" field to the value that was provided on create.
  1517. func (u *ContactUpsertOne) UpdateDontseeme() *ContactUpsertOne {
  1518. return u.Update(func(s *ContactUpsert) {
  1519. s.UpdateDontseeme()
  1520. })
  1521. }
  1522. // SetLag sets the "lag" field.
  1523. func (u *ContactUpsertOne) SetLag(v string) *ContactUpsertOne {
  1524. return u.Update(func(s *ContactUpsert) {
  1525. s.SetLag(v)
  1526. })
  1527. }
  1528. // UpdateLag sets the "lag" field to the value that was provided on create.
  1529. func (u *ContactUpsertOne) UpdateLag() *ContactUpsertOne {
  1530. return u.Update(func(s *ContactUpsert) {
  1531. s.UpdateLag()
  1532. })
  1533. }
  1534. // SetGid sets the "gid" field.
  1535. func (u *ContactUpsertOne) SetGid(v string) *ContactUpsertOne {
  1536. return u.Update(func(s *ContactUpsert) {
  1537. s.SetGid(v)
  1538. })
  1539. }
  1540. // UpdateGid sets the "gid" field to the value that was provided on create.
  1541. func (u *ContactUpsertOne) UpdateGid() *ContactUpsertOne {
  1542. return u.Update(func(s *ContactUpsert) {
  1543. s.UpdateGid()
  1544. })
  1545. }
  1546. // SetGname sets the "gname" field.
  1547. func (u *ContactUpsertOne) SetGname(v string) *ContactUpsertOne {
  1548. return u.Update(func(s *ContactUpsert) {
  1549. s.SetGname(v)
  1550. })
  1551. }
  1552. // UpdateGname sets the "gname" field to the value that was provided on create.
  1553. func (u *ContactUpsertOne) UpdateGname() *ContactUpsertOne {
  1554. return u.Update(func(s *ContactUpsert) {
  1555. s.UpdateGname()
  1556. })
  1557. }
  1558. // SetV3 sets the "v3" field.
  1559. func (u *ContactUpsertOne) SetV3(v string) *ContactUpsertOne {
  1560. return u.Update(func(s *ContactUpsert) {
  1561. s.SetV3(v)
  1562. })
  1563. }
  1564. // UpdateV3 sets the "v3" field to the value that was provided on create.
  1565. func (u *ContactUpsertOne) UpdateV3() *ContactUpsertOne {
  1566. return u.Update(func(s *ContactUpsert) {
  1567. s.UpdateV3()
  1568. })
  1569. }
  1570. // SetOrganizationID sets the "organization_id" field.
  1571. func (u *ContactUpsertOne) SetOrganizationID(v uint64) *ContactUpsertOne {
  1572. return u.Update(func(s *ContactUpsert) {
  1573. s.SetOrganizationID(v)
  1574. })
  1575. }
  1576. // AddOrganizationID adds v to the "organization_id" field.
  1577. func (u *ContactUpsertOne) AddOrganizationID(v uint64) *ContactUpsertOne {
  1578. return u.Update(func(s *ContactUpsert) {
  1579. s.AddOrganizationID(v)
  1580. })
  1581. }
  1582. // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
  1583. func (u *ContactUpsertOne) UpdateOrganizationID() *ContactUpsertOne {
  1584. return u.Update(func(s *ContactUpsert) {
  1585. s.UpdateOrganizationID()
  1586. })
  1587. }
  1588. // ClearOrganizationID clears the value of the "organization_id" field.
  1589. func (u *ContactUpsertOne) ClearOrganizationID() *ContactUpsertOne {
  1590. return u.Update(func(s *ContactUpsert) {
  1591. s.ClearOrganizationID()
  1592. })
  1593. }
  1594. // SetCtype sets the "ctype" field.
  1595. func (u *ContactUpsertOne) SetCtype(v uint64) *ContactUpsertOne {
  1596. return u.Update(func(s *ContactUpsert) {
  1597. s.SetCtype(v)
  1598. })
  1599. }
  1600. // AddCtype adds v to the "ctype" field.
  1601. func (u *ContactUpsertOne) AddCtype(v uint64) *ContactUpsertOne {
  1602. return u.Update(func(s *ContactUpsert) {
  1603. s.AddCtype(v)
  1604. })
  1605. }
  1606. // UpdateCtype sets the "ctype" field to the value that was provided on create.
  1607. func (u *ContactUpsertOne) UpdateCtype() *ContactUpsertOne {
  1608. return u.Update(func(s *ContactUpsert) {
  1609. s.UpdateCtype()
  1610. })
  1611. }
  1612. // SetCage sets the "cage" field.
  1613. func (u *ContactUpsertOne) SetCage(v int) *ContactUpsertOne {
  1614. return u.Update(func(s *ContactUpsert) {
  1615. s.SetCage(v)
  1616. })
  1617. }
  1618. // AddCage adds v to the "cage" field.
  1619. func (u *ContactUpsertOne) AddCage(v int) *ContactUpsertOne {
  1620. return u.Update(func(s *ContactUpsert) {
  1621. s.AddCage(v)
  1622. })
  1623. }
  1624. // UpdateCage sets the "cage" field to the value that was provided on create.
  1625. func (u *ContactUpsertOne) UpdateCage() *ContactUpsertOne {
  1626. return u.Update(func(s *ContactUpsert) {
  1627. s.UpdateCage()
  1628. })
  1629. }
  1630. // SetCname sets the "cname" field.
  1631. func (u *ContactUpsertOne) SetCname(v string) *ContactUpsertOne {
  1632. return u.Update(func(s *ContactUpsert) {
  1633. s.SetCname(v)
  1634. })
  1635. }
  1636. // UpdateCname sets the "cname" field to the value that was provided on create.
  1637. func (u *ContactUpsertOne) UpdateCname() *ContactUpsertOne {
  1638. return u.Update(func(s *ContactUpsert) {
  1639. s.UpdateCname()
  1640. })
  1641. }
  1642. // SetCarea sets the "carea" field.
  1643. func (u *ContactUpsertOne) SetCarea(v string) *ContactUpsertOne {
  1644. return u.Update(func(s *ContactUpsert) {
  1645. s.SetCarea(v)
  1646. })
  1647. }
  1648. // UpdateCarea sets the "carea" field to the value that was provided on create.
  1649. func (u *ContactUpsertOne) UpdateCarea() *ContactUpsertOne {
  1650. return u.Update(func(s *ContactUpsert) {
  1651. s.UpdateCarea()
  1652. })
  1653. }
  1654. // SetCbirthday sets the "cbirthday" field.
  1655. func (u *ContactUpsertOne) SetCbirthday(v string) *ContactUpsertOne {
  1656. return u.Update(func(s *ContactUpsert) {
  1657. s.SetCbirthday(v)
  1658. })
  1659. }
  1660. // UpdateCbirthday sets the "cbirthday" field to the value that was provided on create.
  1661. func (u *ContactUpsertOne) UpdateCbirthday() *ContactUpsertOne {
  1662. return u.Update(func(s *ContactUpsert) {
  1663. s.UpdateCbirthday()
  1664. })
  1665. }
  1666. // SetCbirtharea sets the "cbirtharea" field.
  1667. func (u *ContactUpsertOne) SetCbirtharea(v string) *ContactUpsertOne {
  1668. return u.Update(func(s *ContactUpsert) {
  1669. s.SetCbirtharea(v)
  1670. })
  1671. }
  1672. // UpdateCbirtharea sets the "cbirtharea" field to the value that was provided on create.
  1673. func (u *ContactUpsertOne) UpdateCbirtharea() *ContactUpsertOne {
  1674. return u.Update(func(s *ContactUpsert) {
  1675. s.UpdateCbirtharea()
  1676. })
  1677. }
  1678. // SetCidcardNo sets the "cidcard_no" field.
  1679. func (u *ContactUpsertOne) SetCidcardNo(v string) *ContactUpsertOne {
  1680. return u.Update(func(s *ContactUpsert) {
  1681. s.SetCidcardNo(v)
  1682. })
  1683. }
  1684. // UpdateCidcardNo sets the "cidcard_no" field to the value that was provided on create.
  1685. func (u *ContactUpsertOne) UpdateCidcardNo() *ContactUpsertOne {
  1686. return u.Update(func(s *ContactUpsert) {
  1687. s.UpdateCidcardNo()
  1688. })
  1689. }
  1690. // SetCtitle sets the "ctitle" field.
  1691. func (u *ContactUpsertOne) SetCtitle(v string) *ContactUpsertOne {
  1692. return u.Update(func(s *ContactUpsert) {
  1693. s.SetCtitle(v)
  1694. })
  1695. }
  1696. // UpdateCtitle sets the "ctitle" field to the value that was provided on create.
  1697. func (u *ContactUpsertOne) UpdateCtitle() *ContactUpsertOne {
  1698. return u.Update(func(s *ContactUpsert) {
  1699. s.UpdateCtitle()
  1700. })
  1701. }
  1702. // SetCc sets the "cc" field.
  1703. func (u *ContactUpsertOne) SetCc(v string) *ContactUpsertOne {
  1704. return u.Update(func(s *ContactUpsert) {
  1705. s.SetCc(v)
  1706. })
  1707. }
  1708. // UpdateCc sets the "cc" field to the value that was provided on create.
  1709. func (u *ContactUpsertOne) UpdateCc() *ContactUpsertOne {
  1710. return u.Update(func(s *ContactUpsert) {
  1711. s.UpdateCc()
  1712. })
  1713. }
  1714. // SetPhone sets the "phone" field.
  1715. func (u *ContactUpsertOne) SetPhone(v string) *ContactUpsertOne {
  1716. return u.Update(func(s *ContactUpsert) {
  1717. s.SetPhone(v)
  1718. })
  1719. }
  1720. // UpdatePhone sets the "phone" field to the value that was provided on create.
  1721. func (u *ContactUpsertOne) UpdatePhone() *ContactUpsertOne {
  1722. return u.Update(func(s *ContactUpsert) {
  1723. s.UpdatePhone()
  1724. })
  1725. }
  1726. // Exec executes the query.
  1727. func (u *ContactUpsertOne) Exec(ctx context.Context) error {
  1728. if len(u.create.conflict) == 0 {
  1729. return errors.New("ent: missing options for ContactCreate.OnConflict")
  1730. }
  1731. return u.create.Exec(ctx)
  1732. }
  1733. // ExecX is like Exec, but panics if an error occurs.
  1734. func (u *ContactUpsertOne) ExecX(ctx context.Context) {
  1735. if err := u.create.Exec(ctx); err != nil {
  1736. panic(err)
  1737. }
  1738. }
  1739. // Exec executes the UPSERT query and returns the inserted/updated ID.
  1740. func (u *ContactUpsertOne) ID(ctx context.Context) (id uint64, err error) {
  1741. node, err := u.create.Save(ctx)
  1742. if err != nil {
  1743. return id, err
  1744. }
  1745. return node.ID, nil
  1746. }
  1747. // IDX is like ID, but panics if an error occurs.
  1748. func (u *ContactUpsertOne) IDX(ctx context.Context) uint64 {
  1749. id, err := u.ID(ctx)
  1750. if err != nil {
  1751. panic(err)
  1752. }
  1753. return id
  1754. }
  1755. // ContactCreateBulk is the builder for creating many Contact entities in bulk.
  1756. type ContactCreateBulk struct {
  1757. config
  1758. err error
  1759. builders []*ContactCreate
  1760. conflict []sql.ConflictOption
  1761. }
  1762. // Save creates the Contact entities in the database.
  1763. func (ccb *ContactCreateBulk) Save(ctx context.Context) ([]*Contact, error) {
  1764. if ccb.err != nil {
  1765. return nil, ccb.err
  1766. }
  1767. specs := make([]*sqlgraph.CreateSpec, len(ccb.builders))
  1768. nodes := make([]*Contact, len(ccb.builders))
  1769. mutators := make([]Mutator, len(ccb.builders))
  1770. for i := range ccb.builders {
  1771. func(i int, root context.Context) {
  1772. builder := ccb.builders[i]
  1773. builder.defaults()
  1774. var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
  1775. mutation, ok := m.(*ContactMutation)
  1776. if !ok {
  1777. return nil, fmt.Errorf("unexpected mutation type %T", m)
  1778. }
  1779. if err := builder.check(); err != nil {
  1780. return nil, err
  1781. }
  1782. builder.mutation = mutation
  1783. var err error
  1784. nodes[i], specs[i] = builder.createSpec()
  1785. if i < len(mutators)-1 {
  1786. _, err = mutators[i+1].Mutate(root, ccb.builders[i+1].mutation)
  1787. } else {
  1788. spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
  1789. spec.OnConflict = ccb.conflict
  1790. // Invoke the actual operation on the latest mutation in the chain.
  1791. if err = sqlgraph.BatchCreate(ctx, ccb.driver, spec); err != nil {
  1792. if sqlgraph.IsConstraintError(err) {
  1793. err = &ConstraintError{msg: err.Error(), wrap: err}
  1794. }
  1795. }
  1796. }
  1797. if err != nil {
  1798. return nil, err
  1799. }
  1800. mutation.id = &nodes[i].ID
  1801. if specs[i].ID.Value != nil && nodes[i].ID == 0 {
  1802. id := specs[i].ID.Value.(int64)
  1803. nodes[i].ID = uint64(id)
  1804. }
  1805. mutation.done = true
  1806. return nodes[i], nil
  1807. })
  1808. for i := len(builder.hooks) - 1; i >= 0; i-- {
  1809. mut = builder.hooks[i](mut)
  1810. }
  1811. mutators[i] = mut
  1812. }(i, ctx)
  1813. }
  1814. if len(mutators) > 0 {
  1815. if _, err := mutators[0].Mutate(ctx, ccb.builders[0].mutation); err != nil {
  1816. return nil, err
  1817. }
  1818. }
  1819. return nodes, nil
  1820. }
  1821. // SaveX is like Save, but panics if an error occurs.
  1822. func (ccb *ContactCreateBulk) SaveX(ctx context.Context) []*Contact {
  1823. v, err := ccb.Save(ctx)
  1824. if err != nil {
  1825. panic(err)
  1826. }
  1827. return v
  1828. }
  1829. // Exec executes the query.
  1830. func (ccb *ContactCreateBulk) Exec(ctx context.Context) error {
  1831. _, err := ccb.Save(ctx)
  1832. return err
  1833. }
  1834. // ExecX is like Exec, but panics if an error occurs.
  1835. func (ccb *ContactCreateBulk) ExecX(ctx context.Context) {
  1836. if err := ccb.Exec(ctx); err != nil {
  1837. panic(err)
  1838. }
  1839. }
  1840. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  1841. // of the `INSERT` statement. For example:
  1842. //
  1843. // client.Contact.CreateBulk(builders...).
  1844. // OnConflict(
  1845. // // Update the row with the new values
  1846. // // the was proposed for insertion.
  1847. // sql.ResolveWithNewValues(),
  1848. // ).
  1849. // // Override some of the fields with custom
  1850. // // update values.
  1851. // Update(func(u *ent.ContactUpsert) {
  1852. // SetCreatedAt(v+v).
  1853. // }).
  1854. // Exec(ctx)
  1855. func (ccb *ContactCreateBulk) OnConflict(opts ...sql.ConflictOption) *ContactUpsertBulk {
  1856. ccb.conflict = opts
  1857. return &ContactUpsertBulk{
  1858. create: ccb,
  1859. }
  1860. }
  1861. // OnConflictColumns calls `OnConflict` and configures the columns
  1862. // as conflict target. Using this option is equivalent to using:
  1863. //
  1864. // client.Contact.Create().
  1865. // OnConflict(sql.ConflictColumns(columns...)).
  1866. // Exec(ctx)
  1867. func (ccb *ContactCreateBulk) OnConflictColumns(columns ...string) *ContactUpsertBulk {
  1868. ccb.conflict = append(ccb.conflict, sql.ConflictColumns(columns...))
  1869. return &ContactUpsertBulk{
  1870. create: ccb,
  1871. }
  1872. }
  1873. // ContactUpsertBulk is the builder for "upsert"-ing
  1874. // a bulk of Contact nodes.
  1875. type ContactUpsertBulk struct {
  1876. create *ContactCreateBulk
  1877. }
  1878. // UpdateNewValues updates the mutable fields using the new values that
  1879. // were set on create. Using this option is equivalent to using:
  1880. //
  1881. // client.Contact.Create().
  1882. // OnConflict(
  1883. // sql.ResolveWithNewValues(),
  1884. // sql.ResolveWith(func(u *sql.UpdateSet) {
  1885. // u.SetIgnore(contact.FieldID)
  1886. // }),
  1887. // ).
  1888. // Exec(ctx)
  1889. func (u *ContactUpsertBulk) UpdateNewValues() *ContactUpsertBulk {
  1890. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  1891. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  1892. for _, b := range u.create.builders {
  1893. if _, exists := b.mutation.ID(); exists {
  1894. s.SetIgnore(contact.FieldID)
  1895. }
  1896. if _, exists := b.mutation.CreatedAt(); exists {
  1897. s.SetIgnore(contact.FieldCreatedAt)
  1898. }
  1899. }
  1900. }))
  1901. return u
  1902. }
  1903. // Ignore sets each column to itself in case of conflict.
  1904. // Using this option is equivalent to using:
  1905. //
  1906. // client.Contact.Create().
  1907. // OnConflict(sql.ResolveWithIgnore()).
  1908. // Exec(ctx)
  1909. func (u *ContactUpsertBulk) Ignore() *ContactUpsertBulk {
  1910. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  1911. return u
  1912. }
  1913. // DoNothing configures the conflict_action to `DO NOTHING`.
  1914. // Supported only by SQLite and PostgreSQL.
  1915. func (u *ContactUpsertBulk) DoNothing() *ContactUpsertBulk {
  1916. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  1917. return u
  1918. }
  1919. // Update allows overriding fields `UPDATE` values. See the ContactCreateBulk.OnConflict
  1920. // documentation for more info.
  1921. func (u *ContactUpsertBulk) Update(set func(*ContactUpsert)) *ContactUpsertBulk {
  1922. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  1923. set(&ContactUpsert{UpdateSet: update})
  1924. }))
  1925. return u
  1926. }
  1927. // SetUpdatedAt sets the "updated_at" field.
  1928. func (u *ContactUpsertBulk) SetUpdatedAt(v time.Time) *ContactUpsertBulk {
  1929. return u.Update(func(s *ContactUpsert) {
  1930. s.SetUpdatedAt(v)
  1931. })
  1932. }
  1933. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  1934. func (u *ContactUpsertBulk) UpdateUpdatedAt() *ContactUpsertBulk {
  1935. return u.Update(func(s *ContactUpsert) {
  1936. s.UpdateUpdatedAt()
  1937. })
  1938. }
  1939. // SetStatus sets the "status" field.
  1940. func (u *ContactUpsertBulk) SetStatus(v uint8) *ContactUpsertBulk {
  1941. return u.Update(func(s *ContactUpsert) {
  1942. s.SetStatus(v)
  1943. })
  1944. }
  1945. // AddStatus adds v to the "status" field.
  1946. func (u *ContactUpsertBulk) AddStatus(v uint8) *ContactUpsertBulk {
  1947. return u.Update(func(s *ContactUpsert) {
  1948. s.AddStatus(v)
  1949. })
  1950. }
  1951. // UpdateStatus sets the "status" field to the value that was provided on create.
  1952. func (u *ContactUpsertBulk) UpdateStatus() *ContactUpsertBulk {
  1953. return u.Update(func(s *ContactUpsert) {
  1954. s.UpdateStatus()
  1955. })
  1956. }
  1957. // ClearStatus clears the value of the "status" field.
  1958. func (u *ContactUpsertBulk) ClearStatus() *ContactUpsertBulk {
  1959. return u.Update(func(s *ContactUpsert) {
  1960. s.ClearStatus()
  1961. })
  1962. }
  1963. // SetDeletedAt sets the "deleted_at" field.
  1964. func (u *ContactUpsertBulk) SetDeletedAt(v time.Time) *ContactUpsertBulk {
  1965. return u.Update(func(s *ContactUpsert) {
  1966. s.SetDeletedAt(v)
  1967. })
  1968. }
  1969. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  1970. func (u *ContactUpsertBulk) UpdateDeletedAt() *ContactUpsertBulk {
  1971. return u.Update(func(s *ContactUpsert) {
  1972. s.UpdateDeletedAt()
  1973. })
  1974. }
  1975. // ClearDeletedAt clears the value of the "deleted_at" field.
  1976. func (u *ContactUpsertBulk) ClearDeletedAt() *ContactUpsertBulk {
  1977. return u.Update(func(s *ContactUpsert) {
  1978. s.ClearDeletedAt()
  1979. })
  1980. }
  1981. // SetWxWxid sets the "wx_wxid" field.
  1982. func (u *ContactUpsertBulk) SetWxWxid(v string) *ContactUpsertBulk {
  1983. return u.Update(func(s *ContactUpsert) {
  1984. s.SetWxWxid(v)
  1985. })
  1986. }
  1987. // UpdateWxWxid sets the "wx_wxid" field to the value that was provided on create.
  1988. func (u *ContactUpsertBulk) UpdateWxWxid() *ContactUpsertBulk {
  1989. return u.Update(func(s *ContactUpsert) {
  1990. s.UpdateWxWxid()
  1991. })
  1992. }
  1993. // SetType sets the "type" field.
  1994. func (u *ContactUpsertBulk) SetType(v int) *ContactUpsertBulk {
  1995. return u.Update(func(s *ContactUpsert) {
  1996. s.SetType(v)
  1997. })
  1998. }
  1999. // AddType adds v to the "type" field.
  2000. func (u *ContactUpsertBulk) AddType(v int) *ContactUpsertBulk {
  2001. return u.Update(func(s *ContactUpsert) {
  2002. s.AddType(v)
  2003. })
  2004. }
  2005. // UpdateType sets the "type" field to the value that was provided on create.
  2006. func (u *ContactUpsertBulk) UpdateType() *ContactUpsertBulk {
  2007. return u.Update(func(s *ContactUpsert) {
  2008. s.UpdateType()
  2009. })
  2010. }
  2011. // ClearType clears the value of the "type" field.
  2012. func (u *ContactUpsertBulk) ClearType() *ContactUpsertBulk {
  2013. return u.Update(func(s *ContactUpsert) {
  2014. s.ClearType()
  2015. })
  2016. }
  2017. // SetWxid sets the "wxid" field.
  2018. func (u *ContactUpsertBulk) SetWxid(v string) *ContactUpsertBulk {
  2019. return u.Update(func(s *ContactUpsert) {
  2020. s.SetWxid(v)
  2021. })
  2022. }
  2023. // UpdateWxid sets the "wxid" field to the value that was provided on create.
  2024. func (u *ContactUpsertBulk) UpdateWxid() *ContactUpsertBulk {
  2025. return u.Update(func(s *ContactUpsert) {
  2026. s.UpdateWxid()
  2027. })
  2028. }
  2029. // SetAccount sets the "account" field.
  2030. func (u *ContactUpsertBulk) SetAccount(v string) *ContactUpsertBulk {
  2031. return u.Update(func(s *ContactUpsert) {
  2032. s.SetAccount(v)
  2033. })
  2034. }
  2035. // UpdateAccount sets the "account" field to the value that was provided on create.
  2036. func (u *ContactUpsertBulk) UpdateAccount() *ContactUpsertBulk {
  2037. return u.Update(func(s *ContactUpsert) {
  2038. s.UpdateAccount()
  2039. })
  2040. }
  2041. // SetNickname sets the "nickname" field.
  2042. func (u *ContactUpsertBulk) SetNickname(v string) *ContactUpsertBulk {
  2043. return u.Update(func(s *ContactUpsert) {
  2044. s.SetNickname(v)
  2045. })
  2046. }
  2047. // UpdateNickname sets the "nickname" field to the value that was provided on create.
  2048. func (u *ContactUpsertBulk) UpdateNickname() *ContactUpsertBulk {
  2049. return u.Update(func(s *ContactUpsert) {
  2050. s.UpdateNickname()
  2051. })
  2052. }
  2053. // SetMarkname sets the "markname" field.
  2054. func (u *ContactUpsertBulk) SetMarkname(v string) *ContactUpsertBulk {
  2055. return u.Update(func(s *ContactUpsert) {
  2056. s.SetMarkname(v)
  2057. })
  2058. }
  2059. // UpdateMarkname sets the "markname" field to the value that was provided on create.
  2060. func (u *ContactUpsertBulk) UpdateMarkname() *ContactUpsertBulk {
  2061. return u.Update(func(s *ContactUpsert) {
  2062. s.UpdateMarkname()
  2063. })
  2064. }
  2065. // SetHeadimg sets the "headimg" field.
  2066. func (u *ContactUpsertBulk) SetHeadimg(v string) *ContactUpsertBulk {
  2067. return u.Update(func(s *ContactUpsert) {
  2068. s.SetHeadimg(v)
  2069. })
  2070. }
  2071. // UpdateHeadimg sets the "headimg" field to the value that was provided on create.
  2072. func (u *ContactUpsertBulk) UpdateHeadimg() *ContactUpsertBulk {
  2073. return u.Update(func(s *ContactUpsert) {
  2074. s.UpdateHeadimg()
  2075. })
  2076. }
  2077. // SetSex sets the "sex" field.
  2078. func (u *ContactUpsertBulk) SetSex(v int) *ContactUpsertBulk {
  2079. return u.Update(func(s *ContactUpsert) {
  2080. s.SetSex(v)
  2081. })
  2082. }
  2083. // AddSex adds v to the "sex" field.
  2084. func (u *ContactUpsertBulk) AddSex(v int) *ContactUpsertBulk {
  2085. return u.Update(func(s *ContactUpsert) {
  2086. s.AddSex(v)
  2087. })
  2088. }
  2089. // UpdateSex sets the "sex" field to the value that was provided on create.
  2090. func (u *ContactUpsertBulk) UpdateSex() *ContactUpsertBulk {
  2091. return u.Update(func(s *ContactUpsert) {
  2092. s.UpdateSex()
  2093. })
  2094. }
  2095. // SetStarrole sets the "starrole" field.
  2096. func (u *ContactUpsertBulk) SetStarrole(v string) *ContactUpsertBulk {
  2097. return u.Update(func(s *ContactUpsert) {
  2098. s.SetStarrole(v)
  2099. })
  2100. }
  2101. // UpdateStarrole sets the "starrole" field to the value that was provided on create.
  2102. func (u *ContactUpsertBulk) UpdateStarrole() *ContactUpsertBulk {
  2103. return u.Update(func(s *ContactUpsert) {
  2104. s.UpdateStarrole()
  2105. })
  2106. }
  2107. // SetDontseeit sets the "dontseeit" field.
  2108. func (u *ContactUpsertBulk) SetDontseeit(v int) *ContactUpsertBulk {
  2109. return u.Update(func(s *ContactUpsert) {
  2110. s.SetDontseeit(v)
  2111. })
  2112. }
  2113. // AddDontseeit adds v to the "dontseeit" field.
  2114. func (u *ContactUpsertBulk) AddDontseeit(v int) *ContactUpsertBulk {
  2115. return u.Update(func(s *ContactUpsert) {
  2116. s.AddDontseeit(v)
  2117. })
  2118. }
  2119. // UpdateDontseeit sets the "dontseeit" field to the value that was provided on create.
  2120. func (u *ContactUpsertBulk) UpdateDontseeit() *ContactUpsertBulk {
  2121. return u.Update(func(s *ContactUpsert) {
  2122. s.UpdateDontseeit()
  2123. })
  2124. }
  2125. // SetDontseeme sets the "dontseeme" field.
  2126. func (u *ContactUpsertBulk) SetDontseeme(v int) *ContactUpsertBulk {
  2127. return u.Update(func(s *ContactUpsert) {
  2128. s.SetDontseeme(v)
  2129. })
  2130. }
  2131. // AddDontseeme adds v to the "dontseeme" field.
  2132. func (u *ContactUpsertBulk) AddDontseeme(v int) *ContactUpsertBulk {
  2133. return u.Update(func(s *ContactUpsert) {
  2134. s.AddDontseeme(v)
  2135. })
  2136. }
  2137. // UpdateDontseeme sets the "dontseeme" field to the value that was provided on create.
  2138. func (u *ContactUpsertBulk) UpdateDontseeme() *ContactUpsertBulk {
  2139. return u.Update(func(s *ContactUpsert) {
  2140. s.UpdateDontseeme()
  2141. })
  2142. }
  2143. // SetLag sets the "lag" field.
  2144. func (u *ContactUpsertBulk) SetLag(v string) *ContactUpsertBulk {
  2145. return u.Update(func(s *ContactUpsert) {
  2146. s.SetLag(v)
  2147. })
  2148. }
  2149. // UpdateLag sets the "lag" field to the value that was provided on create.
  2150. func (u *ContactUpsertBulk) UpdateLag() *ContactUpsertBulk {
  2151. return u.Update(func(s *ContactUpsert) {
  2152. s.UpdateLag()
  2153. })
  2154. }
  2155. // SetGid sets the "gid" field.
  2156. func (u *ContactUpsertBulk) SetGid(v string) *ContactUpsertBulk {
  2157. return u.Update(func(s *ContactUpsert) {
  2158. s.SetGid(v)
  2159. })
  2160. }
  2161. // UpdateGid sets the "gid" field to the value that was provided on create.
  2162. func (u *ContactUpsertBulk) UpdateGid() *ContactUpsertBulk {
  2163. return u.Update(func(s *ContactUpsert) {
  2164. s.UpdateGid()
  2165. })
  2166. }
  2167. // SetGname sets the "gname" field.
  2168. func (u *ContactUpsertBulk) SetGname(v string) *ContactUpsertBulk {
  2169. return u.Update(func(s *ContactUpsert) {
  2170. s.SetGname(v)
  2171. })
  2172. }
  2173. // UpdateGname sets the "gname" field to the value that was provided on create.
  2174. func (u *ContactUpsertBulk) UpdateGname() *ContactUpsertBulk {
  2175. return u.Update(func(s *ContactUpsert) {
  2176. s.UpdateGname()
  2177. })
  2178. }
  2179. // SetV3 sets the "v3" field.
  2180. func (u *ContactUpsertBulk) SetV3(v string) *ContactUpsertBulk {
  2181. return u.Update(func(s *ContactUpsert) {
  2182. s.SetV3(v)
  2183. })
  2184. }
  2185. // UpdateV3 sets the "v3" field to the value that was provided on create.
  2186. func (u *ContactUpsertBulk) UpdateV3() *ContactUpsertBulk {
  2187. return u.Update(func(s *ContactUpsert) {
  2188. s.UpdateV3()
  2189. })
  2190. }
  2191. // SetOrganizationID sets the "organization_id" field.
  2192. func (u *ContactUpsertBulk) SetOrganizationID(v uint64) *ContactUpsertBulk {
  2193. return u.Update(func(s *ContactUpsert) {
  2194. s.SetOrganizationID(v)
  2195. })
  2196. }
  2197. // AddOrganizationID adds v to the "organization_id" field.
  2198. func (u *ContactUpsertBulk) AddOrganizationID(v uint64) *ContactUpsertBulk {
  2199. return u.Update(func(s *ContactUpsert) {
  2200. s.AddOrganizationID(v)
  2201. })
  2202. }
  2203. // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
  2204. func (u *ContactUpsertBulk) UpdateOrganizationID() *ContactUpsertBulk {
  2205. return u.Update(func(s *ContactUpsert) {
  2206. s.UpdateOrganizationID()
  2207. })
  2208. }
  2209. // ClearOrganizationID clears the value of the "organization_id" field.
  2210. func (u *ContactUpsertBulk) ClearOrganizationID() *ContactUpsertBulk {
  2211. return u.Update(func(s *ContactUpsert) {
  2212. s.ClearOrganizationID()
  2213. })
  2214. }
  2215. // SetCtype sets the "ctype" field.
  2216. func (u *ContactUpsertBulk) SetCtype(v uint64) *ContactUpsertBulk {
  2217. return u.Update(func(s *ContactUpsert) {
  2218. s.SetCtype(v)
  2219. })
  2220. }
  2221. // AddCtype adds v to the "ctype" field.
  2222. func (u *ContactUpsertBulk) AddCtype(v uint64) *ContactUpsertBulk {
  2223. return u.Update(func(s *ContactUpsert) {
  2224. s.AddCtype(v)
  2225. })
  2226. }
  2227. // UpdateCtype sets the "ctype" field to the value that was provided on create.
  2228. func (u *ContactUpsertBulk) UpdateCtype() *ContactUpsertBulk {
  2229. return u.Update(func(s *ContactUpsert) {
  2230. s.UpdateCtype()
  2231. })
  2232. }
  2233. // SetCage sets the "cage" field.
  2234. func (u *ContactUpsertBulk) SetCage(v int) *ContactUpsertBulk {
  2235. return u.Update(func(s *ContactUpsert) {
  2236. s.SetCage(v)
  2237. })
  2238. }
  2239. // AddCage adds v to the "cage" field.
  2240. func (u *ContactUpsertBulk) AddCage(v int) *ContactUpsertBulk {
  2241. return u.Update(func(s *ContactUpsert) {
  2242. s.AddCage(v)
  2243. })
  2244. }
  2245. // UpdateCage sets the "cage" field to the value that was provided on create.
  2246. func (u *ContactUpsertBulk) UpdateCage() *ContactUpsertBulk {
  2247. return u.Update(func(s *ContactUpsert) {
  2248. s.UpdateCage()
  2249. })
  2250. }
  2251. // SetCname sets the "cname" field.
  2252. func (u *ContactUpsertBulk) SetCname(v string) *ContactUpsertBulk {
  2253. return u.Update(func(s *ContactUpsert) {
  2254. s.SetCname(v)
  2255. })
  2256. }
  2257. // UpdateCname sets the "cname" field to the value that was provided on create.
  2258. func (u *ContactUpsertBulk) UpdateCname() *ContactUpsertBulk {
  2259. return u.Update(func(s *ContactUpsert) {
  2260. s.UpdateCname()
  2261. })
  2262. }
  2263. // SetCarea sets the "carea" field.
  2264. func (u *ContactUpsertBulk) SetCarea(v string) *ContactUpsertBulk {
  2265. return u.Update(func(s *ContactUpsert) {
  2266. s.SetCarea(v)
  2267. })
  2268. }
  2269. // UpdateCarea sets the "carea" field to the value that was provided on create.
  2270. func (u *ContactUpsertBulk) UpdateCarea() *ContactUpsertBulk {
  2271. return u.Update(func(s *ContactUpsert) {
  2272. s.UpdateCarea()
  2273. })
  2274. }
  2275. // SetCbirthday sets the "cbirthday" field.
  2276. func (u *ContactUpsertBulk) SetCbirthday(v string) *ContactUpsertBulk {
  2277. return u.Update(func(s *ContactUpsert) {
  2278. s.SetCbirthday(v)
  2279. })
  2280. }
  2281. // UpdateCbirthday sets the "cbirthday" field to the value that was provided on create.
  2282. func (u *ContactUpsertBulk) UpdateCbirthday() *ContactUpsertBulk {
  2283. return u.Update(func(s *ContactUpsert) {
  2284. s.UpdateCbirthday()
  2285. })
  2286. }
  2287. // SetCbirtharea sets the "cbirtharea" field.
  2288. func (u *ContactUpsertBulk) SetCbirtharea(v string) *ContactUpsertBulk {
  2289. return u.Update(func(s *ContactUpsert) {
  2290. s.SetCbirtharea(v)
  2291. })
  2292. }
  2293. // UpdateCbirtharea sets the "cbirtharea" field to the value that was provided on create.
  2294. func (u *ContactUpsertBulk) UpdateCbirtharea() *ContactUpsertBulk {
  2295. return u.Update(func(s *ContactUpsert) {
  2296. s.UpdateCbirtharea()
  2297. })
  2298. }
  2299. // SetCidcardNo sets the "cidcard_no" field.
  2300. func (u *ContactUpsertBulk) SetCidcardNo(v string) *ContactUpsertBulk {
  2301. return u.Update(func(s *ContactUpsert) {
  2302. s.SetCidcardNo(v)
  2303. })
  2304. }
  2305. // UpdateCidcardNo sets the "cidcard_no" field to the value that was provided on create.
  2306. func (u *ContactUpsertBulk) UpdateCidcardNo() *ContactUpsertBulk {
  2307. return u.Update(func(s *ContactUpsert) {
  2308. s.UpdateCidcardNo()
  2309. })
  2310. }
  2311. // SetCtitle sets the "ctitle" field.
  2312. func (u *ContactUpsertBulk) SetCtitle(v string) *ContactUpsertBulk {
  2313. return u.Update(func(s *ContactUpsert) {
  2314. s.SetCtitle(v)
  2315. })
  2316. }
  2317. // UpdateCtitle sets the "ctitle" field to the value that was provided on create.
  2318. func (u *ContactUpsertBulk) UpdateCtitle() *ContactUpsertBulk {
  2319. return u.Update(func(s *ContactUpsert) {
  2320. s.UpdateCtitle()
  2321. })
  2322. }
  2323. // SetCc sets the "cc" field.
  2324. func (u *ContactUpsertBulk) SetCc(v string) *ContactUpsertBulk {
  2325. return u.Update(func(s *ContactUpsert) {
  2326. s.SetCc(v)
  2327. })
  2328. }
  2329. // UpdateCc sets the "cc" field to the value that was provided on create.
  2330. func (u *ContactUpsertBulk) UpdateCc() *ContactUpsertBulk {
  2331. return u.Update(func(s *ContactUpsert) {
  2332. s.UpdateCc()
  2333. })
  2334. }
  2335. // SetPhone sets the "phone" field.
  2336. func (u *ContactUpsertBulk) SetPhone(v string) *ContactUpsertBulk {
  2337. return u.Update(func(s *ContactUpsert) {
  2338. s.SetPhone(v)
  2339. })
  2340. }
  2341. // UpdatePhone sets the "phone" field to the value that was provided on create.
  2342. func (u *ContactUpsertBulk) UpdatePhone() *ContactUpsertBulk {
  2343. return u.Update(func(s *ContactUpsert) {
  2344. s.UpdatePhone()
  2345. })
  2346. }
  2347. // Exec executes the query.
  2348. func (u *ContactUpsertBulk) Exec(ctx context.Context) error {
  2349. if u.create.err != nil {
  2350. return u.create.err
  2351. }
  2352. for i, b := range u.create.builders {
  2353. if len(b.conflict) != 0 {
  2354. return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the ContactCreateBulk instead", i)
  2355. }
  2356. }
  2357. if len(u.create.conflict) == 0 {
  2358. return errors.New("ent: missing options for ContactCreateBulk.OnConflict")
  2359. }
  2360. return u.create.Exec(ctx)
  2361. }
  2362. // ExecX is like Exec, but panics if an error occurs.
  2363. func (u *ContactUpsertBulk) ExecX(ctx context.Context) {
  2364. if err := u.create.Exec(ctx); err != nil {
  2365. panic(err)
  2366. }
  2367. }