payrecharge_create.go 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145
  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/payrecharge"
  9. "entgo.io/ent/dialect/sql"
  10. "entgo.io/ent/dialect/sql/sqlgraph"
  11. "entgo.io/ent/schema/field"
  12. )
  13. // PayRechargeCreate is the builder for creating a PayRecharge entity.
  14. type PayRechargeCreate struct {
  15. config
  16. mutation *PayRechargeMutation
  17. hooks []Hook
  18. conflict []sql.ConflictOption
  19. }
  20. // SetCreatedAt sets the "created_at" field.
  21. func (prc *PayRechargeCreate) SetCreatedAt(t time.Time) *PayRechargeCreate {
  22. prc.mutation.SetCreatedAt(t)
  23. return prc
  24. }
  25. // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
  26. func (prc *PayRechargeCreate) SetNillableCreatedAt(t *time.Time) *PayRechargeCreate {
  27. if t != nil {
  28. prc.SetCreatedAt(*t)
  29. }
  30. return prc
  31. }
  32. // SetUpdatedAt sets the "updated_at" field.
  33. func (prc *PayRechargeCreate) SetUpdatedAt(t time.Time) *PayRechargeCreate {
  34. prc.mutation.SetUpdatedAt(t)
  35. return prc
  36. }
  37. // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
  38. func (prc *PayRechargeCreate) SetNillableUpdatedAt(t *time.Time) *PayRechargeCreate {
  39. if t != nil {
  40. prc.SetUpdatedAt(*t)
  41. }
  42. return prc
  43. }
  44. // SetDeletedAt sets the "deleted_at" field.
  45. func (prc *PayRechargeCreate) SetDeletedAt(t time.Time) *PayRechargeCreate {
  46. prc.mutation.SetDeletedAt(t)
  47. return prc
  48. }
  49. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  50. func (prc *PayRechargeCreate) SetNillableDeletedAt(t *time.Time) *PayRechargeCreate {
  51. if t != nil {
  52. prc.SetDeletedAt(*t)
  53. }
  54. return prc
  55. }
  56. // SetUserID sets the "user_id" field.
  57. func (prc *PayRechargeCreate) SetUserID(s string) *PayRechargeCreate {
  58. prc.mutation.SetUserID(s)
  59. return prc
  60. }
  61. // SetNumber sets the "number" field.
  62. func (prc *PayRechargeCreate) SetNumber(f float32) *PayRechargeCreate {
  63. prc.mutation.SetNumber(f)
  64. return prc
  65. }
  66. // SetNillableNumber sets the "number" field if the given value is not nil.
  67. func (prc *PayRechargeCreate) SetNillableNumber(f *float32) *PayRechargeCreate {
  68. if f != nil {
  69. prc.SetNumber(*f)
  70. }
  71. return prc
  72. }
  73. // SetStatus sets the "status" field.
  74. func (prc *PayRechargeCreate) SetStatus(i int) *PayRechargeCreate {
  75. prc.mutation.SetStatus(i)
  76. return prc
  77. }
  78. // SetNillableStatus sets the "status" field if the given value is not nil.
  79. func (prc *PayRechargeCreate) SetNillableStatus(i *int) *PayRechargeCreate {
  80. if i != nil {
  81. prc.SetStatus(*i)
  82. }
  83. return prc
  84. }
  85. // SetMoney sets the "money" field.
  86. func (prc *PayRechargeCreate) SetMoney(f float32) *PayRechargeCreate {
  87. prc.mutation.SetMoney(f)
  88. return prc
  89. }
  90. // SetNillableMoney sets the "money" field if the given value is not nil.
  91. func (prc *PayRechargeCreate) SetNillableMoney(f *float32) *PayRechargeCreate {
  92. if f != nil {
  93. prc.SetMoney(*f)
  94. }
  95. return prc
  96. }
  97. // SetOutTradeNo sets the "out_trade_no" field.
  98. func (prc *PayRechargeCreate) SetOutTradeNo(s string) *PayRechargeCreate {
  99. prc.mutation.SetOutTradeNo(s)
  100. return prc
  101. }
  102. // SetNillableOutTradeNo sets the "out_trade_no" field if the given value is not nil.
  103. func (prc *PayRechargeCreate) SetNillableOutTradeNo(s *string) *PayRechargeCreate {
  104. if s != nil {
  105. prc.SetOutTradeNo(*s)
  106. }
  107. return prc
  108. }
  109. // SetOrganizationID sets the "organization_id" field.
  110. func (prc *PayRechargeCreate) SetOrganizationID(u uint64) *PayRechargeCreate {
  111. prc.mutation.SetOrganizationID(u)
  112. return prc
  113. }
  114. // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
  115. func (prc *PayRechargeCreate) SetNillableOrganizationID(u *uint64) *PayRechargeCreate {
  116. if u != nil {
  117. prc.SetOrganizationID(*u)
  118. }
  119. return prc
  120. }
  121. // SetID sets the "id" field.
  122. func (prc *PayRechargeCreate) SetID(u uint64) *PayRechargeCreate {
  123. prc.mutation.SetID(u)
  124. return prc
  125. }
  126. // Mutation returns the PayRechargeMutation object of the builder.
  127. func (prc *PayRechargeCreate) Mutation() *PayRechargeMutation {
  128. return prc.mutation
  129. }
  130. // Save creates the PayRecharge in the database.
  131. func (prc *PayRechargeCreate) Save(ctx context.Context) (*PayRecharge, error) {
  132. if err := prc.defaults(); err != nil {
  133. return nil, err
  134. }
  135. return withHooks(ctx, prc.sqlSave, prc.mutation, prc.hooks)
  136. }
  137. // SaveX calls Save and panics if Save returns an error.
  138. func (prc *PayRechargeCreate) SaveX(ctx context.Context) *PayRecharge {
  139. v, err := prc.Save(ctx)
  140. if err != nil {
  141. panic(err)
  142. }
  143. return v
  144. }
  145. // Exec executes the query.
  146. func (prc *PayRechargeCreate) Exec(ctx context.Context) error {
  147. _, err := prc.Save(ctx)
  148. return err
  149. }
  150. // ExecX is like Exec, but panics if an error occurs.
  151. func (prc *PayRechargeCreate) ExecX(ctx context.Context) {
  152. if err := prc.Exec(ctx); err != nil {
  153. panic(err)
  154. }
  155. }
  156. // defaults sets the default values of the builder before save.
  157. func (prc *PayRechargeCreate) defaults() error {
  158. if _, ok := prc.mutation.CreatedAt(); !ok {
  159. if payrecharge.DefaultCreatedAt == nil {
  160. return fmt.Errorf("ent: uninitialized payrecharge.DefaultCreatedAt (forgotten import ent/runtime?)")
  161. }
  162. v := payrecharge.DefaultCreatedAt()
  163. prc.mutation.SetCreatedAt(v)
  164. }
  165. if _, ok := prc.mutation.UpdatedAt(); !ok {
  166. if payrecharge.DefaultUpdatedAt == nil {
  167. return fmt.Errorf("ent: uninitialized payrecharge.DefaultUpdatedAt (forgotten import ent/runtime?)")
  168. }
  169. v := payrecharge.DefaultUpdatedAt()
  170. prc.mutation.SetUpdatedAt(v)
  171. }
  172. if _, ok := prc.mutation.Number(); !ok {
  173. v := payrecharge.DefaultNumber
  174. prc.mutation.SetNumber(v)
  175. }
  176. if _, ok := prc.mutation.Status(); !ok {
  177. v := payrecharge.DefaultStatus
  178. prc.mutation.SetStatus(v)
  179. }
  180. if _, ok := prc.mutation.Money(); !ok {
  181. v := payrecharge.DefaultMoney
  182. prc.mutation.SetMoney(v)
  183. }
  184. if _, ok := prc.mutation.OutTradeNo(); !ok {
  185. v := payrecharge.DefaultOutTradeNo
  186. prc.mutation.SetOutTradeNo(v)
  187. }
  188. if _, ok := prc.mutation.OrganizationID(); !ok {
  189. v := payrecharge.DefaultOrganizationID
  190. prc.mutation.SetOrganizationID(v)
  191. }
  192. return nil
  193. }
  194. // check runs all checks and user-defined validators on the builder.
  195. func (prc *PayRechargeCreate) check() error {
  196. if _, ok := prc.mutation.CreatedAt(); !ok {
  197. return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "PayRecharge.created_at"`)}
  198. }
  199. if _, ok := prc.mutation.UpdatedAt(); !ok {
  200. return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "PayRecharge.updated_at"`)}
  201. }
  202. if _, ok := prc.mutation.UserID(); !ok {
  203. return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "PayRecharge.user_id"`)}
  204. }
  205. if v, ok := prc.mutation.UserID(); ok {
  206. if err := payrecharge.UserIDValidator(v); err != nil {
  207. return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "PayRecharge.user_id": %w`, err)}
  208. }
  209. }
  210. if _, ok := prc.mutation.Number(); !ok {
  211. return &ValidationError{Name: "number", err: errors.New(`ent: missing required field "PayRecharge.number"`)}
  212. }
  213. if v, ok := prc.mutation.Status(); ok {
  214. if err := payrecharge.StatusValidator(v); err != nil {
  215. return &ValidationError{Name: "status", err: fmt.Errorf(`ent: validator failed for field "PayRecharge.status": %w`, err)}
  216. }
  217. }
  218. if _, ok := prc.mutation.OrganizationID(); !ok {
  219. return &ValidationError{Name: "organization_id", err: errors.New(`ent: missing required field "PayRecharge.organization_id"`)}
  220. }
  221. if v, ok := prc.mutation.OrganizationID(); ok {
  222. if err := payrecharge.OrganizationIDValidator(v); err != nil {
  223. return &ValidationError{Name: "organization_id", err: fmt.Errorf(`ent: validator failed for field "PayRecharge.organization_id": %w`, err)}
  224. }
  225. }
  226. return nil
  227. }
  228. func (prc *PayRechargeCreate) sqlSave(ctx context.Context) (*PayRecharge, error) {
  229. if err := prc.check(); err != nil {
  230. return nil, err
  231. }
  232. _node, _spec := prc.createSpec()
  233. if err := sqlgraph.CreateNode(ctx, prc.driver, _spec); err != nil {
  234. if sqlgraph.IsConstraintError(err) {
  235. err = &ConstraintError{msg: err.Error(), wrap: err}
  236. }
  237. return nil, err
  238. }
  239. if _spec.ID.Value != _node.ID {
  240. id := _spec.ID.Value.(int64)
  241. _node.ID = uint64(id)
  242. }
  243. prc.mutation.id = &_node.ID
  244. prc.mutation.done = true
  245. return _node, nil
  246. }
  247. func (prc *PayRechargeCreate) createSpec() (*PayRecharge, *sqlgraph.CreateSpec) {
  248. var (
  249. _node = &PayRecharge{config: prc.config}
  250. _spec = sqlgraph.NewCreateSpec(payrecharge.Table, sqlgraph.NewFieldSpec(payrecharge.FieldID, field.TypeUint64))
  251. )
  252. _spec.OnConflict = prc.conflict
  253. if id, ok := prc.mutation.ID(); ok {
  254. _node.ID = id
  255. _spec.ID.Value = id
  256. }
  257. if value, ok := prc.mutation.CreatedAt(); ok {
  258. _spec.SetField(payrecharge.FieldCreatedAt, field.TypeTime, value)
  259. _node.CreatedAt = value
  260. }
  261. if value, ok := prc.mutation.UpdatedAt(); ok {
  262. _spec.SetField(payrecharge.FieldUpdatedAt, field.TypeTime, value)
  263. _node.UpdatedAt = value
  264. }
  265. if value, ok := prc.mutation.DeletedAt(); ok {
  266. _spec.SetField(payrecharge.FieldDeletedAt, field.TypeTime, value)
  267. _node.DeletedAt = value
  268. }
  269. if value, ok := prc.mutation.UserID(); ok {
  270. _spec.SetField(payrecharge.FieldUserID, field.TypeString, value)
  271. _node.UserID = value
  272. }
  273. if value, ok := prc.mutation.Number(); ok {
  274. _spec.SetField(payrecharge.FieldNumber, field.TypeFloat32, value)
  275. _node.Number = value
  276. }
  277. if value, ok := prc.mutation.Status(); ok {
  278. _spec.SetField(payrecharge.FieldStatus, field.TypeInt, value)
  279. _node.Status = value
  280. }
  281. if value, ok := prc.mutation.Money(); ok {
  282. _spec.SetField(payrecharge.FieldMoney, field.TypeFloat32, value)
  283. _node.Money = value
  284. }
  285. if value, ok := prc.mutation.OutTradeNo(); ok {
  286. _spec.SetField(payrecharge.FieldOutTradeNo, field.TypeString, value)
  287. _node.OutTradeNo = value
  288. }
  289. if value, ok := prc.mutation.OrganizationID(); ok {
  290. _spec.SetField(payrecharge.FieldOrganizationID, field.TypeUint64, value)
  291. _node.OrganizationID = value
  292. }
  293. return _node, _spec
  294. }
  295. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  296. // of the `INSERT` statement. For example:
  297. //
  298. // client.PayRecharge.Create().
  299. // SetCreatedAt(v).
  300. // OnConflict(
  301. // // Update the row with the new values
  302. // // the was proposed for insertion.
  303. // sql.ResolveWithNewValues(),
  304. // ).
  305. // // Override some of the fields with custom
  306. // // update values.
  307. // Update(func(u *ent.PayRechargeUpsert) {
  308. // SetCreatedAt(v+v).
  309. // }).
  310. // Exec(ctx)
  311. func (prc *PayRechargeCreate) OnConflict(opts ...sql.ConflictOption) *PayRechargeUpsertOne {
  312. prc.conflict = opts
  313. return &PayRechargeUpsertOne{
  314. create: prc,
  315. }
  316. }
  317. // OnConflictColumns calls `OnConflict` and configures the columns
  318. // as conflict target. Using this option is equivalent to using:
  319. //
  320. // client.PayRecharge.Create().
  321. // OnConflict(sql.ConflictColumns(columns...)).
  322. // Exec(ctx)
  323. func (prc *PayRechargeCreate) OnConflictColumns(columns ...string) *PayRechargeUpsertOne {
  324. prc.conflict = append(prc.conflict, sql.ConflictColumns(columns...))
  325. return &PayRechargeUpsertOne{
  326. create: prc,
  327. }
  328. }
  329. type (
  330. // PayRechargeUpsertOne is the builder for "upsert"-ing
  331. // one PayRecharge node.
  332. PayRechargeUpsertOne struct {
  333. create *PayRechargeCreate
  334. }
  335. // PayRechargeUpsert is the "OnConflict" setter.
  336. PayRechargeUpsert struct {
  337. *sql.UpdateSet
  338. }
  339. )
  340. // SetUpdatedAt sets the "updated_at" field.
  341. func (u *PayRechargeUpsert) SetUpdatedAt(v time.Time) *PayRechargeUpsert {
  342. u.Set(payrecharge.FieldUpdatedAt, v)
  343. return u
  344. }
  345. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  346. func (u *PayRechargeUpsert) UpdateUpdatedAt() *PayRechargeUpsert {
  347. u.SetExcluded(payrecharge.FieldUpdatedAt)
  348. return u
  349. }
  350. // SetDeletedAt sets the "deleted_at" field.
  351. func (u *PayRechargeUpsert) SetDeletedAt(v time.Time) *PayRechargeUpsert {
  352. u.Set(payrecharge.FieldDeletedAt, v)
  353. return u
  354. }
  355. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  356. func (u *PayRechargeUpsert) UpdateDeletedAt() *PayRechargeUpsert {
  357. u.SetExcluded(payrecharge.FieldDeletedAt)
  358. return u
  359. }
  360. // ClearDeletedAt clears the value of the "deleted_at" field.
  361. func (u *PayRechargeUpsert) ClearDeletedAt() *PayRechargeUpsert {
  362. u.SetNull(payrecharge.FieldDeletedAt)
  363. return u
  364. }
  365. // SetUserID sets the "user_id" field.
  366. func (u *PayRechargeUpsert) SetUserID(v string) *PayRechargeUpsert {
  367. u.Set(payrecharge.FieldUserID, v)
  368. return u
  369. }
  370. // UpdateUserID sets the "user_id" field to the value that was provided on create.
  371. func (u *PayRechargeUpsert) UpdateUserID() *PayRechargeUpsert {
  372. u.SetExcluded(payrecharge.FieldUserID)
  373. return u
  374. }
  375. // SetNumber sets the "number" field.
  376. func (u *PayRechargeUpsert) SetNumber(v float32) *PayRechargeUpsert {
  377. u.Set(payrecharge.FieldNumber, v)
  378. return u
  379. }
  380. // UpdateNumber sets the "number" field to the value that was provided on create.
  381. func (u *PayRechargeUpsert) UpdateNumber() *PayRechargeUpsert {
  382. u.SetExcluded(payrecharge.FieldNumber)
  383. return u
  384. }
  385. // AddNumber adds v to the "number" field.
  386. func (u *PayRechargeUpsert) AddNumber(v float32) *PayRechargeUpsert {
  387. u.Add(payrecharge.FieldNumber, v)
  388. return u
  389. }
  390. // SetStatus sets the "status" field.
  391. func (u *PayRechargeUpsert) SetStatus(v int) *PayRechargeUpsert {
  392. u.Set(payrecharge.FieldStatus, v)
  393. return u
  394. }
  395. // UpdateStatus sets the "status" field to the value that was provided on create.
  396. func (u *PayRechargeUpsert) UpdateStatus() *PayRechargeUpsert {
  397. u.SetExcluded(payrecharge.FieldStatus)
  398. return u
  399. }
  400. // AddStatus adds v to the "status" field.
  401. func (u *PayRechargeUpsert) AddStatus(v int) *PayRechargeUpsert {
  402. u.Add(payrecharge.FieldStatus, v)
  403. return u
  404. }
  405. // ClearStatus clears the value of the "status" field.
  406. func (u *PayRechargeUpsert) ClearStatus() *PayRechargeUpsert {
  407. u.SetNull(payrecharge.FieldStatus)
  408. return u
  409. }
  410. // SetMoney sets the "money" field.
  411. func (u *PayRechargeUpsert) SetMoney(v float32) *PayRechargeUpsert {
  412. u.Set(payrecharge.FieldMoney, v)
  413. return u
  414. }
  415. // UpdateMoney sets the "money" field to the value that was provided on create.
  416. func (u *PayRechargeUpsert) UpdateMoney() *PayRechargeUpsert {
  417. u.SetExcluded(payrecharge.FieldMoney)
  418. return u
  419. }
  420. // AddMoney adds v to the "money" field.
  421. func (u *PayRechargeUpsert) AddMoney(v float32) *PayRechargeUpsert {
  422. u.Add(payrecharge.FieldMoney, v)
  423. return u
  424. }
  425. // ClearMoney clears the value of the "money" field.
  426. func (u *PayRechargeUpsert) ClearMoney() *PayRechargeUpsert {
  427. u.SetNull(payrecharge.FieldMoney)
  428. return u
  429. }
  430. // SetOutTradeNo sets the "out_trade_no" field.
  431. func (u *PayRechargeUpsert) SetOutTradeNo(v string) *PayRechargeUpsert {
  432. u.Set(payrecharge.FieldOutTradeNo, v)
  433. return u
  434. }
  435. // UpdateOutTradeNo sets the "out_trade_no" field to the value that was provided on create.
  436. func (u *PayRechargeUpsert) UpdateOutTradeNo() *PayRechargeUpsert {
  437. u.SetExcluded(payrecharge.FieldOutTradeNo)
  438. return u
  439. }
  440. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  441. func (u *PayRechargeUpsert) ClearOutTradeNo() *PayRechargeUpsert {
  442. u.SetNull(payrecharge.FieldOutTradeNo)
  443. return u
  444. }
  445. // SetOrganizationID sets the "organization_id" field.
  446. func (u *PayRechargeUpsert) SetOrganizationID(v uint64) *PayRechargeUpsert {
  447. u.Set(payrecharge.FieldOrganizationID, v)
  448. return u
  449. }
  450. // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
  451. func (u *PayRechargeUpsert) UpdateOrganizationID() *PayRechargeUpsert {
  452. u.SetExcluded(payrecharge.FieldOrganizationID)
  453. return u
  454. }
  455. // AddOrganizationID adds v to the "organization_id" field.
  456. func (u *PayRechargeUpsert) AddOrganizationID(v uint64) *PayRechargeUpsert {
  457. u.Add(payrecharge.FieldOrganizationID, v)
  458. return u
  459. }
  460. // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
  461. // Using this option is equivalent to using:
  462. //
  463. // client.PayRecharge.Create().
  464. // OnConflict(
  465. // sql.ResolveWithNewValues(),
  466. // sql.ResolveWith(func(u *sql.UpdateSet) {
  467. // u.SetIgnore(payrecharge.FieldID)
  468. // }),
  469. // ).
  470. // Exec(ctx)
  471. func (u *PayRechargeUpsertOne) UpdateNewValues() *PayRechargeUpsertOne {
  472. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  473. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  474. if _, exists := u.create.mutation.ID(); exists {
  475. s.SetIgnore(payrecharge.FieldID)
  476. }
  477. if _, exists := u.create.mutation.CreatedAt(); exists {
  478. s.SetIgnore(payrecharge.FieldCreatedAt)
  479. }
  480. }))
  481. return u
  482. }
  483. // Ignore sets each column to itself in case of conflict.
  484. // Using this option is equivalent to using:
  485. //
  486. // client.PayRecharge.Create().
  487. // OnConflict(sql.ResolveWithIgnore()).
  488. // Exec(ctx)
  489. func (u *PayRechargeUpsertOne) Ignore() *PayRechargeUpsertOne {
  490. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  491. return u
  492. }
  493. // DoNothing configures the conflict_action to `DO NOTHING`.
  494. // Supported only by SQLite and PostgreSQL.
  495. func (u *PayRechargeUpsertOne) DoNothing() *PayRechargeUpsertOne {
  496. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  497. return u
  498. }
  499. // Update allows overriding fields `UPDATE` values. See the PayRechargeCreate.OnConflict
  500. // documentation for more info.
  501. func (u *PayRechargeUpsertOne) Update(set func(*PayRechargeUpsert)) *PayRechargeUpsertOne {
  502. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  503. set(&PayRechargeUpsert{UpdateSet: update})
  504. }))
  505. return u
  506. }
  507. // SetUpdatedAt sets the "updated_at" field.
  508. func (u *PayRechargeUpsertOne) SetUpdatedAt(v time.Time) *PayRechargeUpsertOne {
  509. return u.Update(func(s *PayRechargeUpsert) {
  510. s.SetUpdatedAt(v)
  511. })
  512. }
  513. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  514. func (u *PayRechargeUpsertOne) UpdateUpdatedAt() *PayRechargeUpsertOne {
  515. return u.Update(func(s *PayRechargeUpsert) {
  516. s.UpdateUpdatedAt()
  517. })
  518. }
  519. // SetDeletedAt sets the "deleted_at" field.
  520. func (u *PayRechargeUpsertOne) SetDeletedAt(v time.Time) *PayRechargeUpsertOne {
  521. return u.Update(func(s *PayRechargeUpsert) {
  522. s.SetDeletedAt(v)
  523. })
  524. }
  525. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  526. func (u *PayRechargeUpsertOne) UpdateDeletedAt() *PayRechargeUpsertOne {
  527. return u.Update(func(s *PayRechargeUpsert) {
  528. s.UpdateDeletedAt()
  529. })
  530. }
  531. // ClearDeletedAt clears the value of the "deleted_at" field.
  532. func (u *PayRechargeUpsertOne) ClearDeletedAt() *PayRechargeUpsertOne {
  533. return u.Update(func(s *PayRechargeUpsert) {
  534. s.ClearDeletedAt()
  535. })
  536. }
  537. // SetUserID sets the "user_id" field.
  538. func (u *PayRechargeUpsertOne) SetUserID(v string) *PayRechargeUpsertOne {
  539. return u.Update(func(s *PayRechargeUpsert) {
  540. s.SetUserID(v)
  541. })
  542. }
  543. // UpdateUserID sets the "user_id" field to the value that was provided on create.
  544. func (u *PayRechargeUpsertOne) UpdateUserID() *PayRechargeUpsertOne {
  545. return u.Update(func(s *PayRechargeUpsert) {
  546. s.UpdateUserID()
  547. })
  548. }
  549. // SetNumber sets the "number" field.
  550. func (u *PayRechargeUpsertOne) SetNumber(v float32) *PayRechargeUpsertOne {
  551. return u.Update(func(s *PayRechargeUpsert) {
  552. s.SetNumber(v)
  553. })
  554. }
  555. // AddNumber adds v to the "number" field.
  556. func (u *PayRechargeUpsertOne) AddNumber(v float32) *PayRechargeUpsertOne {
  557. return u.Update(func(s *PayRechargeUpsert) {
  558. s.AddNumber(v)
  559. })
  560. }
  561. // UpdateNumber sets the "number" field to the value that was provided on create.
  562. func (u *PayRechargeUpsertOne) UpdateNumber() *PayRechargeUpsertOne {
  563. return u.Update(func(s *PayRechargeUpsert) {
  564. s.UpdateNumber()
  565. })
  566. }
  567. // SetStatus sets the "status" field.
  568. func (u *PayRechargeUpsertOne) SetStatus(v int) *PayRechargeUpsertOne {
  569. return u.Update(func(s *PayRechargeUpsert) {
  570. s.SetStatus(v)
  571. })
  572. }
  573. // AddStatus adds v to the "status" field.
  574. func (u *PayRechargeUpsertOne) AddStatus(v int) *PayRechargeUpsertOne {
  575. return u.Update(func(s *PayRechargeUpsert) {
  576. s.AddStatus(v)
  577. })
  578. }
  579. // UpdateStatus sets the "status" field to the value that was provided on create.
  580. func (u *PayRechargeUpsertOne) UpdateStatus() *PayRechargeUpsertOne {
  581. return u.Update(func(s *PayRechargeUpsert) {
  582. s.UpdateStatus()
  583. })
  584. }
  585. // ClearStatus clears the value of the "status" field.
  586. func (u *PayRechargeUpsertOne) ClearStatus() *PayRechargeUpsertOne {
  587. return u.Update(func(s *PayRechargeUpsert) {
  588. s.ClearStatus()
  589. })
  590. }
  591. // SetMoney sets the "money" field.
  592. func (u *PayRechargeUpsertOne) SetMoney(v float32) *PayRechargeUpsertOne {
  593. return u.Update(func(s *PayRechargeUpsert) {
  594. s.SetMoney(v)
  595. })
  596. }
  597. // AddMoney adds v to the "money" field.
  598. func (u *PayRechargeUpsertOne) AddMoney(v float32) *PayRechargeUpsertOne {
  599. return u.Update(func(s *PayRechargeUpsert) {
  600. s.AddMoney(v)
  601. })
  602. }
  603. // UpdateMoney sets the "money" field to the value that was provided on create.
  604. func (u *PayRechargeUpsertOne) UpdateMoney() *PayRechargeUpsertOne {
  605. return u.Update(func(s *PayRechargeUpsert) {
  606. s.UpdateMoney()
  607. })
  608. }
  609. // ClearMoney clears the value of the "money" field.
  610. func (u *PayRechargeUpsertOne) ClearMoney() *PayRechargeUpsertOne {
  611. return u.Update(func(s *PayRechargeUpsert) {
  612. s.ClearMoney()
  613. })
  614. }
  615. // SetOutTradeNo sets the "out_trade_no" field.
  616. func (u *PayRechargeUpsertOne) SetOutTradeNo(v string) *PayRechargeUpsertOne {
  617. return u.Update(func(s *PayRechargeUpsert) {
  618. s.SetOutTradeNo(v)
  619. })
  620. }
  621. // UpdateOutTradeNo sets the "out_trade_no" field to the value that was provided on create.
  622. func (u *PayRechargeUpsertOne) UpdateOutTradeNo() *PayRechargeUpsertOne {
  623. return u.Update(func(s *PayRechargeUpsert) {
  624. s.UpdateOutTradeNo()
  625. })
  626. }
  627. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  628. func (u *PayRechargeUpsertOne) ClearOutTradeNo() *PayRechargeUpsertOne {
  629. return u.Update(func(s *PayRechargeUpsert) {
  630. s.ClearOutTradeNo()
  631. })
  632. }
  633. // SetOrganizationID sets the "organization_id" field.
  634. func (u *PayRechargeUpsertOne) SetOrganizationID(v uint64) *PayRechargeUpsertOne {
  635. return u.Update(func(s *PayRechargeUpsert) {
  636. s.SetOrganizationID(v)
  637. })
  638. }
  639. // AddOrganizationID adds v to the "organization_id" field.
  640. func (u *PayRechargeUpsertOne) AddOrganizationID(v uint64) *PayRechargeUpsertOne {
  641. return u.Update(func(s *PayRechargeUpsert) {
  642. s.AddOrganizationID(v)
  643. })
  644. }
  645. // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
  646. func (u *PayRechargeUpsertOne) UpdateOrganizationID() *PayRechargeUpsertOne {
  647. return u.Update(func(s *PayRechargeUpsert) {
  648. s.UpdateOrganizationID()
  649. })
  650. }
  651. // Exec executes the query.
  652. func (u *PayRechargeUpsertOne) Exec(ctx context.Context) error {
  653. if len(u.create.conflict) == 0 {
  654. return errors.New("ent: missing options for PayRechargeCreate.OnConflict")
  655. }
  656. return u.create.Exec(ctx)
  657. }
  658. // ExecX is like Exec, but panics if an error occurs.
  659. func (u *PayRechargeUpsertOne) ExecX(ctx context.Context) {
  660. if err := u.create.Exec(ctx); err != nil {
  661. panic(err)
  662. }
  663. }
  664. // Exec executes the UPSERT query and returns the inserted/updated ID.
  665. func (u *PayRechargeUpsertOne) ID(ctx context.Context) (id uint64, err error) {
  666. node, err := u.create.Save(ctx)
  667. if err != nil {
  668. return id, err
  669. }
  670. return node.ID, nil
  671. }
  672. // IDX is like ID, but panics if an error occurs.
  673. func (u *PayRechargeUpsertOne) IDX(ctx context.Context) uint64 {
  674. id, err := u.ID(ctx)
  675. if err != nil {
  676. panic(err)
  677. }
  678. return id
  679. }
  680. // PayRechargeCreateBulk is the builder for creating many PayRecharge entities in bulk.
  681. type PayRechargeCreateBulk struct {
  682. config
  683. err error
  684. builders []*PayRechargeCreate
  685. conflict []sql.ConflictOption
  686. }
  687. // Save creates the PayRecharge entities in the database.
  688. func (prcb *PayRechargeCreateBulk) Save(ctx context.Context) ([]*PayRecharge, error) {
  689. if prcb.err != nil {
  690. return nil, prcb.err
  691. }
  692. specs := make([]*sqlgraph.CreateSpec, len(prcb.builders))
  693. nodes := make([]*PayRecharge, len(prcb.builders))
  694. mutators := make([]Mutator, len(prcb.builders))
  695. for i := range prcb.builders {
  696. func(i int, root context.Context) {
  697. builder := prcb.builders[i]
  698. builder.defaults()
  699. var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
  700. mutation, ok := m.(*PayRechargeMutation)
  701. if !ok {
  702. return nil, fmt.Errorf("unexpected mutation type %T", m)
  703. }
  704. if err := builder.check(); err != nil {
  705. return nil, err
  706. }
  707. builder.mutation = mutation
  708. var err error
  709. nodes[i], specs[i] = builder.createSpec()
  710. if i < len(mutators)-1 {
  711. _, err = mutators[i+1].Mutate(root, prcb.builders[i+1].mutation)
  712. } else {
  713. spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
  714. spec.OnConflict = prcb.conflict
  715. // Invoke the actual operation on the latest mutation in the chain.
  716. if err = sqlgraph.BatchCreate(ctx, prcb.driver, spec); err != nil {
  717. if sqlgraph.IsConstraintError(err) {
  718. err = &ConstraintError{msg: err.Error(), wrap: err}
  719. }
  720. }
  721. }
  722. if err != nil {
  723. return nil, err
  724. }
  725. mutation.id = &nodes[i].ID
  726. if specs[i].ID.Value != nil && nodes[i].ID == 0 {
  727. id := specs[i].ID.Value.(int64)
  728. nodes[i].ID = uint64(id)
  729. }
  730. mutation.done = true
  731. return nodes[i], nil
  732. })
  733. for i := len(builder.hooks) - 1; i >= 0; i-- {
  734. mut = builder.hooks[i](mut)
  735. }
  736. mutators[i] = mut
  737. }(i, ctx)
  738. }
  739. if len(mutators) > 0 {
  740. if _, err := mutators[0].Mutate(ctx, prcb.builders[0].mutation); err != nil {
  741. return nil, err
  742. }
  743. }
  744. return nodes, nil
  745. }
  746. // SaveX is like Save, but panics if an error occurs.
  747. func (prcb *PayRechargeCreateBulk) SaveX(ctx context.Context) []*PayRecharge {
  748. v, err := prcb.Save(ctx)
  749. if err != nil {
  750. panic(err)
  751. }
  752. return v
  753. }
  754. // Exec executes the query.
  755. func (prcb *PayRechargeCreateBulk) Exec(ctx context.Context) error {
  756. _, err := prcb.Save(ctx)
  757. return err
  758. }
  759. // ExecX is like Exec, but panics if an error occurs.
  760. func (prcb *PayRechargeCreateBulk) ExecX(ctx context.Context) {
  761. if err := prcb.Exec(ctx); err != nil {
  762. panic(err)
  763. }
  764. }
  765. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  766. // of the `INSERT` statement. For example:
  767. //
  768. // client.PayRecharge.CreateBulk(builders...).
  769. // OnConflict(
  770. // // Update the row with the new values
  771. // // the was proposed for insertion.
  772. // sql.ResolveWithNewValues(),
  773. // ).
  774. // // Override some of the fields with custom
  775. // // update values.
  776. // Update(func(u *ent.PayRechargeUpsert) {
  777. // SetCreatedAt(v+v).
  778. // }).
  779. // Exec(ctx)
  780. func (prcb *PayRechargeCreateBulk) OnConflict(opts ...sql.ConflictOption) *PayRechargeUpsertBulk {
  781. prcb.conflict = opts
  782. return &PayRechargeUpsertBulk{
  783. create: prcb,
  784. }
  785. }
  786. // OnConflictColumns calls `OnConflict` and configures the columns
  787. // as conflict target. Using this option is equivalent to using:
  788. //
  789. // client.PayRecharge.Create().
  790. // OnConflict(sql.ConflictColumns(columns...)).
  791. // Exec(ctx)
  792. func (prcb *PayRechargeCreateBulk) OnConflictColumns(columns ...string) *PayRechargeUpsertBulk {
  793. prcb.conflict = append(prcb.conflict, sql.ConflictColumns(columns...))
  794. return &PayRechargeUpsertBulk{
  795. create: prcb,
  796. }
  797. }
  798. // PayRechargeUpsertBulk is the builder for "upsert"-ing
  799. // a bulk of PayRecharge nodes.
  800. type PayRechargeUpsertBulk struct {
  801. create *PayRechargeCreateBulk
  802. }
  803. // UpdateNewValues updates the mutable fields using the new values that
  804. // were set on create. Using this option is equivalent to using:
  805. //
  806. // client.PayRecharge.Create().
  807. // OnConflict(
  808. // sql.ResolveWithNewValues(),
  809. // sql.ResolveWith(func(u *sql.UpdateSet) {
  810. // u.SetIgnore(payrecharge.FieldID)
  811. // }),
  812. // ).
  813. // Exec(ctx)
  814. func (u *PayRechargeUpsertBulk) UpdateNewValues() *PayRechargeUpsertBulk {
  815. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  816. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  817. for _, b := range u.create.builders {
  818. if _, exists := b.mutation.ID(); exists {
  819. s.SetIgnore(payrecharge.FieldID)
  820. }
  821. if _, exists := b.mutation.CreatedAt(); exists {
  822. s.SetIgnore(payrecharge.FieldCreatedAt)
  823. }
  824. }
  825. }))
  826. return u
  827. }
  828. // Ignore sets each column to itself in case of conflict.
  829. // Using this option is equivalent to using:
  830. //
  831. // client.PayRecharge.Create().
  832. // OnConflict(sql.ResolveWithIgnore()).
  833. // Exec(ctx)
  834. func (u *PayRechargeUpsertBulk) Ignore() *PayRechargeUpsertBulk {
  835. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  836. return u
  837. }
  838. // DoNothing configures the conflict_action to `DO NOTHING`.
  839. // Supported only by SQLite and PostgreSQL.
  840. func (u *PayRechargeUpsertBulk) DoNothing() *PayRechargeUpsertBulk {
  841. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  842. return u
  843. }
  844. // Update allows overriding fields `UPDATE` values. See the PayRechargeCreateBulk.OnConflict
  845. // documentation for more info.
  846. func (u *PayRechargeUpsertBulk) Update(set func(*PayRechargeUpsert)) *PayRechargeUpsertBulk {
  847. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  848. set(&PayRechargeUpsert{UpdateSet: update})
  849. }))
  850. return u
  851. }
  852. // SetUpdatedAt sets the "updated_at" field.
  853. func (u *PayRechargeUpsertBulk) SetUpdatedAt(v time.Time) *PayRechargeUpsertBulk {
  854. return u.Update(func(s *PayRechargeUpsert) {
  855. s.SetUpdatedAt(v)
  856. })
  857. }
  858. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  859. func (u *PayRechargeUpsertBulk) UpdateUpdatedAt() *PayRechargeUpsertBulk {
  860. return u.Update(func(s *PayRechargeUpsert) {
  861. s.UpdateUpdatedAt()
  862. })
  863. }
  864. // SetDeletedAt sets the "deleted_at" field.
  865. func (u *PayRechargeUpsertBulk) SetDeletedAt(v time.Time) *PayRechargeUpsertBulk {
  866. return u.Update(func(s *PayRechargeUpsert) {
  867. s.SetDeletedAt(v)
  868. })
  869. }
  870. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  871. func (u *PayRechargeUpsertBulk) UpdateDeletedAt() *PayRechargeUpsertBulk {
  872. return u.Update(func(s *PayRechargeUpsert) {
  873. s.UpdateDeletedAt()
  874. })
  875. }
  876. // ClearDeletedAt clears the value of the "deleted_at" field.
  877. func (u *PayRechargeUpsertBulk) ClearDeletedAt() *PayRechargeUpsertBulk {
  878. return u.Update(func(s *PayRechargeUpsert) {
  879. s.ClearDeletedAt()
  880. })
  881. }
  882. // SetUserID sets the "user_id" field.
  883. func (u *PayRechargeUpsertBulk) SetUserID(v string) *PayRechargeUpsertBulk {
  884. return u.Update(func(s *PayRechargeUpsert) {
  885. s.SetUserID(v)
  886. })
  887. }
  888. // UpdateUserID sets the "user_id" field to the value that was provided on create.
  889. func (u *PayRechargeUpsertBulk) UpdateUserID() *PayRechargeUpsertBulk {
  890. return u.Update(func(s *PayRechargeUpsert) {
  891. s.UpdateUserID()
  892. })
  893. }
  894. // SetNumber sets the "number" field.
  895. func (u *PayRechargeUpsertBulk) SetNumber(v float32) *PayRechargeUpsertBulk {
  896. return u.Update(func(s *PayRechargeUpsert) {
  897. s.SetNumber(v)
  898. })
  899. }
  900. // AddNumber adds v to the "number" field.
  901. func (u *PayRechargeUpsertBulk) AddNumber(v float32) *PayRechargeUpsertBulk {
  902. return u.Update(func(s *PayRechargeUpsert) {
  903. s.AddNumber(v)
  904. })
  905. }
  906. // UpdateNumber sets the "number" field to the value that was provided on create.
  907. func (u *PayRechargeUpsertBulk) UpdateNumber() *PayRechargeUpsertBulk {
  908. return u.Update(func(s *PayRechargeUpsert) {
  909. s.UpdateNumber()
  910. })
  911. }
  912. // SetStatus sets the "status" field.
  913. func (u *PayRechargeUpsertBulk) SetStatus(v int) *PayRechargeUpsertBulk {
  914. return u.Update(func(s *PayRechargeUpsert) {
  915. s.SetStatus(v)
  916. })
  917. }
  918. // AddStatus adds v to the "status" field.
  919. func (u *PayRechargeUpsertBulk) AddStatus(v int) *PayRechargeUpsertBulk {
  920. return u.Update(func(s *PayRechargeUpsert) {
  921. s.AddStatus(v)
  922. })
  923. }
  924. // UpdateStatus sets the "status" field to the value that was provided on create.
  925. func (u *PayRechargeUpsertBulk) UpdateStatus() *PayRechargeUpsertBulk {
  926. return u.Update(func(s *PayRechargeUpsert) {
  927. s.UpdateStatus()
  928. })
  929. }
  930. // ClearStatus clears the value of the "status" field.
  931. func (u *PayRechargeUpsertBulk) ClearStatus() *PayRechargeUpsertBulk {
  932. return u.Update(func(s *PayRechargeUpsert) {
  933. s.ClearStatus()
  934. })
  935. }
  936. // SetMoney sets the "money" field.
  937. func (u *PayRechargeUpsertBulk) SetMoney(v float32) *PayRechargeUpsertBulk {
  938. return u.Update(func(s *PayRechargeUpsert) {
  939. s.SetMoney(v)
  940. })
  941. }
  942. // AddMoney adds v to the "money" field.
  943. func (u *PayRechargeUpsertBulk) AddMoney(v float32) *PayRechargeUpsertBulk {
  944. return u.Update(func(s *PayRechargeUpsert) {
  945. s.AddMoney(v)
  946. })
  947. }
  948. // UpdateMoney sets the "money" field to the value that was provided on create.
  949. func (u *PayRechargeUpsertBulk) UpdateMoney() *PayRechargeUpsertBulk {
  950. return u.Update(func(s *PayRechargeUpsert) {
  951. s.UpdateMoney()
  952. })
  953. }
  954. // ClearMoney clears the value of the "money" field.
  955. func (u *PayRechargeUpsertBulk) ClearMoney() *PayRechargeUpsertBulk {
  956. return u.Update(func(s *PayRechargeUpsert) {
  957. s.ClearMoney()
  958. })
  959. }
  960. // SetOutTradeNo sets the "out_trade_no" field.
  961. func (u *PayRechargeUpsertBulk) SetOutTradeNo(v string) *PayRechargeUpsertBulk {
  962. return u.Update(func(s *PayRechargeUpsert) {
  963. s.SetOutTradeNo(v)
  964. })
  965. }
  966. // UpdateOutTradeNo sets the "out_trade_no" field to the value that was provided on create.
  967. func (u *PayRechargeUpsertBulk) UpdateOutTradeNo() *PayRechargeUpsertBulk {
  968. return u.Update(func(s *PayRechargeUpsert) {
  969. s.UpdateOutTradeNo()
  970. })
  971. }
  972. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  973. func (u *PayRechargeUpsertBulk) ClearOutTradeNo() *PayRechargeUpsertBulk {
  974. return u.Update(func(s *PayRechargeUpsert) {
  975. s.ClearOutTradeNo()
  976. })
  977. }
  978. // SetOrganizationID sets the "organization_id" field.
  979. func (u *PayRechargeUpsertBulk) SetOrganizationID(v uint64) *PayRechargeUpsertBulk {
  980. return u.Update(func(s *PayRechargeUpsert) {
  981. s.SetOrganizationID(v)
  982. })
  983. }
  984. // AddOrganizationID adds v to the "organization_id" field.
  985. func (u *PayRechargeUpsertBulk) AddOrganizationID(v uint64) *PayRechargeUpsertBulk {
  986. return u.Update(func(s *PayRechargeUpsert) {
  987. s.AddOrganizationID(v)
  988. })
  989. }
  990. // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
  991. func (u *PayRechargeUpsertBulk) UpdateOrganizationID() *PayRechargeUpsertBulk {
  992. return u.Update(func(s *PayRechargeUpsert) {
  993. s.UpdateOrganizationID()
  994. })
  995. }
  996. // Exec executes the query.
  997. func (u *PayRechargeUpsertBulk) Exec(ctx context.Context) error {
  998. if u.create.err != nil {
  999. return u.create.err
  1000. }
  1001. for i, b := range u.create.builders {
  1002. if len(b.conflict) != 0 {
  1003. return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the PayRechargeCreateBulk instead", i)
  1004. }
  1005. }
  1006. if len(u.create.conflict) == 0 {
  1007. return errors.New("ent: missing options for PayRechargeCreateBulk.OnConflict")
  1008. }
  1009. return u.create.Exec(ctx)
  1010. }
  1011. // ExecX is like Exec, but panics if an error occurs.
  1012. func (u *PayRechargeUpsertBulk) ExecX(ctx context.Context) {
  1013. if err := u.create.Exec(ctx); err != nil {
  1014. panic(err)
  1015. }
  1016. }