contact_create.go 73 KB

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