msg_update.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  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/msg"
  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. // MsgUpdate is the builder for updating Msg entities.
  15. type MsgUpdate struct {
  16. config
  17. hooks []Hook
  18. mutation *MsgMutation
  19. }
  20. // Where appends a list predicates to the MsgUpdate builder.
  21. func (mu *MsgUpdate) Where(ps ...predicate.Msg) *MsgUpdate {
  22. mu.mutation.Where(ps...)
  23. return mu
  24. }
  25. // SetCreatedAt sets the "created_at" field.
  26. func (mu *MsgUpdate) SetCreatedAt(t time.Time) *MsgUpdate {
  27. mu.mutation.SetCreatedAt(t)
  28. return mu
  29. }
  30. // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
  31. func (mu *MsgUpdate) SetNillableCreatedAt(t *time.Time) *MsgUpdate {
  32. if t != nil {
  33. mu.SetCreatedAt(*t)
  34. }
  35. return mu
  36. }
  37. // SetUpdatedAt sets the "updated_at" field.
  38. func (mu *MsgUpdate) SetUpdatedAt(t time.Time) *MsgUpdate {
  39. mu.mutation.SetUpdatedAt(t)
  40. return mu
  41. }
  42. // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
  43. func (mu *MsgUpdate) SetNillableUpdatedAt(t *time.Time) *MsgUpdate {
  44. if t != nil {
  45. mu.SetUpdatedAt(*t)
  46. }
  47. return mu
  48. }
  49. // SetDeletedAt sets the "deleted_at" field.
  50. func (mu *MsgUpdate) SetDeletedAt(t time.Time) *MsgUpdate {
  51. mu.mutation.SetDeletedAt(t)
  52. return mu
  53. }
  54. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  55. func (mu *MsgUpdate) SetNillableDeletedAt(t *time.Time) *MsgUpdate {
  56. if t != nil {
  57. mu.SetDeletedAt(*t)
  58. }
  59. return mu
  60. }
  61. // ClearDeletedAt clears the value of the "deleted_at" field.
  62. func (mu *MsgUpdate) ClearDeletedAt() *MsgUpdate {
  63. mu.mutation.ClearDeletedAt()
  64. return mu
  65. }
  66. // SetStatus sets the "status" field.
  67. func (mu *MsgUpdate) SetStatus(u uint8) *MsgUpdate {
  68. mu.mutation.ResetStatus()
  69. mu.mutation.SetStatus(u)
  70. return mu
  71. }
  72. // SetNillableStatus sets the "status" field if the given value is not nil.
  73. func (mu *MsgUpdate) SetNillableStatus(u *uint8) *MsgUpdate {
  74. if u != nil {
  75. mu.SetStatus(*u)
  76. }
  77. return mu
  78. }
  79. // AddStatus adds u to the "status" field.
  80. func (mu *MsgUpdate) AddStatus(u int8) *MsgUpdate {
  81. mu.mutation.AddStatus(u)
  82. return mu
  83. }
  84. // ClearStatus clears the value of the "status" field.
  85. func (mu *MsgUpdate) ClearStatus() *MsgUpdate {
  86. mu.mutation.ClearStatus()
  87. return mu
  88. }
  89. // SetFromwxid sets the "fromwxid" field.
  90. func (mu *MsgUpdate) SetFromwxid(s string) *MsgUpdate {
  91. mu.mutation.SetFromwxid(s)
  92. return mu
  93. }
  94. // SetNillableFromwxid sets the "fromwxid" field if the given value is not nil.
  95. func (mu *MsgUpdate) SetNillableFromwxid(s *string) *MsgUpdate {
  96. if s != nil {
  97. mu.SetFromwxid(*s)
  98. }
  99. return mu
  100. }
  101. // ClearFromwxid clears the value of the "fromwxid" field.
  102. func (mu *MsgUpdate) ClearFromwxid() *MsgUpdate {
  103. mu.mutation.ClearFromwxid()
  104. return mu
  105. }
  106. // SetToid sets the "toid" field.
  107. func (mu *MsgUpdate) SetToid(s string) *MsgUpdate {
  108. mu.mutation.SetToid(s)
  109. return mu
  110. }
  111. // SetNillableToid sets the "toid" field if the given value is not nil.
  112. func (mu *MsgUpdate) SetNillableToid(s *string) *MsgUpdate {
  113. if s != nil {
  114. mu.SetToid(*s)
  115. }
  116. return mu
  117. }
  118. // ClearToid clears the value of the "toid" field.
  119. func (mu *MsgUpdate) ClearToid() *MsgUpdate {
  120. mu.mutation.ClearToid()
  121. return mu
  122. }
  123. // SetMsgtype sets the "msgtype" field.
  124. func (mu *MsgUpdate) SetMsgtype(i int32) *MsgUpdate {
  125. mu.mutation.ResetMsgtype()
  126. mu.mutation.SetMsgtype(i)
  127. return mu
  128. }
  129. // SetNillableMsgtype sets the "msgtype" field if the given value is not nil.
  130. func (mu *MsgUpdate) SetNillableMsgtype(i *int32) *MsgUpdate {
  131. if i != nil {
  132. mu.SetMsgtype(*i)
  133. }
  134. return mu
  135. }
  136. // AddMsgtype adds i to the "msgtype" field.
  137. func (mu *MsgUpdate) AddMsgtype(i int32) *MsgUpdate {
  138. mu.mutation.AddMsgtype(i)
  139. return mu
  140. }
  141. // ClearMsgtype clears the value of the "msgtype" field.
  142. func (mu *MsgUpdate) ClearMsgtype() *MsgUpdate {
  143. mu.mutation.ClearMsgtype()
  144. return mu
  145. }
  146. // SetMsg sets the "msg" field.
  147. func (mu *MsgUpdate) SetMsg(s string) *MsgUpdate {
  148. mu.mutation.SetMsg(s)
  149. return mu
  150. }
  151. // SetNillableMsg sets the "msg" field if the given value is not nil.
  152. func (mu *MsgUpdate) SetNillableMsg(s *string) *MsgUpdate {
  153. if s != nil {
  154. mu.SetMsg(*s)
  155. }
  156. return mu
  157. }
  158. // ClearMsg clears the value of the "msg" field.
  159. func (mu *MsgUpdate) ClearMsg() *MsgUpdate {
  160. mu.mutation.ClearMsg()
  161. return mu
  162. }
  163. // SetBatchNo sets the "batch_no" field.
  164. func (mu *MsgUpdate) SetBatchNo(s string) *MsgUpdate {
  165. mu.mutation.SetBatchNo(s)
  166. return mu
  167. }
  168. // SetNillableBatchNo sets the "batch_no" field if the given value is not nil.
  169. func (mu *MsgUpdate) SetNillableBatchNo(s *string) *MsgUpdate {
  170. if s != nil {
  171. mu.SetBatchNo(*s)
  172. }
  173. return mu
  174. }
  175. // ClearBatchNo clears the value of the "batch_no" field.
  176. func (mu *MsgUpdate) ClearBatchNo() *MsgUpdate {
  177. mu.mutation.ClearBatchNo()
  178. return mu
  179. }
  180. // Mutation returns the MsgMutation object of the builder.
  181. func (mu *MsgUpdate) Mutation() *MsgMutation {
  182. return mu.mutation
  183. }
  184. // Save executes the query and returns the number of nodes affected by the update operation.
  185. func (mu *MsgUpdate) Save(ctx context.Context) (int, error) {
  186. return withHooks(ctx, mu.sqlSave, mu.mutation, mu.hooks)
  187. }
  188. // SaveX is like Save, but panics if an error occurs.
  189. func (mu *MsgUpdate) SaveX(ctx context.Context) int {
  190. affected, err := mu.Save(ctx)
  191. if err != nil {
  192. panic(err)
  193. }
  194. return affected
  195. }
  196. // Exec executes the query.
  197. func (mu *MsgUpdate) Exec(ctx context.Context) error {
  198. _, err := mu.Save(ctx)
  199. return err
  200. }
  201. // ExecX is like Exec, but panics if an error occurs.
  202. func (mu *MsgUpdate) ExecX(ctx context.Context) {
  203. if err := mu.Exec(ctx); err != nil {
  204. panic(err)
  205. }
  206. }
  207. func (mu *MsgUpdate) sqlSave(ctx context.Context) (n int, err error) {
  208. _spec := sqlgraph.NewUpdateSpec(msg.Table, msg.Columns, sqlgraph.NewFieldSpec(msg.FieldID, field.TypeInt))
  209. if ps := mu.mutation.predicates; len(ps) > 0 {
  210. _spec.Predicate = func(selector *sql.Selector) {
  211. for i := range ps {
  212. ps[i](selector)
  213. }
  214. }
  215. }
  216. if value, ok := mu.mutation.CreatedAt(); ok {
  217. _spec.SetField(msg.FieldCreatedAt, field.TypeTime, value)
  218. }
  219. if value, ok := mu.mutation.UpdatedAt(); ok {
  220. _spec.SetField(msg.FieldUpdatedAt, field.TypeTime, value)
  221. }
  222. if value, ok := mu.mutation.DeletedAt(); ok {
  223. _spec.SetField(msg.FieldDeletedAt, field.TypeTime, value)
  224. }
  225. if mu.mutation.DeletedAtCleared() {
  226. _spec.ClearField(msg.FieldDeletedAt, field.TypeTime)
  227. }
  228. if value, ok := mu.mutation.Status(); ok {
  229. _spec.SetField(msg.FieldStatus, field.TypeUint8, value)
  230. }
  231. if value, ok := mu.mutation.AddedStatus(); ok {
  232. _spec.AddField(msg.FieldStatus, field.TypeUint8, value)
  233. }
  234. if mu.mutation.StatusCleared() {
  235. _spec.ClearField(msg.FieldStatus, field.TypeUint8)
  236. }
  237. if value, ok := mu.mutation.Fromwxid(); ok {
  238. _spec.SetField(msg.FieldFromwxid, field.TypeString, value)
  239. }
  240. if mu.mutation.FromwxidCleared() {
  241. _spec.ClearField(msg.FieldFromwxid, field.TypeString)
  242. }
  243. if value, ok := mu.mutation.Toid(); ok {
  244. _spec.SetField(msg.FieldToid, field.TypeString, value)
  245. }
  246. if mu.mutation.ToidCleared() {
  247. _spec.ClearField(msg.FieldToid, field.TypeString)
  248. }
  249. if value, ok := mu.mutation.Msgtype(); ok {
  250. _spec.SetField(msg.FieldMsgtype, field.TypeInt32, value)
  251. }
  252. if value, ok := mu.mutation.AddedMsgtype(); ok {
  253. _spec.AddField(msg.FieldMsgtype, field.TypeInt32, value)
  254. }
  255. if mu.mutation.MsgtypeCleared() {
  256. _spec.ClearField(msg.FieldMsgtype, field.TypeInt32)
  257. }
  258. if value, ok := mu.mutation.Msg(); ok {
  259. _spec.SetField(msg.FieldMsg, field.TypeString, value)
  260. }
  261. if mu.mutation.MsgCleared() {
  262. _spec.ClearField(msg.FieldMsg, field.TypeString)
  263. }
  264. if value, ok := mu.mutation.BatchNo(); ok {
  265. _spec.SetField(msg.FieldBatchNo, field.TypeString, value)
  266. }
  267. if mu.mutation.BatchNoCleared() {
  268. _spec.ClearField(msg.FieldBatchNo, field.TypeString)
  269. }
  270. if n, err = sqlgraph.UpdateNodes(ctx, mu.driver, _spec); err != nil {
  271. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  272. err = &NotFoundError{msg.Label}
  273. } else if sqlgraph.IsConstraintError(err) {
  274. err = &ConstraintError{msg: err.Error(), wrap: err}
  275. }
  276. return 0, err
  277. }
  278. mu.mutation.done = true
  279. return n, nil
  280. }
  281. // MsgUpdateOne is the builder for updating a single Msg entity.
  282. type MsgUpdateOne struct {
  283. config
  284. fields []string
  285. hooks []Hook
  286. mutation *MsgMutation
  287. }
  288. // SetCreatedAt sets the "created_at" field.
  289. func (muo *MsgUpdateOne) SetCreatedAt(t time.Time) *MsgUpdateOne {
  290. muo.mutation.SetCreatedAt(t)
  291. return muo
  292. }
  293. // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
  294. func (muo *MsgUpdateOne) SetNillableCreatedAt(t *time.Time) *MsgUpdateOne {
  295. if t != nil {
  296. muo.SetCreatedAt(*t)
  297. }
  298. return muo
  299. }
  300. // SetUpdatedAt sets the "updated_at" field.
  301. func (muo *MsgUpdateOne) SetUpdatedAt(t time.Time) *MsgUpdateOne {
  302. muo.mutation.SetUpdatedAt(t)
  303. return muo
  304. }
  305. // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
  306. func (muo *MsgUpdateOne) SetNillableUpdatedAt(t *time.Time) *MsgUpdateOne {
  307. if t != nil {
  308. muo.SetUpdatedAt(*t)
  309. }
  310. return muo
  311. }
  312. // SetDeletedAt sets the "deleted_at" field.
  313. func (muo *MsgUpdateOne) SetDeletedAt(t time.Time) *MsgUpdateOne {
  314. muo.mutation.SetDeletedAt(t)
  315. return muo
  316. }
  317. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  318. func (muo *MsgUpdateOne) SetNillableDeletedAt(t *time.Time) *MsgUpdateOne {
  319. if t != nil {
  320. muo.SetDeletedAt(*t)
  321. }
  322. return muo
  323. }
  324. // ClearDeletedAt clears the value of the "deleted_at" field.
  325. func (muo *MsgUpdateOne) ClearDeletedAt() *MsgUpdateOne {
  326. muo.mutation.ClearDeletedAt()
  327. return muo
  328. }
  329. // SetStatus sets the "status" field.
  330. func (muo *MsgUpdateOne) SetStatus(u uint8) *MsgUpdateOne {
  331. muo.mutation.ResetStatus()
  332. muo.mutation.SetStatus(u)
  333. return muo
  334. }
  335. // SetNillableStatus sets the "status" field if the given value is not nil.
  336. func (muo *MsgUpdateOne) SetNillableStatus(u *uint8) *MsgUpdateOne {
  337. if u != nil {
  338. muo.SetStatus(*u)
  339. }
  340. return muo
  341. }
  342. // AddStatus adds u to the "status" field.
  343. func (muo *MsgUpdateOne) AddStatus(u int8) *MsgUpdateOne {
  344. muo.mutation.AddStatus(u)
  345. return muo
  346. }
  347. // ClearStatus clears the value of the "status" field.
  348. func (muo *MsgUpdateOne) ClearStatus() *MsgUpdateOne {
  349. muo.mutation.ClearStatus()
  350. return muo
  351. }
  352. // SetFromwxid sets the "fromwxid" field.
  353. func (muo *MsgUpdateOne) SetFromwxid(s string) *MsgUpdateOne {
  354. muo.mutation.SetFromwxid(s)
  355. return muo
  356. }
  357. // SetNillableFromwxid sets the "fromwxid" field if the given value is not nil.
  358. func (muo *MsgUpdateOne) SetNillableFromwxid(s *string) *MsgUpdateOne {
  359. if s != nil {
  360. muo.SetFromwxid(*s)
  361. }
  362. return muo
  363. }
  364. // ClearFromwxid clears the value of the "fromwxid" field.
  365. func (muo *MsgUpdateOne) ClearFromwxid() *MsgUpdateOne {
  366. muo.mutation.ClearFromwxid()
  367. return muo
  368. }
  369. // SetToid sets the "toid" field.
  370. func (muo *MsgUpdateOne) SetToid(s string) *MsgUpdateOne {
  371. muo.mutation.SetToid(s)
  372. return muo
  373. }
  374. // SetNillableToid sets the "toid" field if the given value is not nil.
  375. func (muo *MsgUpdateOne) SetNillableToid(s *string) *MsgUpdateOne {
  376. if s != nil {
  377. muo.SetToid(*s)
  378. }
  379. return muo
  380. }
  381. // ClearToid clears the value of the "toid" field.
  382. func (muo *MsgUpdateOne) ClearToid() *MsgUpdateOne {
  383. muo.mutation.ClearToid()
  384. return muo
  385. }
  386. // SetMsgtype sets the "msgtype" field.
  387. func (muo *MsgUpdateOne) SetMsgtype(i int32) *MsgUpdateOne {
  388. muo.mutation.ResetMsgtype()
  389. muo.mutation.SetMsgtype(i)
  390. return muo
  391. }
  392. // SetNillableMsgtype sets the "msgtype" field if the given value is not nil.
  393. func (muo *MsgUpdateOne) SetNillableMsgtype(i *int32) *MsgUpdateOne {
  394. if i != nil {
  395. muo.SetMsgtype(*i)
  396. }
  397. return muo
  398. }
  399. // AddMsgtype adds i to the "msgtype" field.
  400. func (muo *MsgUpdateOne) AddMsgtype(i int32) *MsgUpdateOne {
  401. muo.mutation.AddMsgtype(i)
  402. return muo
  403. }
  404. // ClearMsgtype clears the value of the "msgtype" field.
  405. func (muo *MsgUpdateOne) ClearMsgtype() *MsgUpdateOne {
  406. muo.mutation.ClearMsgtype()
  407. return muo
  408. }
  409. // SetMsg sets the "msg" field.
  410. func (muo *MsgUpdateOne) SetMsg(s string) *MsgUpdateOne {
  411. muo.mutation.SetMsg(s)
  412. return muo
  413. }
  414. // SetNillableMsg sets the "msg" field if the given value is not nil.
  415. func (muo *MsgUpdateOne) SetNillableMsg(s *string) *MsgUpdateOne {
  416. if s != nil {
  417. muo.SetMsg(*s)
  418. }
  419. return muo
  420. }
  421. // ClearMsg clears the value of the "msg" field.
  422. func (muo *MsgUpdateOne) ClearMsg() *MsgUpdateOne {
  423. muo.mutation.ClearMsg()
  424. return muo
  425. }
  426. // SetBatchNo sets the "batch_no" field.
  427. func (muo *MsgUpdateOne) SetBatchNo(s string) *MsgUpdateOne {
  428. muo.mutation.SetBatchNo(s)
  429. return muo
  430. }
  431. // SetNillableBatchNo sets the "batch_no" field if the given value is not nil.
  432. func (muo *MsgUpdateOne) SetNillableBatchNo(s *string) *MsgUpdateOne {
  433. if s != nil {
  434. muo.SetBatchNo(*s)
  435. }
  436. return muo
  437. }
  438. // ClearBatchNo clears the value of the "batch_no" field.
  439. func (muo *MsgUpdateOne) ClearBatchNo() *MsgUpdateOne {
  440. muo.mutation.ClearBatchNo()
  441. return muo
  442. }
  443. // Mutation returns the MsgMutation object of the builder.
  444. func (muo *MsgUpdateOne) Mutation() *MsgMutation {
  445. return muo.mutation
  446. }
  447. // Where appends a list predicates to the MsgUpdate builder.
  448. func (muo *MsgUpdateOne) Where(ps ...predicate.Msg) *MsgUpdateOne {
  449. muo.mutation.Where(ps...)
  450. return muo
  451. }
  452. // Select allows selecting one or more fields (columns) of the returned entity.
  453. // The default is selecting all fields defined in the entity schema.
  454. func (muo *MsgUpdateOne) Select(field string, fields ...string) *MsgUpdateOne {
  455. muo.fields = append([]string{field}, fields...)
  456. return muo
  457. }
  458. // Save executes the query and returns the updated Msg entity.
  459. func (muo *MsgUpdateOne) Save(ctx context.Context) (*Msg, error) {
  460. return withHooks(ctx, muo.sqlSave, muo.mutation, muo.hooks)
  461. }
  462. // SaveX is like Save, but panics if an error occurs.
  463. func (muo *MsgUpdateOne) SaveX(ctx context.Context) *Msg {
  464. node, err := muo.Save(ctx)
  465. if err != nil {
  466. panic(err)
  467. }
  468. return node
  469. }
  470. // Exec executes the query on the entity.
  471. func (muo *MsgUpdateOne) Exec(ctx context.Context) error {
  472. _, err := muo.Save(ctx)
  473. return err
  474. }
  475. // ExecX is like Exec, but panics if an error occurs.
  476. func (muo *MsgUpdateOne) ExecX(ctx context.Context) {
  477. if err := muo.Exec(ctx); err != nil {
  478. panic(err)
  479. }
  480. }
  481. func (muo *MsgUpdateOne) sqlSave(ctx context.Context) (_node *Msg, err error) {
  482. _spec := sqlgraph.NewUpdateSpec(msg.Table, msg.Columns, sqlgraph.NewFieldSpec(msg.FieldID, field.TypeInt))
  483. id, ok := muo.mutation.ID()
  484. if !ok {
  485. return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Msg.id" for update`)}
  486. }
  487. _spec.Node.ID.Value = id
  488. if fields := muo.fields; len(fields) > 0 {
  489. _spec.Node.Columns = make([]string, 0, len(fields))
  490. _spec.Node.Columns = append(_spec.Node.Columns, msg.FieldID)
  491. for _, f := range fields {
  492. if !msg.ValidColumn(f) {
  493. return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
  494. }
  495. if f != msg.FieldID {
  496. _spec.Node.Columns = append(_spec.Node.Columns, f)
  497. }
  498. }
  499. }
  500. if ps := muo.mutation.predicates; len(ps) > 0 {
  501. _spec.Predicate = func(selector *sql.Selector) {
  502. for i := range ps {
  503. ps[i](selector)
  504. }
  505. }
  506. }
  507. if value, ok := muo.mutation.CreatedAt(); ok {
  508. _spec.SetField(msg.FieldCreatedAt, field.TypeTime, value)
  509. }
  510. if value, ok := muo.mutation.UpdatedAt(); ok {
  511. _spec.SetField(msg.FieldUpdatedAt, field.TypeTime, value)
  512. }
  513. if value, ok := muo.mutation.DeletedAt(); ok {
  514. _spec.SetField(msg.FieldDeletedAt, field.TypeTime, value)
  515. }
  516. if muo.mutation.DeletedAtCleared() {
  517. _spec.ClearField(msg.FieldDeletedAt, field.TypeTime)
  518. }
  519. if value, ok := muo.mutation.Status(); ok {
  520. _spec.SetField(msg.FieldStatus, field.TypeUint8, value)
  521. }
  522. if value, ok := muo.mutation.AddedStatus(); ok {
  523. _spec.AddField(msg.FieldStatus, field.TypeUint8, value)
  524. }
  525. if muo.mutation.StatusCleared() {
  526. _spec.ClearField(msg.FieldStatus, field.TypeUint8)
  527. }
  528. if value, ok := muo.mutation.Fromwxid(); ok {
  529. _spec.SetField(msg.FieldFromwxid, field.TypeString, value)
  530. }
  531. if muo.mutation.FromwxidCleared() {
  532. _spec.ClearField(msg.FieldFromwxid, field.TypeString)
  533. }
  534. if value, ok := muo.mutation.Toid(); ok {
  535. _spec.SetField(msg.FieldToid, field.TypeString, value)
  536. }
  537. if muo.mutation.ToidCleared() {
  538. _spec.ClearField(msg.FieldToid, field.TypeString)
  539. }
  540. if value, ok := muo.mutation.Msgtype(); ok {
  541. _spec.SetField(msg.FieldMsgtype, field.TypeInt32, value)
  542. }
  543. if value, ok := muo.mutation.AddedMsgtype(); ok {
  544. _spec.AddField(msg.FieldMsgtype, field.TypeInt32, value)
  545. }
  546. if muo.mutation.MsgtypeCleared() {
  547. _spec.ClearField(msg.FieldMsgtype, field.TypeInt32)
  548. }
  549. if value, ok := muo.mutation.Msg(); ok {
  550. _spec.SetField(msg.FieldMsg, field.TypeString, value)
  551. }
  552. if muo.mutation.MsgCleared() {
  553. _spec.ClearField(msg.FieldMsg, field.TypeString)
  554. }
  555. if value, ok := muo.mutation.BatchNo(); ok {
  556. _spec.SetField(msg.FieldBatchNo, field.TypeString, value)
  557. }
  558. if muo.mutation.BatchNoCleared() {
  559. _spec.ClearField(msg.FieldBatchNo, field.TypeString)
  560. }
  561. _node = &Msg{config: muo.config}
  562. _spec.Assign = _node.assignValues
  563. _spec.ScanValues = _node.scanValues
  564. if err = sqlgraph.UpdateNode(ctx, muo.driver, _spec); err != nil {
  565. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  566. err = &NotFoundError{msg.Label}
  567. } else if sqlgraph.IsConstraintError(err) {
  568. err = &ConstraintError{msg: err.Error(), wrap: err}
  569. }
  570. return nil, err
  571. }
  572. muo.mutation.done = true
  573. return _node, nil
  574. }