wxcard_create.go 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743
  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/wxcard"
  9. "entgo.io/ent/dialect/sql"
  10. "entgo.io/ent/dialect/sql/sqlgraph"
  11. "entgo.io/ent/schema/field"
  12. )
  13. // WxCardCreate is the builder for creating a WxCard entity.
  14. type WxCardCreate struct {
  15. config
  16. mutation *WxCardMutation
  17. hooks []Hook
  18. conflict []sql.ConflictOption
  19. }
  20. // SetCreatedAt sets the "created_at" field.
  21. func (wcc *WxCardCreate) SetCreatedAt(t time.Time) *WxCardCreate {
  22. wcc.mutation.SetCreatedAt(t)
  23. return wcc
  24. }
  25. // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
  26. func (wcc *WxCardCreate) SetNillableCreatedAt(t *time.Time) *WxCardCreate {
  27. if t != nil {
  28. wcc.SetCreatedAt(*t)
  29. }
  30. return wcc
  31. }
  32. // SetUpdatedAt sets the "updated_at" field.
  33. func (wcc *WxCardCreate) SetUpdatedAt(t time.Time) *WxCardCreate {
  34. wcc.mutation.SetUpdatedAt(t)
  35. return wcc
  36. }
  37. // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
  38. func (wcc *WxCardCreate) SetNillableUpdatedAt(t *time.Time) *WxCardCreate {
  39. if t != nil {
  40. wcc.SetUpdatedAt(*t)
  41. }
  42. return wcc
  43. }
  44. // SetDeletedAt sets the "deleted_at" field.
  45. func (wcc *WxCardCreate) SetDeletedAt(t time.Time) *WxCardCreate {
  46. wcc.mutation.SetDeletedAt(t)
  47. return wcc
  48. }
  49. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  50. func (wcc *WxCardCreate) SetNillableDeletedAt(t *time.Time) *WxCardCreate {
  51. if t != nil {
  52. wcc.SetDeletedAt(*t)
  53. }
  54. return wcc
  55. }
  56. // SetUserID sets the "user_id" field.
  57. func (wcc *WxCardCreate) SetUserID(u uint64) *WxCardCreate {
  58. wcc.mutation.SetUserID(u)
  59. return wcc
  60. }
  61. // SetNillableUserID sets the "user_id" field if the given value is not nil.
  62. func (wcc *WxCardCreate) SetNillableUserID(u *uint64) *WxCardCreate {
  63. if u != nil {
  64. wcc.SetUserID(*u)
  65. }
  66. return wcc
  67. }
  68. // SetWxUserID sets the "wx_user_id" field.
  69. func (wcc *WxCardCreate) SetWxUserID(u uint64) *WxCardCreate {
  70. wcc.mutation.SetWxUserID(u)
  71. return wcc
  72. }
  73. // SetNillableWxUserID sets the "wx_user_id" field if the given value is not nil.
  74. func (wcc *WxCardCreate) SetNillableWxUserID(u *uint64) *WxCardCreate {
  75. if u != nil {
  76. wcc.SetWxUserID(*u)
  77. }
  78. return wcc
  79. }
  80. // SetAvatar sets the "avatar" field.
  81. func (wcc *WxCardCreate) SetAvatar(s string) *WxCardCreate {
  82. wcc.mutation.SetAvatar(s)
  83. return wcc
  84. }
  85. // SetNillableAvatar sets the "avatar" field if the given value is not nil.
  86. func (wcc *WxCardCreate) SetNillableAvatar(s *string) *WxCardCreate {
  87. if s != nil {
  88. wcc.SetAvatar(*s)
  89. }
  90. return wcc
  91. }
  92. // SetLogo sets the "logo" field.
  93. func (wcc *WxCardCreate) SetLogo(s string) *WxCardCreate {
  94. wcc.mutation.SetLogo(s)
  95. return wcc
  96. }
  97. // SetNillableLogo sets the "logo" field if the given value is not nil.
  98. func (wcc *WxCardCreate) SetNillableLogo(s *string) *WxCardCreate {
  99. if s != nil {
  100. wcc.SetLogo(*s)
  101. }
  102. return wcc
  103. }
  104. // SetName sets the "name" field.
  105. func (wcc *WxCardCreate) SetName(s string) *WxCardCreate {
  106. wcc.mutation.SetName(s)
  107. return wcc
  108. }
  109. // SetNillableName sets the "name" field if the given value is not nil.
  110. func (wcc *WxCardCreate) SetNillableName(s *string) *WxCardCreate {
  111. if s != nil {
  112. wcc.SetName(*s)
  113. }
  114. return wcc
  115. }
  116. // SetCompany sets the "company" field.
  117. func (wcc *WxCardCreate) SetCompany(s string) *WxCardCreate {
  118. wcc.mutation.SetCompany(s)
  119. return wcc
  120. }
  121. // SetNillableCompany sets the "company" field if the given value is not nil.
  122. func (wcc *WxCardCreate) SetNillableCompany(s *string) *WxCardCreate {
  123. if s != nil {
  124. wcc.SetCompany(*s)
  125. }
  126. return wcc
  127. }
  128. // SetAddress sets the "address" field.
  129. func (wcc *WxCardCreate) SetAddress(s string) *WxCardCreate {
  130. wcc.mutation.SetAddress(s)
  131. return wcc
  132. }
  133. // SetNillableAddress sets the "address" field if the given value is not nil.
  134. func (wcc *WxCardCreate) SetNillableAddress(s *string) *WxCardCreate {
  135. if s != nil {
  136. wcc.SetAddress(*s)
  137. }
  138. return wcc
  139. }
  140. // SetPhone sets the "phone" field.
  141. func (wcc *WxCardCreate) SetPhone(s string) *WxCardCreate {
  142. wcc.mutation.SetPhone(s)
  143. return wcc
  144. }
  145. // SetNillablePhone sets the "phone" field if the given value is not nil.
  146. func (wcc *WxCardCreate) SetNillablePhone(s *string) *WxCardCreate {
  147. if s != nil {
  148. wcc.SetPhone(*s)
  149. }
  150. return wcc
  151. }
  152. // SetOfficialAccount sets the "official_account" field.
  153. func (wcc *WxCardCreate) SetOfficialAccount(s string) *WxCardCreate {
  154. wcc.mutation.SetOfficialAccount(s)
  155. return wcc
  156. }
  157. // SetNillableOfficialAccount sets the "official_account" field if the given value is not nil.
  158. func (wcc *WxCardCreate) SetNillableOfficialAccount(s *string) *WxCardCreate {
  159. if s != nil {
  160. wcc.SetOfficialAccount(*s)
  161. }
  162. return wcc
  163. }
  164. // SetWechatAccount sets the "wechat_account" field.
  165. func (wcc *WxCardCreate) SetWechatAccount(s string) *WxCardCreate {
  166. wcc.mutation.SetWechatAccount(s)
  167. return wcc
  168. }
  169. // SetNillableWechatAccount sets the "wechat_account" field if the given value is not nil.
  170. func (wcc *WxCardCreate) SetNillableWechatAccount(s *string) *WxCardCreate {
  171. if s != nil {
  172. wcc.SetWechatAccount(*s)
  173. }
  174. return wcc
  175. }
  176. // SetEmail sets the "email" field.
  177. func (wcc *WxCardCreate) SetEmail(s string) *WxCardCreate {
  178. wcc.mutation.SetEmail(s)
  179. return wcc
  180. }
  181. // SetNillableEmail sets the "email" field if the given value is not nil.
  182. func (wcc *WxCardCreate) SetNillableEmail(s *string) *WxCardCreate {
  183. if s != nil {
  184. wcc.SetEmail(*s)
  185. }
  186. return wcc
  187. }
  188. // SetAPIBase sets the "api_base" field.
  189. func (wcc *WxCardCreate) SetAPIBase(s string) *WxCardCreate {
  190. wcc.mutation.SetAPIBase(s)
  191. return wcc
  192. }
  193. // SetNillableAPIBase sets the "api_base" field if the given value is not nil.
  194. func (wcc *WxCardCreate) SetNillableAPIBase(s *string) *WxCardCreate {
  195. if s != nil {
  196. wcc.SetAPIBase(*s)
  197. }
  198. return wcc
  199. }
  200. // SetAPIKey sets the "api_key" field.
  201. func (wcc *WxCardCreate) SetAPIKey(s string) *WxCardCreate {
  202. wcc.mutation.SetAPIKey(s)
  203. return wcc
  204. }
  205. // SetNillableAPIKey sets the "api_key" field if the given value is not nil.
  206. func (wcc *WxCardCreate) SetNillableAPIKey(s *string) *WxCardCreate {
  207. if s != nil {
  208. wcc.SetAPIKey(*s)
  209. }
  210. return wcc
  211. }
  212. // SetAiInfo sets the "ai_info" field.
  213. func (wcc *WxCardCreate) SetAiInfo(s string) *WxCardCreate {
  214. wcc.mutation.SetAiInfo(s)
  215. return wcc
  216. }
  217. // SetNillableAiInfo sets the "ai_info" field if the given value is not nil.
  218. func (wcc *WxCardCreate) SetNillableAiInfo(s *string) *WxCardCreate {
  219. if s != nil {
  220. wcc.SetAiInfo(*s)
  221. }
  222. return wcc
  223. }
  224. // SetIntro sets the "intro" field.
  225. func (wcc *WxCardCreate) SetIntro(s string) *WxCardCreate {
  226. wcc.mutation.SetIntro(s)
  227. return wcc
  228. }
  229. // SetNillableIntro sets the "intro" field if the given value is not nil.
  230. func (wcc *WxCardCreate) SetNillableIntro(s *string) *WxCardCreate {
  231. if s != nil {
  232. wcc.SetIntro(*s)
  233. }
  234. return wcc
  235. }
  236. // SetID sets the "id" field.
  237. func (wcc *WxCardCreate) SetID(u uint64) *WxCardCreate {
  238. wcc.mutation.SetID(u)
  239. return wcc
  240. }
  241. // Mutation returns the WxCardMutation object of the builder.
  242. func (wcc *WxCardCreate) Mutation() *WxCardMutation {
  243. return wcc.mutation
  244. }
  245. // Save creates the WxCard in the database.
  246. func (wcc *WxCardCreate) Save(ctx context.Context) (*WxCard, error) {
  247. if err := wcc.defaults(); err != nil {
  248. return nil, err
  249. }
  250. return withHooks(ctx, wcc.sqlSave, wcc.mutation, wcc.hooks)
  251. }
  252. // SaveX calls Save and panics if Save returns an error.
  253. func (wcc *WxCardCreate) SaveX(ctx context.Context) *WxCard {
  254. v, err := wcc.Save(ctx)
  255. if err != nil {
  256. panic(err)
  257. }
  258. return v
  259. }
  260. // Exec executes the query.
  261. func (wcc *WxCardCreate) Exec(ctx context.Context) error {
  262. _, err := wcc.Save(ctx)
  263. return err
  264. }
  265. // ExecX is like Exec, but panics if an error occurs.
  266. func (wcc *WxCardCreate) ExecX(ctx context.Context) {
  267. if err := wcc.Exec(ctx); err != nil {
  268. panic(err)
  269. }
  270. }
  271. // defaults sets the default values of the builder before save.
  272. func (wcc *WxCardCreate) defaults() error {
  273. if _, ok := wcc.mutation.CreatedAt(); !ok {
  274. if wxcard.DefaultCreatedAt == nil {
  275. return fmt.Errorf("ent: uninitialized wxcard.DefaultCreatedAt (forgotten import ent/runtime?)")
  276. }
  277. v := wxcard.DefaultCreatedAt()
  278. wcc.mutation.SetCreatedAt(v)
  279. }
  280. if _, ok := wcc.mutation.UpdatedAt(); !ok {
  281. if wxcard.DefaultUpdatedAt == nil {
  282. return fmt.Errorf("ent: uninitialized wxcard.DefaultUpdatedAt (forgotten import ent/runtime?)")
  283. }
  284. v := wxcard.DefaultUpdatedAt()
  285. wcc.mutation.SetUpdatedAt(v)
  286. }
  287. if _, ok := wcc.mutation.UserID(); !ok {
  288. v := wxcard.DefaultUserID
  289. wcc.mutation.SetUserID(v)
  290. }
  291. if _, ok := wcc.mutation.WxUserID(); !ok {
  292. v := wxcard.DefaultWxUserID
  293. wcc.mutation.SetWxUserID(v)
  294. }
  295. if _, ok := wcc.mutation.Avatar(); !ok {
  296. v := wxcard.DefaultAvatar
  297. wcc.mutation.SetAvatar(v)
  298. }
  299. if _, ok := wcc.mutation.Logo(); !ok {
  300. v := wxcard.DefaultLogo
  301. wcc.mutation.SetLogo(v)
  302. }
  303. if _, ok := wcc.mutation.Name(); !ok {
  304. v := wxcard.DefaultName
  305. wcc.mutation.SetName(v)
  306. }
  307. if _, ok := wcc.mutation.Company(); !ok {
  308. v := wxcard.DefaultCompany
  309. wcc.mutation.SetCompany(v)
  310. }
  311. if _, ok := wcc.mutation.Address(); !ok {
  312. v := wxcard.DefaultAddress
  313. wcc.mutation.SetAddress(v)
  314. }
  315. if _, ok := wcc.mutation.Phone(); !ok {
  316. v := wxcard.DefaultPhone
  317. wcc.mutation.SetPhone(v)
  318. }
  319. if _, ok := wcc.mutation.OfficialAccount(); !ok {
  320. v := wxcard.DefaultOfficialAccount
  321. wcc.mutation.SetOfficialAccount(v)
  322. }
  323. if _, ok := wcc.mutation.WechatAccount(); !ok {
  324. v := wxcard.DefaultWechatAccount
  325. wcc.mutation.SetWechatAccount(v)
  326. }
  327. if _, ok := wcc.mutation.Email(); !ok {
  328. v := wxcard.DefaultEmail
  329. wcc.mutation.SetEmail(v)
  330. }
  331. if _, ok := wcc.mutation.Intro(); !ok {
  332. v := wxcard.DefaultIntro
  333. wcc.mutation.SetIntro(v)
  334. }
  335. return nil
  336. }
  337. // check runs all checks and user-defined validators on the builder.
  338. func (wcc *WxCardCreate) check() error {
  339. if _, ok := wcc.mutation.CreatedAt(); !ok {
  340. return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "WxCard.created_at"`)}
  341. }
  342. if _, ok := wcc.mutation.UpdatedAt(); !ok {
  343. return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "WxCard.updated_at"`)}
  344. }
  345. if _, ok := wcc.mutation.Avatar(); !ok {
  346. return &ValidationError{Name: "avatar", err: errors.New(`ent: missing required field "WxCard.avatar"`)}
  347. }
  348. if _, ok := wcc.mutation.Logo(); !ok {
  349. return &ValidationError{Name: "logo", err: errors.New(`ent: missing required field "WxCard.logo"`)}
  350. }
  351. if _, ok := wcc.mutation.Name(); !ok {
  352. return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "WxCard.name"`)}
  353. }
  354. if _, ok := wcc.mutation.Company(); !ok {
  355. return &ValidationError{Name: "company", err: errors.New(`ent: missing required field "WxCard.company"`)}
  356. }
  357. if _, ok := wcc.mutation.Address(); !ok {
  358. return &ValidationError{Name: "address", err: errors.New(`ent: missing required field "WxCard.address"`)}
  359. }
  360. if _, ok := wcc.mutation.Phone(); !ok {
  361. return &ValidationError{Name: "phone", err: errors.New(`ent: missing required field "WxCard.phone"`)}
  362. }
  363. if _, ok := wcc.mutation.OfficialAccount(); !ok {
  364. return &ValidationError{Name: "official_account", err: errors.New(`ent: missing required field "WxCard.official_account"`)}
  365. }
  366. if _, ok := wcc.mutation.WechatAccount(); !ok {
  367. return &ValidationError{Name: "wechat_account", err: errors.New(`ent: missing required field "WxCard.wechat_account"`)}
  368. }
  369. return nil
  370. }
  371. func (wcc *WxCardCreate) sqlSave(ctx context.Context) (*WxCard, error) {
  372. if err := wcc.check(); err != nil {
  373. return nil, err
  374. }
  375. _node, _spec := wcc.createSpec()
  376. if err := sqlgraph.CreateNode(ctx, wcc.driver, _spec); err != nil {
  377. if sqlgraph.IsConstraintError(err) {
  378. err = &ConstraintError{msg: err.Error(), wrap: err}
  379. }
  380. return nil, err
  381. }
  382. if _spec.ID.Value != _node.ID {
  383. id := _spec.ID.Value.(int64)
  384. _node.ID = uint64(id)
  385. }
  386. wcc.mutation.id = &_node.ID
  387. wcc.mutation.done = true
  388. return _node, nil
  389. }
  390. func (wcc *WxCardCreate) createSpec() (*WxCard, *sqlgraph.CreateSpec) {
  391. var (
  392. _node = &WxCard{config: wcc.config}
  393. _spec = sqlgraph.NewCreateSpec(wxcard.Table, sqlgraph.NewFieldSpec(wxcard.FieldID, field.TypeUint64))
  394. )
  395. _spec.OnConflict = wcc.conflict
  396. if id, ok := wcc.mutation.ID(); ok {
  397. _node.ID = id
  398. _spec.ID.Value = id
  399. }
  400. if value, ok := wcc.mutation.CreatedAt(); ok {
  401. _spec.SetField(wxcard.FieldCreatedAt, field.TypeTime, value)
  402. _node.CreatedAt = value
  403. }
  404. if value, ok := wcc.mutation.UpdatedAt(); ok {
  405. _spec.SetField(wxcard.FieldUpdatedAt, field.TypeTime, value)
  406. _node.UpdatedAt = value
  407. }
  408. if value, ok := wcc.mutation.DeletedAt(); ok {
  409. _spec.SetField(wxcard.FieldDeletedAt, field.TypeTime, value)
  410. _node.DeletedAt = value
  411. }
  412. if value, ok := wcc.mutation.UserID(); ok {
  413. _spec.SetField(wxcard.FieldUserID, field.TypeUint64, value)
  414. _node.UserID = value
  415. }
  416. if value, ok := wcc.mutation.WxUserID(); ok {
  417. _spec.SetField(wxcard.FieldWxUserID, field.TypeUint64, value)
  418. _node.WxUserID = value
  419. }
  420. if value, ok := wcc.mutation.Avatar(); ok {
  421. _spec.SetField(wxcard.FieldAvatar, field.TypeString, value)
  422. _node.Avatar = value
  423. }
  424. if value, ok := wcc.mutation.Logo(); ok {
  425. _spec.SetField(wxcard.FieldLogo, field.TypeString, value)
  426. _node.Logo = value
  427. }
  428. if value, ok := wcc.mutation.Name(); ok {
  429. _spec.SetField(wxcard.FieldName, field.TypeString, value)
  430. _node.Name = value
  431. }
  432. if value, ok := wcc.mutation.Company(); ok {
  433. _spec.SetField(wxcard.FieldCompany, field.TypeString, value)
  434. _node.Company = value
  435. }
  436. if value, ok := wcc.mutation.Address(); ok {
  437. _spec.SetField(wxcard.FieldAddress, field.TypeString, value)
  438. _node.Address = value
  439. }
  440. if value, ok := wcc.mutation.Phone(); ok {
  441. _spec.SetField(wxcard.FieldPhone, field.TypeString, value)
  442. _node.Phone = value
  443. }
  444. if value, ok := wcc.mutation.OfficialAccount(); ok {
  445. _spec.SetField(wxcard.FieldOfficialAccount, field.TypeString, value)
  446. _node.OfficialAccount = value
  447. }
  448. if value, ok := wcc.mutation.WechatAccount(); ok {
  449. _spec.SetField(wxcard.FieldWechatAccount, field.TypeString, value)
  450. _node.WechatAccount = value
  451. }
  452. if value, ok := wcc.mutation.Email(); ok {
  453. _spec.SetField(wxcard.FieldEmail, field.TypeString, value)
  454. _node.Email = value
  455. }
  456. if value, ok := wcc.mutation.APIBase(); ok {
  457. _spec.SetField(wxcard.FieldAPIBase, field.TypeString, value)
  458. _node.APIBase = value
  459. }
  460. if value, ok := wcc.mutation.APIKey(); ok {
  461. _spec.SetField(wxcard.FieldAPIKey, field.TypeString, value)
  462. _node.APIKey = value
  463. }
  464. if value, ok := wcc.mutation.AiInfo(); ok {
  465. _spec.SetField(wxcard.FieldAiInfo, field.TypeString, value)
  466. _node.AiInfo = value
  467. }
  468. if value, ok := wcc.mutation.Intro(); ok {
  469. _spec.SetField(wxcard.FieldIntro, field.TypeString, value)
  470. _node.Intro = value
  471. }
  472. return _node, _spec
  473. }
  474. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  475. // of the `INSERT` statement. For example:
  476. //
  477. // client.WxCard.Create().
  478. // SetCreatedAt(v).
  479. // OnConflict(
  480. // // Update the row with the new values
  481. // // the was proposed for insertion.
  482. // sql.ResolveWithNewValues(),
  483. // ).
  484. // // Override some of the fields with custom
  485. // // update values.
  486. // Update(func(u *ent.WxCardUpsert) {
  487. // SetCreatedAt(v+v).
  488. // }).
  489. // Exec(ctx)
  490. func (wcc *WxCardCreate) OnConflict(opts ...sql.ConflictOption) *WxCardUpsertOne {
  491. wcc.conflict = opts
  492. return &WxCardUpsertOne{
  493. create: wcc,
  494. }
  495. }
  496. // OnConflictColumns calls `OnConflict` and configures the columns
  497. // as conflict target. Using this option is equivalent to using:
  498. //
  499. // client.WxCard.Create().
  500. // OnConflict(sql.ConflictColumns(columns...)).
  501. // Exec(ctx)
  502. func (wcc *WxCardCreate) OnConflictColumns(columns ...string) *WxCardUpsertOne {
  503. wcc.conflict = append(wcc.conflict, sql.ConflictColumns(columns...))
  504. return &WxCardUpsertOne{
  505. create: wcc,
  506. }
  507. }
  508. type (
  509. // WxCardUpsertOne is the builder for "upsert"-ing
  510. // one WxCard node.
  511. WxCardUpsertOne struct {
  512. create *WxCardCreate
  513. }
  514. // WxCardUpsert is the "OnConflict" setter.
  515. WxCardUpsert struct {
  516. *sql.UpdateSet
  517. }
  518. )
  519. // SetUpdatedAt sets the "updated_at" field.
  520. func (u *WxCardUpsert) SetUpdatedAt(v time.Time) *WxCardUpsert {
  521. u.Set(wxcard.FieldUpdatedAt, v)
  522. return u
  523. }
  524. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  525. func (u *WxCardUpsert) UpdateUpdatedAt() *WxCardUpsert {
  526. u.SetExcluded(wxcard.FieldUpdatedAt)
  527. return u
  528. }
  529. // SetDeletedAt sets the "deleted_at" field.
  530. func (u *WxCardUpsert) SetDeletedAt(v time.Time) *WxCardUpsert {
  531. u.Set(wxcard.FieldDeletedAt, v)
  532. return u
  533. }
  534. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  535. func (u *WxCardUpsert) UpdateDeletedAt() *WxCardUpsert {
  536. u.SetExcluded(wxcard.FieldDeletedAt)
  537. return u
  538. }
  539. // ClearDeletedAt clears the value of the "deleted_at" field.
  540. func (u *WxCardUpsert) ClearDeletedAt() *WxCardUpsert {
  541. u.SetNull(wxcard.FieldDeletedAt)
  542. return u
  543. }
  544. // SetUserID sets the "user_id" field.
  545. func (u *WxCardUpsert) SetUserID(v uint64) *WxCardUpsert {
  546. u.Set(wxcard.FieldUserID, v)
  547. return u
  548. }
  549. // UpdateUserID sets the "user_id" field to the value that was provided on create.
  550. func (u *WxCardUpsert) UpdateUserID() *WxCardUpsert {
  551. u.SetExcluded(wxcard.FieldUserID)
  552. return u
  553. }
  554. // AddUserID adds v to the "user_id" field.
  555. func (u *WxCardUpsert) AddUserID(v uint64) *WxCardUpsert {
  556. u.Add(wxcard.FieldUserID, v)
  557. return u
  558. }
  559. // ClearUserID clears the value of the "user_id" field.
  560. func (u *WxCardUpsert) ClearUserID() *WxCardUpsert {
  561. u.SetNull(wxcard.FieldUserID)
  562. return u
  563. }
  564. // SetWxUserID sets the "wx_user_id" field.
  565. func (u *WxCardUpsert) SetWxUserID(v uint64) *WxCardUpsert {
  566. u.Set(wxcard.FieldWxUserID, v)
  567. return u
  568. }
  569. // UpdateWxUserID sets the "wx_user_id" field to the value that was provided on create.
  570. func (u *WxCardUpsert) UpdateWxUserID() *WxCardUpsert {
  571. u.SetExcluded(wxcard.FieldWxUserID)
  572. return u
  573. }
  574. // AddWxUserID adds v to the "wx_user_id" field.
  575. func (u *WxCardUpsert) AddWxUserID(v uint64) *WxCardUpsert {
  576. u.Add(wxcard.FieldWxUserID, v)
  577. return u
  578. }
  579. // ClearWxUserID clears the value of the "wx_user_id" field.
  580. func (u *WxCardUpsert) ClearWxUserID() *WxCardUpsert {
  581. u.SetNull(wxcard.FieldWxUserID)
  582. return u
  583. }
  584. // SetAvatar sets the "avatar" field.
  585. func (u *WxCardUpsert) SetAvatar(v string) *WxCardUpsert {
  586. u.Set(wxcard.FieldAvatar, v)
  587. return u
  588. }
  589. // UpdateAvatar sets the "avatar" field to the value that was provided on create.
  590. func (u *WxCardUpsert) UpdateAvatar() *WxCardUpsert {
  591. u.SetExcluded(wxcard.FieldAvatar)
  592. return u
  593. }
  594. // SetLogo sets the "logo" field.
  595. func (u *WxCardUpsert) SetLogo(v string) *WxCardUpsert {
  596. u.Set(wxcard.FieldLogo, v)
  597. return u
  598. }
  599. // UpdateLogo sets the "logo" field to the value that was provided on create.
  600. func (u *WxCardUpsert) UpdateLogo() *WxCardUpsert {
  601. u.SetExcluded(wxcard.FieldLogo)
  602. return u
  603. }
  604. // SetName sets the "name" field.
  605. func (u *WxCardUpsert) SetName(v string) *WxCardUpsert {
  606. u.Set(wxcard.FieldName, v)
  607. return u
  608. }
  609. // UpdateName sets the "name" field to the value that was provided on create.
  610. func (u *WxCardUpsert) UpdateName() *WxCardUpsert {
  611. u.SetExcluded(wxcard.FieldName)
  612. return u
  613. }
  614. // SetCompany sets the "company" field.
  615. func (u *WxCardUpsert) SetCompany(v string) *WxCardUpsert {
  616. u.Set(wxcard.FieldCompany, v)
  617. return u
  618. }
  619. // UpdateCompany sets the "company" field to the value that was provided on create.
  620. func (u *WxCardUpsert) UpdateCompany() *WxCardUpsert {
  621. u.SetExcluded(wxcard.FieldCompany)
  622. return u
  623. }
  624. // SetAddress sets the "address" field.
  625. func (u *WxCardUpsert) SetAddress(v string) *WxCardUpsert {
  626. u.Set(wxcard.FieldAddress, v)
  627. return u
  628. }
  629. // UpdateAddress sets the "address" field to the value that was provided on create.
  630. func (u *WxCardUpsert) UpdateAddress() *WxCardUpsert {
  631. u.SetExcluded(wxcard.FieldAddress)
  632. return u
  633. }
  634. // SetPhone sets the "phone" field.
  635. func (u *WxCardUpsert) SetPhone(v string) *WxCardUpsert {
  636. u.Set(wxcard.FieldPhone, v)
  637. return u
  638. }
  639. // UpdatePhone sets the "phone" field to the value that was provided on create.
  640. func (u *WxCardUpsert) UpdatePhone() *WxCardUpsert {
  641. u.SetExcluded(wxcard.FieldPhone)
  642. return u
  643. }
  644. // SetOfficialAccount sets the "official_account" field.
  645. func (u *WxCardUpsert) SetOfficialAccount(v string) *WxCardUpsert {
  646. u.Set(wxcard.FieldOfficialAccount, v)
  647. return u
  648. }
  649. // UpdateOfficialAccount sets the "official_account" field to the value that was provided on create.
  650. func (u *WxCardUpsert) UpdateOfficialAccount() *WxCardUpsert {
  651. u.SetExcluded(wxcard.FieldOfficialAccount)
  652. return u
  653. }
  654. // SetWechatAccount sets the "wechat_account" field.
  655. func (u *WxCardUpsert) SetWechatAccount(v string) *WxCardUpsert {
  656. u.Set(wxcard.FieldWechatAccount, v)
  657. return u
  658. }
  659. // UpdateWechatAccount sets the "wechat_account" field to the value that was provided on create.
  660. func (u *WxCardUpsert) UpdateWechatAccount() *WxCardUpsert {
  661. u.SetExcluded(wxcard.FieldWechatAccount)
  662. return u
  663. }
  664. // SetEmail sets the "email" field.
  665. func (u *WxCardUpsert) SetEmail(v string) *WxCardUpsert {
  666. u.Set(wxcard.FieldEmail, v)
  667. return u
  668. }
  669. // UpdateEmail sets the "email" field to the value that was provided on create.
  670. func (u *WxCardUpsert) UpdateEmail() *WxCardUpsert {
  671. u.SetExcluded(wxcard.FieldEmail)
  672. return u
  673. }
  674. // ClearEmail clears the value of the "email" field.
  675. func (u *WxCardUpsert) ClearEmail() *WxCardUpsert {
  676. u.SetNull(wxcard.FieldEmail)
  677. return u
  678. }
  679. // SetAPIBase sets the "api_base" field.
  680. func (u *WxCardUpsert) SetAPIBase(v string) *WxCardUpsert {
  681. u.Set(wxcard.FieldAPIBase, v)
  682. return u
  683. }
  684. // UpdateAPIBase sets the "api_base" field to the value that was provided on create.
  685. func (u *WxCardUpsert) UpdateAPIBase() *WxCardUpsert {
  686. u.SetExcluded(wxcard.FieldAPIBase)
  687. return u
  688. }
  689. // ClearAPIBase clears the value of the "api_base" field.
  690. func (u *WxCardUpsert) ClearAPIBase() *WxCardUpsert {
  691. u.SetNull(wxcard.FieldAPIBase)
  692. return u
  693. }
  694. // SetAPIKey sets the "api_key" field.
  695. func (u *WxCardUpsert) SetAPIKey(v string) *WxCardUpsert {
  696. u.Set(wxcard.FieldAPIKey, v)
  697. return u
  698. }
  699. // UpdateAPIKey sets the "api_key" field to the value that was provided on create.
  700. func (u *WxCardUpsert) UpdateAPIKey() *WxCardUpsert {
  701. u.SetExcluded(wxcard.FieldAPIKey)
  702. return u
  703. }
  704. // ClearAPIKey clears the value of the "api_key" field.
  705. func (u *WxCardUpsert) ClearAPIKey() *WxCardUpsert {
  706. u.SetNull(wxcard.FieldAPIKey)
  707. return u
  708. }
  709. // SetAiInfo sets the "ai_info" field.
  710. func (u *WxCardUpsert) SetAiInfo(v string) *WxCardUpsert {
  711. u.Set(wxcard.FieldAiInfo, v)
  712. return u
  713. }
  714. // UpdateAiInfo sets the "ai_info" field to the value that was provided on create.
  715. func (u *WxCardUpsert) UpdateAiInfo() *WxCardUpsert {
  716. u.SetExcluded(wxcard.FieldAiInfo)
  717. return u
  718. }
  719. // ClearAiInfo clears the value of the "ai_info" field.
  720. func (u *WxCardUpsert) ClearAiInfo() *WxCardUpsert {
  721. u.SetNull(wxcard.FieldAiInfo)
  722. return u
  723. }
  724. // SetIntro sets the "intro" field.
  725. func (u *WxCardUpsert) SetIntro(v string) *WxCardUpsert {
  726. u.Set(wxcard.FieldIntro, v)
  727. return u
  728. }
  729. // UpdateIntro sets the "intro" field to the value that was provided on create.
  730. func (u *WxCardUpsert) UpdateIntro() *WxCardUpsert {
  731. u.SetExcluded(wxcard.FieldIntro)
  732. return u
  733. }
  734. // ClearIntro clears the value of the "intro" field.
  735. func (u *WxCardUpsert) ClearIntro() *WxCardUpsert {
  736. u.SetNull(wxcard.FieldIntro)
  737. return u
  738. }
  739. // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
  740. // Using this option is equivalent to using:
  741. //
  742. // client.WxCard.Create().
  743. // OnConflict(
  744. // sql.ResolveWithNewValues(),
  745. // sql.ResolveWith(func(u *sql.UpdateSet) {
  746. // u.SetIgnore(wxcard.FieldID)
  747. // }),
  748. // ).
  749. // Exec(ctx)
  750. func (u *WxCardUpsertOne) UpdateNewValues() *WxCardUpsertOne {
  751. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  752. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  753. if _, exists := u.create.mutation.ID(); exists {
  754. s.SetIgnore(wxcard.FieldID)
  755. }
  756. if _, exists := u.create.mutation.CreatedAt(); exists {
  757. s.SetIgnore(wxcard.FieldCreatedAt)
  758. }
  759. }))
  760. return u
  761. }
  762. // Ignore sets each column to itself in case of conflict.
  763. // Using this option is equivalent to using:
  764. //
  765. // client.WxCard.Create().
  766. // OnConflict(sql.ResolveWithIgnore()).
  767. // Exec(ctx)
  768. func (u *WxCardUpsertOne) Ignore() *WxCardUpsertOne {
  769. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  770. return u
  771. }
  772. // DoNothing configures the conflict_action to `DO NOTHING`.
  773. // Supported only by SQLite and PostgreSQL.
  774. func (u *WxCardUpsertOne) DoNothing() *WxCardUpsertOne {
  775. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  776. return u
  777. }
  778. // Update allows overriding fields `UPDATE` values. See the WxCardCreate.OnConflict
  779. // documentation for more info.
  780. func (u *WxCardUpsertOne) Update(set func(*WxCardUpsert)) *WxCardUpsertOne {
  781. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  782. set(&WxCardUpsert{UpdateSet: update})
  783. }))
  784. return u
  785. }
  786. // SetUpdatedAt sets the "updated_at" field.
  787. func (u *WxCardUpsertOne) SetUpdatedAt(v time.Time) *WxCardUpsertOne {
  788. return u.Update(func(s *WxCardUpsert) {
  789. s.SetUpdatedAt(v)
  790. })
  791. }
  792. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  793. func (u *WxCardUpsertOne) UpdateUpdatedAt() *WxCardUpsertOne {
  794. return u.Update(func(s *WxCardUpsert) {
  795. s.UpdateUpdatedAt()
  796. })
  797. }
  798. // SetDeletedAt sets the "deleted_at" field.
  799. func (u *WxCardUpsertOne) SetDeletedAt(v time.Time) *WxCardUpsertOne {
  800. return u.Update(func(s *WxCardUpsert) {
  801. s.SetDeletedAt(v)
  802. })
  803. }
  804. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  805. func (u *WxCardUpsertOne) UpdateDeletedAt() *WxCardUpsertOne {
  806. return u.Update(func(s *WxCardUpsert) {
  807. s.UpdateDeletedAt()
  808. })
  809. }
  810. // ClearDeletedAt clears the value of the "deleted_at" field.
  811. func (u *WxCardUpsertOne) ClearDeletedAt() *WxCardUpsertOne {
  812. return u.Update(func(s *WxCardUpsert) {
  813. s.ClearDeletedAt()
  814. })
  815. }
  816. // SetUserID sets the "user_id" field.
  817. func (u *WxCardUpsertOne) SetUserID(v uint64) *WxCardUpsertOne {
  818. return u.Update(func(s *WxCardUpsert) {
  819. s.SetUserID(v)
  820. })
  821. }
  822. // AddUserID adds v to the "user_id" field.
  823. func (u *WxCardUpsertOne) AddUserID(v uint64) *WxCardUpsertOne {
  824. return u.Update(func(s *WxCardUpsert) {
  825. s.AddUserID(v)
  826. })
  827. }
  828. // UpdateUserID sets the "user_id" field to the value that was provided on create.
  829. func (u *WxCardUpsertOne) UpdateUserID() *WxCardUpsertOne {
  830. return u.Update(func(s *WxCardUpsert) {
  831. s.UpdateUserID()
  832. })
  833. }
  834. // ClearUserID clears the value of the "user_id" field.
  835. func (u *WxCardUpsertOne) ClearUserID() *WxCardUpsertOne {
  836. return u.Update(func(s *WxCardUpsert) {
  837. s.ClearUserID()
  838. })
  839. }
  840. // SetWxUserID sets the "wx_user_id" field.
  841. func (u *WxCardUpsertOne) SetWxUserID(v uint64) *WxCardUpsertOne {
  842. return u.Update(func(s *WxCardUpsert) {
  843. s.SetWxUserID(v)
  844. })
  845. }
  846. // AddWxUserID adds v to the "wx_user_id" field.
  847. func (u *WxCardUpsertOne) AddWxUserID(v uint64) *WxCardUpsertOne {
  848. return u.Update(func(s *WxCardUpsert) {
  849. s.AddWxUserID(v)
  850. })
  851. }
  852. // UpdateWxUserID sets the "wx_user_id" field to the value that was provided on create.
  853. func (u *WxCardUpsertOne) UpdateWxUserID() *WxCardUpsertOne {
  854. return u.Update(func(s *WxCardUpsert) {
  855. s.UpdateWxUserID()
  856. })
  857. }
  858. // ClearWxUserID clears the value of the "wx_user_id" field.
  859. func (u *WxCardUpsertOne) ClearWxUserID() *WxCardUpsertOne {
  860. return u.Update(func(s *WxCardUpsert) {
  861. s.ClearWxUserID()
  862. })
  863. }
  864. // SetAvatar sets the "avatar" field.
  865. func (u *WxCardUpsertOne) SetAvatar(v string) *WxCardUpsertOne {
  866. return u.Update(func(s *WxCardUpsert) {
  867. s.SetAvatar(v)
  868. })
  869. }
  870. // UpdateAvatar sets the "avatar" field to the value that was provided on create.
  871. func (u *WxCardUpsertOne) UpdateAvatar() *WxCardUpsertOne {
  872. return u.Update(func(s *WxCardUpsert) {
  873. s.UpdateAvatar()
  874. })
  875. }
  876. // SetLogo sets the "logo" field.
  877. func (u *WxCardUpsertOne) SetLogo(v string) *WxCardUpsertOne {
  878. return u.Update(func(s *WxCardUpsert) {
  879. s.SetLogo(v)
  880. })
  881. }
  882. // UpdateLogo sets the "logo" field to the value that was provided on create.
  883. func (u *WxCardUpsertOne) UpdateLogo() *WxCardUpsertOne {
  884. return u.Update(func(s *WxCardUpsert) {
  885. s.UpdateLogo()
  886. })
  887. }
  888. // SetName sets the "name" field.
  889. func (u *WxCardUpsertOne) SetName(v string) *WxCardUpsertOne {
  890. return u.Update(func(s *WxCardUpsert) {
  891. s.SetName(v)
  892. })
  893. }
  894. // UpdateName sets the "name" field to the value that was provided on create.
  895. func (u *WxCardUpsertOne) UpdateName() *WxCardUpsertOne {
  896. return u.Update(func(s *WxCardUpsert) {
  897. s.UpdateName()
  898. })
  899. }
  900. // SetCompany sets the "company" field.
  901. func (u *WxCardUpsertOne) SetCompany(v string) *WxCardUpsertOne {
  902. return u.Update(func(s *WxCardUpsert) {
  903. s.SetCompany(v)
  904. })
  905. }
  906. // UpdateCompany sets the "company" field to the value that was provided on create.
  907. func (u *WxCardUpsertOne) UpdateCompany() *WxCardUpsertOne {
  908. return u.Update(func(s *WxCardUpsert) {
  909. s.UpdateCompany()
  910. })
  911. }
  912. // SetAddress sets the "address" field.
  913. func (u *WxCardUpsertOne) SetAddress(v string) *WxCardUpsertOne {
  914. return u.Update(func(s *WxCardUpsert) {
  915. s.SetAddress(v)
  916. })
  917. }
  918. // UpdateAddress sets the "address" field to the value that was provided on create.
  919. func (u *WxCardUpsertOne) UpdateAddress() *WxCardUpsertOne {
  920. return u.Update(func(s *WxCardUpsert) {
  921. s.UpdateAddress()
  922. })
  923. }
  924. // SetPhone sets the "phone" field.
  925. func (u *WxCardUpsertOne) SetPhone(v string) *WxCardUpsertOne {
  926. return u.Update(func(s *WxCardUpsert) {
  927. s.SetPhone(v)
  928. })
  929. }
  930. // UpdatePhone sets the "phone" field to the value that was provided on create.
  931. func (u *WxCardUpsertOne) UpdatePhone() *WxCardUpsertOne {
  932. return u.Update(func(s *WxCardUpsert) {
  933. s.UpdatePhone()
  934. })
  935. }
  936. // SetOfficialAccount sets the "official_account" field.
  937. func (u *WxCardUpsertOne) SetOfficialAccount(v string) *WxCardUpsertOne {
  938. return u.Update(func(s *WxCardUpsert) {
  939. s.SetOfficialAccount(v)
  940. })
  941. }
  942. // UpdateOfficialAccount sets the "official_account" field to the value that was provided on create.
  943. func (u *WxCardUpsertOne) UpdateOfficialAccount() *WxCardUpsertOne {
  944. return u.Update(func(s *WxCardUpsert) {
  945. s.UpdateOfficialAccount()
  946. })
  947. }
  948. // SetWechatAccount sets the "wechat_account" field.
  949. func (u *WxCardUpsertOne) SetWechatAccount(v string) *WxCardUpsertOne {
  950. return u.Update(func(s *WxCardUpsert) {
  951. s.SetWechatAccount(v)
  952. })
  953. }
  954. // UpdateWechatAccount sets the "wechat_account" field to the value that was provided on create.
  955. func (u *WxCardUpsertOne) UpdateWechatAccount() *WxCardUpsertOne {
  956. return u.Update(func(s *WxCardUpsert) {
  957. s.UpdateWechatAccount()
  958. })
  959. }
  960. // SetEmail sets the "email" field.
  961. func (u *WxCardUpsertOne) SetEmail(v string) *WxCardUpsertOne {
  962. return u.Update(func(s *WxCardUpsert) {
  963. s.SetEmail(v)
  964. })
  965. }
  966. // UpdateEmail sets the "email" field to the value that was provided on create.
  967. func (u *WxCardUpsertOne) UpdateEmail() *WxCardUpsertOne {
  968. return u.Update(func(s *WxCardUpsert) {
  969. s.UpdateEmail()
  970. })
  971. }
  972. // ClearEmail clears the value of the "email" field.
  973. func (u *WxCardUpsertOne) ClearEmail() *WxCardUpsertOne {
  974. return u.Update(func(s *WxCardUpsert) {
  975. s.ClearEmail()
  976. })
  977. }
  978. // SetAPIBase sets the "api_base" field.
  979. func (u *WxCardUpsertOne) SetAPIBase(v string) *WxCardUpsertOne {
  980. return u.Update(func(s *WxCardUpsert) {
  981. s.SetAPIBase(v)
  982. })
  983. }
  984. // UpdateAPIBase sets the "api_base" field to the value that was provided on create.
  985. func (u *WxCardUpsertOne) UpdateAPIBase() *WxCardUpsertOne {
  986. return u.Update(func(s *WxCardUpsert) {
  987. s.UpdateAPIBase()
  988. })
  989. }
  990. // ClearAPIBase clears the value of the "api_base" field.
  991. func (u *WxCardUpsertOne) ClearAPIBase() *WxCardUpsertOne {
  992. return u.Update(func(s *WxCardUpsert) {
  993. s.ClearAPIBase()
  994. })
  995. }
  996. // SetAPIKey sets the "api_key" field.
  997. func (u *WxCardUpsertOne) SetAPIKey(v string) *WxCardUpsertOne {
  998. return u.Update(func(s *WxCardUpsert) {
  999. s.SetAPIKey(v)
  1000. })
  1001. }
  1002. // UpdateAPIKey sets the "api_key" field to the value that was provided on create.
  1003. func (u *WxCardUpsertOne) UpdateAPIKey() *WxCardUpsertOne {
  1004. return u.Update(func(s *WxCardUpsert) {
  1005. s.UpdateAPIKey()
  1006. })
  1007. }
  1008. // ClearAPIKey clears the value of the "api_key" field.
  1009. func (u *WxCardUpsertOne) ClearAPIKey() *WxCardUpsertOne {
  1010. return u.Update(func(s *WxCardUpsert) {
  1011. s.ClearAPIKey()
  1012. })
  1013. }
  1014. // SetAiInfo sets the "ai_info" field.
  1015. func (u *WxCardUpsertOne) SetAiInfo(v string) *WxCardUpsertOne {
  1016. return u.Update(func(s *WxCardUpsert) {
  1017. s.SetAiInfo(v)
  1018. })
  1019. }
  1020. // UpdateAiInfo sets the "ai_info" field to the value that was provided on create.
  1021. func (u *WxCardUpsertOne) UpdateAiInfo() *WxCardUpsertOne {
  1022. return u.Update(func(s *WxCardUpsert) {
  1023. s.UpdateAiInfo()
  1024. })
  1025. }
  1026. // ClearAiInfo clears the value of the "ai_info" field.
  1027. func (u *WxCardUpsertOne) ClearAiInfo() *WxCardUpsertOne {
  1028. return u.Update(func(s *WxCardUpsert) {
  1029. s.ClearAiInfo()
  1030. })
  1031. }
  1032. // SetIntro sets the "intro" field.
  1033. func (u *WxCardUpsertOne) SetIntro(v string) *WxCardUpsertOne {
  1034. return u.Update(func(s *WxCardUpsert) {
  1035. s.SetIntro(v)
  1036. })
  1037. }
  1038. // UpdateIntro sets the "intro" field to the value that was provided on create.
  1039. func (u *WxCardUpsertOne) UpdateIntro() *WxCardUpsertOne {
  1040. return u.Update(func(s *WxCardUpsert) {
  1041. s.UpdateIntro()
  1042. })
  1043. }
  1044. // ClearIntro clears the value of the "intro" field.
  1045. func (u *WxCardUpsertOne) ClearIntro() *WxCardUpsertOne {
  1046. return u.Update(func(s *WxCardUpsert) {
  1047. s.ClearIntro()
  1048. })
  1049. }
  1050. // Exec executes the query.
  1051. func (u *WxCardUpsertOne) Exec(ctx context.Context) error {
  1052. if len(u.create.conflict) == 0 {
  1053. return errors.New("ent: missing options for WxCardCreate.OnConflict")
  1054. }
  1055. return u.create.Exec(ctx)
  1056. }
  1057. // ExecX is like Exec, but panics if an error occurs.
  1058. func (u *WxCardUpsertOne) ExecX(ctx context.Context) {
  1059. if err := u.create.Exec(ctx); err != nil {
  1060. panic(err)
  1061. }
  1062. }
  1063. // Exec executes the UPSERT query and returns the inserted/updated ID.
  1064. func (u *WxCardUpsertOne) ID(ctx context.Context) (id uint64, err error) {
  1065. node, err := u.create.Save(ctx)
  1066. if err != nil {
  1067. return id, err
  1068. }
  1069. return node.ID, nil
  1070. }
  1071. // IDX is like ID, but panics if an error occurs.
  1072. func (u *WxCardUpsertOne) IDX(ctx context.Context) uint64 {
  1073. id, err := u.ID(ctx)
  1074. if err != nil {
  1075. panic(err)
  1076. }
  1077. return id
  1078. }
  1079. // WxCardCreateBulk is the builder for creating many WxCard entities in bulk.
  1080. type WxCardCreateBulk struct {
  1081. config
  1082. err error
  1083. builders []*WxCardCreate
  1084. conflict []sql.ConflictOption
  1085. }
  1086. // Save creates the WxCard entities in the database.
  1087. func (wccb *WxCardCreateBulk) Save(ctx context.Context) ([]*WxCard, error) {
  1088. if wccb.err != nil {
  1089. return nil, wccb.err
  1090. }
  1091. specs := make([]*sqlgraph.CreateSpec, len(wccb.builders))
  1092. nodes := make([]*WxCard, len(wccb.builders))
  1093. mutators := make([]Mutator, len(wccb.builders))
  1094. for i := range wccb.builders {
  1095. func(i int, root context.Context) {
  1096. builder := wccb.builders[i]
  1097. builder.defaults()
  1098. var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
  1099. mutation, ok := m.(*WxCardMutation)
  1100. if !ok {
  1101. return nil, fmt.Errorf("unexpected mutation type %T", m)
  1102. }
  1103. if err := builder.check(); err != nil {
  1104. return nil, err
  1105. }
  1106. builder.mutation = mutation
  1107. var err error
  1108. nodes[i], specs[i] = builder.createSpec()
  1109. if i < len(mutators)-1 {
  1110. _, err = mutators[i+1].Mutate(root, wccb.builders[i+1].mutation)
  1111. } else {
  1112. spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
  1113. spec.OnConflict = wccb.conflict
  1114. // Invoke the actual operation on the latest mutation in the chain.
  1115. if err = sqlgraph.BatchCreate(ctx, wccb.driver, spec); err != nil {
  1116. if sqlgraph.IsConstraintError(err) {
  1117. err = &ConstraintError{msg: err.Error(), wrap: err}
  1118. }
  1119. }
  1120. }
  1121. if err != nil {
  1122. return nil, err
  1123. }
  1124. mutation.id = &nodes[i].ID
  1125. if specs[i].ID.Value != nil && nodes[i].ID == 0 {
  1126. id := specs[i].ID.Value.(int64)
  1127. nodes[i].ID = uint64(id)
  1128. }
  1129. mutation.done = true
  1130. return nodes[i], nil
  1131. })
  1132. for i := len(builder.hooks) - 1; i >= 0; i-- {
  1133. mut = builder.hooks[i](mut)
  1134. }
  1135. mutators[i] = mut
  1136. }(i, ctx)
  1137. }
  1138. if len(mutators) > 0 {
  1139. if _, err := mutators[0].Mutate(ctx, wccb.builders[0].mutation); err != nil {
  1140. return nil, err
  1141. }
  1142. }
  1143. return nodes, nil
  1144. }
  1145. // SaveX is like Save, but panics if an error occurs.
  1146. func (wccb *WxCardCreateBulk) SaveX(ctx context.Context) []*WxCard {
  1147. v, err := wccb.Save(ctx)
  1148. if err != nil {
  1149. panic(err)
  1150. }
  1151. return v
  1152. }
  1153. // Exec executes the query.
  1154. func (wccb *WxCardCreateBulk) Exec(ctx context.Context) error {
  1155. _, err := wccb.Save(ctx)
  1156. return err
  1157. }
  1158. // ExecX is like Exec, but panics if an error occurs.
  1159. func (wccb *WxCardCreateBulk) ExecX(ctx context.Context) {
  1160. if err := wccb.Exec(ctx); err != nil {
  1161. panic(err)
  1162. }
  1163. }
  1164. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  1165. // of the `INSERT` statement. For example:
  1166. //
  1167. // client.WxCard.CreateBulk(builders...).
  1168. // OnConflict(
  1169. // // Update the row with the new values
  1170. // // the was proposed for insertion.
  1171. // sql.ResolveWithNewValues(),
  1172. // ).
  1173. // // Override some of the fields with custom
  1174. // // update values.
  1175. // Update(func(u *ent.WxCardUpsert) {
  1176. // SetCreatedAt(v+v).
  1177. // }).
  1178. // Exec(ctx)
  1179. func (wccb *WxCardCreateBulk) OnConflict(opts ...sql.ConflictOption) *WxCardUpsertBulk {
  1180. wccb.conflict = opts
  1181. return &WxCardUpsertBulk{
  1182. create: wccb,
  1183. }
  1184. }
  1185. // OnConflictColumns calls `OnConflict` and configures the columns
  1186. // as conflict target. Using this option is equivalent to using:
  1187. //
  1188. // client.WxCard.Create().
  1189. // OnConflict(sql.ConflictColumns(columns...)).
  1190. // Exec(ctx)
  1191. func (wccb *WxCardCreateBulk) OnConflictColumns(columns ...string) *WxCardUpsertBulk {
  1192. wccb.conflict = append(wccb.conflict, sql.ConflictColumns(columns...))
  1193. return &WxCardUpsertBulk{
  1194. create: wccb,
  1195. }
  1196. }
  1197. // WxCardUpsertBulk is the builder for "upsert"-ing
  1198. // a bulk of WxCard nodes.
  1199. type WxCardUpsertBulk struct {
  1200. create *WxCardCreateBulk
  1201. }
  1202. // UpdateNewValues updates the mutable fields using the new values that
  1203. // were set on create. Using this option is equivalent to using:
  1204. //
  1205. // client.WxCard.Create().
  1206. // OnConflict(
  1207. // sql.ResolveWithNewValues(),
  1208. // sql.ResolveWith(func(u *sql.UpdateSet) {
  1209. // u.SetIgnore(wxcard.FieldID)
  1210. // }),
  1211. // ).
  1212. // Exec(ctx)
  1213. func (u *WxCardUpsertBulk) UpdateNewValues() *WxCardUpsertBulk {
  1214. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  1215. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  1216. for _, b := range u.create.builders {
  1217. if _, exists := b.mutation.ID(); exists {
  1218. s.SetIgnore(wxcard.FieldID)
  1219. }
  1220. if _, exists := b.mutation.CreatedAt(); exists {
  1221. s.SetIgnore(wxcard.FieldCreatedAt)
  1222. }
  1223. }
  1224. }))
  1225. return u
  1226. }
  1227. // Ignore sets each column to itself in case of conflict.
  1228. // Using this option is equivalent to using:
  1229. //
  1230. // client.WxCard.Create().
  1231. // OnConflict(sql.ResolveWithIgnore()).
  1232. // Exec(ctx)
  1233. func (u *WxCardUpsertBulk) Ignore() *WxCardUpsertBulk {
  1234. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  1235. return u
  1236. }
  1237. // DoNothing configures the conflict_action to `DO NOTHING`.
  1238. // Supported only by SQLite and PostgreSQL.
  1239. func (u *WxCardUpsertBulk) DoNothing() *WxCardUpsertBulk {
  1240. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  1241. return u
  1242. }
  1243. // Update allows overriding fields `UPDATE` values. See the WxCardCreateBulk.OnConflict
  1244. // documentation for more info.
  1245. func (u *WxCardUpsertBulk) Update(set func(*WxCardUpsert)) *WxCardUpsertBulk {
  1246. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  1247. set(&WxCardUpsert{UpdateSet: update})
  1248. }))
  1249. return u
  1250. }
  1251. // SetUpdatedAt sets the "updated_at" field.
  1252. func (u *WxCardUpsertBulk) SetUpdatedAt(v time.Time) *WxCardUpsertBulk {
  1253. return u.Update(func(s *WxCardUpsert) {
  1254. s.SetUpdatedAt(v)
  1255. })
  1256. }
  1257. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  1258. func (u *WxCardUpsertBulk) UpdateUpdatedAt() *WxCardUpsertBulk {
  1259. return u.Update(func(s *WxCardUpsert) {
  1260. s.UpdateUpdatedAt()
  1261. })
  1262. }
  1263. // SetDeletedAt sets the "deleted_at" field.
  1264. func (u *WxCardUpsertBulk) SetDeletedAt(v time.Time) *WxCardUpsertBulk {
  1265. return u.Update(func(s *WxCardUpsert) {
  1266. s.SetDeletedAt(v)
  1267. })
  1268. }
  1269. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  1270. func (u *WxCardUpsertBulk) UpdateDeletedAt() *WxCardUpsertBulk {
  1271. return u.Update(func(s *WxCardUpsert) {
  1272. s.UpdateDeletedAt()
  1273. })
  1274. }
  1275. // ClearDeletedAt clears the value of the "deleted_at" field.
  1276. func (u *WxCardUpsertBulk) ClearDeletedAt() *WxCardUpsertBulk {
  1277. return u.Update(func(s *WxCardUpsert) {
  1278. s.ClearDeletedAt()
  1279. })
  1280. }
  1281. // SetUserID sets the "user_id" field.
  1282. func (u *WxCardUpsertBulk) SetUserID(v uint64) *WxCardUpsertBulk {
  1283. return u.Update(func(s *WxCardUpsert) {
  1284. s.SetUserID(v)
  1285. })
  1286. }
  1287. // AddUserID adds v to the "user_id" field.
  1288. func (u *WxCardUpsertBulk) AddUserID(v uint64) *WxCardUpsertBulk {
  1289. return u.Update(func(s *WxCardUpsert) {
  1290. s.AddUserID(v)
  1291. })
  1292. }
  1293. // UpdateUserID sets the "user_id" field to the value that was provided on create.
  1294. func (u *WxCardUpsertBulk) UpdateUserID() *WxCardUpsertBulk {
  1295. return u.Update(func(s *WxCardUpsert) {
  1296. s.UpdateUserID()
  1297. })
  1298. }
  1299. // ClearUserID clears the value of the "user_id" field.
  1300. func (u *WxCardUpsertBulk) ClearUserID() *WxCardUpsertBulk {
  1301. return u.Update(func(s *WxCardUpsert) {
  1302. s.ClearUserID()
  1303. })
  1304. }
  1305. // SetWxUserID sets the "wx_user_id" field.
  1306. func (u *WxCardUpsertBulk) SetWxUserID(v uint64) *WxCardUpsertBulk {
  1307. return u.Update(func(s *WxCardUpsert) {
  1308. s.SetWxUserID(v)
  1309. })
  1310. }
  1311. // AddWxUserID adds v to the "wx_user_id" field.
  1312. func (u *WxCardUpsertBulk) AddWxUserID(v uint64) *WxCardUpsertBulk {
  1313. return u.Update(func(s *WxCardUpsert) {
  1314. s.AddWxUserID(v)
  1315. })
  1316. }
  1317. // UpdateWxUserID sets the "wx_user_id" field to the value that was provided on create.
  1318. func (u *WxCardUpsertBulk) UpdateWxUserID() *WxCardUpsertBulk {
  1319. return u.Update(func(s *WxCardUpsert) {
  1320. s.UpdateWxUserID()
  1321. })
  1322. }
  1323. // ClearWxUserID clears the value of the "wx_user_id" field.
  1324. func (u *WxCardUpsertBulk) ClearWxUserID() *WxCardUpsertBulk {
  1325. return u.Update(func(s *WxCardUpsert) {
  1326. s.ClearWxUserID()
  1327. })
  1328. }
  1329. // SetAvatar sets the "avatar" field.
  1330. func (u *WxCardUpsertBulk) SetAvatar(v string) *WxCardUpsertBulk {
  1331. return u.Update(func(s *WxCardUpsert) {
  1332. s.SetAvatar(v)
  1333. })
  1334. }
  1335. // UpdateAvatar sets the "avatar" field to the value that was provided on create.
  1336. func (u *WxCardUpsertBulk) UpdateAvatar() *WxCardUpsertBulk {
  1337. return u.Update(func(s *WxCardUpsert) {
  1338. s.UpdateAvatar()
  1339. })
  1340. }
  1341. // SetLogo sets the "logo" field.
  1342. func (u *WxCardUpsertBulk) SetLogo(v string) *WxCardUpsertBulk {
  1343. return u.Update(func(s *WxCardUpsert) {
  1344. s.SetLogo(v)
  1345. })
  1346. }
  1347. // UpdateLogo sets the "logo" field to the value that was provided on create.
  1348. func (u *WxCardUpsertBulk) UpdateLogo() *WxCardUpsertBulk {
  1349. return u.Update(func(s *WxCardUpsert) {
  1350. s.UpdateLogo()
  1351. })
  1352. }
  1353. // SetName sets the "name" field.
  1354. func (u *WxCardUpsertBulk) SetName(v string) *WxCardUpsertBulk {
  1355. return u.Update(func(s *WxCardUpsert) {
  1356. s.SetName(v)
  1357. })
  1358. }
  1359. // UpdateName sets the "name" field to the value that was provided on create.
  1360. func (u *WxCardUpsertBulk) UpdateName() *WxCardUpsertBulk {
  1361. return u.Update(func(s *WxCardUpsert) {
  1362. s.UpdateName()
  1363. })
  1364. }
  1365. // SetCompany sets the "company" field.
  1366. func (u *WxCardUpsertBulk) SetCompany(v string) *WxCardUpsertBulk {
  1367. return u.Update(func(s *WxCardUpsert) {
  1368. s.SetCompany(v)
  1369. })
  1370. }
  1371. // UpdateCompany sets the "company" field to the value that was provided on create.
  1372. func (u *WxCardUpsertBulk) UpdateCompany() *WxCardUpsertBulk {
  1373. return u.Update(func(s *WxCardUpsert) {
  1374. s.UpdateCompany()
  1375. })
  1376. }
  1377. // SetAddress sets the "address" field.
  1378. func (u *WxCardUpsertBulk) SetAddress(v string) *WxCardUpsertBulk {
  1379. return u.Update(func(s *WxCardUpsert) {
  1380. s.SetAddress(v)
  1381. })
  1382. }
  1383. // UpdateAddress sets the "address" field to the value that was provided on create.
  1384. func (u *WxCardUpsertBulk) UpdateAddress() *WxCardUpsertBulk {
  1385. return u.Update(func(s *WxCardUpsert) {
  1386. s.UpdateAddress()
  1387. })
  1388. }
  1389. // SetPhone sets the "phone" field.
  1390. func (u *WxCardUpsertBulk) SetPhone(v string) *WxCardUpsertBulk {
  1391. return u.Update(func(s *WxCardUpsert) {
  1392. s.SetPhone(v)
  1393. })
  1394. }
  1395. // UpdatePhone sets the "phone" field to the value that was provided on create.
  1396. func (u *WxCardUpsertBulk) UpdatePhone() *WxCardUpsertBulk {
  1397. return u.Update(func(s *WxCardUpsert) {
  1398. s.UpdatePhone()
  1399. })
  1400. }
  1401. // SetOfficialAccount sets the "official_account" field.
  1402. func (u *WxCardUpsertBulk) SetOfficialAccount(v string) *WxCardUpsertBulk {
  1403. return u.Update(func(s *WxCardUpsert) {
  1404. s.SetOfficialAccount(v)
  1405. })
  1406. }
  1407. // UpdateOfficialAccount sets the "official_account" field to the value that was provided on create.
  1408. func (u *WxCardUpsertBulk) UpdateOfficialAccount() *WxCardUpsertBulk {
  1409. return u.Update(func(s *WxCardUpsert) {
  1410. s.UpdateOfficialAccount()
  1411. })
  1412. }
  1413. // SetWechatAccount sets the "wechat_account" field.
  1414. func (u *WxCardUpsertBulk) SetWechatAccount(v string) *WxCardUpsertBulk {
  1415. return u.Update(func(s *WxCardUpsert) {
  1416. s.SetWechatAccount(v)
  1417. })
  1418. }
  1419. // UpdateWechatAccount sets the "wechat_account" field to the value that was provided on create.
  1420. func (u *WxCardUpsertBulk) UpdateWechatAccount() *WxCardUpsertBulk {
  1421. return u.Update(func(s *WxCardUpsert) {
  1422. s.UpdateWechatAccount()
  1423. })
  1424. }
  1425. // SetEmail sets the "email" field.
  1426. func (u *WxCardUpsertBulk) SetEmail(v string) *WxCardUpsertBulk {
  1427. return u.Update(func(s *WxCardUpsert) {
  1428. s.SetEmail(v)
  1429. })
  1430. }
  1431. // UpdateEmail sets the "email" field to the value that was provided on create.
  1432. func (u *WxCardUpsertBulk) UpdateEmail() *WxCardUpsertBulk {
  1433. return u.Update(func(s *WxCardUpsert) {
  1434. s.UpdateEmail()
  1435. })
  1436. }
  1437. // ClearEmail clears the value of the "email" field.
  1438. func (u *WxCardUpsertBulk) ClearEmail() *WxCardUpsertBulk {
  1439. return u.Update(func(s *WxCardUpsert) {
  1440. s.ClearEmail()
  1441. })
  1442. }
  1443. // SetAPIBase sets the "api_base" field.
  1444. func (u *WxCardUpsertBulk) SetAPIBase(v string) *WxCardUpsertBulk {
  1445. return u.Update(func(s *WxCardUpsert) {
  1446. s.SetAPIBase(v)
  1447. })
  1448. }
  1449. // UpdateAPIBase sets the "api_base" field to the value that was provided on create.
  1450. func (u *WxCardUpsertBulk) UpdateAPIBase() *WxCardUpsertBulk {
  1451. return u.Update(func(s *WxCardUpsert) {
  1452. s.UpdateAPIBase()
  1453. })
  1454. }
  1455. // ClearAPIBase clears the value of the "api_base" field.
  1456. func (u *WxCardUpsertBulk) ClearAPIBase() *WxCardUpsertBulk {
  1457. return u.Update(func(s *WxCardUpsert) {
  1458. s.ClearAPIBase()
  1459. })
  1460. }
  1461. // SetAPIKey sets the "api_key" field.
  1462. func (u *WxCardUpsertBulk) SetAPIKey(v string) *WxCardUpsertBulk {
  1463. return u.Update(func(s *WxCardUpsert) {
  1464. s.SetAPIKey(v)
  1465. })
  1466. }
  1467. // UpdateAPIKey sets the "api_key" field to the value that was provided on create.
  1468. func (u *WxCardUpsertBulk) UpdateAPIKey() *WxCardUpsertBulk {
  1469. return u.Update(func(s *WxCardUpsert) {
  1470. s.UpdateAPIKey()
  1471. })
  1472. }
  1473. // ClearAPIKey clears the value of the "api_key" field.
  1474. func (u *WxCardUpsertBulk) ClearAPIKey() *WxCardUpsertBulk {
  1475. return u.Update(func(s *WxCardUpsert) {
  1476. s.ClearAPIKey()
  1477. })
  1478. }
  1479. // SetAiInfo sets the "ai_info" field.
  1480. func (u *WxCardUpsertBulk) SetAiInfo(v string) *WxCardUpsertBulk {
  1481. return u.Update(func(s *WxCardUpsert) {
  1482. s.SetAiInfo(v)
  1483. })
  1484. }
  1485. // UpdateAiInfo sets the "ai_info" field to the value that was provided on create.
  1486. func (u *WxCardUpsertBulk) UpdateAiInfo() *WxCardUpsertBulk {
  1487. return u.Update(func(s *WxCardUpsert) {
  1488. s.UpdateAiInfo()
  1489. })
  1490. }
  1491. // ClearAiInfo clears the value of the "ai_info" field.
  1492. func (u *WxCardUpsertBulk) ClearAiInfo() *WxCardUpsertBulk {
  1493. return u.Update(func(s *WxCardUpsert) {
  1494. s.ClearAiInfo()
  1495. })
  1496. }
  1497. // SetIntro sets the "intro" field.
  1498. func (u *WxCardUpsertBulk) SetIntro(v string) *WxCardUpsertBulk {
  1499. return u.Update(func(s *WxCardUpsert) {
  1500. s.SetIntro(v)
  1501. })
  1502. }
  1503. // UpdateIntro sets the "intro" field to the value that was provided on create.
  1504. func (u *WxCardUpsertBulk) UpdateIntro() *WxCardUpsertBulk {
  1505. return u.Update(func(s *WxCardUpsert) {
  1506. s.UpdateIntro()
  1507. })
  1508. }
  1509. // ClearIntro clears the value of the "intro" field.
  1510. func (u *WxCardUpsertBulk) ClearIntro() *WxCardUpsertBulk {
  1511. return u.Update(func(s *WxCardUpsert) {
  1512. s.ClearIntro()
  1513. })
  1514. }
  1515. // Exec executes the query.
  1516. func (u *WxCardUpsertBulk) Exec(ctx context.Context) error {
  1517. if u.create.err != nil {
  1518. return u.create.err
  1519. }
  1520. for i, b := range u.create.builders {
  1521. if len(b.conflict) != 0 {
  1522. return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the WxCardCreateBulk instead", i)
  1523. }
  1524. }
  1525. if len(u.create.conflict) == 0 {
  1526. return errors.New("ent: missing options for WxCardCreateBulk.OnConflict")
  1527. }
  1528. return u.create.Exec(ctx)
  1529. }
  1530. // ExecX is like Exec, but panics if an error occurs.
  1531. func (u *WxCardUpsertBulk) ExecX(ctx context.Context) {
  1532. if err := u.create.Exec(ctx); err != nil {
  1533. panic(err)
  1534. }
  1535. }