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