batchmsg_update.go 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184
  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. // Mutation returns the BatchMsgMutation object of the builder.
  334. func (bmu *BatchMsgUpdate) Mutation() *BatchMsgMutation {
  335. return bmu.mutation
  336. }
  337. // Save executes the query and returns the number of nodes affected by the update operation.
  338. func (bmu *BatchMsgUpdate) Save(ctx context.Context) (int, error) {
  339. if err := bmu.defaults(); err != nil {
  340. return 0, err
  341. }
  342. return withHooks(ctx, bmu.sqlSave, bmu.mutation, bmu.hooks)
  343. }
  344. // SaveX is like Save, but panics if an error occurs.
  345. func (bmu *BatchMsgUpdate) SaveX(ctx context.Context) int {
  346. affected, err := bmu.Save(ctx)
  347. if err != nil {
  348. panic(err)
  349. }
  350. return affected
  351. }
  352. // Exec executes the query.
  353. func (bmu *BatchMsgUpdate) Exec(ctx context.Context) error {
  354. _, err := bmu.Save(ctx)
  355. return err
  356. }
  357. // ExecX is like Exec, but panics if an error occurs.
  358. func (bmu *BatchMsgUpdate) ExecX(ctx context.Context) {
  359. if err := bmu.Exec(ctx); err != nil {
  360. panic(err)
  361. }
  362. }
  363. // defaults sets the default values of the builder before save.
  364. func (bmu *BatchMsgUpdate) defaults() error {
  365. if _, ok := bmu.mutation.UpdatedAt(); !ok {
  366. if batchmsg.UpdateDefaultUpdatedAt == nil {
  367. return fmt.Errorf("ent: uninitialized batchmsg.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
  368. }
  369. v := batchmsg.UpdateDefaultUpdatedAt()
  370. bmu.mutation.SetUpdatedAt(v)
  371. }
  372. return nil
  373. }
  374. // check runs all checks and user-defined validators on the builder.
  375. func (bmu *BatchMsgUpdate) check() error {
  376. if v, ok := bmu.mutation.OrganizationID(); ok {
  377. if err := batchmsg.OrganizationIDValidator(v); err != nil {
  378. return &ValidationError{Name: "organization_id", err: fmt.Errorf(`ent: validator failed for field "BatchMsg.organization_id": %w`, err)}
  379. }
  380. }
  381. return nil
  382. }
  383. func (bmu *BatchMsgUpdate) sqlSave(ctx context.Context) (n int, err error) {
  384. if err := bmu.check(); err != nil {
  385. return n, err
  386. }
  387. _spec := sqlgraph.NewUpdateSpec(batchmsg.Table, batchmsg.Columns, sqlgraph.NewFieldSpec(batchmsg.FieldID, field.TypeUint64))
  388. if ps := bmu.mutation.predicates; len(ps) > 0 {
  389. _spec.Predicate = func(selector *sql.Selector) {
  390. for i := range ps {
  391. ps[i](selector)
  392. }
  393. }
  394. }
  395. if value, ok := bmu.mutation.UpdatedAt(); ok {
  396. _spec.SetField(batchmsg.FieldUpdatedAt, field.TypeTime, value)
  397. }
  398. if value, ok := bmu.mutation.DeletedAt(); ok {
  399. _spec.SetField(batchmsg.FieldDeletedAt, field.TypeTime, value)
  400. }
  401. if bmu.mutation.DeletedAtCleared() {
  402. _spec.ClearField(batchmsg.FieldDeletedAt, field.TypeTime)
  403. }
  404. if value, ok := bmu.mutation.Status(); ok {
  405. _spec.SetField(batchmsg.FieldStatus, field.TypeUint8, value)
  406. }
  407. if value, ok := bmu.mutation.AddedStatus(); ok {
  408. _spec.AddField(batchmsg.FieldStatus, field.TypeUint8, value)
  409. }
  410. if bmu.mutation.StatusCleared() {
  411. _spec.ClearField(batchmsg.FieldStatus, field.TypeUint8)
  412. }
  413. if value, ok := bmu.mutation.BatchNo(); ok {
  414. _spec.SetField(batchmsg.FieldBatchNo, field.TypeString, value)
  415. }
  416. if bmu.mutation.BatchNoCleared() {
  417. _spec.ClearField(batchmsg.FieldBatchNo, field.TypeString)
  418. }
  419. if value, ok := bmu.mutation.TaskName(); ok {
  420. _spec.SetField(batchmsg.FieldTaskName, field.TypeString, value)
  421. }
  422. if bmu.mutation.TaskNameCleared() {
  423. _spec.ClearField(batchmsg.FieldTaskName, field.TypeString)
  424. }
  425. if value, ok := bmu.mutation.Fromwxid(); ok {
  426. _spec.SetField(batchmsg.FieldFromwxid, field.TypeString, value)
  427. }
  428. if bmu.mutation.FromwxidCleared() {
  429. _spec.ClearField(batchmsg.FieldFromwxid, field.TypeString)
  430. }
  431. if value, ok := bmu.mutation.Msg(); ok {
  432. _spec.SetField(batchmsg.FieldMsg, field.TypeString, value)
  433. }
  434. if bmu.mutation.MsgCleared() {
  435. _spec.ClearField(batchmsg.FieldMsg, field.TypeString)
  436. }
  437. if value, ok := bmu.mutation.Tag(); ok {
  438. _spec.SetField(batchmsg.FieldTag, field.TypeString, value)
  439. }
  440. if bmu.mutation.TagCleared() {
  441. _spec.ClearField(batchmsg.FieldTag, field.TypeString)
  442. }
  443. if value, ok := bmu.mutation.Tagids(); ok {
  444. _spec.SetField(batchmsg.FieldTagids, field.TypeString, value)
  445. }
  446. if bmu.mutation.TagidsCleared() {
  447. _spec.ClearField(batchmsg.FieldTagids, field.TypeString)
  448. }
  449. if value, ok := bmu.mutation.Total(); ok {
  450. _spec.SetField(batchmsg.FieldTotal, field.TypeInt32, value)
  451. }
  452. if value, ok := bmu.mutation.AddedTotal(); ok {
  453. _spec.AddField(batchmsg.FieldTotal, field.TypeInt32, value)
  454. }
  455. if bmu.mutation.TotalCleared() {
  456. _spec.ClearField(batchmsg.FieldTotal, field.TypeInt32)
  457. }
  458. if value, ok := bmu.mutation.Success(); ok {
  459. _spec.SetField(batchmsg.FieldSuccess, field.TypeInt32, value)
  460. }
  461. if value, ok := bmu.mutation.AddedSuccess(); ok {
  462. _spec.AddField(batchmsg.FieldSuccess, field.TypeInt32, value)
  463. }
  464. if bmu.mutation.SuccessCleared() {
  465. _spec.ClearField(batchmsg.FieldSuccess, field.TypeInt32)
  466. }
  467. if value, ok := bmu.mutation.Fail(); ok {
  468. _spec.SetField(batchmsg.FieldFail, field.TypeInt32, value)
  469. }
  470. if value, ok := bmu.mutation.AddedFail(); ok {
  471. _spec.AddField(batchmsg.FieldFail, field.TypeInt32, value)
  472. }
  473. if bmu.mutation.FailCleared() {
  474. _spec.ClearField(batchmsg.FieldFail, field.TypeInt32)
  475. }
  476. if value, ok := bmu.mutation.StartTime(); ok {
  477. _spec.SetField(batchmsg.FieldStartTime, field.TypeTime, value)
  478. }
  479. if bmu.mutation.StartTimeCleared() {
  480. _spec.ClearField(batchmsg.FieldStartTime, field.TypeTime)
  481. }
  482. if value, ok := bmu.mutation.StopTime(); ok {
  483. _spec.SetField(batchmsg.FieldStopTime, field.TypeTime, value)
  484. }
  485. if bmu.mutation.StopTimeCleared() {
  486. _spec.ClearField(batchmsg.FieldStopTime, field.TypeTime)
  487. }
  488. if value, ok := bmu.mutation.SendTime(); ok {
  489. _spec.SetField(batchmsg.FieldSendTime, field.TypeTime, value)
  490. }
  491. if bmu.mutation.SendTimeCleared() {
  492. _spec.ClearField(batchmsg.FieldSendTime, field.TypeTime)
  493. }
  494. if value, ok := bmu.mutation.GetType(); ok {
  495. _spec.SetField(batchmsg.FieldType, field.TypeInt32, value)
  496. }
  497. if value, ok := bmu.mutation.AddedType(); ok {
  498. _spec.AddField(batchmsg.FieldType, field.TypeInt32, value)
  499. }
  500. if bmu.mutation.TypeCleared() {
  501. _spec.ClearField(batchmsg.FieldType, field.TypeInt32)
  502. }
  503. if value, ok := bmu.mutation.OrganizationID(); ok {
  504. _spec.SetField(batchmsg.FieldOrganizationID, field.TypeUint64, value)
  505. }
  506. if value, ok := bmu.mutation.AddedOrganizationID(); ok {
  507. _spec.AddField(batchmsg.FieldOrganizationID, field.TypeUint64, value)
  508. }
  509. if n, err = sqlgraph.UpdateNodes(ctx, bmu.driver, _spec); err != nil {
  510. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  511. err = &NotFoundError{batchmsg.Label}
  512. } else if sqlgraph.IsConstraintError(err) {
  513. err = &ConstraintError{msg: err.Error(), wrap: err}
  514. }
  515. return 0, err
  516. }
  517. bmu.mutation.done = true
  518. return n, nil
  519. }
  520. // BatchMsgUpdateOne is the builder for updating a single BatchMsg entity.
  521. type BatchMsgUpdateOne struct {
  522. config
  523. fields []string
  524. hooks []Hook
  525. mutation *BatchMsgMutation
  526. }
  527. // SetUpdatedAt sets the "updated_at" field.
  528. func (bmuo *BatchMsgUpdateOne) SetUpdatedAt(t time.Time) *BatchMsgUpdateOne {
  529. bmuo.mutation.SetUpdatedAt(t)
  530. return bmuo
  531. }
  532. // SetDeletedAt sets the "deleted_at" field.
  533. func (bmuo *BatchMsgUpdateOne) SetDeletedAt(t time.Time) *BatchMsgUpdateOne {
  534. bmuo.mutation.SetDeletedAt(t)
  535. return bmuo
  536. }
  537. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  538. func (bmuo *BatchMsgUpdateOne) SetNillableDeletedAt(t *time.Time) *BatchMsgUpdateOne {
  539. if t != nil {
  540. bmuo.SetDeletedAt(*t)
  541. }
  542. return bmuo
  543. }
  544. // ClearDeletedAt clears the value of the "deleted_at" field.
  545. func (bmuo *BatchMsgUpdateOne) ClearDeletedAt() *BatchMsgUpdateOne {
  546. bmuo.mutation.ClearDeletedAt()
  547. return bmuo
  548. }
  549. // SetStatus sets the "status" field.
  550. func (bmuo *BatchMsgUpdateOne) SetStatus(u uint8) *BatchMsgUpdateOne {
  551. bmuo.mutation.ResetStatus()
  552. bmuo.mutation.SetStatus(u)
  553. return bmuo
  554. }
  555. // SetNillableStatus sets the "status" field if the given value is not nil.
  556. func (bmuo *BatchMsgUpdateOne) SetNillableStatus(u *uint8) *BatchMsgUpdateOne {
  557. if u != nil {
  558. bmuo.SetStatus(*u)
  559. }
  560. return bmuo
  561. }
  562. // AddStatus adds u to the "status" field.
  563. func (bmuo *BatchMsgUpdateOne) AddStatus(u int8) *BatchMsgUpdateOne {
  564. bmuo.mutation.AddStatus(u)
  565. return bmuo
  566. }
  567. // ClearStatus clears the value of the "status" field.
  568. func (bmuo *BatchMsgUpdateOne) ClearStatus() *BatchMsgUpdateOne {
  569. bmuo.mutation.ClearStatus()
  570. return bmuo
  571. }
  572. // SetBatchNo sets the "batch_no" field.
  573. func (bmuo *BatchMsgUpdateOne) SetBatchNo(s string) *BatchMsgUpdateOne {
  574. bmuo.mutation.SetBatchNo(s)
  575. return bmuo
  576. }
  577. // SetNillableBatchNo sets the "batch_no" field if the given value is not nil.
  578. func (bmuo *BatchMsgUpdateOne) SetNillableBatchNo(s *string) *BatchMsgUpdateOne {
  579. if s != nil {
  580. bmuo.SetBatchNo(*s)
  581. }
  582. return bmuo
  583. }
  584. // ClearBatchNo clears the value of the "batch_no" field.
  585. func (bmuo *BatchMsgUpdateOne) ClearBatchNo() *BatchMsgUpdateOne {
  586. bmuo.mutation.ClearBatchNo()
  587. return bmuo
  588. }
  589. // SetTaskName sets the "task_name" field.
  590. func (bmuo *BatchMsgUpdateOne) SetTaskName(s string) *BatchMsgUpdateOne {
  591. bmuo.mutation.SetTaskName(s)
  592. return bmuo
  593. }
  594. // SetNillableTaskName sets the "task_name" field if the given value is not nil.
  595. func (bmuo *BatchMsgUpdateOne) SetNillableTaskName(s *string) *BatchMsgUpdateOne {
  596. if s != nil {
  597. bmuo.SetTaskName(*s)
  598. }
  599. return bmuo
  600. }
  601. // ClearTaskName clears the value of the "task_name" field.
  602. func (bmuo *BatchMsgUpdateOne) ClearTaskName() *BatchMsgUpdateOne {
  603. bmuo.mutation.ClearTaskName()
  604. return bmuo
  605. }
  606. // SetFromwxid sets the "fromwxid" field.
  607. func (bmuo *BatchMsgUpdateOne) SetFromwxid(s string) *BatchMsgUpdateOne {
  608. bmuo.mutation.SetFromwxid(s)
  609. return bmuo
  610. }
  611. // SetNillableFromwxid sets the "fromwxid" field if the given value is not nil.
  612. func (bmuo *BatchMsgUpdateOne) SetNillableFromwxid(s *string) *BatchMsgUpdateOne {
  613. if s != nil {
  614. bmuo.SetFromwxid(*s)
  615. }
  616. return bmuo
  617. }
  618. // ClearFromwxid clears the value of the "fromwxid" field.
  619. func (bmuo *BatchMsgUpdateOne) ClearFromwxid() *BatchMsgUpdateOne {
  620. bmuo.mutation.ClearFromwxid()
  621. return bmuo
  622. }
  623. // SetMsg sets the "msg" field.
  624. func (bmuo *BatchMsgUpdateOne) SetMsg(s string) *BatchMsgUpdateOne {
  625. bmuo.mutation.SetMsg(s)
  626. return bmuo
  627. }
  628. // SetNillableMsg sets the "msg" field if the given value is not nil.
  629. func (bmuo *BatchMsgUpdateOne) SetNillableMsg(s *string) *BatchMsgUpdateOne {
  630. if s != nil {
  631. bmuo.SetMsg(*s)
  632. }
  633. return bmuo
  634. }
  635. // ClearMsg clears the value of the "msg" field.
  636. func (bmuo *BatchMsgUpdateOne) ClearMsg() *BatchMsgUpdateOne {
  637. bmuo.mutation.ClearMsg()
  638. return bmuo
  639. }
  640. // SetTag sets the "tag" field.
  641. func (bmuo *BatchMsgUpdateOne) SetTag(s string) *BatchMsgUpdateOne {
  642. bmuo.mutation.SetTag(s)
  643. return bmuo
  644. }
  645. // SetNillableTag sets the "tag" field if the given value is not nil.
  646. func (bmuo *BatchMsgUpdateOne) SetNillableTag(s *string) *BatchMsgUpdateOne {
  647. if s != nil {
  648. bmuo.SetTag(*s)
  649. }
  650. return bmuo
  651. }
  652. // ClearTag clears the value of the "tag" field.
  653. func (bmuo *BatchMsgUpdateOne) ClearTag() *BatchMsgUpdateOne {
  654. bmuo.mutation.ClearTag()
  655. return bmuo
  656. }
  657. // SetTagids sets the "tagids" field.
  658. func (bmuo *BatchMsgUpdateOne) SetTagids(s string) *BatchMsgUpdateOne {
  659. bmuo.mutation.SetTagids(s)
  660. return bmuo
  661. }
  662. // SetNillableTagids sets the "tagids" field if the given value is not nil.
  663. func (bmuo *BatchMsgUpdateOne) SetNillableTagids(s *string) *BatchMsgUpdateOne {
  664. if s != nil {
  665. bmuo.SetTagids(*s)
  666. }
  667. return bmuo
  668. }
  669. // ClearTagids clears the value of the "tagids" field.
  670. func (bmuo *BatchMsgUpdateOne) ClearTagids() *BatchMsgUpdateOne {
  671. bmuo.mutation.ClearTagids()
  672. return bmuo
  673. }
  674. // SetTotal sets the "total" field.
  675. func (bmuo *BatchMsgUpdateOne) SetTotal(i int32) *BatchMsgUpdateOne {
  676. bmuo.mutation.ResetTotal()
  677. bmuo.mutation.SetTotal(i)
  678. return bmuo
  679. }
  680. // SetNillableTotal sets the "total" field if the given value is not nil.
  681. func (bmuo *BatchMsgUpdateOne) SetNillableTotal(i *int32) *BatchMsgUpdateOne {
  682. if i != nil {
  683. bmuo.SetTotal(*i)
  684. }
  685. return bmuo
  686. }
  687. // AddTotal adds i to the "total" field.
  688. func (bmuo *BatchMsgUpdateOne) AddTotal(i int32) *BatchMsgUpdateOne {
  689. bmuo.mutation.AddTotal(i)
  690. return bmuo
  691. }
  692. // ClearTotal clears the value of the "total" field.
  693. func (bmuo *BatchMsgUpdateOne) ClearTotal() *BatchMsgUpdateOne {
  694. bmuo.mutation.ClearTotal()
  695. return bmuo
  696. }
  697. // SetSuccess sets the "success" field.
  698. func (bmuo *BatchMsgUpdateOne) SetSuccess(i int32) *BatchMsgUpdateOne {
  699. bmuo.mutation.ResetSuccess()
  700. bmuo.mutation.SetSuccess(i)
  701. return bmuo
  702. }
  703. // SetNillableSuccess sets the "success" field if the given value is not nil.
  704. func (bmuo *BatchMsgUpdateOne) SetNillableSuccess(i *int32) *BatchMsgUpdateOne {
  705. if i != nil {
  706. bmuo.SetSuccess(*i)
  707. }
  708. return bmuo
  709. }
  710. // AddSuccess adds i to the "success" field.
  711. func (bmuo *BatchMsgUpdateOne) AddSuccess(i int32) *BatchMsgUpdateOne {
  712. bmuo.mutation.AddSuccess(i)
  713. return bmuo
  714. }
  715. // ClearSuccess clears the value of the "success" field.
  716. func (bmuo *BatchMsgUpdateOne) ClearSuccess() *BatchMsgUpdateOne {
  717. bmuo.mutation.ClearSuccess()
  718. return bmuo
  719. }
  720. // SetFail sets the "fail" field.
  721. func (bmuo *BatchMsgUpdateOne) SetFail(i int32) *BatchMsgUpdateOne {
  722. bmuo.mutation.ResetFail()
  723. bmuo.mutation.SetFail(i)
  724. return bmuo
  725. }
  726. // SetNillableFail sets the "fail" field if the given value is not nil.
  727. func (bmuo *BatchMsgUpdateOne) SetNillableFail(i *int32) *BatchMsgUpdateOne {
  728. if i != nil {
  729. bmuo.SetFail(*i)
  730. }
  731. return bmuo
  732. }
  733. // AddFail adds i to the "fail" field.
  734. func (bmuo *BatchMsgUpdateOne) AddFail(i int32) *BatchMsgUpdateOne {
  735. bmuo.mutation.AddFail(i)
  736. return bmuo
  737. }
  738. // ClearFail clears the value of the "fail" field.
  739. func (bmuo *BatchMsgUpdateOne) ClearFail() *BatchMsgUpdateOne {
  740. bmuo.mutation.ClearFail()
  741. return bmuo
  742. }
  743. // SetStartTime sets the "start_time" field.
  744. func (bmuo *BatchMsgUpdateOne) SetStartTime(t time.Time) *BatchMsgUpdateOne {
  745. bmuo.mutation.SetStartTime(t)
  746. return bmuo
  747. }
  748. // SetNillableStartTime sets the "start_time" field if the given value is not nil.
  749. func (bmuo *BatchMsgUpdateOne) SetNillableStartTime(t *time.Time) *BatchMsgUpdateOne {
  750. if t != nil {
  751. bmuo.SetStartTime(*t)
  752. }
  753. return bmuo
  754. }
  755. // ClearStartTime clears the value of the "start_time" field.
  756. func (bmuo *BatchMsgUpdateOne) ClearStartTime() *BatchMsgUpdateOne {
  757. bmuo.mutation.ClearStartTime()
  758. return bmuo
  759. }
  760. // SetStopTime sets the "stop_time" field.
  761. func (bmuo *BatchMsgUpdateOne) SetStopTime(t time.Time) *BatchMsgUpdateOne {
  762. bmuo.mutation.SetStopTime(t)
  763. return bmuo
  764. }
  765. // SetNillableStopTime sets the "stop_time" field if the given value is not nil.
  766. func (bmuo *BatchMsgUpdateOne) SetNillableStopTime(t *time.Time) *BatchMsgUpdateOne {
  767. if t != nil {
  768. bmuo.SetStopTime(*t)
  769. }
  770. return bmuo
  771. }
  772. // ClearStopTime clears the value of the "stop_time" field.
  773. func (bmuo *BatchMsgUpdateOne) ClearStopTime() *BatchMsgUpdateOne {
  774. bmuo.mutation.ClearStopTime()
  775. return bmuo
  776. }
  777. // SetSendTime sets the "send_time" field.
  778. func (bmuo *BatchMsgUpdateOne) SetSendTime(t time.Time) *BatchMsgUpdateOne {
  779. bmuo.mutation.SetSendTime(t)
  780. return bmuo
  781. }
  782. // SetNillableSendTime sets the "send_time" field if the given value is not nil.
  783. func (bmuo *BatchMsgUpdateOne) SetNillableSendTime(t *time.Time) *BatchMsgUpdateOne {
  784. if t != nil {
  785. bmuo.SetSendTime(*t)
  786. }
  787. return bmuo
  788. }
  789. // ClearSendTime clears the value of the "send_time" field.
  790. func (bmuo *BatchMsgUpdateOne) ClearSendTime() *BatchMsgUpdateOne {
  791. bmuo.mutation.ClearSendTime()
  792. return bmuo
  793. }
  794. // SetType sets the "type" field.
  795. func (bmuo *BatchMsgUpdateOne) SetType(i int32) *BatchMsgUpdateOne {
  796. bmuo.mutation.ResetType()
  797. bmuo.mutation.SetType(i)
  798. return bmuo
  799. }
  800. // SetNillableType sets the "type" field if the given value is not nil.
  801. func (bmuo *BatchMsgUpdateOne) SetNillableType(i *int32) *BatchMsgUpdateOne {
  802. if i != nil {
  803. bmuo.SetType(*i)
  804. }
  805. return bmuo
  806. }
  807. // AddType adds i to the "type" field.
  808. func (bmuo *BatchMsgUpdateOne) AddType(i int32) *BatchMsgUpdateOne {
  809. bmuo.mutation.AddType(i)
  810. return bmuo
  811. }
  812. // ClearType clears the value of the "type" field.
  813. func (bmuo *BatchMsgUpdateOne) ClearType() *BatchMsgUpdateOne {
  814. bmuo.mutation.ClearType()
  815. return bmuo
  816. }
  817. // SetOrganizationID sets the "organization_id" field.
  818. func (bmuo *BatchMsgUpdateOne) SetOrganizationID(u uint64) *BatchMsgUpdateOne {
  819. bmuo.mutation.ResetOrganizationID()
  820. bmuo.mutation.SetOrganizationID(u)
  821. return bmuo
  822. }
  823. // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
  824. func (bmuo *BatchMsgUpdateOne) SetNillableOrganizationID(u *uint64) *BatchMsgUpdateOne {
  825. if u != nil {
  826. bmuo.SetOrganizationID(*u)
  827. }
  828. return bmuo
  829. }
  830. // AddOrganizationID adds u to the "organization_id" field.
  831. func (bmuo *BatchMsgUpdateOne) AddOrganizationID(u int64) *BatchMsgUpdateOne {
  832. bmuo.mutation.AddOrganizationID(u)
  833. return bmuo
  834. }
  835. // Mutation returns the BatchMsgMutation object of the builder.
  836. func (bmuo *BatchMsgUpdateOne) Mutation() *BatchMsgMutation {
  837. return bmuo.mutation
  838. }
  839. // Where appends a list predicates to the BatchMsgUpdate builder.
  840. func (bmuo *BatchMsgUpdateOne) Where(ps ...predicate.BatchMsg) *BatchMsgUpdateOne {
  841. bmuo.mutation.Where(ps...)
  842. return bmuo
  843. }
  844. // Select allows selecting one or more fields (columns) of the returned entity.
  845. // The default is selecting all fields defined in the entity schema.
  846. func (bmuo *BatchMsgUpdateOne) Select(field string, fields ...string) *BatchMsgUpdateOne {
  847. bmuo.fields = append([]string{field}, fields...)
  848. return bmuo
  849. }
  850. // Save executes the query and returns the updated BatchMsg entity.
  851. func (bmuo *BatchMsgUpdateOne) Save(ctx context.Context) (*BatchMsg, error) {
  852. if err := bmuo.defaults(); err != nil {
  853. return nil, err
  854. }
  855. return withHooks(ctx, bmuo.sqlSave, bmuo.mutation, bmuo.hooks)
  856. }
  857. // SaveX is like Save, but panics if an error occurs.
  858. func (bmuo *BatchMsgUpdateOne) SaveX(ctx context.Context) *BatchMsg {
  859. node, err := bmuo.Save(ctx)
  860. if err != nil {
  861. panic(err)
  862. }
  863. return node
  864. }
  865. // Exec executes the query on the entity.
  866. func (bmuo *BatchMsgUpdateOne) Exec(ctx context.Context) error {
  867. _, err := bmuo.Save(ctx)
  868. return err
  869. }
  870. // ExecX is like Exec, but panics if an error occurs.
  871. func (bmuo *BatchMsgUpdateOne) ExecX(ctx context.Context) {
  872. if err := bmuo.Exec(ctx); err != nil {
  873. panic(err)
  874. }
  875. }
  876. // defaults sets the default values of the builder before save.
  877. func (bmuo *BatchMsgUpdateOne) defaults() error {
  878. if _, ok := bmuo.mutation.UpdatedAt(); !ok {
  879. if batchmsg.UpdateDefaultUpdatedAt == nil {
  880. return fmt.Errorf("ent: uninitialized batchmsg.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
  881. }
  882. v := batchmsg.UpdateDefaultUpdatedAt()
  883. bmuo.mutation.SetUpdatedAt(v)
  884. }
  885. return nil
  886. }
  887. // check runs all checks and user-defined validators on the builder.
  888. func (bmuo *BatchMsgUpdateOne) check() error {
  889. if v, ok := bmuo.mutation.OrganizationID(); ok {
  890. if err := batchmsg.OrganizationIDValidator(v); err != nil {
  891. return &ValidationError{Name: "organization_id", err: fmt.Errorf(`ent: validator failed for field "BatchMsg.organization_id": %w`, err)}
  892. }
  893. }
  894. return nil
  895. }
  896. func (bmuo *BatchMsgUpdateOne) sqlSave(ctx context.Context) (_node *BatchMsg, err error) {
  897. if err := bmuo.check(); err != nil {
  898. return _node, err
  899. }
  900. _spec := sqlgraph.NewUpdateSpec(batchmsg.Table, batchmsg.Columns, sqlgraph.NewFieldSpec(batchmsg.FieldID, field.TypeUint64))
  901. id, ok := bmuo.mutation.ID()
  902. if !ok {
  903. return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "BatchMsg.id" for update`)}
  904. }
  905. _spec.Node.ID.Value = id
  906. if fields := bmuo.fields; len(fields) > 0 {
  907. _spec.Node.Columns = make([]string, 0, len(fields))
  908. _spec.Node.Columns = append(_spec.Node.Columns, batchmsg.FieldID)
  909. for _, f := range fields {
  910. if !batchmsg.ValidColumn(f) {
  911. return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
  912. }
  913. if f != batchmsg.FieldID {
  914. _spec.Node.Columns = append(_spec.Node.Columns, f)
  915. }
  916. }
  917. }
  918. if ps := bmuo.mutation.predicates; len(ps) > 0 {
  919. _spec.Predicate = func(selector *sql.Selector) {
  920. for i := range ps {
  921. ps[i](selector)
  922. }
  923. }
  924. }
  925. if value, ok := bmuo.mutation.UpdatedAt(); ok {
  926. _spec.SetField(batchmsg.FieldUpdatedAt, field.TypeTime, value)
  927. }
  928. if value, ok := bmuo.mutation.DeletedAt(); ok {
  929. _spec.SetField(batchmsg.FieldDeletedAt, field.TypeTime, value)
  930. }
  931. if bmuo.mutation.DeletedAtCleared() {
  932. _spec.ClearField(batchmsg.FieldDeletedAt, field.TypeTime)
  933. }
  934. if value, ok := bmuo.mutation.Status(); ok {
  935. _spec.SetField(batchmsg.FieldStatus, field.TypeUint8, value)
  936. }
  937. if value, ok := bmuo.mutation.AddedStatus(); ok {
  938. _spec.AddField(batchmsg.FieldStatus, field.TypeUint8, value)
  939. }
  940. if bmuo.mutation.StatusCleared() {
  941. _spec.ClearField(batchmsg.FieldStatus, field.TypeUint8)
  942. }
  943. if value, ok := bmuo.mutation.BatchNo(); ok {
  944. _spec.SetField(batchmsg.FieldBatchNo, field.TypeString, value)
  945. }
  946. if bmuo.mutation.BatchNoCleared() {
  947. _spec.ClearField(batchmsg.FieldBatchNo, field.TypeString)
  948. }
  949. if value, ok := bmuo.mutation.TaskName(); ok {
  950. _spec.SetField(batchmsg.FieldTaskName, field.TypeString, value)
  951. }
  952. if bmuo.mutation.TaskNameCleared() {
  953. _spec.ClearField(batchmsg.FieldTaskName, field.TypeString)
  954. }
  955. if value, ok := bmuo.mutation.Fromwxid(); ok {
  956. _spec.SetField(batchmsg.FieldFromwxid, field.TypeString, value)
  957. }
  958. if bmuo.mutation.FromwxidCleared() {
  959. _spec.ClearField(batchmsg.FieldFromwxid, field.TypeString)
  960. }
  961. if value, ok := bmuo.mutation.Msg(); ok {
  962. _spec.SetField(batchmsg.FieldMsg, field.TypeString, value)
  963. }
  964. if bmuo.mutation.MsgCleared() {
  965. _spec.ClearField(batchmsg.FieldMsg, field.TypeString)
  966. }
  967. if value, ok := bmuo.mutation.Tag(); ok {
  968. _spec.SetField(batchmsg.FieldTag, field.TypeString, value)
  969. }
  970. if bmuo.mutation.TagCleared() {
  971. _spec.ClearField(batchmsg.FieldTag, field.TypeString)
  972. }
  973. if value, ok := bmuo.mutation.Tagids(); ok {
  974. _spec.SetField(batchmsg.FieldTagids, field.TypeString, value)
  975. }
  976. if bmuo.mutation.TagidsCleared() {
  977. _spec.ClearField(batchmsg.FieldTagids, field.TypeString)
  978. }
  979. if value, ok := bmuo.mutation.Total(); ok {
  980. _spec.SetField(batchmsg.FieldTotal, field.TypeInt32, value)
  981. }
  982. if value, ok := bmuo.mutation.AddedTotal(); ok {
  983. _spec.AddField(batchmsg.FieldTotal, field.TypeInt32, value)
  984. }
  985. if bmuo.mutation.TotalCleared() {
  986. _spec.ClearField(batchmsg.FieldTotal, field.TypeInt32)
  987. }
  988. if value, ok := bmuo.mutation.Success(); ok {
  989. _spec.SetField(batchmsg.FieldSuccess, field.TypeInt32, value)
  990. }
  991. if value, ok := bmuo.mutation.AddedSuccess(); ok {
  992. _spec.AddField(batchmsg.FieldSuccess, field.TypeInt32, value)
  993. }
  994. if bmuo.mutation.SuccessCleared() {
  995. _spec.ClearField(batchmsg.FieldSuccess, field.TypeInt32)
  996. }
  997. if value, ok := bmuo.mutation.Fail(); ok {
  998. _spec.SetField(batchmsg.FieldFail, field.TypeInt32, value)
  999. }
  1000. if value, ok := bmuo.mutation.AddedFail(); ok {
  1001. _spec.AddField(batchmsg.FieldFail, field.TypeInt32, value)
  1002. }
  1003. if bmuo.mutation.FailCleared() {
  1004. _spec.ClearField(batchmsg.FieldFail, field.TypeInt32)
  1005. }
  1006. if value, ok := bmuo.mutation.StartTime(); ok {
  1007. _spec.SetField(batchmsg.FieldStartTime, field.TypeTime, value)
  1008. }
  1009. if bmuo.mutation.StartTimeCleared() {
  1010. _spec.ClearField(batchmsg.FieldStartTime, field.TypeTime)
  1011. }
  1012. if value, ok := bmuo.mutation.StopTime(); ok {
  1013. _spec.SetField(batchmsg.FieldStopTime, field.TypeTime, value)
  1014. }
  1015. if bmuo.mutation.StopTimeCleared() {
  1016. _spec.ClearField(batchmsg.FieldStopTime, field.TypeTime)
  1017. }
  1018. if value, ok := bmuo.mutation.SendTime(); ok {
  1019. _spec.SetField(batchmsg.FieldSendTime, field.TypeTime, value)
  1020. }
  1021. if bmuo.mutation.SendTimeCleared() {
  1022. _spec.ClearField(batchmsg.FieldSendTime, field.TypeTime)
  1023. }
  1024. if value, ok := bmuo.mutation.GetType(); ok {
  1025. _spec.SetField(batchmsg.FieldType, field.TypeInt32, value)
  1026. }
  1027. if value, ok := bmuo.mutation.AddedType(); ok {
  1028. _spec.AddField(batchmsg.FieldType, field.TypeInt32, value)
  1029. }
  1030. if bmuo.mutation.TypeCleared() {
  1031. _spec.ClearField(batchmsg.FieldType, field.TypeInt32)
  1032. }
  1033. if value, ok := bmuo.mutation.OrganizationID(); ok {
  1034. _spec.SetField(batchmsg.FieldOrganizationID, field.TypeUint64, value)
  1035. }
  1036. if value, ok := bmuo.mutation.AddedOrganizationID(); ok {
  1037. _spec.AddField(batchmsg.FieldOrganizationID, field.TypeUint64, value)
  1038. }
  1039. _node = &BatchMsg{config: bmuo.config}
  1040. _spec.Assign = _node.assignValues
  1041. _spec.ScanValues = _node.scanValues
  1042. if err = sqlgraph.UpdateNode(ctx, bmuo.driver, _spec); err != nil {
  1043. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  1044. err = &NotFoundError{batchmsg.Label}
  1045. } else if sqlgraph.IsConstraintError(err) {
  1046. err = &ConstraintError{msg: err.Error(), wrap: err}
  1047. }
  1048. return nil, err
  1049. }
  1050. bmuo.mutation.done = true
  1051. return _node, nil
  1052. }