batchmsg_create.go 65 KB

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