contact_create.go 77 KB

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