wxcarduser_update.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  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/predicate"
  9. "wechat-api/ent/wxcarduser"
  10. "entgo.io/ent/dialect/sql"
  11. "entgo.io/ent/dialect/sql/sqlgraph"
  12. "entgo.io/ent/schema/field"
  13. )
  14. // WxCardUserUpdate is the builder for updating WxCardUser entities.
  15. type WxCardUserUpdate struct {
  16. config
  17. hooks []Hook
  18. mutation *WxCardUserMutation
  19. }
  20. // Where appends a list predicates to the WxCardUserUpdate builder.
  21. func (wcuu *WxCardUserUpdate) Where(ps ...predicate.WxCardUser) *WxCardUserUpdate {
  22. wcuu.mutation.Where(ps...)
  23. return wcuu
  24. }
  25. // SetUpdatedAt sets the "updated_at" field.
  26. func (wcuu *WxCardUserUpdate) SetUpdatedAt(t time.Time) *WxCardUserUpdate {
  27. wcuu.mutation.SetUpdatedAt(t)
  28. return wcuu
  29. }
  30. // SetDeletedAt sets the "deleted_at" field.
  31. func (wcuu *WxCardUserUpdate) SetDeletedAt(t time.Time) *WxCardUserUpdate {
  32. wcuu.mutation.SetDeletedAt(t)
  33. return wcuu
  34. }
  35. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  36. func (wcuu *WxCardUserUpdate) SetNillableDeletedAt(t *time.Time) *WxCardUserUpdate {
  37. if t != nil {
  38. wcuu.SetDeletedAt(*t)
  39. }
  40. return wcuu
  41. }
  42. // ClearDeletedAt clears the value of the "deleted_at" field.
  43. func (wcuu *WxCardUserUpdate) ClearDeletedAt() *WxCardUserUpdate {
  44. wcuu.mutation.ClearDeletedAt()
  45. return wcuu
  46. }
  47. // SetWxid sets the "wxid" field.
  48. func (wcuu *WxCardUserUpdate) SetWxid(s string) *WxCardUserUpdate {
  49. wcuu.mutation.SetWxid(s)
  50. return wcuu
  51. }
  52. // SetNillableWxid sets the "wxid" field if the given value is not nil.
  53. func (wcuu *WxCardUserUpdate) SetNillableWxid(s *string) *WxCardUserUpdate {
  54. if s != nil {
  55. wcuu.SetWxid(*s)
  56. }
  57. return wcuu
  58. }
  59. // SetAccount sets the "account" field.
  60. func (wcuu *WxCardUserUpdate) SetAccount(s string) *WxCardUserUpdate {
  61. wcuu.mutation.SetAccount(s)
  62. return wcuu
  63. }
  64. // SetNillableAccount sets the "account" field if the given value is not nil.
  65. func (wcuu *WxCardUserUpdate) SetNillableAccount(s *string) *WxCardUserUpdate {
  66. if s != nil {
  67. wcuu.SetAccount(*s)
  68. }
  69. return wcuu
  70. }
  71. // SetAvatar sets the "avatar" field.
  72. func (wcuu *WxCardUserUpdate) SetAvatar(s string) *WxCardUserUpdate {
  73. wcuu.mutation.SetAvatar(s)
  74. return wcuu
  75. }
  76. // SetNillableAvatar sets the "avatar" field if the given value is not nil.
  77. func (wcuu *WxCardUserUpdate) SetNillableAvatar(s *string) *WxCardUserUpdate {
  78. if s != nil {
  79. wcuu.SetAvatar(*s)
  80. }
  81. return wcuu
  82. }
  83. // SetNickname sets the "nickname" field.
  84. func (wcuu *WxCardUserUpdate) SetNickname(s string) *WxCardUserUpdate {
  85. wcuu.mutation.SetNickname(s)
  86. return wcuu
  87. }
  88. // SetNillableNickname sets the "nickname" field if the given value is not nil.
  89. func (wcuu *WxCardUserUpdate) SetNillableNickname(s *string) *WxCardUserUpdate {
  90. if s != nil {
  91. wcuu.SetNickname(*s)
  92. }
  93. return wcuu
  94. }
  95. // SetRemark sets the "remark" field.
  96. func (wcuu *WxCardUserUpdate) SetRemark(s string) *WxCardUserUpdate {
  97. wcuu.mutation.SetRemark(s)
  98. return wcuu
  99. }
  100. // SetNillableRemark sets the "remark" field if the given value is not nil.
  101. func (wcuu *WxCardUserUpdate) SetNillableRemark(s *string) *WxCardUserUpdate {
  102. if s != nil {
  103. wcuu.SetRemark(*s)
  104. }
  105. return wcuu
  106. }
  107. // SetPhone sets the "phone" field.
  108. func (wcuu *WxCardUserUpdate) SetPhone(s string) *WxCardUserUpdate {
  109. wcuu.mutation.SetPhone(s)
  110. return wcuu
  111. }
  112. // SetNillablePhone sets the "phone" field if the given value is not nil.
  113. func (wcuu *WxCardUserUpdate) SetNillablePhone(s *string) *WxCardUserUpdate {
  114. if s != nil {
  115. wcuu.SetPhone(*s)
  116. }
  117. return wcuu
  118. }
  119. // SetOpenID sets the "open_id" field.
  120. func (wcuu *WxCardUserUpdate) SetOpenID(s string) *WxCardUserUpdate {
  121. wcuu.mutation.SetOpenID(s)
  122. return wcuu
  123. }
  124. // SetNillableOpenID sets the "open_id" field if the given value is not nil.
  125. func (wcuu *WxCardUserUpdate) SetNillableOpenID(s *string) *WxCardUserUpdate {
  126. if s != nil {
  127. wcuu.SetOpenID(*s)
  128. }
  129. return wcuu
  130. }
  131. // SetUnionID sets the "union_id" field.
  132. func (wcuu *WxCardUserUpdate) SetUnionID(s string) *WxCardUserUpdate {
  133. wcuu.mutation.SetUnionID(s)
  134. return wcuu
  135. }
  136. // SetNillableUnionID sets the "union_id" field if the given value is not nil.
  137. func (wcuu *WxCardUserUpdate) SetNillableUnionID(s *string) *WxCardUserUpdate {
  138. if s != nil {
  139. wcuu.SetUnionID(*s)
  140. }
  141. return wcuu
  142. }
  143. // SetSessionKey sets the "session_key" field.
  144. func (wcuu *WxCardUserUpdate) SetSessionKey(s string) *WxCardUserUpdate {
  145. wcuu.mutation.SetSessionKey(s)
  146. return wcuu
  147. }
  148. // SetNillableSessionKey sets the "session_key" field if the given value is not nil.
  149. func (wcuu *WxCardUserUpdate) SetNillableSessionKey(s *string) *WxCardUserUpdate {
  150. if s != nil {
  151. wcuu.SetSessionKey(*s)
  152. }
  153. return wcuu
  154. }
  155. // Mutation returns the WxCardUserMutation object of the builder.
  156. func (wcuu *WxCardUserUpdate) Mutation() *WxCardUserMutation {
  157. return wcuu.mutation
  158. }
  159. // Save executes the query and returns the number of nodes affected by the update operation.
  160. func (wcuu *WxCardUserUpdate) Save(ctx context.Context) (int, error) {
  161. if err := wcuu.defaults(); err != nil {
  162. return 0, err
  163. }
  164. return withHooks(ctx, wcuu.sqlSave, wcuu.mutation, wcuu.hooks)
  165. }
  166. // SaveX is like Save, but panics if an error occurs.
  167. func (wcuu *WxCardUserUpdate) SaveX(ctx context.Context) int {
  168. affected, err := wcuu.Save(ctx)
  169. if err != nil {
  170. panic(err)
  171. }
  172. return affected
  173. }
  174. // Exec executes the query.
  175. func (wcuu *WxCardUserUpdate) Exec(ctx context.Context) error {
  176. _, err := wcuu.Save(ctx)
  177. return err
  178. }
  179. // ExecX is like Exec, but panics if an error occurs.
  180. func (wcuu *WxCardUserUpdate) ExecX(ctx context.Context) {
  181. if err := wcuu.Exec(ctx); err != nil {
  182. panic(err)
  183. }
  184. }
  185. // defaults sets the default values of the builder before save.
  186. func (wcuu *WxCardUserUpdate) defaults() error {
  187. if _, ok := wcuu.mutation.UpdatedAt(); !ok {
  188. if wxcarduser.UpdateDefaultUpdatedAt == nil {
  189. return fmt.Errorf("ent: uninitialized wxcarduser.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
  190. }
  191. v := wxcarduser.UpdateDefaultUpdatedAt()
  192. wcuu.mutation.SetUpdatedAt(v)
  193. }
  194. return nil
  195. }
  196. func (wcuu *WxCardUserUpdate) sqlSave(ctx context.Context) (n int, err error) {
  197. _spec := sqlgraph.NewUpdateSpec(wxcarduser.Table, wxcarduser.Columns, sqlgraph.NewFieldSpec(wxcarduser.FieldID, field.TypeUint64))
  198. if ps := wcuu.mutation.predicates; len(ps) > 0 {
  199. _spec.Predicate = func(selector *sql.Selector) {
  200. for i := range ps {
  201. ps[i](selector)
  202. }
  203. }
  204. }
  205. if value, ok := wcuu.mutation.UpdatedAt(); ok {
  206. _spec.SetField(wxcarduser.FieldUpdatedAt, field.TypeTime, value)
  207. }
  208. if value, ok := wcuu.mutation.DeletedAt(); ok {
  209. _spec.SetField(wxcarduser.FieldDeletedAt, field.TypeTime, value)
  210. }
  211. if wcuu.mutation.DeletedAtCleared() {
  212. _spec.ClearField(wxcarduser.FieldDeletedAt, field.TypeTime)
  213. }
  214. if value, ok := wcuu.mutation.Wxid(); ok {
  215. _spec.SetField(wxcarduser.FieldWxid, field.TypeString, value)
  216. }
  217. if value, ok := wcuu.mutation.Account(); ok {
  218. _spec.SetField(wxcarduser.FieldAccount, field.TypeString, value)
  219. }
  220. if value, ok := wcuu.mutation.Avatar(); ok {
  221. _spec.SetField(wxcarduser.FieldAvatar, field.TypeString, value)
  222. }
  223. if value, ok := wcuu.mutation.Nickname(); ok {
  224. _spec.SetField(wxcarduser.FieldNickname, field.TypeString, value)
  225. }
  226. if value, ok := wcuu.mutation.Remark(); ok {
  227. _spec.SetField(wxcarduser.FieldRemark, field.TypeString, value)
  228. }
  229. if value, ok := wcuu.mutation.Phone(); ok {
  230. _spec.SetField(wxcarduser.FieldPhone, field.TypeString, value)
  231. }
  232. if value, ok := wcuu.mutation.OpenID(); ok {
  233. _spec.SetField(wxcarduser.FieldOpenID, field.TypeString, value)
  234. }
  235. if value, ok := wcuu.mutation.UnionID(); ok {
  236. _spec.SetField(wxcarduser.FieldUnionID, field.TypeString, value)
  237. }
  238. if value, ok := wcuu.mutation.SessionKey(); ok {
  239. _spec.SetField(wxcarduser.FieldSessionKey, field.TypeString, value)
  240. }
  241. if n, err = sqlgraph.UpdateNodes(ctx, wcuu.driver, _spec); err != nil {
  242. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  243. err = &NotFoundError{wxcarduser.Label}
  244. } else if sqlgraph.IsConstraintError(err) {
  245. err = &ConstraintError{msg: err.Error(), wrap: err}
  246. }
  247. return 0, err
  248. }
  249. wcuu.mutation.done = true
  250. return n, nil
  251. }
  252. // WxCardUserUpdateOne is the builder for updating a single WxCardUser entity.
  253. type WxCardUserUpdateOne struct {
  254. config
  255. fields []string
  256. hooks []Hook
  257. mutation *WxCardUserMutation
  258. }
  259. // SetUpdatedAt sets the "updated_at" field.
  260. func (wcuuo *WxCardUserUpdateOne) SetUpdatedAt(t time.Time) *WxCardUserUpdateOne {
  261. wcuuo.mutation.SetUpdatedAt(t)
  262. return wcuuo
  263. }
  264. // SetDeletedAt sets the "deleted_at" field.
  265. func (wcuuo *WxCardUserUpdateOne) SetDeletedAt(t time.Time) *WxCardUserUpdateOne {
  266. wcuuo.mutation.SetDeletedAt(t)
  267. return wcuuo
  268. }
  269. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  270. func (wcuuo *WxCardUserUpdateOne) SetNillableDeletedAt(t *time.Time) *WxCardUserUpdateOne {
  271. if t != nil {
  272. wcuuo.SetDeletedAt(*t)
  273. }
  274. return wcuuo
  275. }
  276. // ClearDeletedAt clears the value of the "deleted_at" field.
  277. func (wcuuo *WxCardUserUpdateOne) ClearDeletedAt() *WxCardUserUpdateOne {
  278. wcuuo.mutation.ClearDeletedAt()
  279. return wcuuo
  280. }
  281. // SetWxid sets the "wxid" field.
  282. func (wcuuo *WxCardUserUpdateOne) SetWxid(s string) *WxCardUserUpdateOne {
  283. wcuuo.mutation.SetWxid(s)
  284. return wcuuo
  285. }
  286. // SetNillableWxid sets the "wxid" field if the given value is not nil.
  287. func (wcuuo *WxCardUserUpdateOne) SetNillableWxid(s *string) *WxCardUserUpdateOne {
  288. if s != nil {
  289. wcuuo.SetWxid(*s)
  290. }
  291. return wcuuo
  292. }
  293. // SetAccount sets the "account" field.
  294. func (wcuuo *WxCardUserUpdateOne) SetAccount(s string) *WxCardUserUpdateOne {
  295. wcuuo.mutation.SetAccount(s)
  296. return wcuuo
  297. }
  298. // SetNillableAccount sets the "account" field if the given value is not nil.
  299. func (wcuuo *WxCardUserUpdateOne) SetNillableAccount(s *string) *WxCardUserUpdateOne {
  300. if s != nil {
  301. wcuuo.SetAccount(*s)
  302. }
  303. return wcuuo
  304. }
  305. // SetAvatar sets the "avatar" field.
  306. func (wcuuo *WxCardUserUpdateOne) SetAvatar(s string) *WxCardUserUpdateOne {
  307. wcuuo.mutation.SetAvatar(s)
  308. return wcuuo
  309. }
  310. // SetNillableAvatar sets the "avatar" field if the given value is not nil.
  311. func (wcuuo *WxCardUserUpdateOne) SetNillableAvatar(s *string) *WxCardUserUpdateOne {
  312. if s != nil {
  313. wcuuo.SetAvatar(*s)
  314. }
  315. return wcuuo
  316. }
  317. // SetNickname sets the "nickname" field.
  318. func (wcuuo *WxCardUserUpdateOne) SetNickname(s string) *WxCardUserUpdateOne {
  319. wcuuo.mutation.SetNickname(s)
  320. return wcuuo
  321. }
  322. // SetNillableNickname sets the "nickname" field if the given value is not nil.
  323. func (wcuuo *WxCardUserUpdateOne) SetNillableNickname(s *string) *WxCardUserUpdateOne {
  324. if s != nil {
  325. wcuuo.SetNickname(*s)
  326. }
  327. return wcuuo
  328. }
  329. // SetRemark sets the "remark" field.
  330. func (wcuuo *WxCardUserUpdateOne) SetRemark(s string) *WxCardUserUpdateOne {
  331. wcuuo.mutation.SetRemark(s)
  332. return wcuuo
  333. }
  334. // SetNillableRemark sets the "remark" field if the given value is not nil.
  335. func (wcuuo *WxCardUserUpdateOne) SetNillableRemark(s *string) *WxCardUserUpdateOne {
  336. if s != nil {
  337. wcuuo.SetRemark(*s)
  338. }
  339. return wcuuo
  340. }
  341. // SetPhone sets the "phone" field.
  342. func (wcuuo *WxCardUserUpdateOne) SetPhone(s string) *WxCardUserUpdateOne {
  343. wcuuo.mutation.SetPhone(s)
  344. return wcuuo
  345. }
  346. // SetNillablePhone sets the "phone" field if the given value is not nil.
  347. func (wcuuo *WxCardUserUpdateOne) SetNillablePhone(s *string) *WxCardUserUpdateOne {
  348. if s != nil {
  349. wcuuo.SetPhone(*s)
  350. }
  351. return wcuuo
  352. }
  353. // SetOpenID sets the "open_id" field.
  354. func (wcuuo *WxCardUserUpdateOne) SetOpenID(s string) *WxCardUserUpdateOne {
  355. wcuuo.mutation.SetOpenID(s)
  356. return wcuuo
  357. }
  358. // SetNillableOpenID sets the "open_id" field if the given value is not nil.
  359. func (wcuuo *WxCardUserUpdateOne) SetNillableOpenID(s *string) *WxCardUserUpdateOne {
  360. if s != nil {
  361. wcuuo.SetOpenID(*s)
  362. }
  363. return wcuuo
  364. }
  365. // SetUnionID sets the "union_id" field.
  366. func (wcuuo *WxCardUserUpdateOne) SetUnionID(s string) *WxCardUserUpdateOne {
  367. wcuuo.mutation.SetUnionID(s)
  368. return wcuuo
  369. }
  370. // SetNillableUnionID sets the "union_id" field if the given value is not nil.
  371. func (wcuuo *WxCardUserUpdateOne) SetNillableUnionID(s *string) *WxCardUserUpdateOne {
  372. if s != nil {
  373. wcuuo.SetUnionID(*s)
  374. }
  375. return wcuuo
  376. }
  377. // SetSessionKey sets the "session_key" field.
  378. func (wcuuo *WxCardUserUpdateOne) SetSessionKey(s string) *WxCardUserUpdateOne {
  379. wcuuo.mutation.SetSessionKey(s)
  380. return wcuuo
  381. }
  382. // SetNillableSessionKey sets the "session_key" field if the given value is not nil.
  383. func (wcuuo *WxCardUserUpdateOne) SetNillableSessionKey(s *string) *WxCardUserUpdateOne {
  384. if s != nil {
  385. wcuuo.SetSessionKey(*s)
  386. }
  387. return wcuuo
  388. }
  389. // Mutation returns the WxCardUserMutation object of the builder.
  390. func (wcuuo *WxCardUserUpdateOne) Mutation() *WxCardUserMutation {
  391. return wcuuo.mutation
  392. }
  393. // Where appends a list predicates to the WxCardUserUpdate builder.
  394. func (wcuuo *WxCardUserUpdateOne) Where(ps ...predicate.WxCardUser) *WxCardUserUpdateOne {
  395. wcuuo.mutation.Where(ps...)
  396. return wcuuo
  397. }
  398. // Select allows selecting one or more fields (columns) of the returned entity.
  399. // The default is selecting all fields defined in the entity schema.
  400. func (wcuuo *WxCardUserUpdateOne) Select(field string, fields ...string) *WxCardUserUpdateOne {
  401. wcuuo.fields = append([]string{field}, fields...)
  402. return wcuuo
  403. }
  404. // Save executes the query and returns the updated WxCardUser entity.
  405. func (wcuuo *WxCardUserUpdateOne) Save(ctx context.Context) (*WxCardUser, error) {
  406. if err := wcuuo.defaults(); err != nil {
  407. return nil, err
  408. }
  409. return withHooks(ctx, wcuuo.sqlSave, wcuuo.mutation, wcuuo.hooks)
  410. }
  411. // SaveX is like Save, but panics if an error occurs.
  412. func (wcuuo *WxCardUserUpdateOne) SaveX(ctx context.Context) *WxCardUser {
  413. node, err := wcuuo.Save(ctx)
  414. if err != nil {
  415. panic(err)
  416. }
  417. return node
  418. }
  419. // Exec executes the query on the entity.
  420. func (wcuuo *WxCardUserUpdateOne) Exec(ctx context.Context) error {
  421. _, err := wcuuo.Save(ctx)
  422. return err
  423. }
  424. // ExecX is like Exec, but panics if an error occurs.
  425. func (wcuuo *WxCardUserUpdateOne) ExecX(ctx context.Context) {
  426. if err := wcuuo.Exec(ctx); err != nil {
  427. panic(err)
  428. }
  429. }
  430. // defaults sets the default values of the builder before save.
  431. func (wcuuo *WxCardUserUpdateOne) defaults() error {
  432. if _, ok := wcuuo.mutation.UpdatedAt(); !ok {
  433. if wxcarduser.UpdateDefaultUpdatedAt == nil {
  434. return fmt.Errorf("ent: uninitialized wxcarduser.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
  435. }
  436. v := wxcarduser.UpdateDefaultUpdatedAt()
  437. wcuuo.mutation.SetUpdatedAt(v)
  438. }
  439. return nil
  440. }
  441. func (wcuuo *WxCardUserUpdateOne) sqlSave(ctx context.Context) (_node *WxCardUser, err error) {
  442. _spec := sqlgraph.NewUpdateSpec(wxcarduser.Table, wxcarduser.Columns, sqlgraph.NewFieldSpec(wxcarduser.FieldID, field.TypeUint64))
  443. id, ok := wcuuo.mutation.ID()
  444. if !ok {
  445. return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "WxCardUser.id" for update`)}
  446. }
  447. _spec.Node.ID.Value = id
  448. if fields := wcuuo.fields; len(fields) > 0 {
  449. _spec.Node.Columns = make([]string, 0, len(fields))
  450. _spec.Node.Columns = append(_spec.Node.Columns, wxcarduser.FieldID)
  451. for _, f := range fields {
  452. if !wxcarduser.ValidColumn(f) {
  453. return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
  454. }
  455. if f != wxcarduser.FieldID {
  456. _spec.Node.Columns = append(_spec.Node.Columns, f)
  457. }
  458. }
  459. }
  460. if ps := wcuuo.mutation.predicates; len(ps) > 0 {
  461. _spec.Predicate = func(selector *sql.Selector) {
  462. for i := range ps {
  463. ps[i](selector)
  464. }
  465. }
  466. }
  467. if value, ok := wcuuo.mutation.UpdatedAt(); ok {
  468. _spec.SetField(wxcarduser.FieldUpdatedAt, field.TypeTime, value)
  469. }
  470. if value, ok := wcuuo.mutation.DeletedAt(); ok {
  471. _spec.SetField(wxcarduser.FieldDeletedAt, field.TypeTime, value)
  472. }
  473. if wcuuo.mutation.DeletedAtCleared() {
  474. _spec.ClearField(wxcarduser.FieldDeletedAt, field.TypeTime)
  475. }
  476. if value, ok := wcuuo.mutation.Wxid(); ok {
  477. _spec.SetField(wxcarduser.FieldWxid, field.TypeString, value)
  478. }
  479. if value, ok := wcuuo.mutation.Account(); ok {
  480. _spec.SetField(wxcarduser.FieldAccount, field.TypeString, value)
  481. }
  482. if value, ok := wcuuo.mutation.Avatar(); ok {
  483. _spec.SetField(wxcarduser.FieldAvatar, field.TypeString, value)
  484. }
  485. if value, ok := wcuuo.mutation.Nickname(); ok {
  486. _spec.SetField(wxcarduser.FieldNickname, field.TypeString, value)
  487. }
  488. if value, ok := wcuuo.mutation.Remark(); ok {
  489. _spec.SetField(wxcarduser.FieldRemark, field.TypeString, value)
  490. }
  491. if value, ok := wcuuo.mutation.Phone(); ok {
  492. _spec.SetField(wxcarduser.FieldPhone, field.TypeString, value)
  493. }
  494. if value, ok := wcuuo.mutation.OpenID(); ok {
  495. _spec.SetField(wxcarduser.FieldOpenID, field.TypeString, value)
  496. }
  497. if value, ok := wcuuo.mutation.UnionID(); ok {
  498. _spec.SetField(wxcarduser.FieldUnionID, field.TypeString, value)
  499. }
  500. if value, ok := wcuuo.mutation.SessionKey(); ok {
  501. _spec.SetField(wxcarduser.FieldSessionKey, field.TypeString, value)
  502. }
  503. _node = &WxCardUser{config: wcuuo.config}
  504. _spec.Assign = _node.assignValues
  505. _spec.ScanValues = _node.scanValues
  506. if err = sqlgraph.UpdateNode(ctx, wcuuo.driver, _spec); err != nil {
  507. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  508. err = &NotFoundError{wxcarduser.Label}
  509. } else if sqlgraph.IsConstraintError(err) {
  510. err = &ConstraintError{msg: err.Error(), wrap: err}
  511. }
  512. return nil, err
  513. }
  514. wcuuo.mutation.done = true
  515. return _node, nil
  516. }