batchmsg_create.go 52 KB

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