contact_create.go 54 KB

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