batchmsg_update.go 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498
  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. "wechat-api/ent/predicate"
  10. "entgo.io/ent/dialect/sql"
  11. "entgo.io/ent/dialect/sql/sqlgraph"
  12. "entgo.io/ent/schema/field"
  13. )
  14. // BatchMsgUpdate is the builder for updating BatchMsg entities.
  15. type BatchMsgUpdate struct {
  16. config
  17. hooks []Hook
  18. mutation *BatchMsgMutation
  19. }
  20. // Where appends a list predicates to the BatchMsgUpdate builder.
  21. func (bmu *BatchMsgUpdate) Where(ps ...predicate.BatchMsg) *BatchMsgUpdate {
  22. bmu.mutation.Where(ps...)
  23. return bmu
  24. }
  25. // SetUpdatedAt sets the "updated_at" field.
  26. func (bmu *BatchMsgUpdate) SetUpdatedAt(t time.Time) *BatchMsgUpdate {
  27. bmu.mutation.SetUpdatedAt(t)
  28. return bmu
  29. }
  30. // SetDeletedAt sets the "deleted_at" field.
  31. func (bmu *BatchMsgUpdate) SetDeletedAt(t time.Time) *BatchMsgUpdate {
  32. bmu.mutation.SetDeletedAt(t)
  33. return bmu
  34. }
  35. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  36. func (bmu *BatchMsgUpdate) SetNillableDeletedAt(t *time.Time) *BatchMsgUpdate {
  37. if t != nil {
  38. bmu.SetDeletedAt(*t)
  39. }
  40. return bmu
  41. }
  42. // ClearDeletedAt clears the value of the "deleted_at" field.
  43. func (bmu *BatchMsgUpdate) ClearDeletedAt() *BatchMsgUpdate {
  44. bmu.mutation.ClearDeletedAt()
  45. return bmu
  46. }
  47. // SetStatus sets the "status" field.
  48. func (bmu *BatchMsgUpdate) SetStatus(u uint8) *BatchMsgUpdate {
  49. bmu.mutation.ResetStatus()
  50. bmu.mutation.SetStatus(u)
  51. return bmu
  52. }
  53. // SetNillableStatus sets the "status" field if the given value is not nil.
  54. func (bmu *BatchMsgUpdate) SetNillableStatus(u *uint8) *BatchMsgUpdate {
  55. if u != nil {
  56. bmu.SetStatus(*u)
  57. }
  58. return bmu
  59. }
  60. // AddStatus adds u to the "status" field.
  61. func (bmu *BatchMsgUpdate) AddStatus(u int8) *BatchMsgUpdate {
  62. bmu.mutation.AddStatus(u)
  63. return bmu
  64. }
  65. // ClearStatus clears the value of the "status" field.
  66. func (bmu *BatchMsgUpdate) ClearStatus() *BatchMsgUpdate {
  67. bmu.mutation.ClearStatus()
  68. return bmu
  69. }
  70. // SetBatchNo sets the "batch_no" field.
  71. func (bmu *BatchMsgUpdate) SetBatchNo(s string) *BatchMsgUpdate {
  72. bmu.mutation.SetBatchNo(s)
  73. return bmu
  74. }
  75. // SetNillableBatchNo sets the "batch_no" field if the given value is not nil.
  76. func (bmu *BatchMsgUpdate) SetNillableBatchNo(s *string) *BatchMsgUpdate {
  77. if s != nil {
  78. bmu.SetBatchNo(*s)
  79. }
  80. return bmu
  81. }
  82. // ClearBatchNo clears the value of the "batch_no" field.
  83. func (bmu *BatchMsgUpdate) ClearBatchNo() *BatchMsgUpdate {
  84. bmu.mutation.ClearBatchNo()
  85. return bmu
  86. }
  87. // SetTaskName sets the "task_name" field.
  88. func (bmu *BatchMsgUpdate) SetTaskName(s string) *BatchMsgUpdate {
  89. bmu.mutation.SetTaskName(s)
  90. return bmu
  91. }
  92. // SetNillableTaskName sets the "task_name" field if the given value is not nil.
  93. func (bmu *BatchMsgUpdate) SetNillableTaskName(s *string) *BatchMsgUpdate {
  94. if s != nil {
  95. bmu.SetTaskName(*s)
  96. }
  97. return bmu
  98. }
  99. // ClearTaskName clears the value of the "task_name" field.
  100. func (bmu *BatchMsgUpdate) ClearTaskName() *BatchMsgUpdate {
  101. bmu.mutation.ClearTaskName()
  102. return bmu
  103. }
  104. // SetFromwxid sets the "fromwxid" field.
  105. func (bmu *BatchMsgUpdate) SetFromwxid(s string) *BatchMsgUpdate {
  106. bmu.mutation.SetFromwxid(s)
  107. return bmu
  108. }
  109. // SetNillableFromwxid sets the "fromwxid" field if the given value is not nil.
  110. func (bmu *BatchMsgUpdate) SetNillableFromwxid(s *string) *BatchMsgUpdate {
  111. if s != nil {
  112. bmu.SetFromwxid(*s)
  113. }
  114. return bmu
  115. }
  116. // ClearFromwxid clears the value of the "fromwxid" field.
  117. func (bmu *BatchMsgUpdate) ClearFromwxid() *BatchMsgUpdate {
  118. bmu.mutation.ClearFromwxid()
  119. return bmu
  120. }
  121. // SetMsg sets the "msg" field.
  122. func (bmu *BatchMsgUpdate) SetMsg(s string) *BatchMsgUpdate {
  123. bmu.mutation.SetMsg(s)
  124. return bmu
  125. }
  126. // SetNillableMsg sets the "msg" field if the given value is not nil.
  127. func (bmu *BatchMsgUpdate) SetNillableMsg(s *string) *BatchMsgUpdate {
  128. if s != nil {
  129. bmu.SetMsg(*s)
  130. }
  131. return bmu
  132. }
  133. // ClearMsg clears the value of the "msg" field.
  134. func (bmu *BatchMsgUpdate) ClearMsg() *BatchMsgUpdate {
  135. bmu.mutation.ClearMsg()
  136. return bmu
  137. }
  138. // SetTag sets the "tag" field.
  139. func (bmu *BatchMsgUpdate) SetTag(s string) *BatchMsgUpdate {
  140. bmu.mutation.SetTag(s)
  141. return bmu
  142. }
  143. // SetNillableTag sets the "tag" field if the given value is not nil.
  144. func (bmu *BatchMsgUpdate) SetNillableTag(s *string) *BatchMsgUpdate {
  145. if s != nil {
  146. bmu.SetTag(*s)
  147. }
  148. return bmu
  149. }
  150. // ClearTag clears the value of the "tag" field.
  151. func (bmu *BatchMsgUpdate) ClearTag() *BatchMsgUpdate {
  152. bmu.mutation.ClearTag()
  153. return bmu
  154. }
  155. // SetTagids sets the "tagids" field.
  156. func (bmu *BatchMsgUpdate) SetTagids(s string) *BatchMsgUpdate {
  157. bmu.mutation.SetTagids(s)
  158. return bmu
  159. }
  160. // SetNillableTagids sets the "tagids" field if the given value is not nil.
  161. func (bmu *BatchMsgUpdate) SetNillableTagids(s *string) *BatchMsgUpdate {
  162. if s != nil {
  163. bmu.SetTagids(*s)
  164. }
  165. return bmu
  166. }
  167. // ClearTagids clears the value of the "tagids" field.
  168. func (bmu *BatchMsgUpdate) ClearTagids() *BatchMsgUpdate {
  169. bmu.mutation.ClearTagids()
  170. return bmu
  171. }
  172. // SetTotal sets the "total" field.
  173. func (bmu *BatchMsgUpdate) SetTotal(i int32) *BatchMsgUpdate {
  174. bmu.mutation.ResetTotal()
  175. bmu.mutation.SetTotal(i)
  176. return bmu
  177. }
  178. // SetNillableTotal sets the "total" field if the given value is not nil.
  179. func (bmu *BatchMsgUpdate) SetNillableTotal(i *int32) *BatchMsgUpdate {
  180. if i != nil {
  181. bmu.SetTotal(*i)
  182. }
  183. return bmu
  184. }
  185. // AddTotal adds i to the "total" field.
  186. func (bmu *BatchMsgUpdate) AddTotal(i int32) *BatchMsgUpdate {
  187. bmu.mutation.AddTotal(i)
  188. return bmu
  189. }
  190. // ClearTotal clears the value of the "total" field.
  191. func (bmu *BatchMsgUpdate) ClearTotal() *BatchMsgUpdate {
  192. bmu.mutation.ClearTotal()
  193. return bmu
  194. }
  195. // SetSuccess sets the "success" field.
  196. func (bmu *BatchMsgUpdate) SetSuccess(i int32) *BatchMsgUpdate {
  197. bmu.mutation.ResetSuccess()
  198. bmu.mutation.SetSuccess(i)
  199. return bmu
  200. }
  201. // SetNillableSuccess sets the "success" field if the given value is not nil.
  202. func (bmu *BatchMsgUpdate) SetNillableSuccess(i *int32) *BatchMsgUpdate {
  203. if i != nil {
  204. bmu.SetSuccess(*i)
  205. }
  206. return bmu
  207. }
  208. // AddSuccess adds i to the "success" field.
  209. func (bmu *BatchMsgUpdate) AddSuccess(i int32) *BatchMsgUpdate {
  210. bmu.mutation.AddSuccess(i)
  211. return bmu
  212. }
  213. // ClearSuccess clears the value of the "success" field.
  214. func (bmu *BatchMsgUpdate) ClearSuccess() *BatchMsgUpdate {
  215. bmu.mutation.ClearSuccess()
  216. return bmu
  217. }
  218. // SetFail sets the "fail" field.
  219. func (bmu *BatchMsgUpdate) SetFail(i int32) *BatchMsgUpdate {
  220. bmu.mutation.ResetFail()
  221. bmu.mutation.SetFail(i)
  222. return bmu
  223. }
  224. // SetNillableFail sets the "fail" field if the given value is not nil.
  225. func (bmu *BatchMsgUpdate) SetNillableFail(i *int32) *BatchMsgUpdate {
  226. if i != nil {
  227. bmu.SetFail(*i)
  228. }
  229. return bmu
  230. }
  231. // AddFail adds i to the "fail" field.
  232. func (bmu *BatchMsgUpdate) AddFail(i int32) *BatchMsgUpdate {
  233. bmu.mutation.AddFail(i)
  234. return bmu
  235. }
  236. // ClearFail clears the value of the "fail" field.
  237. func (bmu *BatchMsgUpdate) ClearFail() *BatchMsgUpdate {
  238. bmu.mutation.ClearFail()
  239. return bmu
  240. }
  241. // SetStartTime sets the "start_time" field.
  242. func (bmu *BatchMsgUpdate) SetStartTime(t time.Time) *BatchMsgUpdate {
  243. bmu.mutation.SetStartTime(t)
  244. return bmu
  245. }
  246. // SetNillableStartTime sets the "start_time" field if the given value is not nil.
  247. func (bmu *BatchMsgUpdate) SetNillableStartTime(t *time.Time) *BatchMsgUpdate {
  248. if t != nil {
  249. bmu.SetStartTime(*t)
  250. }
  251. return bmu
  252. }
  253. // ClearStartTime clears the value of the "start_time" field.
  254. func (bmu *BatchMsgUpdate) ClearStartTime() *BatchMsgUpdate {
  255. bmu.mutation.ClearStartTime()
  256. return bmu
  257. }
  258. // SetStopTime sets the "stop_time" field.
  259. func (bmu *BatchMsgUpdate) SetStopTime(t time.Time) *BatchMsgUpdate {
  260. bmu.mutation.SetStopTime(t)
  261. return bmu
  262. }
  263. // SetNillableStopTime sets the "stop_time" field if the given value is not nil.
  264. func (bmu *BatchMsgUpdate) SetNillableStopTime(t *time.Time) *BatchMsgUpdate {
  265. if t != nil {
  266. bmu.SetStopTime(*t)
  267. }
  268. return bmu
  269. }
  270. // ClearStopTime clears the value of the "stop_time" field.
  271. func (bmu *BatchMsgUpdate) ClearStopTime() *BatchMsgUpdate {
  272. bmu.mutation.ClearStopTime()
  273. return bmu
  274. }
  275. // SetSendTime sets the "send_time" field.
  276. func (bmu *BatchMsgUpdate) SetSendTime(t time.Time) *BatchMsgUpdate {
  277. bmu.mutation.SetSendTime(t)
  278. return bmu
  279. }
  280. // SetNillableSendTime sets the "send_time" field if the given value is not nil.
  281. func (bmu *BatchMsgUpdate) SetNillableSendTime(t *time.Time) *BatchMsgUpdate {
  282. if t != nil {
  283. bmu.SetSendTime(*t)
  284. }
  285. return bmu
  286. }
  287. // ClearSendTime clears the value of the "send_time" field.
  288. func (bmu *BatchMsgUpdate) ClearSendTime() *BatchMsgUpdate {
  289. bmu.mutation.ClearSendTime()
  290. return bmu
  291. }
  292. // SetType sets the "type" field.
  293. func (bmu *BatchMsgUpdate) SetType(i int32) *BatchMsgUpdate {
  294. bmu.mutation.ResetType()
  295. bmu.mutation.SetType(i)
  296. return bmu
  297. }
  298. // SetNillableType sets the "type" field if the given value is not nil.
  299. func (bmu *BatchMsgUpdate) SetNillableType(i *int32) *BatchMsgUpdate {
  300. if i != nil {
  301. bmu.SetType(*i)
  302. }
  303. return bmu
  304. }
  305. // AddType adds i to the "type" field.
  306. func (bmu *BatchMsgUpdate) AddType(i int32) *BatchMsgUpdate {
  307. bmu.mutation.AddType(i)
  308. return bmu
  309. }
  310. // ClearType clears the value of the "type" field.
  311. func (bmu *BatchMsgUpdate) ClearType() *BatchMsgUpdate {
  312. bmu.mutation.ClearType()
  313. return bmu
  314. }
  315. // SetOrganizationID sets the "organization_id" field.
  316. func (bmu *BatchMsgUpdate) SetOrganizationID(u uint64) *BatchMsgUpdate {
  317. bmu.mutation.ResetOrganizationID()
  318. bmu.mutation.SetOrganizationID(u)
  319. return bmu
  320. }
  321. // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
  322. func (bmu *BatchMsgUpdate) SetNillableOrganizationID(u *uint64) *BatchMsgUpdate {
  323. if u != nil {
  324. bmu.SetOrganizationID(*u)
  325. }
  326. return bmu
  327. }
  328. // AddOrganizationID adds u to the "organization_id" field.
  329. func (bmu *BatchMsgUpdate) AddOrganizationID(u int64) *BatchMsgUpdate {
  330. bmu.mutation.AddOrganizationID(u)
  331. return bmu
  332. }
  333. // SetCtype sets the "ctype" field.
  334. func (bmu *BatchMsgUpdate) SetCtype(u uint64) *BatchMsgUpdate {
  335. bmu.mutation.ResetCtype()
  336. bmu.mutation.SetCtype(u)
  337. return bmu
  338. }
  339. // SetNillableCtype sets the "ctype" field if the given value is not nil.
  340. func (bmu *BatchMsgUpdate) SetNillableCtype(u *uint64) *BatchMsgUpdate {
  341. if u != nil {
  342. bmu.SetCtype(*u)
  343. }
  344. return bmu
  345. }
  346. // AddCtype adds u to the "ctype" field.
  347. func (bmu *BatchMsgUpdate) AddCtype(u int64) *BatchMsgUpdate {
  348. bmu.mutation.AddCtype(u)
  349. return bmu
  350. }
  351. // SetCc sets the "cc" field.
  352. func (bmu *BatchMsgUpdate) SetCc(s string) *BatchMsgUpdate {
  353. bmu.mutation.SetCc(s)
  354. return bmu
  355. }
  356. // SetNillableCc sets the "cc" field if the given value is not nil.
  357. func (bmu *BatchMsgUpdate) SetNillableCc(s *string) *BatchMsgUpdate {
  358. if s != nil {
  359. bmu.SetCc(*s)
  360. }
  361. return bmu
  362. }
  363. // ClearCc clears the value of the "cc" field.
  364. func (bmu *BatchMsgUpdate) ClearCc() *BatchMsgUpdate {
  365. bmu.mutation.ClearCc()
  366. return bmu
  367. }
  368. // SetPhone sets the "phone" field.
  369. func (bmu *BatchMsgUpdate) SetPhone(s string) *BatchMsgUpdate {
  370. bmu.mutation.SetPhone(s)
  371. return bmu
  372. }
  373. // SetNillablePhone sets the "phone" field if the given value is not nil.
  374. func (bmu *BatchMsgUpdate) SetNillablePhone(s *string) *BatchMsgUpdate {
  375. if s != nil {
  376. bmu.SetPhone(*s)
  377. }
  378. return bmu
  379. }
  380. // ClearPhone clears the value of the "phone" field.
  381. func (bmu *BatchMsgUpdate) ClearPhone() *BatchMsgUpdate {
  382. bmu.mutation.ClearPhone()
  383. return bmu
  384. }
  385. // SetTemplateName sets the "template_name" field.
  386. func (bmu *BatchMsgUpdate) SetTemplateName(s string) *BatchMsgUpdate {
  387. bmu.mutation.SetTemplateName(s)
  388. return bmu
  389. }
  390. // SetNillableTemplateName sets the "template_name" field if the given value is not nil.
  391. func (bmu *BatchMsgUpdate) SetNillableTemplateName(s *string) *BatchMsgUpdate {
  392. if s != nil {
  393. bmu.SetTemplateName(*s)
  394. }
  395. return bmu
  396. }
  397. // ClearTemplateName clears the value of the "template_name" field.
  398. func (bmu *BatchMsgUpdate) ClearTemplateName() *BatchMsgUpdate {
  399. bmu.mutation.ClearTemplateName()
  400. return bmu
  401. }
  402. // SetTemplateCode sets the "template_code" field.
  403. func (bmu *BatchMsgUpdate) SetTemplateCode(s string) *BatchMsgUpdate {
  404. bmu.mutation.SetTemplateCode(s)
  405. return bmu
  406. }
  407. // SetNillableTemplateCode sets the "template_code" field if the given value is not nil.
  408. func (bmu *BatchMsgUpdate) SetNillableTemplateCode(s *string) *BatchMsgUpdate {
  409. if s != nil {
  410. bmu.SetTemplateCode(*s)
  411. }
  412. return bmu
  413. }
  414. // ClearTemplateCode clears the value of the "template_code" field.
  415. func (bmu *BatchMsgUpdate) ClearTemplateCode() *BatchMsgUpdate {
  416. bmu.mutation.ClearTemplateCode()
  417. return bmu
  418. }
  419. // SetLang sets the "lang" field.
  420. func (bmu *BatchMsgUpdate) SetLang(s string) *BatchMsgUpdate {
  421. bmu.mutation.SetLang(s)
  422. return bmu
  423. }
  424. // SetNillableLang sets the "lang" field if the given value is not nil.
  425. func (bmu *BatchMsgUpdate) SetNillableLang(s *string) *BatchMsgUpdate {
  426. if s != nil {
  427. bmu.SetLang(*s)
  428. }
  429. return bmu
  430. }
  431. // ClearLang clears the value of the "lang" field.
  432. func (bmu *BatchMsgUpdate) ClearLang() *BatchMsgUpdate {
  433. bmu.mutation.ClearLang()
  434. return bmu
  435. }
  436. // Mutation returns the BatchMsgMutation object of the builder.
  437. func (bmu *BatchMsgUpdate) Mutation() *BatchMsgMutation {
  438. return bmu.mutation
  439. }
  440. // Save executes the query and returns the number of nodes affected by the update operation.
  441. func (bmu *BatchMsgUpdate) Save(ctx context.Context) (int, error) {
  442. if err := bmu.defaults(); err != nil {
  443. return 0, err
  444. }
  445. return withHooks(ctx, bmu.sqlSave, bmu.mutation, bmu.hooks)
  446. }
  447. // SaveX is like Save, but panics if an error occurs.
  448. func (bmu *BatchMsgUpdate) SaveX(ctx context.Context) int {
  449. affected, err := bmu.Save(ctx)
  450. if err != nil {
  451. panic(err)
  452. }
  453. return affected
  454. }
  455. // Exec executes the query.
  456. func (bmu *BatchMsgUpdate) Exec(ctx context.Context) error {
  457. _, err := bmu.Save(ctx)
  458. return err
  459. }
  460. // ExecX is like Exec, but panics if an error occurs.
  461. func (bmu *BatchMsgUpdate) ExecX(ctx context.Context) {
  462. if err := bmu.Exec(ctx); err != nil {
  463. panic(err)
  464. }
  465. }
  466. // defaults sets the default values of the builder before save.
  467. func (bmu *BatchMsgUpdate) defaults() error {
  468. if _, ok := bmu.mutation.UpdatedAt(); !ok {
  469. if batchmsg.UpdateDefaultUpdatedAt == nil {
  470. return fmt.Errorf("ent: uninitialized batchmsg.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
  471. }
  472. v := batchmsg.UpdateDefaultUpdatedAt()
  473. bmu.mutation.SetUpdatedAt(v)
  474. }
  475. return nil
  476. }
  477. // check runs all checks and user-defined validators on the builder.
  478. func (bmu *BatchMsgUpdate) check() error {
  479. if v, ok := bmu.mutation.OrganizationID(); ok {
  480. if err := batchmsg.OrganizationIDValidator(v); err != nil {
  481. return &ValidationError{Name: "organization_id", err: fmt.Errorf(`ent: validator failed for field "BatchMsg.organization_id": %w`, err)}
  482. }
  483. }
  484. return nil
  485. }
  486. func (bmu *BatchMsgUpdate) sqlSave(ctx context.Context) (n int, err error) {
  487. if err := bmu.check(); err != nil {
  488. return n, err
  489. }
  490. _spec := sqlgraph.NewUpdateSpec(batchmsg.Table, batchmsg.Columns, sqlgraph.NewFieldSpec(batchmsg.FieldID, field.TypeUint64))
  491. if ps := bmu.mutation.predicates; len(ps) > 0 {
  492. _spec.Predicate = func(selector *sql.Selector) {
  493. for i := range ps {
  494. ps[i](selector)
  495. }
  496. }
  497. }
  498. if value, ok := bmu.mutation.UpdatedAt(); ok {
  499. _spec.SetField(batchmsg.FieldUpdatedAt, field.TypeTime, value)
  500. }
  501. if value, ok := bmu.mutation.DeletedAt(); ok {
  502. _spec.SetField(batchmsg.FieldDeletedAt, field.TypeTime, value)
  503. }
  504. if bmu.mutation.DeletedAtCleared() {
  505. _spec.ClearField(batchmsg.FieldDeletedAt, field.TypeTime)
  506. }
  507. if value, ok := bmu.mutation.Status(); ok {
  508. _spec.SetField(batchmsg.FieldStatus, field.TypeUint8, value)
  509. }
  510. if value, ok := bmu.mutation.AddedStatus(); ok {
  511. _spec.AddField(batchmsg.FieldStatus, field.TypeUint8, value)
  512. }
  513. if bmu.mutation.StatusCleared() {
  514. _spec.ClearField(batchmsg.FieldStatus, field.TypeUint8)
  515. }
  516. if value, ok := bmu.mutation.BatchNo(); ok {
  517. _spec.SetField(batchmsg.FieldBatchNo, field.TypeString, value)
  518. }
  519. if bmu.mutation.BatchNoCleared() {
  520. _spec.ClearField(batchmsg.FieldBatchNo, field.TypeString)
  521. }
  522. if value, ok := bmu.mutation.TaskName(); ok {
  523. _spec.SetField(batchmsg.FieldTaskName, field.TypeString, value)
  524. }
  525. if bmu.mutation.TaskNameCleared() {
  526. _spec.ClearField(batchmsg.FieldTaskName, field.TypeString)
  527. }
  528. if value, ok := bmu.mutation.Fromwxid(); ok {
  529. _spec.SetField(batchmsg.FieldFromwxid, field.TypeString, value)
  530. }
  531. if bmu.mutation.FromwxidCleared() {
  532. _spec.ClearField(batchmsg.FieldFromwxid, field.TypeString)
  533. }
  534. if value, ok := bmu.mutation.Msg(); ok {
  535. _spec.SetField(batchmsg.FieldMsg, field.TypeString, value)
  536. }
  537. if bmu.mutation.MsgCleared() {
  538. _spec.ClearField(batchmsg.FieldMsg, field.TypeString)
  539. }
  540. if value, ok := bmu.mutation.Tag(); ok {
  541. _spec.SetField(batchmsg.FieldTag, field.TypeString, value)
  542. }
  543. if bmu.mutation.TagCleared() {
  544. _spec.ClearField(batchmsg.FieldTag, field.TypeString)
  545. }
  546. if value, ok := bmu.mutation.Tagids(); ok {
  547. _spec.SetField(batchmsg.FieldTagids, field.TypeString, value)
  548. }
  549. if bmu.mutation.TagidsCleared() {
  550. _spec.ClearField(batchmsg.FieldTagids, field.TypeString)
  551. }
  552. if value, ok := bmu.mutation.Total(); ok {
  553. _spec.SetField(batchmsg.FieldTotal, field.TypeInt32, value)
  554. }
  555. if value, ok := bmu.mutation.AddedTotal(); ok {
  556. _spec.AddField(batchmsg.FieldTotal, field.TypeInt32, value)
  557. }
  558. if bmu.mutation.TotalCleared() {
  559. _spec.ClearField(batchmsg.FieldTotal, field.TypeInt32)
  560. }
  561. if value, ok := bmu.mutation.Success(); ok {
  562. _spec.SetField(batchmsg.FieldSuccess, field.TypeInt32, value)
  563. }
  564. if value, ok := bmu.mutation.AddedSuccess(); ok {
  565. _spec.AddField(batchmsg.FieldSuccess, field.TypeInt32, value)
  566. }
  567. if bmu.mutation.SuccessCleared() {
  568. _spec.ClearField(batchmsg.FieldSuccess, field.TypeInt32)
  569. }
  570. if value, ok := bmu.mutation.Fail(); ok {
  571. _spec.SetField(batchmsg.FieldFail, field.TypeInt32, value)
  572. }
  573. if value, ok := bmu.mutation.AddedFail(); ok {
  574. _spec.AddField(batchmsg.FieldFail, field.TypeInt32, value)
  575. }
  576. if bmu.mutation.FailCleared() {
  577. _spec.ClearField(batchmsg.FieldFail, field.TypeInt32)
  578. }
  579. if value, ok := bmu.mutation.StartTime(); ok {
  580. _spec.SetField(batchmsg.FieldStartTime, field.TypeTime, value)
  581. }
  582. if bmu.mutation.StartTimeCleared() {
  583. _spec.ClearField(batchmsg.FieldStartTime, field.TypeTime)
  584. }
  585. if value, ok := bmu.mutation.StopTime(); ok {
  586. _spec.SetField(batchmsg.FieldStopTime, field.TypeTime, value)
  587. }
  588. if bmu.mutation.StopTimeCleared() {
  589. _spec.ClearField(batchmsg.FieldStopTime, field.TypeTime)
  590. }
  591. if value, ok := bmu.mutation.SendTime(); ok {
  592. _spec.SetField(batchmsg.FieldSendTime, field.TypeTime, value)
  593. }
  594. if bmu.mutation.SendTimeCleared() {
  595. _spec.ClearField(batchmsg.FieldSendTime, field.TypeTime)
  596. }
  597. if value, ok := bmu.mutation.GetType(); ok {
  598. _spec.SetField(batchmsg.FieldType, field.TypeInt32, value)
  599. }
  600. if value, ok := bmu.mutation.AddedType(); ok {
  601. _spec.AddField(batchmsg.FieldType, field.TypeInt32, value)
  602. }
  603. if bmu.mutation.TypeCleared() {
  604. _spec.ClearField(batchmsg.FieldType, field.TypeInt32)
  605. }
  606. if value, ok := bmu.mutation.OrganizationID(); ok {
  607. _spec.SetField(batchmsg.FieldOrganizationID, field.TypeUint64, value)
  608. }
  609. if value, ok := bmu.mutation.AddedOrganizationID(); ok {
  610. _spec.AddField(batchmsg.FieldOrganizationID, field.TypeUint64, value)
  611. }
  612. if value, ok := bmu.mutation.Ctype(); ok {
  613. _spec.SetField(batchmsg.FieldCtype, field.TypeUint64, value)
  614. }
  615. if value, ok := bmu.mutation.AddedCtype(); ok {
  616. _spec.AddField(batchmsg.FieldCtype, field.TypeUint64, value)
  617. }
  618. if value, ok := bmu.mutation.Cc(); ok {
  619. _spec.SetField(batchmsg.FieldCc, field.TypeString, value)
  620. }
  621. if bmu.mutation.CcCleared() {
  622. _spec.ClearField(batchmsg.FieldCc, field.TypeString)
  623. }
  624. if value, ok := bmu.mutation.Phone(); ok {
  625. _spec.SetField(batchmsg.FieldPhone, field.TypeString, value)
  626. }
  627. if bmu.mutation.PhoneCleared() {
  628. _spec.ClearField(batchmsg.FieldPhone, field.TypeString)
  629. }
  630. if value, ok := bmu.mutation.TemplateName(); ok {
  631. _spec.SetField(batchmsg.FieldTemplateName, field.TypeString, value)
  632. }
  633. if bmu.mutation.TemplateNameCleared() {
  634. _spec.ClearField(batchmsg.FieldTemplateName, field.TypeString)
  635. }
  636. if value, ok := bmu.mutation.TemplateCode(); ok {
  637. _spec.SetField(batchmsg.FieldTemplateCode, field.TypeString, value)
  638. }
  639. if bmu.mutation.TemplateCodeCleared() {
  640. _spec.ClearField(batchmsg.FieldTemplateCode, field.TypeString)
  641. }
  642. if value, ok := bmu.mutation.Lang(); ok {
  643. _spec.SetField(batchmsg.FieldLang, field.TypeString, value)
  644. }
  645. if bmu.mutation.LangCleared() {
  646. _spec.ClearField(batchmsg.FieldLang, field.TypeString)
  647. }
  648. if n, err = sqlgraph.UpdateNodes(ctx, bmu.driver, _spec); err != nil {
  649. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  650. err = &NotFoundError{batchmsg.Label}
  651. } else if sqlgraph.IsConstraintError(err) {
  652. err = &ConstraintError{msg: err.Error(), wrap: err}
  653. }
  654. return 0, err
  655. }
  656. bmu.mutation.done = true
  657. return n, nil
  658. }
  659. // BatchMsgUpdateOne is the builder for updating a single BatchMsg entity.
  660. type BatchMsgUpdateOne struct {
  661. config
  662. fields []string
  663. hooks []Hook
  664. mutation *BatchMsgMutation
  665. }
  666. // SetUpdatedAt sets the "updated_at" field.
  667. func (bmuo *BatchMsgUpdateOne) SetUpdatedAt(t time.Time) *BatchMsgUpdateOne {
  668. bmuo.mutation.SetUpdatedAt(t)
  669. return bmuo
  670. }
  671. // SetDeletedAt sets the "deleted_at" field.
  672. func (bmuo *BatchMsgUpdateOne) SetDeletedAt(t time.Time) *BatchMsgUpdateOne {
  673. bmuo.mutation.SetDeletedAt(t)
  674. return bmuo
  675. }
  676. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  677. func (bmuo *BatchMsgUpdateOne) SetNillableDeletedAt(t *time.Time) *BatchMsgUpdateOne {
  678. if t != nil {
  679. bmuo.SetDeletedAt(*t)
  680. }
  681. return bmuo
  682. }
  683. // ClearDeletedAt clears the value of the "deleted_at" field.
  684. func (bmuo *BatchMsgUpdateOne) ClearDeletedAt() *BatchMsgUpdateOne {
  685. bmuo.mutation.ClearDeletedAt()
  686. return bmuo
  687. }
  688. // SetStatus sets the "status" field.
  689. func (bmuo *BatchMsgUpdateOne) SetStatus(u uint8) *BatchMsgUpdateOne {
  690. bmuo.mutation.ResetStatus()
  691. bmuo.mutation.SetStatus(u)
  692. return bmuo
  693. }
  694. // SetNillableStatus sets the "status" field if the given value is not nil.
  695. func (bmuo *BatchMsgUpdateOne) SetNillableStatus(u *uint8) *BatchMsgUpdateOne {
  696. if u != nil {
  697. bmuo.SetStatus(*u)
  698. }
  699. return bmuo
  700. }
  701. // AddStatus adds u to the "status" field.
  702. func (bmuo *BatchMsgUpdateOne) AddStatus(u int8) *BatchMsgUpdateOne {
  703. bmuo.mutation.AddStatus(u)
  704. return bmuo
  705. }
  706. // ClearStatus clears the value of the "status" field.
  707. func (bmuo *BatchMsgUpdateOne) ClearStatus() *BatchMsgUpdateOne {
  708. bmuo.mutation.ClearStatus()
  709. return bmuo
  710. }
  711. // SetBatchNo sets the "batch_no" field.
  712. func (bmuo *BatchMsgUpdateOne) SetBatchNo(s string) *BatchMsgUpdateOne {
  713. bmuo.mutation.SetBatchNo(s)
  714. return bmuo
  715. }
  716. // SetNillableBatchNo sets the "batch_no" field if the given value is not nil.
  717. func (bmuo *BatchMsgUpdateOne) SetNillableBatchNo(s *string) *BatchMsgUpdateOne {
  718. if s != nil {
  719. bmuo.SetBatchNo(*s)
  720. }
  721. return bmuo
  722. }
  723. // ClearBatchNo clears the value of the "batch_no" field.
  724. func (bmuo *BatchMsgUpdateOne) ClearBatchNo() *BatchMsgUpdateOne {
  725. bmuo.mutation.ClearBatchNo()
  726. return bmuo
  727. }
  728. // SetTaskName sets the "task_name" field.
  729. func (bmuo *BatchMsgUpdateOne) SetTaskName(s string) *BatchMsgUpdateOne {
  730. bmuo.mutation.SetTaskName(s)
  731. return bmuo
  732. }
  733. // SetNillableTaskName sets the "task_name" field if the given value is not nil.
  734. func (bmuo *BatchMsgUpdateOne) SetNillableTaskName(s *string) *BatchMsgUpdateOne {
  735. if s != nil {
  736. bmuo.SetTaskName(*s)
  737. }
  738. return bmuo
  739. }
  740. // ClearTaskName clears the value of the "task_name" field.
  741. func (bmuo *BatchMsgUpdateOne) ClearTaskName() *BatchMsgUpdateOne {
  742. bmuo.mutation.ClearTaskName()
  743. return bmuo
  744. }
  745. // SetFromwxid sets the "fromwxid" field.
  746. func (bmuo *BatchMsgUpdateOne) SetFromwxid(s string) *BatchMsgUpdateOne {
  747. bmuo.mutation.SetFromwxid(s)
  748. return bmuo
  749. }
  750. // SetNillableFromwxid sets the "fromwxid" field if the given value is not nil.
  751. func (bmuo *BatchMsgUpdateOne) SetNillableFromwxid(s *string) *BatchMsgUpdateOne {
  752. if s != nil {
  753. bmuo.SetFromwxid(*s)
  754. }
  755. return bmuo
  756. }
  757. // ClearFromwxid clears the value of the "fromwxid" field.
  758. func (bmuo *BatchMsgUpdateOne) ClearFromwxid() *BatchMsgUpdateOne {
  759. bmuo.mutation.ClearFromwxid()
  760. return bmuo
  761. }
  762. // SetMsg sets the "msg" field.
  763. func (bmuo *BatchMsgUpdateOne) SetMsg(s string) *BatchMsgUpdateOne {
  764. bmuo.mutation.SetMsg(s)
  765. return bmuo
  766. }
  767. // SetNillableMsg sets the "msg" field if the given value is not nil.
  768. func (bmuo *BatchMsgUpdateOne) SetNillableMsg(s *string) *BatchMsgUpdateOne {
  769. if s != nil {
  770. bmuo.SetMsg(*s)
  771. }
  772. return bmuo
  773. }
  774. // ClearMsg clears the value of the "msg" field.
  775. func (bmuo *BatchMsgUpdateOne) ClearMsg() *BatchMsgUpdateOne {
  776. bmuo.mutation.ClearMsg()
  777. return bmuo
  778. }
  779. // SetTag sets the "tag" field.
  780. func (bmuo *BatchMsgUpdateOne) SetTag(s string) *BatchMsgUpdateOne {
  781. bmuo.mutation.SetTag(s)
  782. return bmuo
  783. }
  784. // SetNillableTag sets the "tag" field if the given value is not nil.
  785. func (bmuo *BatchMsgUpdateOne) SetNillableTag(s *string) *BatchMsgUpdateOne {
  786. if s != nil {
  787. bmuo.SetTag(*s)
  788. }
  789. return bmuo
  790. }
  791. // ClearTag clears the value of the "tag" field.
  792. func (bmuo *BatchMsgUpdateOne) ClearTag() *BatchMsgUpdateOne {
  793. bmuo.mutation.ClearTag()
  794. return bmuo
  795. }
  796. // SetTagids sets the "tagids" field.
  797. func (bmuo *BatchMsgUpdateOne) SetTagids(s string) *BatchMsgUpdateOne {
  798. bmuo.mutation.SetTagids(s)
  799. return bmuo
  800. }
  801. // SetNillableTagids sets the "tagids" field if the given value is not nil.
  802. func (bmuo *BatchMsgUpdateOne) SetNillableTagids(s *string) *BatchMsgUpdateOne {
  803. if s != nil {
  804. bmuo.SetTagids(*s)
  805. }
  806. return bmuo
  807. }
  808. // ClearTagids clears the value of the "tagids" field.
  809. func (bmuo *BatchMsgUpdateOne) ClearTagids() *BatchMsgUpdateOne {
  810. bmuo.mutation.ClearTagids()
  811. return bmuo
  812. }
  813. // SetTotal sets the "total" field.
  814. func (bmuo *BatchMsgUpdateOne) SetTotal(i int32) *BatchMsgUpdateOne {
  815. bmuo.mutation.ResetTotal()
  816. bmuo.mutation.SetTotal(i)
  817. return bmuo
  818. }
  819. // SetNillableTotal sets the "total" field if the given value is not nil.
  820. func (bmuo *BatchMsgUpdateOne) SetNillableTotal(i *int32) *BatchMsgUpdateOne {
  821. if i != nil {
  822. bmuo.SetTotal(*i)
  823. }
  824. return bmuo
  825. }
  826. // AddTotal adds i to the "total" field.
  827. func (bmuo *BatchMsgUpdateOne) AddTotal(i int32) *BatchMsgUpdateOne {
  828. bmuo.mutation.AddTotal(i)
  829. return bmuo
  830. }
  831. // ClearTotal clears the value of the "total" field.
  832. func (bmuo *BatchMsgUpdateOne) ClearTotal() *BatchMsgUpdateOne {
  833. bmuo.mutation.ClearTotal()
  834. return bmuo
  835. }
  836. // SetSuccess sets the "success" field.
  837. func (bmuo *BatchMsgUpdateOne) SetSuccess(i int32) *BatchMsgUpdateOne {
  838. bmuo.mutation.ResetSuccess()
  839. bmuo.mutation.SetSuccess(i)
  840. return bmuo
  841. }
  842. // SetNillableSuccess sets the "success" field if the given value is not nil.
  843. func (bmuo *BatchMsgUpdateOne) SetNillableSuccess(i *int32) *BatchMsgUpdateOne {
  844. if i != nil {
  845. bmuo.SetSuccess(*i)
  846. }
  847. return bmuo
  848. }
  849. // AddSuccess adds i to the "success" field.
  850. func (bmuo *BatchMsgUpdateOne) AddSuccess(i int32) *BatchMsgUpdateOne {
  851. bmuo.mutation.AddSuccess(i)
  852. return bmuo
  853. }
  854. // ClearSuccess clears the value of the "success" field.
  855. func (bmuo *BatchMsgUpdateOne) ClearSuccess() *BatchMsgUpdateOne {
  856. bmuo.mutation.ClearSuccess()
  857. return bmuo
  858. }
  859. // SetFail sets the "fail" field.
  860. func (bmuo *BatchMsgUpdateOne) SetFail(i int32) *BatchMsgUpdateOne {
  861. bmuo.mutation.ResetFail()
  862. bmuo.mutation.SetFail(i)
  863. return bmuo
  864. }
  865. // SetNillableFail sets the "fail" field if the given value is not nil.
  866. func (bmuo *BatchMsgUpdateOne) SetNillableFail(i *int32) *BatchMsgUpdateOne {
  867. if i != nil {
  868. bmuo.SetFail(*i)
  869. }
  870. return bmuo
  871. }
  872. // AddFail adds i to the "fail" field.
  873. func (bmuo *BatchMsgUpdateOne) AddFail(i int32) *BatchMsgUpdateOne {
  874. bmuo.mutation.AddFail(i)
  875. return bmuo
  876. }
  877. // ClearFail clears the value of the "fail" field.
  878. func (bmuo *BatchMsgUpdateOne) ClearFail() *BatchMsgUpdateOne {
  879. bmuo.mutation.ClearFail()
  880. return bmuo
  881. }
  882. // SetStartTime sets the "start_time" field.
  883. func (bmuo *BatchMsgUpdateOne) SetStartTime(t time.Time) *BatchMsgUpdateOne {
  884. bmuo.mutation.SetStartTime(t)
  885. return bmuo
  886. }
  887. // SetNillableStartTime sets the "start_time" field if the given value is not nil.
  888. func (bmuo *BatchMsgUpdateOne) SetNillableStartTime(t *time.Time) *BatchMsgUpdateOne {
  889. if t != nil {
  890. bmuo.SetStartTime(*t)
  891. }
  892. return bmuo
  893. }
  894. // ClearStartTime clears the value of the "start_time" field.
  895. func (bmuo *BatchMsgUpdateOne) ClearStartTime() *BatchMsgUpdateOne {
  896. bmuo.mutation.ClearStartTime()
  897. return bmuo
  898. }
  899. // SetStopTime sets the "stop_time" field.
  900. func (bmuo *BatchMsgUpdateOne) SetStopTime(t time.Time) *BatchMsgUpdateOne {
  901. bmuo.mutation.SetStopTime(t)
  902. return bmuo
  903. }
  904. // SetNillableStopTime sets the "stop_time" field if the given value is not nil.
  905. func (bmuo *BatchMsgUpdateOne) SetNillableStopTime(t *time.Time) *BatchMsgUpdateOne {
  906. if t != nil {
  907. bmuo.SetStopTime(*t)
  908. }
  909. return bmuo
  910. }
  911. // ClearStopTime clears the value of the "stop_time" field.
  912. func (bmuo *BatchMsgUpdateOne) ClearStopTime() *BatchMsgUpdateOne {
  913. bmuo.mutation.ClearStopTime()
  914. return bmuo
  915. }
  916. // SetSendTime sets the "send_time" field.
  917. func (bmuo *BatchMsgUpdateOne) SetSendTime(t time.Time) *BatchMsgUpdateOne {
  918. bmuo.mutation.SetSendTime(t)
  919. return bmuo
  920. }
  921. // SetNillableSendTime sets the "send_time" field if the given value is not nil.
  922. func (bmuo *BatchMsgUpdateOne) SetNillableSendTime(t *time.Time) *BatchMsgUpdateOne {
  923. if t != nil {
  924. bmuo.SetSendTime(*t)
  925. }
  926. return bmuo
  927. }
  928. // ClearSendTime clears the value of the "send_time" field.
  929. func (bmuo *BatchMsgUpdateOne) ClearSendTime() *BatchMsgUpdateOne {
  930. bmuo.mutation.ClearSendTime()
  931. return bmuo
  932. }
  933. // SetType sets the "type" field.
  934. func (bmuo *BatchMsgUpdateOne) SetType(i int32) *BatchMsgUpdateOne {
  935. bmuo.mutation.ResetType()
  936. bmuo.mutation.SetType(i)
  937. return bmuo
  938. }
  939. // SetNillableType sets the "type" field if the given value is not nil.
  940. func (bmuo *BatchMsgUpdateOne) SetNillableType(i *int32) *BatchMsgUpdateOne {
  941. if i != nil {
  942. bmuo.SetType(*i)
  943. }
  944. return bmuo
  945. }
  946. // AddType adds i to the "type" field.
  947. func (bmuo *BatchMsgUpdateOne) AddType(i int32) *BatchMsgUpdateOne {
  948. bmuo.mutation.AddType(i)
  949. return bmuo
  950. }
  951. // ClearType clears the value of the "type" field.
  952. func (bmuo *BatchMsgUpdateOne) ClearType() *BatchMsgUpdateOne {
  953. bmuo.mutation.ClearType()
  954. return bmuo
  955. }
  956. // SetOrganizationID sets the "organization_id" field.
  957. func (bmuo *BatchMsgUpdateOne) SetOrganizationID(u uint64) *BatchMsgUpdateOne {
  958. bmuo.mutation.ResetOrganizationID()
  959. bmuo.mutation.SetOrganizationID(u)
  960. return bmuo
  961. }
  962. // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
  963. func (bmuo *BatchMsgUpdateOne) SetNillableOrganizationID(u *uint64) *BatchMsgUpdateOne {
  964. if u != nil {
  965. bmuo.SetOrganizationID(*u)
  966. }
  967. return bmuo
  968. }
  969. // AddOrganizationID adds u to the "organization_id" field.
  970. func (bmuo *BatchMsgUpdateOne) AddOrganizationID(u int64) *BatchMsgUpdateOne {
  971. bmuo.mutation.AddOrganizationID(u)
  972. return bmuo
  973. }
  974. // SetCtype sets the "ctype" field.
  975. func (bmuo *BatchMsgUpdateOne) SetCtype(u uint64) *BatchMsgUpdateOne {
  976. bmuo.mutation.ResetCtype()
  977. bmuo.mutation.SetCtype(u)
  978. return bmuo
  979. }
  980. // SetNillableCtype sets the "ctype" field if the given value is not nil.
  981. func (bmuo *BatchMsgUpdateOne) SetNillableCtype(u *uint64) *BatchMsgUpdateOne {
  982. if u != nil {
  983. bmuo.SetCtype(*u)
  984. }
  985. return bmuo
  986. }
  987. // AddCtype adds u to the "ctype" field.
  988. func (bmuo *BatchMsgUpdateOne) AddCtype(u int64) *BatchMsgUpdateOne {
  989. bmuo.mutation.AddCtype(u)
  990. return bmuo
  991. }
  992. // SetCc sets the "cc" field.
  993. func (bmuo *BatchMsgUpdateOne) SetCc(s string) *BatchMsgUpdateOne {
  994. bmuo.mutation.SetCc(s)
  995. return bmuo
  996. }
  997. // SetNillableCc sets the "cc" field if the given value is not nil.
  998. func (bmuo *BatchMsgUpdateOne) SetNillableCc(s *string) *BatchMsgUpdateOne {
  999. if s != nil {
  1000. bmuo.SetCc(*s)
  1001. }
  1002. return bmuo
  1003. }
  1004. // ClearCc clears the value of the "cc" field.
  1005. func (bmuo *BatchMsgUpdateOne) ClearCc() *BatchMsgUpdateOne {
  1006. bmuo.mutation.ClearCc()
  1007. return bmuo
  1008. }
  1009. // SetPhone sets the "phone" field.
  1010. func (bmuo *BatchMsgUpdateOne) SetPhone(s string) *BatchMsgUpdateOne {
  1011. bmuo.mutation.SetPhone(s)
  1012. return bmuo
  1013. }
  1014. // SetNillablePhone sets the "phone" field if the given value is not nil.
  1015. func (bmuo *BatchMsgUpdateOne) SetNillablePhone(s *string) *BatchMsgUpdateOne {
  1016. if s != nil {
  1017. bmuo.SetPhone(*s)
  1018. }
  1019. return bmuo
  1020. }
  1021. // ClearPhone clears the value of the "phone" field.
  1022. func (bmuo *BatchMsgUpdateOne) ClearPhone() *BatchMsgUpdateOne {
  1023. bmuo.mutation.ClearPhone()
  1024. return bmuo
  1025. }
  1026. // SetTemplateName sets the "template_name" field.
  1027. func (bmuo *BatchMsgUpdateOne) SetTemplateName(s string) *BatchMsgUpdateOne {
  1028. bmuo.mutation.SetTemplateName(s)
  1029. return bmuo
  1030. }
  1031. // SetNillableTemplateName sets the "template_name" field if the given value is not nil.
  1032. func (bmuo *BatchMsgUpdateOne) SetNillableTemplateName(s *string) *BatchMsgUpdateOne {
  1033. if s != nil {
  1034. bmuo.SetTemplateName(*s)
  1035. }
  1036. return bmuo
  1037. }
  1038. // ClearTemplateName clears the value of the "template_name" field.
  1039. func (bmuo *BatchMsgUpdateOne) ClearTemplateName() *BatchMsgUpdateOne {
  1040. bmuo.mutation.ClearTemplateName()
  1041. return bmuo
  1042. }
  1043. // SetTemplateCode sets the "template_code" field.
  1044. func (bmuo *BatchMsgUpdateOne) SetTemplateCode(s string) *BatchMsgUpdateOne {
  1045. bmuo.mutation.SetTemplateCode(s)
  1046. return bmuo
  1047. }
  1048. // SetNillableTemplateCode sets the "template_code" field if the given value is not nil.
  1049. func (bmuo *BatchMsgUpdateOne) SetNillableTemplateCode(s *string) *BatchMsgUpdateOne {
  1050. if s != nil {
  1051. bmuo.SetTemplateCode(*s)
  1052. }
  1053. return bmuo
  1054. }
  1055. // ClearTemplateCode clears the value of the "template_code" field.
  1056. func (bmuo *BatchMsgUpdateOne) ClearTemplateCode() *BatchMsgUpdateOne {
  1057. bmuo.mutation.ClearTemplateCode()
  1058. return bmuo
  1059. }
  1060. // SetLang sets the "lang" field.
  1061. func (bmuo *BatchMsgUpdateOne) SetLang(s string) *BatchMsgUpdateOne {
  1062. bmuo.mutation.SetLang(s)
  1063. return bmuo
  1064. }
  1065. // SetNillableLang sets the "lang" field if the given value is not nil.
  1066. func (bmuo *BatchMsgUpdateOne) SetNillableLang(s *string) *BatchMsgUpdateOne {
  1067. if s != nil {
  1068. bmuo.SetLang(*s)
  1069. }
  1070. return bmuo
  1071. }
  1072. // ClearLang clears the value of the "lang" field.
  1073. func (bmuo *BatchMsgUpdateOne) ClearLang() *BatchMsgUpdateOne {
  1074. bmuo.mutation.ClearLang()
  1075. return bmuo
  1076. }
  1077. // Mutation returns the BatchMsgMutation object of the builder.
  1078. func (bmuo *BatchMsgUpdateOne) Mutation() *BatchMsgMutation {
  1079. return bmuo.mutation
  1080. }
  1081. // Where appends a list predicates to the BatchMsgUpdate builder.
  1082. func (bmuo *BatchMsgUpdateOne) Where(ps ...predicate.BatchMsg) *BatchMsgUpdateOne {
  1083. bmuo.mutation.Where(ps...)
  1084. return bmuo
  1085. }
  1086. // Select allows selecting one or more fields (columns) of the returned entity.
  1087. // The default is selecting all fields defined in the entity schema.
  1088. func (bmuo *BatchMsgUpdateOne) Select(field string, fields ...string) *BatchMsgUpdateOne {
  1089. bmuo.fields = append([]string{field}, fields...)
  1090. return bmuo
  1091. }
  1092. // Save executes the query and returns the updated BatchMsg entity.
  1093. func (bmuo *BatchMsgUpdateOne) Save(ctx context.Context) (*BatchMsg, error) {
  1094. if err := bmuo.defaults(); err != nil {
  1095. return nil, err
  1096. }
  1097. return withHooks(ctx, bmuo.sqlSave, bmuo.mutation, bmuo.hooks)
  1098. }
  1099. // SaveX is like Save, but panics if an error occurs.
  1100. func (bmuo *BatchMsgUpdateOne) SaveX(ctx context.Context) *BatchMsg {
  1101. node, err := bmuo.Save(ctx)
  1102. if err != nil {
  1103. panic(err)
  1104. }
  1105. return node
  1106. }
  1107. // Exec executes the query on the entity.
  1108. func (bmuo *BatchMsgUpdateOne) Exec(ctx context.Context) error {
  1109. _, err := bmuo.Save(ctx)
  1110. return err
  1111. }
  1112. // ExecX is like Exec, but panics if an error occurs.
  1113. func (bmuo *BatchMsgUpdateOne) ExecX(ctx context.Context) {
  1114. if err := bmuo.Exec(ctx); err != nil {
  1115. panic(err)
  1116. }
  1117. }
  1118. // defaults sets the default values of the builder before save.
  1119. func (bmuo *BatchMsgUpdateOne) defaults() error {
  1120. if _, ok := bmuo.mutation.UpdatedAt(); !ok {
  1121. if batchmsg.UpdateDefaultUpdatedAt == nil {
  1122. return fmt.Errorf("ent: uninitialized batchmsg.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
  1123. }
  1124. v := batchmsg.UpdateDefaultUpdatedAt()
  1125. bmuo.mutation.SetUpdatedAt(v)
  1126. }
  1127. return nil
  1128. }
  1129. // check runs all checks and user-defined validators on the builder.
  1130. func (bmuo *BatchMsgUpdateOne) check() error {
  1131. if v, ok := bmuo.mutation.OrganizationID(); ok {
  1132. if err := batchmsg.OrganizationIDValidator(v); err != nil {
  1133. return &ValidationError{Name: "organization_id", err: fmt.Errorf(`ent: validator failed for field "BatchMsg.organization_id": %w`, err)}
  1134. }
  1135. }
  1136. return nil
  1137. }
  1138. func (bmuo *BatchMsgUpdateOne) sqlSave(ctx context.Context) (_node *BatchMsg, err error) {
  1139. if err := bmuo.check(); err != nil {
  1140. return _node, err
  1141. }
  1142. _spec := sqlgraph.NewUpdateSpec(batchmsg.Table, batchmsg.Columns, sqlgraph.NewFieldSpec(batchmsg.FieldID, field.TypeUint64))
  1143. id, ok := bmuo.mutation.ID()
  1144. if !ok {
  1145. return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "BatchMsg.id" for update`)}
  1146. }
  1147. _spec.Node.ID.Value = id
  1148. if fields := bmuo.fields; len(fields) > 0 {
  1149. _spec.Node.Columns = make([]string, 0, len(fields))
  1150. _spec.Node.Columns = append(_spec.Node.Columns, batchmsg.FieldID)
  1151. for _, f := range fields {
  1152. if !batchmsg.ValidColumn(f) {
  1153. return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
  1154. }
  1155. if f != batchmsg.FieldID {
  1156. _spec.Node.Columns = append(_spec.Node.Columns, f)
  1157. }
  1158. }
  1159. }
  1160. if ps := bmuo.mutation.predicates; len(ps) > 0 {
  1161. _spec.Predicate = func(selector *sql.Selector) {
  1162. for i := range ps {
  1163. ps[i](selector)
  1164. }
  1165. }
  1166. }
  1167. if value, ok := bmuo.mutation.UpdatedAt(); ok {
  1168. _spec.SetField(batchmsg.FieldUpdatedAt, field.TypeTime, value)
  1169. }
  1170. if value, ok := bmuo.mutation.DeletedAt(); ok {
  1171. _spec.SetField(batchmsg.FieldDeletedAt, field.TypeTime, value)
  1172. }
  1173. if bmuo.mutation.DeletedAtCleared() {
  1174. _spec.ClearField(batchmsg.FieldDeletedAt, field.TypeTime)
  1175. }
  1176. if value, ok := bmuo.mutation.Status(); ok {
  1177. _spec.SetField(batchmsg.FieldStatus, field.TypeUint8, value)
  1178. }
  1179. if value, ok := bmuo.mutation.AddedStatus(); ok {
  1180. _spec.AddField(batchmsg.FieldStatus, field.TypeUint8, value)
  1181. }
  1182. if bmuo.mutation.StatusCleared() {
  1183. _spec.ClearField(batchmsg.FieldStatus, field.TypeUint8)
  1184. }
  1185. if value, ok := bmuo.mutation.BatchNo(); ok {
  1186. _spec.SetField(batchmsg.FieldBatchNo, field.TypeString, value)
  1187. }
  1188. if bmuo.mutation.BatchNoCleared() {
  1189. _spec.ClearField(batchmsg.FieldBatchNo, field.TypeString)
  1190. }
  1191. if value, ok := bmuo.mutation.TaskName(); ok {
  1192. _spec.SetField(batchmsg.FieldTaskName, field.TypeString, value)
  1193. }
  1194. if bmuo.mutation.TaskNameCleared() {
  1195. _spec.ClearField(batchmsg.FieldTaskName, field.TypeString)
  1196. }
  1197. if value, ok := bmuo.mutation.Fromwxid(); ok {
  1198. _spec.SetField(batchmsg.FieldFromwxid, field.TypeString, value)
  1199. }
  1200. if bmuo.mutation.FromwxidCleared() {
  1201. _spec.ClearField(batchmsg.FieldFromwxid, field.TypeString)
  1202. }
  1203. if value, ok := bmuo.mutation.Msg(); ok {
  1204. _spec.SetField(batchmsg.FieldMsg, field.TypeString, value)
  1205. }
  1206. if bmuo.mutation.MsgCleared() {
  1207. _spec.ClearField(batchmsg.FieldMsg, field.TypeString)
  1208. }
  1209. if value, ok := bmuo.mutation.Tag(); ok {
  1210. _spec.SetField(batchmsg.FieldTag, field.TypeString, value)
  1211. }
  1212. if bmuo.mutation.TagCleared() {
  1213. _spec.ClearField(batchmsg.FieldTag, field.TypeString)
  1214. }
  1215. if value, ok := bmuo.mutation.Tagids(); ok {
  1216. _spec.SetField(batchmsg.FieldTagids, field.TypeString, value)
  1217. }
  1218. if bmuo.mutation.TagidsCleared() {
  1219. _spec.ClearField(batchmsg.FieldTagids, field.TypeString)
  1220. }
  1221. if value, ok := bmuo.mutation.Total(); ok {
  1222. _spec.SetField(batchmsg.FieldTotal, field.TypeInt32, value)
  1223. }
  1224. if value, ok := bmuo.mutation.AddedTotal(); ok {
  1225. _spec.AddField(batchmsg.FieldTotal, field.TypeInt32, value)
  1226. }
  1227. if bmuo.mutation.TotalCleared() {
  1228. _spec.ClearField(batchmsg.FieldTotal, field.TypeInt32)
  1229. }
  1230. if value, ok := bmuo.mutation.Success(); ok {
  1231. _spec.SetField(batchmsg.FieldSuccess, field.TypeInt32, value)
  1232. }
  1233. if value, ok := bmuo.mutation.AddedSuccess(); ok {
  1234. _spec.AddField(batchmsg.FieldSuccess, field.TypeInt32, value)
  1235. }
  1236. if bmuo.mutation.SuccessCleared() {
  1237. _spec.ClearField(batchmsg.FieldSuccess, field.TypeInt32)
  1238. }
  1239. if value, ok := bmuo.mutation.Fail(); ok {
  1240. _spec.SetField(batchmsg.FieldFail, field.TypeInt32, value)
  1241. }
  1242. if value, ok := bmuo.mutation.AddedFail(); ok {
  1243. _spec.AddField(batchmsg.FieldFail, field.TypeInt32, value)
  1244. }
  1245. if bmuo.mutation.FailCleared() {
  1246. _spec.ClearField(batchmsg.FieldFail, field.TypeInt32)
  1247. }
  1248. if value, ok := bmuo.mutation.StartTime(); ok {
  1249. _spec.SetField(batchmsg.FieldStartTime, field.TypeTime, value)
  1250. }
  1251. if bmuo.mutation.StartTimeCleared() {
  1252. _spec.ClearField(batchmsg.FieldStartTime, field.TypeTime)
  1253. }
  1254. if value, ok := bmuo.mutation.StopTime(); ok {
  1255. _spec.SetField(batchmsg.FieldStopTime, field.TypeTime, value)
  1256. }
  1257. if bmuo.mutation.StopTimeCleared() {
  1258. _spec.ClearField(batchmsg.FieldStopTime, field.TypeTime)
  1259. }
  1260. if value, ok := bmuo.mutation.SendTime(); ok {
  1261. _spec.SetField(batchmsg.FieldSendTime, field.TypeTime, value)
  1262. }
  1263. if bmuo.mutation.SendTimeCleared() {
  1264. _spec.ClearField(batchmsg.FieldSendTime, field.TypeTime)
  1265. }
  1266. if value, ok := bmuo.mutation.GetType(); ok {
  1267. _spec.SetField(batchmsg.FieldType, field.TypeInt32, value)
  1268. }
  1269. if value, ok := bmuo.mutation.AddedType(); ok {
  1270. _spec.AddField(batchmsg.FieldType, field.TypeInt32, value)
  1271. }
  1272. if bmuo.mutation.TypeCleared() {
  1273. _spec.ClearField(batchmsg.FieldType, field.TypeInt32)
  1274. }
  1275. if value, ok := bmuo.mutation.OrganizationID(); ok {
  1276. _spec.SetField(batchmsg.FieldOrganizationID, field.TypeUint64, value)
  1277. }
  1278. if value, ok := bmuo.mutation.AddedOrganizationID(); ok {
  1279. _spec.AddField(batchmsg.FieldOrganizationID, field.TypeUint64, value)
  1280. }
  1281. if value, ok := bmuo.mutation.Ctype(); ok {
  1282. _spec.SetField(batchmsg.FieldCtype, field.TypeUint64, value)
  1283. }
  1284. if value, ok := bmuo.mutation.AddedCtype(); ok {
  1285. _spec.AddField(batchmsg.FieldCtype, field.TypeUint64, value)
  1286. }
  1287. if value, ok := bmuo.mutation.Cc(); ok {
  1288. _spec.SetField(batchmsg.FieldCc, field.TypeString, value)
  1289. }
  1290. if bmuo.mutation.CcCleared() {
  1291. _spec.ClearField(batchmsg.FieldCc, field.TypeString)
  1292. }
  1293. if value, ok := bmuo.mutation.Phone(); ok {
  1294. _spec.SetField(batchmsg.FieldPhone, field.TypeString, value)
  1295. }
  1296. if bmuo.mutation.PhoneCleared() {
  1297. _spec.ClearField(batchmsg.FieldPhone, field.TypeString)
  1298. }
  1299. if value, ok := bmuo.mutation.TemplateName(); ok {
  1300. _spec.SetField(batchmsg.FieldTemplateName, field.TypeString, value)
  1301. }
  1302. if bmuo.mutation.TemplateNameCleared() {
  1303. _spec.ClearField(batchmsg.FieldTemplateName, field.TypeString)
  1304. }
  1305. if value, ok := bmuo.mutation.TemplateCode(); ok {
  1306. _spec.SetField(batchmsg.FieldTemplateCode, field.TypeString, value)
  1307. }
  1308. if bmuo.mutation.TemplateCodeCleared() {
  1309. _spec.ClearField(batchmsg.FieldTemplateCode, field.TypeString)
  1310. }
  1311. if value, ok := bmuo.mutation.Lang(); ok {
  1312. _spec.SetField(batchmsg.FieldLang, field.TypeString, value)
  1313. }
  1314. if bmuo.mutation.LangCleared() {
  1315. _spec.ClearField(batchmsg.FieldLang, field.TypeString)
  1316. }
  1317. _node = &BatchMsg{config: bmuo.config}
  1318. _spec.Assign = _node.assignValues
  1319. _spec.ScanValues = _node.scanValues
  1320. if err = sqlgraph.UpdateNode(ctx, bmuo.driver, _spec); err != nil {
  1321. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  1322. err = &NotFoundError{batchmsg.Label}
  1323. } else if sqlgraph.IsConstraintError(err) {
  1324. err = &ConstraintError{msg: err.Error(), wrap: err}
  1325. }
  1326. return nil, err
  1327. }
  1328. bmuo.mutation.done = true
  1329. return _node, nil
  1330. }