batchmsg_create.go 47 KB

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