batchmsg_create.go 58 KB

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