contact_create.go 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961
  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. // SetID sets the "id" field.
  263. func (cc *ContactCreate) SetID(u uint64) *ContactCreate {
  264. cc.mutation.SetID(u)
  265. return cc
  266. }
  267. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by IDs.
  268. func (cc *ContactCreate) AddContactRelationshipIDs(ids ...uint64) *ContactCreate {
  269. cc.mutation.AddContactRelationshipIDs(ids...)
  270. return cc
  271. }
  272. // AddContactRelationships adds the "contact_relationships" edges to the LabelRelationship entity.
  273. func (cc *ContactCreate) AddContactRelationships(l ...*LabelRelationship) *ContactCreate {
  274. ids := make([]uint64, len(l))
  275. for i := range l {
  276. ids[i] = l[i].ID
  277. }
  278. return cc.AddContactRelationshipIDs(ids...)
  279. }
  280. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by IDs.
  281. func (cc *ContactCreate) AddContactMessageIDs(ids ...uint64) *ContactCreate {
  282. cc.mutation.AddContactMessageIDs(ids...)
  283. return cc
  284. }
  285. // AddContactMessages adds the "contact_messages" edges to the MessageRecords entity.
  286. func (cc *ContactCreate) AddContactMessages(m ...*MessageRecords) *ContactCreate {
  287. ids := make([]uint64, len(m))
  288. for i := range m {
  289. ids[i] = m[i].ID
  290. }
  291. return cc.AddContactMessageIDs(ids...)
  292. }
  293. // Mutation returns the ContactMutation object of the builder.
  294. func (cc *ContactCreate) Mutation() *ContactMutation {
  295. return cc.mutation
  296. }
  297. // Save creates the Contact in the database.
  298. func (cc *ContactCreate) Save(ctx context.Context) (*Contact, error) {
  299. if err := cc.defaults(); err != nil {
  300. return nil, err
  301. }
  302. return withHooks(ctx, cc.sqlSave, cc.mutation, cc.hooks)
  303. }
  304. // SaveX calls Save and panics if Save returns an error.
  305. func (cc *ContactCreate) SaveX(ctx context.Context) *Contact {
  306. v, err := cc.Save(ctx)
  307. if err != nil {
  308. panic(err)
  309. }
  310. return v
  311. }
  312. // Exec executes the query.
  313. func (cc *ContactCreate) Exec(ctx context.Context) error {
  314. _, err := cc.Save(ctx)
  315. return err
  316. }
  317. // ExecX is like Exec, but panics if an error occurs.
  318. func (cc *ContactCreate) ExecX(ctx context.Context) {
  319. if err := cc.Exec(ctx); err != nil {
  320. panic(err)
  321. }
  322. }
  323. // defaults sets the default values of the builder before save.
  324. func (cc *ContactCreate) defaults() error {
  325. if _, ok := cc.mutation.CreatedAt(); !ok {
  326. if contact.DefaultCreatedAt == nil {
  327. return fmt.Errorf("ent: uninitialized contact.DefaultCreatedAt (forgotten import ent/runtime?)")
  328. }
  329. v := contact.DefaultCreatedAt()
  330. cc.mutation.SetCreatedAt(v)
  331. }
  332. if _, ok := cc.mutation.UpdatedAt(); !ok {
  333. if contact.DefaultUpdatedAt == nil {
  334. return fmt.Errorf("ent: uninitialized contact.DefaultUpdatedAt (forgotten import ent/runtime?)")
  335. }
  336. v := contact.DefaultUpdatedAt()
  337. cc.mutation.SetUpdatedAt(v)
  338. }
  339. if _, ok := cc.mutation.Status(); !ok {
  340. v := contact.DefaultStatus
  341. cc.mutation.SetStatus(v)
  342. }
  343. if _, ok := cc.mutation.WxWxid(); !ok {
  344. v := contact.DefaultWxWxid
  345. cc.mutation.SetWxWxid(v)
  346. }
  347. if _, ok := cc.mutation.GetType(); !ok {
  348. v := contact.DefaultType
  349. cc.mutation.SetType(v)
  350. }
  351. if _, ok := cc.mutation.Wxid(); !ok {
  352. v := contact.DefaultWxid
  353. cc.mutation.SetWxid(v)
  354. }
  355. if _, ok := cc.mutation.Account(); !ok {
  356. v := contact.DefaultAccount
  357. cc.mutation.SetAccount(v)
  358. }
  359. if _, ok := cc.mutation.Nickname(); !ok {
  360. v := contact.DefaultNickname
  361. cc.mutation.SetNickname(v)
  362. }
  363. if _, ok := cc.mutation.Markname(); !ok {
  364. v := contact.DefaultMarkname
  365. cc.mutation.SetMarkname(v)
  366. }
  367. if _, ok := cc.mutation.Headimg(); !ok {
  368. v := contact.DefaultHeadimg
  369. cc.mutation.SetHeadimg(v)
  370. }
  371. if _, ok := cc.mutation.Sex(); !ok {
  372. v := contact.DefaultSex
  373. cc.mutation.SetSex(v)
  374. }
  375. if _, ok := cc.mutation.Starrole(); !ok {
  376. v := contact.DefaultStarrole
  377. cc.mutation.SetStarrole(v)
  378. }
  379. if _, ok := cc.mutation.Dontseeit(); !ok {
  380. v := contact.DefaultDontseeit
  381. cc.mutation.SetDontseeit(v)
  382. }
  383. if _, ok := cc.mutation.Dontseeme(); !ok {
  384. v := contact.DefaultDontseeme
  385. cc.mutation.SetDontseeme(v)
  386. }
  387. if _, ok := cc.mutation.Lag(); !ok {
  388. v := contact.DefaultLag
  389. cc.mutation.SetLag(v)
  390. }
  391. if _, ok := cc.mutation.Gid(); !ok {
  392. v := contact.DefaultGid
  393. cc.mutation.SetGid(v)
  394. }
  395. if _, ok := cc.mutation.Gname(); !ok {
  396. v := contact.DefaultGname
  397. cc.mutation.SetGname(v)
  398. }
  399. if _, ok := cc.mutation.V3(); !ok {
  400. v := contact.DefaultV3
  401. cc.mutation.SetV3(v)
  402. }
  403. if _, ok := cc.mutation.OrganizationID(); !ok {
  404. v := contact.DefaultOrganizationID
  405. cc.mutation.SetOrganizationID(v)
  406. }
  407. return nil
  408. }
  409. // check runs all checks and user-defined validators on the builder.
  410. func (cc *ContactCreate) check() error {
  411. if _, ok := cc.mutation.CreatedAt(); !ok {
  412. return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Contact.created_at"`)}
  413. }
  414. if _, ok := cc.mutation.UpdatedAt(); !ok {
  415. return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Contact.updated_at"`)}
  416. }
  417. if _, ok := cc.mutation.WxWxid(); !ok {
  418. return &ValidationError{Name: "wx_wxid", err: errors.New(`ent: missing required field "Contact.wx_wxid"`)}
  419. }
  420. if _, ok := cc.mutation.Wxid(); !ok {
  421. return &ValidationError{Name: "wxid", err: errors.New(`ent: missing required field "Contact.wxid"`)}
  422. }
  423. if _, ok := cc.mutation.Account(); !ok {
  424. return &ValidationError{Name: "account", err: errors.New(`ent: missing required field "Contact.account"`)}
  425. }
  426. if _, ok := cc.mutation.Nickname(); !ok {
  427. return &ValidationError{Name: "nickname", err: errors.New(`ent: missing required field "Contact.nickname"`)}
  428. }
  429. if _, ok := cc.mutation.Markname(); !ok {
  430. return &ValidationError{Name: "markname", err: errors.New(`ent: missing required field "Contact.markname"`)}
  431. }
  432. if _, ok := cc.mutation.Headimg(); !ok {
  433. return &ValidationError{Name: "headimg", err: errors.New(`ent: missing required field "Contact.headimg"`)}
  434. }
  435. if _, ok := cc.mutation.Sex(); !ok {
  436. return &ValidationError{Name: "sex", err: errors.New(`ent: missing required field "Contact.sex"`)}
  437. }
  438. if _, ok := cc.mutation.Starrole(); !ok {
  439. return &ValidationError{Name: "starrole", err: errors.New(`ent: missing required field "Contact.starrole"`)}
  440. }
  441. if _, ok := cc.mutation.Dontseeit(); !ok {
  442. return &ValidationError{Name: "dontseeit", err: errors.New(`ent: missing required field "Contact.dontseeit"`)}
  443. }
  444. if _, ok := cc.mutation.Dontseeme(); !ok {
  445. return &ValidationError{Name: "dontseeme", err: errors.New(`ent: missing required field "Contact.dontseeme"`)}
  446. }
  447. if _, ok := cc.mutation.Lag(); !ok {
  448. return &ValidationError{Name: "lag", err: errors.New(`ent: missing required field "Contact.lag"`)}
  449. }
  450. if _, ok := cc.mutation.Gid(); !ok {
  451. return &ValidationError{Name: "gid", err: errors.New(`ent: missing required field "Contact.gid"`)}
  452. }
  453. if _, ok := cc.mutation.Gname(); !ok {
  454. return &ValidationError{Name: "gname", err: errors.New(`ent: missing required field "Contact.gname"`)}
  455. }
  456. if _, ok := cc.mutation.V3(); !ok {
  457. return &ValidationError{Name: "v3", err: errors.New(`ent: missing required field "Contact.v3"`)}
  458. }
  459. return nil
  460. }
  461. func (cc *ContactCreate) sqlSave(ctx context.Context) (*Contact, error) {
  462. if err := cc.check(); err != nil {
  463. return nil, err
  464. }
  465. _node, _spec := cc.createSpec()
  466. if err := sqlgraph.CreateNode(ctx, cc.driver, _spec); err != nil {
  467. if sqlgraph.IsConstraintError(err) {
  468. err = &ConstraintError{msg: err.Error(), wrap: err}
  469. }
  470. return nil, err
  471. }
  472. if _spec.ID.Value != _node.ID {
  473. id := _spec.ID.Value.(int64)
  474. _node.ID = uint64(id)
  475. }
  476. cc.mutation.id = &_node.ID
  477. cc.mutation.done = true
  478. return _node, nil
  479. }
  480. func (cc *ContactCreate) createSpec() (*Contact, *sqlgraph.CreateSpec) {
  481. var (
  482. _node = &Contact{config: cc.config}
  483. _spec = sqlgraph.NewCreateSpec(contact.Table, sqlgraph.NewFieldSpec(contact.FieldID, field.TypeUint64))
  484. )
  485. _spec.OnConflict = cc.conflict
  486. if id, ok := cc.mutation.ID(); ok {
  487. _node.ID = id
  488. _spec.ID.Value = id
  489. }
  490. if value, ok := cc.mutation.CreatedAt(); ok {
  491. _spec.SetField(contact.FieldCreatedAt, field.TypeTime, value)
  492. _node.CreatedAt = value
  493. }
  494. if value, ok := cc.mutation.UpdatedAt(); ok {
  495. _spec.SetField(contact.FieldUpdatedAt, field.TypeTime, value)
  496. _node.UpdatedAt = value
  497. }
  498. if value, ok := cc.mutation.Status(); ok {
  499. _spec.SetField(contact.FieldStatus, field.TypeUint8, value)
  500. _node.Status = value
  501. }
  502. if value, ok := cc.mutation.DeletedAt(); ok {
  503. _spec.SetField(contact.FieldDeletedAt, field.TypeTime, value)
  504. _node.DeletedAt = value
  505. }
  506. if value, ok := cc.mutation.WxWxid(); ok {
  507. _spec.SetField(contact.FieldWxWxid, field.TypeString, value)
  508. _node.WxWxid = value
  509. }
  510. if value, ok := cc.mutation.GetType(); ok {
  511. _spec.SetField(contact.FieldType, field.TypeInt, value)
  512. _node.Type = value
  513. }
  514. if value, ok := cc.mutation.Wxid(); ok {
  515. _spec.SetField(contact.FieldWxid, field.TypeString, value)
  516. _node.Wxid = value
  517. }
  518. if value, ok := cc.mutation.Account(); ok {
  519. _spec.SetField(contact.FieldAccount, field.TypeString, value)
  520. _node.Account = value
  521. }
  522. if value, ok := cc.mutation.Nickname(); ok {
  523. _spec.SetField(contact.FieldNickname, field.TypeString, value)
  524. _node.Nickname = value
  525. }
  526. if value, ok := cc.mutation.Markname(); ok {
  527. _spec.SetField(contact.FieldMarkname, field.TypeString, value)
  528. _node.Markname = value
  529. }
  530. if value, ok := cc.mutation.Headimg(); ok {
  531. _spec.SetField(contact.FieldHeadimg, field.TypeString, value)
  532. _node.Headimg = value
  533. }
  534. if value, ok := cc.mutation.Sex(); ok {
  535. _spec.SetField(contact.FieldSex, field.TypeInt, value)
  536. _node.Sex = value
  537. }
  538. if value, ok := cc.mutation.Starrole(); ok {
  539. _spec.SetField(contact.FieldStarrole, field.TypeString, value)
  540. _node.Starrole = value
  541. }
  542. if value, ok := cc.mutation.Dontseeit(); ok {
  543. _spec.SetField(contact.FieldDontseeit, field.TypeInt, value)
  544. _node.Dontseeit = value
  545. }
  546. if value, ok := cc.mutation.Dontseeme(); ok {
  547. _spec.SetField(contact.FieldDontseeme, field.TypeInt, value)
  548. _node.Dontseeme = value
  549. }
  550. if value, ok := cc.mutation.Lag(); ok {
  551. _spec.SetField(contact.FieldLag, field.TypeString, value)
  552. _node.Lag = value
  553. }
  554. if value, ok := cc.mutation.Gid(); ok {
  555. _spec.SetField(contact.FieldGid, field.TypeString, value)
  556. _node.Gid = value
  557. }
  558. if value, ok := cc.mutation.Gname(); ok {
  559. _spec.SetField(contact.FieldGname, field.TypeString, value)
  560. _node.Gname = value
  561. }
  562. if value, ok := cc.mutation.V3(); ok {
  563. _spec.SetField(contact.FieldV3, field.TypeString, value)
  564. _node.V3 = value
  565. }
  566. if value, ok := cc.mutation.OrganizationID(); ok {
  567. _spec.SetField(contact.FieldOrganizationID, field.TypeUint64, value)
  568. _node.OrganizationID = value
  569. }
  570. if nodes := cc.mutation.ContactRelationshipsIDs(); len(nodes) > 0 {
  571. edge := &sqlgraph.EdgeSpec{
  572. Rel: sqlgraph.O2M,
  573. Inverse: false,
  574. Table: contact.ContactRelationshipsTable,
  575. Columns: []string{contact.ContactRelationshipsColumn},
  576. Bidi: false,
  577. Target: &sqlgraph.EdgeTarget{
  578. IDSpec: sqlgraph.NewFieldSpec(labelrelationship.FieldID, field.TypeUint64),
  579. },
  580. }
  581. for _, k := range nodes {
  582. edge.Target.Nodes = append(edge.Target.Nodes, k)
  583. }
  584. _spec.Edges = append(_spec.Edges, edge)
  585. }
  586. if nodes := cc.mutation.ContactMessagesIDs(); len(nodes) > 0 {
  587. edge := &sqlgraph.EdgeSpec{
  588. Rel: sqlgraph.O2M,
  589. Inverse: false,
  590. Table: contact.ContactMessagesTable,
  591. Columns: []string{contact.ContactMessagesColumn},
  592. Bidi: false,
  593. Target: &sqlgraph.EdgeTarget{
  594. IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
  595. },
  596. }
  597. for _, k := range nodes {
  598. edge.Target.Nodes = append(edge.Target.Nodes, k)
  599. }
  600. _spec.Edges = append(_spec.Edges, edge)
  601. }
  602. return _node, _spec
  603. }
  604. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  605. // of the `INSERT` statement. For example:
  606. //
  607. // client.Contact.Create().
  608. // SetCreatedAt(v).
  609. // OnConflict(
  610. // // Update the row with the new values
  611. // // the was proposed for insertion.
  612. // sql.ResolveWithNewValues(),
  613. // ).
  614. // // Override some of the fields with custom
  615. // // update values.
  616. // Update(func(u *ent.ContactUpsert) {
  617. // SetCreatedAt(v+v).
  618. // }).
  619. // Exec(ctx)
  620. func (cc *ContactCreate) OnConflict(opts ...sql.ConflictOption) *ContactUpsertOne {
  621. cc.conflict = opts
  622. return &ContactUpsertOne{
  623. create: cc,
  624. }
  625. }
  626. // OnConflictColumns calls `OnConflict` and configures the columns
  627. // as conflict target. Using this option is equivalent to using:
  628. //
  629. // client.Contact.Create().
  630. // OnConflict(sql.ConflictColumns(columns...)).
  631. // Exec(ctx)
  632. func (cc *ContactCreate) OnConflictColumns(columns ...string) *ContactUpsertOne {
  633. cc.conflict = append(cc.conflict, sql.ConflictColumns(columns...))
  634. return &ContactUpsertOne{
  635. create: cc,
  636. }
  637. }
  638. type (
  639. // ContactUpsertOne is the builder for "upsert"-ing
  640. // one Contact node.
  641. ContactUpsertOne struct {
  642. create *ContactCreate
  643. }
  644. // ContactUpsert is the "OnConflict" setter.
  645. ContactUpsert struct {
  646. *sql.UpdateSet
  647. }
  648. )
  649. // SetUpdatedAt sets the "updated_at" field.
  650. func (u *ContactUpsert) SetUpdatedAt(v time.Time) *ContactUpsert {
  651. u.Set(contact.FieldUpdatedAt, v)
  652. return u
  653. }
  654. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  655. func (u *ContactUpsert) UpdateUpdatedAt() *ContactUpsert {
  656. u.SetExcluded(contact.FieldUpdatedAt)
  657. return u
  658. }
  659. // SetStatus sets the "status" field.
  660. func (u *ContactUpsert) SetStatus(v uint8) *ContactUpsert {
  661. u.Set(contact.FieldStatus, v)
  662. return u
  663. }
  664. // UpdateStatus sets the "status" field to the value that was provided on create.
  665. func (u *ContactUpsert) UpdateStatus() *ContactUpsert {
  666. u.SetExcluded(contact.FieldStatus)
  667. return u
  668. }
  669. // AddStatus adds v to the "status" field.
  670. func (u *ContactUpsert) AddStatus(v uint8) *ContactUpsert {
  671. u.Add(contact.FieldStatus, v)
  672. return u
  673. }
  674. // ClearStatus clears the value of the "status" field.
  675. func (u *ContactUpsert) ClearStatus() *ContactUpsert {
  676. u.SetNull(contact.FieldStatus)
  677. return u
  678. }
  679. // SetDeletedAt sets the "deleted_at" field.
  680. func (u *ContactUpsert) SetDeletedAt(v time.Time) *ContactUpsert {
  681. u.Set(contact.FieldDeletedAt, v)
  682. return u
  683. }
  684. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  685. func (u *ContactUpsert) UpdateDeletedAt() *ContactUpsert {
  686. u.SetExcluded(contact.FieldDeletedAt)
  687. return u
  688. }
  689. // ClearDeletedAt clears the value of the "deleted_at" field.
  690. func (u *ContactUpsert) ClearDeletedAt() *ContactUpsert {
  691. u.SetNull(contact.FieldDeletedAt)
  692. return u
  693. }
  694. // SetWxWxid sets the "wx_wxid" field.
  695. func (u *ContactUpsert) SetWxWxid(v string) *ContactUpsert {
  696. u.Set(contact.FieldWxWxid, v)
  697. return u
  698. }
  699. // UpdateWxWxid sets the "wx_wxid" field to the value that was provided on create.
  700. func (u *ContactUpsert) UpdateWxWxid() *ContactUpsert {
  701. u.SetExcluded(contact.FieldWxWxid)
  702. return u
  703. }
  704. // SetType sets the "type" field.
  705. func (u *ContactUpsert) SetType(v int) *ContactUpsert {
  706. u.Set(contact.FieldType, v)
  707. return u
  708. }
  709. // UpdateType sets the "type" field to the value that was provided on create.
  710. func (u *ContactUpsert) UpdateType() *ContactUpsert {
  711. u.SetExcluded(contact.FieldType)
  712. return u
  713. }
  714. // AddType adds v to the "type" field.
  715. func (u *ContactUpsert) AddType(v int) *ContactUpsert {
  716. u.Add(contact.FieldType, v)
  717. return u
  718. }
  719. // ClearType clears the value of the "type" field.
  720. func (u *ContactUpsert) ClearType() *ContactUpsert {
  721. u.SetNull(contact.FieldType)
  722. return u
  723. }
  724. // SetWxid sets the "wxid" field.
  725. func (u *ContactUpsert) SetWxid(v string) *ContactUpsert {
  726. u.Set(contact.FieldWxid, v)
  727. return u
  728. }
  729. // UpdateWxid sets the "wxid" field to the value that was provided on create.
  730. func (u *ContactUpsert) UpdateWxid() *ContactUpsert {
  731. u.SetExcluded(contact.FieldWxid)
  732. return u
  733. }
  734. // SetAccount sets the "account" field.
  735. func (u *ContactUpsert) SetAccount(v string) *ContactUpsert {
  736. u.Set(contact.FieldAccount, v)
  737. return u
  738. }
  739. // UpdateAccount sets the "account" field to the value that was provided on create.
  740. func (u *ContactUpsert) UpdateAccount() *ContactUpsert {
  741. u.SetExcluded(contact.FieldAccount)
  742. return u
  743. }
  744. // SetNickname sets the "nickname" field.
  745. func (u *ContactUpsert) SetNickname(v string) *ContactUpsert {
  746. u.Set(contact.FieldNickname, v)
  747. return u
  748. }
  749. // UpdateNickname sets the "nickname" field to the value that was provided on create.
  750. func (u *ContactUpsert) UpdateNickname() *ContactUpsert {
  751. u.SetExcluded(contact.FieldNickname)
  752. return u
  753. }
  754. // SetMarkname sets the "markname" field.
  755. func (u *ContactUpsert) SetMarkname(v string) *ContactUpsert {
  756. u.Set(contact.FieldMarkname, v)
  757. return u
  758. }
  759. // UpdateMarkname sets the "markname" field to the value that was provided on create.
  760. func (u *ContactUpsert) UpdateMarkname() *ContactUpsert {
  761. u.SetExcluded(contact.FieldMarkname)
  762. return u
  763. }
  764. // SetHeadimg sets the "headimg" field.
  765. func (u *ContactUpsert) SetHeadimg(v string) *ContactUpsert {
  766. u.Set(contact.FieldHeadimg, v)
  767. return u
  768. }
  769. // UpdateHeadimg sets the "headimg" field to the value that was provided on create.
  770. func (u *ContactUpsert) UpdateHeadimg() *ContactUpsert {
  771. u.SetExcluded(contact.FieldHeadimg)
  772. return u
  773. }
  774. // SetSex sets the "sex" field.
  775. func (u *ContactUpsert) SetSex(v int) *ContactUpsert {
  776. u.Set(contact.FieldSex, v)
  777. return u
  778. }
  779. // UpdateSex sets the "sex" field to the value that was provided on create.
  780. func (u *ContactUpsert) UpdateSex() *ContactUpsert {
  781. u.SetExcluded(contact.FieldSex)
  782. return u
  783. }
  784. // AddSex adds v to the "sex" field.
  785. func (u *ContactUpsert) AddSex(v int) *ContactUpsert {
  786. u.Add(contact.FieldSex, v)
  787. return u
  788. }
  789. // SetStarrole sets the "starrole" field.
  790. func (u *ContactUpsert) SetStarrole(v string) *ContactUpsert {
  791. u.Set(contact.FieldStarrole, v)
  792. return u
  793. }
  794. // UpdateStarrole sets the "starrole" field to the value that was provided on create.
  795. func (u *ContactUpsert) UpdateStarrole() *ContactUpsert {
  796. u.SetExcluded(contact.FieldStarrole)
  797. return u
  798. }
  799. // SetDontseeit sets the "dontseeit" field.
  800. func (u *ContactUpsert) SetDontseeit(v int) *ContactUpsert {
  801. u.Set(contact.FieldDontseeit, v)
  802. return u
  803. }
  804. // UpdateDontseeit sets the "dontseeit" field to the value that was provided on create.
  805. func (u *ContactUpsert) UpdateDontseeit() *ContactUpsert {
  806. u.SetExcluded(contact.FieldDontseeit)
  807. return u
  808. }
  809. // AddDontseeit adds v to the "dontseeit" field.
  810. func (u *ContactUpsert) AddDontseeit(v int) *ContactUpsert {
  811. u.Add(contact.FieldDontseeit, v)
  812. return u
  813. }
  814. // SetDontseeme sets the "dontseeme" field.
  815. func (u *ContactUpsert) SetDontseeme(v int) *ContactUpsert {
  816. u.Set(contact.FieldDontseeme, v)
  817. return u
  818. }
  819. // UpdateDontseeme sets the "dontseeme" field to the value that was provided on create.
  820. func (u *ContactUpsert) UpdateDontseeme() *ContactUpsert {
  821. u.SetExcluded(contact.FieldDontseeme)
  822. return u
  823. }
  824. // AddDontseeme adds v to the "dontseeme" field.
  825. func (u *ContactUpsert) AddDontseeme(v int) *ContactUpsert {
  826. u.Add(contact.FieldDontseeme, v)
  827. return u
  828. }
  829. // SetLag sets the "lag" field.
  830. func (u *ContactUpsert) SetLag(v string) *ContactUpsert {
  831. u.Set(contact.FieldLag, v)
  832. return u
  833. }
  834. // UpdateLag sets the "lag" field to the value that was provided on create.
  835. func (u *ContactUpsert) UpdateLag() *ContactUpsert {
  836. u.SetExcluded(contact.FieldLag)
  837. return u
  838. }
  839. // SetGid sets the "gid" field.
  840. func (u *ContactUpsert) SetGid(v string) *ContactUpsert {
  841. u.Set(contact.FieldGid, v)
  842. return u
  843. }
  844. // UpdateGid sets the "gid" field to the value that was provided on create.
  845. func (u *ContactUpsert) UpdateGid() *ContactUpsert {
  846. u.SetExcluded(contact.FieldGid)
  847. return u
  848. }
  849. // SetGname sets the "gname" field.
  850. func (u *ContactUpsert) SetGname(v string) *ContactUpsert {
  851. u.Set(contact.FieldGname, v)
  852. return u
  853. }
  854. // UpdateGname sets the "gname" field to the value that was provided on create.
  855. func (u *ContactUpsert) UpdateGname() *ContactUpsert {
  856. u.SetExcluded(contact.FieldGname)
  857. return u
  858. }
  859. // SetV3 sets the "v3" field.
  860. func (u *ContactUpsert) SetV3(v string) *ContactUpsert {
  861. u.Set(contact.FieldV3, v)
  862. return u
  863. }
  864. // UpdateV3 sets the "v3" field to the value that was provided on create.
  865. func (u *ContactUpsert) UpdateV3() *ContactUpsert {
  866. u.SetExcluded(contact.FieldV3)
  867. return u
  868. }
  869. // SetOrganizationID sets the "organization_id" field.
  870. func (u *ContactUpsert) SetOrganizationID(v uint64) *ContactUpsert {
  871. u.Set(contact.FieldOrganizationID, v)
  872. return u
  873. }
  874. // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
  875. func (u *ContactUpsert) UpdateOrganizationID() *ContactUpsert {
  876. u.SetExcluded(contact.FieldOrganizationID)
  877. return u
  878. }
  879. // AddOrganizationID adds v to the "organization_id" field.
  880. func (u *ContactUpsert) AddOrganizationID(v uint64) *ContactUpsert {
  881. u.Add(contact.FieldOrganizationID, v)
  882. return u
  883. }
  884. // ClearOrganizationID clears the value of the "organization_id" field.
  885. func (u *ContactUpsert) ClearOrganizationID() *ContactUpsert {
  886. u.SetNull(contact.FieldOrganizationID)
  887. return u
  888. }
  889. // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
  890. // Using this option is equivalent to using:
  891. //
  892. // client.Contact.Create().
  893. // OnConflict(
  894. // sql.ResolveWithNewValues(),
  895. // sql.ResolveWith(func(u *sql.UpdateSet) {
  896. // u.SetIgnore(contact.FieldID)
  897. // }),
  898. // ).
  899. // Exec(ctx)
  900. func (u *ContactUpsertOne) UpdateNewValues() *ContactUpsertOne {
  901. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  902. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  903. if _, exists := u.create.mutation.ID(); exists {
  904. s.SetIgnore(contact.FieldID)
  905. }
  906. if _, exists := u.create.mutation.CreatedAt(); exists {
  907. s.SetIgnore(contact.FieldCreatedAt)
  908. }
  909. }))
  910. return u
  911. }
  912. // Ignore sets each column to itself in case of conflict.
  913. // Using this option is equivalent to using:
  914. //
  915. // client.Contact.Create().
  916. // OnConflict(sql.ResolveWithIgnore()).
  917. // Exec(ctx)
  918. func (u *ContactUpsertOne) Ignore() *ContactUpsertOne {
  919. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  920. return u
  921. }
  922. // DoNothing configures the conflict_action to `DO NOTHING`.
  923. // Supported only by SQLite and PostgreSQL.
  924. func (u *ContactUpsertOne) DoNothing() *ContactUpsertOne {
  925. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  926. return u
  927. }
  928. // Update allows overriding fields `UPDATE` values. See the ContactCreate.OnConflict
  929. // documentation for more info.
  930. func (u *ContactUpsertOne) Update(set func(*ContactUpsert)) *ContactUpsertOne {
  931. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  932. set(&ContactUpsert{UpdateSet: update})
  933. }))
  934. return u
  935. }
  936. // SetUpdatedAt sets the "updated_at" field.
  937. func (u *ContactUpsertOne) SetUpdatedAt(v time.Time) *ContactUpsertOne {
  938. return u.Update(func(s *ContactUpsert) {
  939. s.SetUpdatedAt(v)
  940. })
  941. }
  942. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  943. func (u *ContactUpsertOne) UpdateUpdatedAt() *ContactUpsertOne {
  944. return u.Update(func(s *ContactUpsert) {
  945. s.UpdateUpdatedAt()
  946. })
  947. }
  948. // SetStatus sets the "status" field.
  949. func (u *ContactUpsertOne) SetStatus(v uint8) *ContactUpsertOne {
  950. return u.Update(func(s *ContactUpsert) {
  951. s.SetStatus(v)
  952. })
  953. }
  954. // AddStatus adds v to the "status" field.
  955. func (u *ContactUpsertOne) AddStatus(v uint8) *ContactUpsertOne {
  956. return u.Update(func(s *ContactUpsert) {
  957. s.AddStatus(v)
  958. })
  959. }
  960. // UpdateStatus sets the "status" field to the value that was provided on create.
  961. func (u *ContactUpsertOne) UpdateStatus() *ContactUpsertOne {
  962. return u.Update(func(s *ContactUpsert) {
  963. s.UpdateStatus()
  964. })
  965. }
  966. // ClearStatus clears the value of the "status" field.
  967. func (u *ContactUpsertOne) ClearStatus() *ContactUpsertOne {
  968. return u.Update(func(s *ContactUpsert) {
  969. s.ClearStatus()
  970. })
  971. }
  972. // SetDeletedAt sets the "deleted_at" field.
  973. func (u *ContactUpsertOne) SetDeletedAt(v time.Time) *ContactUpsertOne {
  974. return u.Update(func(s *ContactUpsert) {
  975. s.SetDeletedAt(v)
  976. })
  977. }
  978. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  979. func (u *ContactUpsertOne) UpdateDeletedAt() *ContactUpsertOne {
  980. return u.Update(func(s *ContactUpsert) {
  981. s.UpdateDeletedAt()
  982. })
  983. }
  984. // ClearDeletedAt clears the value of the "deleted_at" field.
  985. func (u *ContactUpsertOne) ClearDeletedAt() *ContactUpsertOne {
  986. return u.Update(func(s *ContactUpsert) {
  987. s.ClearDeletedAt()
  988. })
  989. }
  990. // SetWxWxid sets the "wx_wxid" field.
  991. func (u *ContactUpsertOne) SetWxWxid(v string) *ContactUpsertOne {
  992. return u.Update(func(s *ContactUpsert) {
  993. s.SetWxWxid(v)
  994. })
  995. }
  996. // UpdateWxWxid sets the "wx_wxid" field to the value that was provided on create.
  997. func (u *ContactUpsertOne) UpdateWxWxid() *ContactUpsertOne {
  998. return u.Update(func(s *ContactUpsert) {
  999. s.UpdateWxWxid()
  1000. })
  1001. }
  1002. // SetType sets the "type" field.
  1003. func (u *ContactUpsertOne) SetType(v int) *ContactUpsertOne {
  1004. return u.Update(func(s *ContactUpsert) {
  1005. s.SetType(v)
  1006. })
  1007. }
  1008. // AddType adds v to the "type" field.
  1009. func (u *ContactUpsertOne) AddType(v int) *ContactUpsertOne {
  1010. return u.Update(func(s *ContactUpsert) {
  1011. s.AddType(v)
  1012. })
  1013. }
  1014. // UpdateType sets the "type" field to the value that was provided on create.
  1015. func (u *ContactUpsertOne) UpdateType() *ContactUpsertOne {
  1016. return u.Update(func(s *ContactUpsert) {
  1017. s.UpdateType()
  1018. })
  1019. }
  1020. // ClearType clears the value of the "type" field.
  1021. func (u *ContactUpsertOne) ClearType() *ContactUpsertOne {
  1022. return u.Update(func(s *ContactUpsert) {
  1023. s.ClearType()
  1024. })
  1025. }
  1026. // SetWxid sets the "wxid" field.
  1027. func (u *ContactUpsertOne) SetWxid(v string) *ContactUpsertOne {
  1028. return u.Update(func(s *ContactUpsert) {
  1029. s.SetWxid(v)
  1030. })
  1031. }
  1032. // UpdateWxid sets the "wxid" field to the value that was provided on create.
  1033. func (u *ContactUpsertOne) UpdateWxid() *ContactUpsertOne {
  1034. return u.Update(func(s *ContactUpsert) {
  1035. s.UpdateWxid()
  1036. })
  1037. }
  1038. // SetAccount sets the "account" field.
  1039. func (u *ContactUpsertOne) SetAccount(v string) *ContactUpsertOne {
  1040. return u.Update(func(s *ContactUpsert) {
  1041. s.SetAccount(v)
  1042. })
  1043. }
  1044. // UpdateAccount sets the "account" field to the value that was provided on create.
  1045. func (u *ContactUpsertOne) UpdateAccount() *ContactUpsertOne {
  1046. return u.Update(func(s *ContactUpsert) {
  1047. s.UpdateAccount()
  1048. })
  1049. }
  1050. // SetNickname sets the "nickname" field.
  1051. func (u *ContactUpsertOne) SetNickname(v string) *ContactUpsertOne {
  1052. return u.Update(func(s *ContactUpsert) {
  1053. s.SetNickname(v)
  1054. })
  1055. }
  1056. // UpdateNickname sets the "nickname" field to the value that was provided on create.
  1057. func (u *ContactUpsertOne) UpdateNickname() *ContactUpsertOne {
  1058. return u.Update(func(s *ContactUpsert) {
  1059. s.UpdateNickname()
  1060. })
  1061. }
  1062. // SetMarkname sets the "markname" field.
  1063. func (u *ContactUpsertOne) SetMarkname(v string) *ContactUpsertOne {
  1064. return u.Update(func(s *ContactUpsert) {
  1065. s.SetMarkname(v)
  1066. })
  1067. }
  1068. // UpdateMarkname sets the "markname" field to the value that was provided on create.
  1069. func (u *ContactUpsertOne) UpdateMarkname() *ContactUpsertOne {
  1070. return u.Update(func(s *ContactUpsert) {
  1071. s.UpdateMarkname()
  1072. })
  1073. }
  1074. // SetHeadimg sets the "headimg" field.
  1075. func (u *ContactUpsertOne) SetHeadimg(v string) *ContactUpsertOne {
  1076. return u.Update(func(s *ContactUpsert) {
  1077. s.SetHeadimg(v)
  1078. })
  1079. }
  1080. // UpdateHeadimg sets the "headimg" field to the value that was provided on create.
  1081. func (u *ContactUpsertOne) UpdateHeadimg() *ContactUpsertOne {
  1082. return u.Update(func(s *ContactUpsert) {
  1083. s.UpdateHeadimg()
  1084. })
  1085. }
  1086. // SetSex sets the "sex" field.
  1087. func (u *ContactUpsertOne) SetSex(v int) *ContactUpsertOne {
  1088. return u.Update(func(s *ContactUpsert) {
  1089. s.SetSex(v)
  1090. })
  1091. }
  1092. // AddSex adds v to the "sex" field.
  1093. func (u *ContactUpsertOne) AddSex(v int) *ContactUpsertOne {
  1094. return u.Update(func(s *ContactUpsert) {
  1095. s.AddSex(v)
  1096. })
  1097. }
  1098. // UpdateSex sets the "sex" field to the value that was provided on create.
  1099. func (u *ContactUpsertOne) UpdateSex() *ContactUpsertOne {
  1100. return u.Update(func(s *ContactUpsert) {
  1101. s.UpdateSex()
  1102. })
  1103. }
  1104. // SetStarrole sets the "starrole" field.
  1105. func (u *ContactUpsertOne) SetStarrole(v string) *ContactUpsertOne {
  1106. return u.Update(func(s *ContactUpsert) {
  1107. s.SetStarrole(v)
  1108. })
  1109. }
  1110. // UpdateStarrole sets the "starrole" field to the value that was provided on create.
  1111. func (u *ContactUpsertOne) UpdateStarrole() *ContactUpsertOne {
  1112. return u.Update(func(s *ContactUpsert) {
  1113. s.UpdateStarrole()
  1114. })
  1115. }
  1116. // SetDontseeit sets the "dontseeit" field.
  1117. func (u *ContactUpsertOne) SetDontseeit(v int) *ContactUpsertOne {
  1118. return u.Update(func(s *ContactUpsert) {
  1119. s.SetDontseeit(v)
  1120. })
  1121. }
  1122. // AddDontseeit adds v to the "dontseeit" field.
  1123. func (u *ContactUpsertOne) AddDontseeit(v int) *ContactUpsertOne {
  1124. return u.Update(func(s *ContactUpsert) {
  1125. s.AddDontseeit(v)
  1126. })
  1127. }
  1128. // UpdateDontseeit sets the "dontseeit" field to the value that was provided on create.
  1129. func (u *ContactUpsertOne) UpdateDontseeit() *ContactUpsertOne {
  1130. return u.Update(func(s *ContactUpsert) {
  1131. s.UpdateDontseeit()
  1132. })
  1133. }
  1134. // SetDontseeme sets the "dontseeme" field.
  1135. func (u *ContactUpsertOne) SetDontseeme(v int) *ContactUpsertOne {
  1136. return u.Update(func(s *ContactUpsert) {
  1137. s.SetDontseeme(v)
  1138. })
  1139. }
  1140. // AddDontseeme adds v to the "dontseeme" field.
  1141. func (u *ContactUpsertOne) AddDontseeme(v int) *ContactUpsertOne {
  1142. return u.Update(func(s *ContactUpsert) {
  1143. s.AddDontseeme(v)
  1144. })
  1145. }
  1146. // UpdateDontseeme sets the "dontseeme" field to the value that was provided on create.
  1147. func (u *ContactUpsertOne) UpdateDontseeme() *ContactUpsertOne {
  1148. return u.Update(func(s *ContactUpsert) {
  1149. s.UpdateDontseeme()
  1150. })
  1151. }
  1152. // SetLag sets the "lag" field.
  1153. func (u *ContactUpsertOne) SetLag(v string) *ContactUpsertOne {
  1154. return u.Update(func(s *ContactUpsert) {
  1155. s.SetLag(v)
  1156. })
  1157. }
  1158. // UpdateLag sets the "lag" field to the value that was provided on create.
  1159. func (u *ContactUpsertOne) UpdateLag() *ContactUpsertOne {
  1160. return u.Update(func(s *ContactUpsert) {
  1161. s.UpdateLag()
  1162. })
  1163. }
  1164. // SetGid sets the "gid" field.
  1165. func (u *ContactUpsertOne) SetGid(v string) *ContactUpsertOne {
  1166. return u.Update(func(s *ContactUpsert) {
  1167. s.SetGid(v)
  1168. })
  1169. }
  1170. // UpdateGid sets the "gid" field to the value that was provided on create.
  1171. func (u *ContactUpsertOne) UpdateGid() *ContactUpsertOne {
  1172. return u.Update(func(s *ContactUpsert) {
  1173. s.UpdateGid()
  1174. })
  1175. }
  1176. // SetGname sets the "gname" field.
  1177. func (u *ContactUpsertOne) SetGname(v string) *ContactUpsertOne {
  1178. return u.Update(func(s *ContactUpsert) {
  1179. s.SetGname(v)
  1180. })
  1181. }
  1182. // UpdateGname sets the "gname" field to the value that was provided on create.
  1183. func (u *ContactUpsertOne) UpdateGname() *ContactUpsertOne {
  1184. return u.Update(func(s *ContactUpsert) {
  1185. s.UpdateGname()
  1186. })
  1187. }
  1188. // SetV3 sets the "v3" field.
  1189. func (u *ContactUpsertOne) SetV3(v string) *ContactUpsertOne {
  1190. return u.Update(func(s *ContactUpsert) {
  1191. s.SetV3(v)
  1192. })
  1193. }
  1194. // UpdateV3 sets the "v3" field to the value that was provided on create.
  1195. func (u *ContactUpsertOne) UpdateV3() *ContactUpsertOne {
  1196. return u.Update(func(s *ContactUpsert) {
  1197. s.UpdateV3()
  1198. })
  1199. }
  1200. // SetOrganizationID sets the "organization_id" field.
  1201. func (u *ContactUpsertOne) SetOrganizationID(v uint64) *ContactUpsertOne {
  1202. return u.Update(func(s *ContactUpsert) {
  1203. s.SetOrganizationID(v)
  1204. })
  1205. }
  1206. // AddOrganizationID adds v to the "organization_id" field.
  1207. func (u *ContactUpsertOne) AddOrganizationID(v uint64) *ContactUpsertOne {
  1208. return u.Update(func(s *ContactUpsert) {
  1209. s.AddOrganizationID(v)
  1210. })
  1211. }
  1212. // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
  1213. func (u *ContactUpsertOne) UpdateOrganizationID() *ContactUpsertOne {
  1214. return u.Update(func(s *ContactUpsert) {
  1215. s.UpdateOrganizationID()
  1216. })
  1217. }
  1218. // ClearOrganizationID clears the value of the "organization_id" field.
  1219. func (u *ContactUpsertOne) ClearOrganizationID() *ContactUpsertOne {
  1220. return u.Update(func(s *ContactUpsert) {
  1221. s.ClearOrganizationID()
  1222. })
  1223. }
  1224. // Exec executes the query.
  1225. func (u *ContactUpsertOne) Exec(ctx context.Context) error {
  1226. if len(u.create.conflict) == 0 {
  1227. return errors.New("ent: missing options for ContactCreate.OnConflict")
  1228. }
  1229. return u.create.Exec(ctx)
  1230. }
  1231. // ExecX is like Exec, but panics if an error occurs.
  1232. func (u *ContactUpsertOne) ExecX(ctx context.Context) {
  1233. if err := u.create.Exec(ctx); err != nil {
  1234. panic(err)
  1235. }
  1236. }
  1237. // Exec executes the UPSERT query and returns the inserted/updated ID.
  1238. func (u *ContactUpsertOne) ID(ctx context.Context) (id uint64, err error) {
  1239. node, err := u.create.Save(ctx)
  1240. if err != nil {
  1241. return id, err
  1242. }
  1243. return node.ID, nil
  1244. }
  1245. // IDX is like ID, but panics if an error occurs.
  1246. func (u *ContactUpsertOne) IDX(ctx context.Context) uint64 {
  1247. id, err := u.ID(ctx)
  1248. if err != nil {
  1249. panic(err)
  1250. }
  1251. return id
  1252. }
  1253. // ContactCreateBulk is the builder for creating many Contact entities in bulk.
  1254. type ContactCreateBulk struct {
  1255. config
  1256. err error
  1257. builders []*ContactCreate
  1258. conflict []sql.ConflictOption
  1259. }
  1260. // Save creates the Contact entities in the database.
  1261. func (ccb *ContactCreateBulk) Save(ctx context.Context) ([]*Contact, error) {
  1262. if ccb.err != nil {
  1263. return nil, ccb.err
  1264. }
  1265. specs := make([]*sqlgraph.CreateSpec, len(ccb.builders))
  1266. nodes := make([]*Contact, len(ccb.builders))
  1267. mutators := make([]Mutator, len(ccb.builders))
  1268. for i := range ccb.builders {
  1269. func(i int, root context.Context) {
  1270. builder := ccb.builders[i]
  1271. builder.defaults()
  1272. var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
  1273. mutation, ok := m.(*ContactMutation)
  1274. if !ok {
  1275. return nil, fmt.Errorf("unexpected mutation type %T", m)
  1276. }
  1277. if err := builder.check(); err != nil {
  1278. return nil, err
  1279. }
  1280. builder.mutation = mutation
  1281. var err error
  1282. nodes[i], specs[i] = builder.createSpec()
  1283. if i < len(mutators)-1 {
  1284. _, err = mutators[i+1].Mutate(root, ccb.builders[i+1].mutation)
  1285. } else {
  1286. spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
  1287. spec.OnConflict = ccb.conflict
  1288. // Invoke the actual operation on the latest mutation in the chain.
  1289. if err = sqlgraph.BatchCreate(ctx, ccb.driver, spec); err != nil {
  1290. if sqlgraph.IsConstraintError(err) {
  1291. err = &ConstraintError{msg: err.Error(), wrap: err}
  1292. }
  1293. }
  1294. }
  1295. if err != nil {
  1296. return nil, err
  1297. }
  1298. mutation.id = &nodes[i].ID
  1299. if specs[i].ID.Value != nil && nodes[i].ID == 0 {
  1300. id := specs[i].ID.Value.(int64)
  1301. nodes[i].ID = uint64(id)
  1302. }
  1303. mutation.done = true
  1304. return nodes[i], nil
  1305. })
  1306. for i := len(builder.hooks) - 1; i >= 0; i-- {
  1307. mut = builder.hooks[i](mut)
  1308. }
  1309. mutators[i] = mut
  1310. }(i, ctx)
  1311. }
  1312. if len(mutators) > 0 {
  1313. if _, err := mutators[0].Mutate(ctx, ccb.builders[0].mutation); err != nil {
  1314. return nil, err
  1315. }
  1316. }
  1317. return nodes, nil
  1318. }
  1319. // SaveX is like Save, but panics if an error occurs.
  1320. func (ccb *ContactCreateBulk) SaveX(ctx context.Context) []*Contact {
  1321. v, err := ccb.Save(ctx)
  1322. if err != nil {
  1323. panic(err)
  1324. }
  1325. return v
  1326. }
  1327. // Exec executes the query.
  1328. func (ccb *ContactCreateBulk) Exec(ctx context.Context) error {
  1329. _, err := ccb.Save(ctx)
  1330. return err
  1331. }
  1332. // ExecX is like Exec, but panics if an error occurs.
  1333. func (ccb *ContactCreateBulk) ExecX(ctx context.Context) {
  1334. if err := ccb.Exec(ctx); err != nil {
  1335. panic(err)
  1336. }
  1337. }
  1338. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  1339. // of the `INSERT` statement. For example:
  1340. //
  1341. // client.Contact.CreateBulk(builders...).
  1342. // OnConflict(
  1343. // // Update the row with the new values
  1344. // // the was proposed for insertion.
  1345. // sql.ResolveWithNewValues(),
  1346. // ).
  1347. // // Override some of the fields with custom
  1348. // // update values.
  1349. // Update(func(u *ent.ContactUpsert) {
  1350. // SetCreatedAt(v+v).
  1351. // }).
  1352. // Exec(ctx)
  1353. func (ccb *ContactCreateBulk) OnConflict(opts ...sql.ConflictOption) *ContactUpsertBulk {
  1354. ccb.conflict = opts
  1355. return &ContactUpsertBulk{
  1356. create: ccb,
  1357. }
  1358. }
  1359. // OnConflictColumns calls `OnConflict` and configures the columns
  1360. // as conflict target. Using this option is equivalent to using:
  1361. //
  1362. // client.Contact.Create().
  1363. // OnConflict(sql.ConflictColumns(columns...)).
  1364. // Exec(ctx)
  1365. func (ccb *ContactCreateBulk) OnConflictColumns(columns ...string) *ContactUpsertBulk {
  1366. ccb.conflict = append(ccb.conflict, sql.ConflictColumns(columns...))
  1367. return &ContactUpsertBulk{
  1368. create: ccb,
  1369. }
  1370. }
  1371. // ContactUpsertBulk is the builder for "upsert"-ing
  1372. // a bulk of Contact nodes.
  1373. type ContactUpsertBulk struct {
  1374. create *ContactCreateBulk
  1375. }
  1376. // UpdateNewValues updates the mutable fields using the new values that
  1377. // were set on create. Using this option is equivalent to using:
  1378. //
  1379. // client.Contact.Create().
  1380. // OnConflict(
  1381. // sql.ResolveWithNewValues(),
  1382. // sql.ResolveWith(func(u *sql.UpdateSet) {
  1383. // u.SetIgnore(contact.FieldID)
  1384. // }),
  1385. // ).
  1386. // Exec(ctx)
  1387. func (u *ContactUpsertBulk) UpdateNewValues() *ContactUpsertBulk {
  1388. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  1389. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  1390. for _, b := range u.create.builders {
  1391. if _, exists := b.mutation.ID(); exists {
  1392. s.SetIgnore(contact.FieldID)
  1393. }
  1394. if _, exists := b.mutation.CreatedAt(); exists {
  1395. s.SetIgnore(contact.FieldCreatedAt)
  1396. }
  1397. }
  1398. }))
  1399. return u
  1400. }
  1401. // Ignore sets each column to itself in case of conflict.
  1402. // Using this option is equivalent to using:
  1403. //
  1404. // client.Contact.Create().
  1405. // OnConflict(sql.ResolveWithIgnore()).
  1406. // Exec(ctx)
  1407. func (u *ContactUpsertBulk) Ignore() *ContactUpsertBulk {
  1408. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  1409. return u
  1410. }
  1411. // DoNothing configures the conflict_action to `DO NOTHING`.
  1412. // Supported only by SQLite and PostgreSQL.
  1413. func (u *ContactUpsertBulk) DoNothing() *ContactUpsertBulk {
  1414. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  1415. return u
  1416. }
  1417. // Update allows overriding fields `UPDATE` values. See the ContactCreateBulk.OnConflict
  1418. // documentation for more info.
  1419. func (u *ContactUpsertBulk) Update(set func(*ContactUpsert)) *ContactUpsertBulk {
  1420. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  1421. set(&ContactUpsert{UpdateSet: update})
  1422. }))
  1423. return u
  1424. }
  1425. // SetUpdatedAt sets the "updated_at" field.
  1426. func (u *ContactUpsertBulk) SetUpdatedAt(v time.Time) *ContactUpsertBulk {
  1427. return u.Update(func(s *ContactUpsert) {
  1428. s.SetUpdatedAt(v)
  1429. })
  1430. }
  1431. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  1432. func (u *ContactUpsertBulk) UpdateUpdatedAt() *ContactUpsertBulk {
  1433. return u.Update(func(s *ContactUpsert) {
  1434. s.UpdateUpdatedAt()
  1435. })
  1436. }
  1437. // SetStatus sets the "status" field.
  1438. func (u *ContactUpsertBulk) SetStatus(v uint8) *ContactUpsertBulk {
  1439. return u.Update(func(s *ContactUpsert) {
  1440. s.SetStatus(v)
  1441. })
  1442. }
  1443. // AddStatus adds v to the "status" field.
  1444. func (u *ContactUpsertBulk) AddStatus(v uint8) *ContactUpsertBulk {
  1445. return u.Update(func(s *ContactUpsert) {
  1446. s.AddStatus(v)
  1447. })
  1448. }
  1449. // UpdateStatus sets the "status" field to the value that was provided on create.
  1450. func (u *ContactUpsertBulk) UpdateStatus() *ContactUpsertBulk {
  1451. return u.Update(func(s *ContactUpsert) {
  1452. s.UpdateStatus()
  1453. })
  1454. }
  1455. // ClearStatus clears the value of the "status" field.
  1456. func (u *ContactUpsertBulk) ClearStatus() *ContactUpsertBulk {
  1457. return u.Update(func(s *ContactUpsert) {
  1458. s.ClearStatus()
  1459. })
  1460. }
  1461. // SetDeletedAt sets the "deleted_at" field.
  1462. func (u *ContactUpsertBulk) SetDeletedAt(v time.Time) *ContactUpsertBulk {
  1463. return u.Update(func(s *ContactUpsert) {
  1464. s.SetDeletedAt(v)
  1465. })
  1466. }
  1467. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  1468. func (u *ContactUpsertBulk) UpdateDeletedAt() *ContactUpsertBulk {
  1469. return u.Update(func(s *ContactUpsert) {
  1470. s.UpdateDeletedAt()
  1471. })
  1472. }
  1473. // ClearDeletedAt clears the value of the "deleted_at" field.
  1474. func (u *ContactUpsertBulk) ClearDeletedAt() *ContactUpsertBulk {
  1475. return u.Update(func(s *ContactUpsert) {
  1476. s.ClearDeletedAt()
  1477. })
  1478. }
  1479. // SetWxWxid sets the "wx_wxid" field.
  1480. func (u *ContactUpsertBulk) SetWxWxid(v string) *ContactUpsertBulk {
  1481. return u.Update(func(s *ContactUpsert) {
  1482. s.SetWxWxid(v)
  1483. })
  1484. }
  1485. // UpdateWxWxid sets the "wx_wxid" field to the value that was provided on create.
  1486. func (u *ContactUpsertBulk) UpdateWxWxid() *ContactUpsertBulk {
  1487. return u.Update(func(s *ContactUpsert) {
  1488. s.UpdateWxWxid()
  1489. })
  1490. }
  1491. // SetType sets the "type" field.
  1492. func (u *ContactUpsertBulk) SetType(v int) *ContactUpsertBulk {
  1493. return u.Update(func(s *ContactUpsert) {
  1494. s.SetType(v)
  1495. })
  1496. }
  1497. // AddType adds v to the "type" field.
  1498. func (u *ContactUpsertBulk) AddType(v int) *ContactUpsertBulk {
  1499. return u.Update(func(s *ContactUpsert) {
  1500. s.AddType(v)
  1501. })
  1502. }
  1503. // UpdateType sets the "type" field to the value that was provided on create.
  1504. func (u *ContactUpsertBulk) UpdateType() *ContactUpsertBulk {
  1505. return u.Update(func(s *ContactUpsert) {
  1506. s.UpdateType()
  1507. })
  1508. }
  1509. // ClearType clears the value of the "type" field.
  1510. func (u *ContactUpsertBulk) ClearType() *ContactUpsertBulk {
  1511. return u.Update(func(s *ContactUpsert) {
  1512. s.ClearType()
  1513. })
  1514. }
  1515. // SetWxid sets the "wxid" field.
  1516. func (u *ContactUpsertBulk) SetWxid(v string) *ContactUpsertBulk {
  1517. return u.Update(func(s *ContactUpsert) {
  1518. s.SetWxid(v)
  1519. })
  1520. }
  1521. // UpdateWxid sets the "wxid" field to the value that was provided on create.
  1522. func (u *ContactUpsertBulk) UpdateWxid() *ContactUpsertBulk {
  1523. return u.Update(func(s *ContactUpsert) {
  1524. s.UpdateWxid()
  1525. })
  1526. }
  1527. // SetAccount sets the "account" field.
  1528. func (u *ContactUpsertBulk) SetAccount(v string) *ContactUpsertBulk {
  1529. return u.Update(func(s *ContactUpsert) {
  1530. s.SetAccount(v)
  1531. })
  1532. }
  1533. // UpdateAccount sets the "account" field to the value that was provided on create.
  1534. func (u *ContactUpsertBulk) UpdateAccount() *ContactUpsertBulk {
  1535. return u.Update(func(s *ContactUpsert) {
  1536. s.UpdateAccount()
  1537. })
  1538. }
  1539. // SetNickname sets the "nickname" field.
  1540. func (u *ContactUpsertBulk) SetNickname(v string) *ContactUpsertBulk {
  1541. return u.Update(func(s *ContactUpsert) {
  1542. s.SetNickname(v)
  1543. })
  1544. }
  1545. // UpdateNickname sets the "nickname" field to the value that was provided on create.
  1546. func (u *ContactUpsertBulk) UpdateNickname() *ContactUpsertBulk {
  1547. return u.Update(func(s *ContactUpsert) {
  1548. s.UpdateNickname()
  1549. })
  1550. }
  1551. // SetMarkname sets the "markname" field.
  1552. func (u *ContactUpsertBulk) SetMarkname(v string) *ContactUpsertBulk {
  1553. return u.Update(func(s *ContactUpsert) {
  1554. s.SetMarkname(v)
  1555. })
  1556. }
  1557. // UpdateMarkname sets the "markname" field to the value that was provided on create.
  1558. func (u *ContactUpsertBulk) UpdateMarkname() *ContactUpsertBulk {
  1559. return u.Update(func(s *ContactUpsert) {
  1560. s.UpdateMarkname()
  1561. })
  1562. }
  1563. // SetHeadimg sets the "headimg" field.
  1564. func (u *ContactUpsertBulk) SetHeadimg(v string) *ContactUpsertBulk {
  1565. return u.Update(func(s *ContactUpsert) {
  1566. s.SetHeadimg(v)
  1567. })
  1568. }
  1569. // UpdateHeadimg sets the "headimg" field to the value that was provided on create.
  1570. func (u *ContactUpsertBulk) UpdateHeadimg() *ContactUpsertBulk {
  1571. return u.Update(func(s *ContactUpsert) {
  1572. s.UpdateHeadimg()
  1573. })
  1574. }
  1575. // SetSex sets the "sex" field.
  1576. func (u *ContactUpsertBulk) SetSex(v int) *ContactUpsertBulk {
  1577. return u.Update(func(s *ContactUpsert) {
  1578. s.SetSex(v)
  1579. })
  1580. }
  1581. // AddSex adds v to the "sex" field.
  1582. func (u *ContactUpsertBulk) AddSex(v int) *ContactUpsertBulk {
  1583. return u.Update(func(s *ContactUpsert) {
  1584. s.AddSex(v)
  1585. })
  1586. }
  1587. // UpdateSex sets the "sex" field to the value that was provided on create.
  1588. func (u *ContactUpsertBulk) UpdateSex() *ContactUpsertBulk {
  1589. return u.Update(func(s *ContactUpsert) {
  1590. s.UpdateSex()
  1591. })
  1592. }
  1593. // SetStarrole sets the "starrole" field.
  1594. func (u *ContactUpsertBulk) SetStarrole(v string) *ContactUpsertBulk {
  1595. return u.Update(func(s *ContactUpsert) {
  1596. s.SetStarrole(v)
  1597. })
  1598. }
  1599. // UpdateStarrole sets the "starrole" field to the value that was provided on create.
  1600. func (u *ContactUpsertBulk) UpdateStarrole() *ContactUpsertBulk {
  1601. return u.Update(func(s *ContactUpsert) {
  1602. s.UpdateStarrole()
  1603. })
  1604. }
  1605. // SetDontseeit sets the "dontseeit" field.
  1606. func (u *ContactUpsertBulk) SetDontseeit(v int) *ContactUpsertBulk {
  1607. return u.Update(func(s *ContactUpsert) {
  1608. s.SetDontseeit(v)
  1609. })
  1610. }
  1611. // AddDontseeit adds v to the "dontseeit" field.
  1612. func (u *ContactUpsertBulk) AddDontseeit(v int) *ContactUpsertBulk {
  1613. return u.Update(func(s *ContactUpsert) {
  1614. s.AddDontseeit(v)
  1615. })
  1616. }
  1617. // UpdateDontseeit sets the "dontseeit" field to the value that was provided on create.
  1618. func (u *ContactUpsertBulk) UpdateDontseeit() *ContactUpsertBulk {
  1619. return u.Update(func(s *ContactUpsert) {
  1620. s.UpdateDontseeit()
  1621. })
  1622. }
  1623. // SetDontseeme sets the "dontseeme" field.
  1624. func (u *ContactUpsertBulk) SetDontseeme(v int) *ContactUpsertBulk {
  1625. return u.Update(func(s *ContactUpsert) {
  1626. s.SetDontseeme(v)
  1627. })
  1628. }
  1629. // AddDontseeme adds v to the "dontseeme" field.
  1630. func (u *ContactUpsertBulk) AddDontseeme(v int) *ContactUpsertBulk {
  1631. return u.Update(func(s *ContactUpsert) {
  1632. s.AddDontseeme(v)
  1633. })
  1634. }
  1635. // UpdateDontseeme sets the "dontseeme" field to the value that was provided on create.
  1636. func (u *ContactUpsertBulk) UpdateDontseeme() *ContactUpsertBulk {
  1637. return u.Update(func(s *ContactUpsert) {
  1638. s.UpdateDontseeme()
  1639. })
  1640. }
  1641. // SetLag sets the "lag" field.
  1642. func (u *ContactUpsertBulk) SetLag(v string) *ContactUpsertBulk {
  1643. return u.Update(func(s *ContactUpsert) {
  1644. s.SetLag(v)
  1645. })
  1646. }
  1647. // UpdateLag sets the "lag" field to the value that was provided on create.
  1648. func (u *ContactUpsertBulk) UpdateLag() *ContactUpsertBulk {
  1649. return u.Update(func(s *ContactUpsert) {
  1650. s.UpdateLag()
  1651. })
  1652. }
  1653. // SetGid sets the "gid" field.
  1654. func (u *ContactUpsertBulk) SetGid(v string) *ContactUpsertBulk {
  1655. return u.Update(func(s *ContactUpsert) {
  1656. s.SetGid(v)
  1657. })
  1658. }
  1659. // UpdateGid sets the "gid" field to the value that was provided on create.
  1660. func (u *ContactUpsertBulk) UpdateGid() *ContactUpsertBulk {
  1661. return u.Update(func(s *ContactUpsert) {
  1662. s.UpdateGid()
  1663. })
  1664. }
  1665. // SetGname sets the "gname" field.
  1666. func (u *ContactUpsertBulk) SetGname(v string) *ContactUpsertBulk {
  1667. return u.Update(func(s *ContactUpsert) {
  1668. s.SetGname(v)
  1669. })
  1670. }
  1671. // UpdateGname sets the "gname" field to the value that was provided on create.
  1672. func (u *ContactUpsertBulk) UpdateGname() *ContactUpsertBulk {
  1673. return u.Update(func(s *ContactUpsert) {
  1674. s.UpdateGname()
  1675. })
  1676. }
  1677. // SetV3 sets the "v3" field.
  1678. func (u *ContactUpsertBulk) SetV3(v string) *ContactUpsertBulk {
  1679. return u.Update(func(s *ContactUpsert) {
  1680. s.SetV3(v)
  1681. })
  1682. }
  1683. // UpdateV3 sets the "v3" field to the value that was provided on create.
  1684. func (u *ContactUpsertBulk) UpdateV3() *ContactUpsertBulk {
  1685. return u.Update(func(s *ContactUpsert) {
  1686. s.UpdateV3()
  1687. })
  1688. }
  1689. // SetOrganizationID sets the "organization_id" field.
  1690. func (u *ContactUpsertBulk) SetOrganizationID(v uint64) *ContactUpsertBulk {
  1691. return u.Update(func(s *ContactUpsert) {
  1692. s.SetOrganizationID(v)
  1693. })
  1694. }
  1695. // AddOrganizationID adds v to the "organization_id" field.
  1696. func (u *ContactUpsertBulk) AddOrganizationID(v uint64) *ContactUpsertBulk {
  1697. return u.Update(func(s *ContactUpsert) {
  1698. s.AddOrganizationID(v)
  1699. })
  1700. }
  1701. // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
  1702. func (u *ContactUpsertBulk) UpdateOrganizationID() *ContactUpsertBulk {
  1703. return u.Update(func(s *ContactUpsert) {
  1704. s.UpdateOrganizationID()
  1705. })
  1706. }
  1707. // ClearOrganizationID clears the value of the "organization_id" field.
  1708. func (u *ContactUpsertBulk) ClearOrganizationID() *ContactUpsertBulk {
  1709. return u.Update(func(s *ContactUpsert) {
  1710. s.ClearOrganizationID()
  1711. })
  1712. }
  1713. // Exec executes the query.
  1714. func (u *ContactUpsertBulk) Exec(ctx context.Context) error {
  1715. if u.create.err != nil {
  1716. return u.create.err
  1717. }
  1718. for i, b := range u.create.builders {
  1719. if len(b.conflict) != 0 {
  1720. return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the ContactCreateBulk instead", i)
  1721. }
  1722. }
  1723. if len(u.create.conflict) == 0 {
  1724. return errors.New("ent: missing options for ContactCreateBulk.OnConflict")
  1725. }
  1726. return u.create.Exec(ctx)
  1727. }
  1728. // ExecX is like Exec, but panics if an error occurs.
  1729. func (u *ContactUpsertBulk) ExecX(ctx context.Context) {
  1730. if err := u.create.Exec(ctx); err != nil {
  1731. panic(err)
  1732. }
  1733. }