msg_create.go 34 KB

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