msg_create.go 32 KB

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