msg_update.go 17 KB

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