whatsapp_update.go 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110
  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/agent"
  9. "wechat-api/ent/predicate"
  10. "wechat-api/ent/whatsapp"
  11. "entgo.io/ent/dialect/sql"
  12. "entgo.io/ent/dialect/sql/sqlgraph"
  13. "entgo.io/ent/dialect/sql/sqljson"
  14. "entgo.io/ent/schema/field"
  15. )
  16. // WhatsappUpdate is the builder for updating Whatsapp entities.
  17. type WhatsappUpdate struct {
  18. config
  19. hooks []Hook
  20. mutation *WhatsappMutation
  21. }
  22. // Where appends a list predicates to the WhatsappUpdate builder.
  23. func (wu *WhatsappUpdate) Where(ps ...predicate.Whatsapp) *WhatsappUpdate {
  24. wu.mutation.Where(ps...)
  25. return wu
  26. }
  27. // SetUpdatedAt sets the "updated_at" field.
  28. func (wu *WhatsappUpdate) SetUpdatedAt(t time.Time) *WhatsappUpdate {
  29. wu.mutation.SetUpdatedAt(t)
  30. return wu
  31. }
  32. // SetStatus sets the "status" field.
  33. func (wu *WhatsappUpdate) SetStatus(u uint8) *WhatsappUpdate {
  34. wu.mutation.ResetStatus()
  35. wu.mutation.SetStatus(u)
  36. return wu
  37. }
  38. // SetNillableStatus sets the "status" field if the given value is not nil.
  39. func (wu *WhatsappUpdate) SetNillableStatus(u *uint8) *WhatsappUpdate {
  40. if u != nil {
  41. wu.SetStatus(*u)
  42. }
  43. return wu
  44. }
  45. // AddStatus adds u to the "status" field.
  46. func (wu *WhatsappUpdate) AddStatus(u int8) *WhatsappUpdate {
  47. wu.mutation.AddStatus(u)
  48. return wu
  49. }
  50. // ClearStatus clears the value of the "status" field.
  51. func (wu *WhatsappUpdate) ClearStatus() *WhatsappUpdate {
  52. wu.mutation.ClearStatus()
  53. return wu
  54. }
  55. // SetDeletedAt sets the "deleted_at" field.
  56. func (wu *WhatsappUpdate) SetDeletedAt(t time.Time) *WhatsappUpdate {
  57. wu.mutation.SetDeletedAt(t)
  58. return wu
  59. }
  60. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  61. func (wu *WhatsappUpdate) SetNillableDeletedAt(t *time.Time) *WhatsappUpdate {
  62. if t != nil {
  63. wu.SetDeletedAt(*t)
  64. }
  65. return wu
  66. }
  67. // ClearDeletedAt clears the value of the "deleted_at" field.
  68. func (wu *WhatsappUpdate) ClearDeletedAt() *WhatsappUpdate {
  69. wu.mutation.ClearDeletedAt()
  70. return wu
  71. }
  72. // SetAk sets the "ak" field.
  73. func (wu *WhatsappUpdate) SetAk(s string) *WhatsappUpdate {
  74. wu.mutation.SetAk(s)
  75. return wu
  76. }
  77. // SetNillableAk sets the "ak" field if the given value is not nil.
  78. func (wu *WhatsappUpdate) SetNillableAk(s *string) *WhatsappUpdate {
  79. if s != nil {
  80. wu.SetAk(*s)
  81. }
  82. return wu
  83. }
  84. // ClearAk clears the value of the "ak" field.
  85. func (wu *WhatsappUpdate) ClearAk() *WhatsappUpdate {
  86. wu.mutation.ClearAk()
  87. return wu
  88. }
  89. // SetSk sets the "sk" field.
  90. func (wu *WhatsappUpdate) SetSk(s string) *WhatsappUpdate {
  91. wu.mutation.SetSk(s)
  92. return wu
  93. }
  94. // SetNillableSk sets the "sk" field if the given value is not nil.
  95. func (wu *WhatsappUpdate) SetNillableSk(s *string) *WhatsappUpdate {
  96. if s != nil {
  97. wu.SetSk(*s)
  98. }
  99. return wu
  100. }
  101. // SetCallback sets the "callback" field.
  102. func (wu *WhatsappUpdate) SetCallback(s string) *WhatsappUpdate {
  103. wu.mutation.SetCallback(s)
  104. return wu
  105. }
  106. // SetNillableCallback sets the "callback" field if the given value is not nil.
  107. func (wu *WhatsappUpdate) SetNillableCallback(s *string) *WhatsappUpdate {
  108. if s != nil {
  109. wu.SetCallback(*s)
  110. }
  111. return wu
  112. }
  113. // SetAccount sets the "account" field.
  114. func (wu *WhatsappUpdate) SetAccount(s string) *WhatsappUpdate {
  115. wu.mutation.SetAccount(s)
  116. return wu
  117. }
  118. // SetNillableAccount sets the "account" field if the given value is not nil.
  119. func (wu *WhatsappUpdate) SetNillableAccount(s *string) *WhatsappUpdate {
  120. if s != nil {
  121. wu.SetAccount(*s)
  122. }
  123. return wu
  124. }
  125. // SetNickname sets the "nickname" field.
  126. func (wu *WhatsappUpdate) SetNickname(s string) *WhatsappUpdate {
  127. wu.mutation.SetNickname(s)
  128. return wu
  129. }
  130. // SetNillableNickname sets the "nickname" field if the given value is not nil.
  131. func (wu *WhatsappUpdate) SetNillableNickname(s *string) *WhatsappUpdate {
  132. if s != nil {
  133. wu.SetNickname(*s)
  134. }
  135. return wu
  136. }
  137. // SetPhone sets the "phone" field.
  138. func (wu *WhatsappUpdate) SetPhone(s string) *WhatsappUpdate {
  139. wu.mutation.SetPhone(s)
  140. return wu
  141. }
  142. // SetNillablePhone sets the "phone" field if the given value is not nil.
  143. func (wu *WhatsappUpdate) SetNillablePhone(s *string) *WhatsappUpdate {
  144. if s != nil {
  145. wu.SetPhone(*s)
  146. }
  147. return wu
  148. }
  149. // SetOrganizationID sets the "organization_id" field.
  150. func (wu *WhatsappUpdate) SetOrganizationID(u uint64) *WhatsappUpdate {
  151. wu.mutation.ResetOrganizationID()
  152. wu.mutation.SetOrganizationID(u)
  153. return wu
  154. }
  155. // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
  156. func (wu *WhatsappUpdate) SetNillableOrganizationID(u *uint64) *WhatsappUpdate {
  157. if u != nil {
  158. wu.SetOrganizationID(*u)
  159. }
  160. return wu
  161. }
  162. // AddOrganizationID adds u to the "organization_id" field.
  163. func (wu *WhatsappUpdate) AddOrganizationID(u int64) *WhatsappUpdate {
  164. wu.mutation.AddOrganizationID(u)
  165. return wu
  166. }
  167. // ClearOrganizationID clears the value of the "organization_id" field.
  168. func (wu *WhatsappUpdate) ClearOrganizationID() *WhatsappUpdate {
  169. wu.mutation.ClearOrganizationID()
  170. return wu
  171. }
  172. // SetAgentID sets the "agent_id" field.
  173. func (wu *WhatsappUpdate) SetAgentID(u uint64) *WhatsappUpdate {
  174. wu.mutation.SetAgentID(u)
  175. return wu
  176. }
  177. // SetNillableAgentID sets the "agent_id" field if the given value is not nil.
  178. func (wu *WhatsappUpdate) SetNillableAgentID(u *uint64) *WhatsappUpdate {
  179. if u != nil {
  180. wu.SetAgentID(*u)
  181. }
  182. return wu
  183. }
  184. // SetAPIBase sets the "api_base" field.
  185. func (wu *WhatsappUpdate) SetAPIBase(s string) *WhatsappUpdate {
  186. wu.mutation.SetAPIBase(s)
  187. return wu
  188. }
  189. // SetNillableAPIBase sets the "api_base" field if the given value is not nil.
  190. func (wu *WhatsappUpdate) SetNillableAPIBase(s *string) *WhatsappUpdate {
  191. if s != nil {
  192. wu.SetAPIBase(*s)
  193. }
  194. return wu
  195. }
  196. // ClearAPIBase clears the value of the "api_base" field.
  197. func (wu *WhatsappUpdate) ClearAPIBase() *WhatsappUpdate {
  198. wu.mutation.ClearAPIBase()
  199. return wu
  200. }
  201. // SetAPIKey sets the "api_key" field.
  202. func (wu *WhatsappUpdate) SetAPIKey(s string) *WhatsappUpdate {
  203. wu.mutation.SetAPIKey(s)
  204. return wu
  205. }
  206. // SetNillableAPIKey sets the "api_key" field if the given value is not nil.
  207. func (wu *WhatsappUpdate) SetNillableAPIKey(s *string) *WhatsappUpdate {
  208. if s != nil {
  209. wu.SetAPIKey(*s)
  210. }
  211. return wu
  212. }
  213. // ClearAPIKey clears the value of the "api_key" field.
  214. func (wu *WhatsappUpdate) ClearAPIKey() *WhatsappUpdate {
  215. wu.mutation.ClearAPIKey()
  216. return wu
  217. }
  218. // SetAllowList sets the "allow_list" field.
  219. func (wu *WhatsappUpdate) SetAllowList(s []string) *WhatsappUpdate {
  220. wu.mutation.SetAllowList(s)
  221. return wu
  222. }
  223. // AppendAllowList appends s to the "allow_list" field.
  224. func (wu *WhatsappUpdate) AppendAllowList(s []string) *WhatsappUpdate {
  225. wu.mutation.AppendAllowList(s)
  226. return wu
  227. }
  228. // ClearAllowList clears the value of the "allow_list" field.
  229. func (wu *WhatsappUpdate) ClearAllowList() *WhatsappUpdate {
  230. wu.mutation.ClearAllowList()
  231. return wu
  232. }
  233. // SetGroupAllowList sets the "group_allow_list" field.
  234. func (wu *WhatsappUpdate) SetGroupAllowList(s []string) *WhatsappUpdate {
  235. wu.mutation.SetGroupAllowList(s)
  236. return wu
  237. }
  238. // AppendGroupAllowList appends s to the "group_allow_list" field.
  239. func (wu *WhatsappUpdate) AppendGroupAllowList(s []string) *WhatsappUpdate {
  240. wu.mutation.AppendGroupAllowList(s)
  241. return wu
  242. }
  243. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  244. func (wu *WhatsappUpdate) ClearGroupAllowList() *WhatsappUpdate {
  245. wu.mutation.ClearGroupAllowList()
  246. return wu
  247. }
  248. // SetBlockList sets the "block_list" field.
  249. func (wu *WhatsappUpdate) SetBlockList(s []string) *WhatsappUpdate {
  250. wu.mutation.SetBlockList(s)
  251. return wu
  252. }
  253. // AppendBlockList appends s to the "block_list" field.
  254. func (wu *WhatsappUpdate) AppendBlockList(s []string) *WhatsappUpdate {
  255. wu.mutation.AppendBlockList(s)
  256. return wu
  257. }
  258. // ClearBlockList clears the value of the "block_list" field.
  259. func (wu *WhatsappUpdate) ClearBlockList() *WhatsappUpdate {
  260. wu.mutation.ClearBlockList()
  261. return wu
  262. }
  263. // SetGroupBlockList sets the "group_block_list" field.
  264. func (wu *WhatsappUpdate) SetGroupBlockList(s []string) *WhatsappUpdate {
  265. wu.mutation.SetGroupBlockList(s)
  266. return wu
  267. }
  268. // AppendGroupBlockList appends s to the "group_block_list" field.
  269. func (wu *WhatsappUpdate) AppendGroupBlockList(s []string) *WhatsappUpdate {
  270. wu.mutation.AppendGroupBlockList(s)
  271. return wu
  272. }
  273. // ClearGroupBlockList clears the value of the "group_block_list" field.
  274. func (wu *WhatsappUpdate) ClearGroupBlockList() *WhatsappUpdate {
  275. wu.mutation.ClearGroupBlockList()
  276. return wu
  277. }
  278. // SetAgent sets the "agent" edge to the Agent entity.
  279. func (wu *WhatsappUpdate) SetAgent(a *Agent) *WhatsappUpdate {
  280. return wu.SetAgentID(a.ID)
  281. }
  282. // Mutation returns the WhatsappMutation object of the builder.
  283. func (wu *WhatsappUpdate) Mutation() *WhatsappMutation {
  284. return wu.mutation
  285. }
  286. // ClearAgent clears the "agent" edge to the Agent entity.
  287. func (wu *WhatsappUpdate) ClearAgent() *WhatsappUpdate {
  288. wu.mutation.ClearAgent()
  289. return wu
  290. }
  291. // Save executes the query and returns the number of nodes affected by the update operation.
  292. func (wu *WhatsappUpdate) Save(ctx context.Context) (int, error) {
  293. if err := wu.defaults(); err != nil {
  294. return 0, err
  295. }
  296. return withHooks(ctx, wu.sqlSave, wu.mutation, wu.hooks)
  297. }
  298. // SaveX is like Save, but panics if an error occurs.
  299. func (wu *WhatsappUpdate) SaveX(ctx context.Context) int {
  300. affected, err := wu.Save(ctx)
  301. if err != nil {
  302. panic(err)
  303. }
  304. return affected
  305. }
  306. // Exec executes the query.
  307. func (wu *WhatsappUpdate) Exec(ctx context.Context) error {
  308. _, err := wu.Save(ctx)
  309. return err
  310. }
  311. // ExecX is like Exec, but panics if an error occurs.
  312. func (wu *WhatsappUpdate) ExecX(ctx context.Context) {
  313. if err := wu.Exec(ctx); err != nil {
  314. panic(err)
  315. }
  316. }
  317. // defaults sets the default values of the builder before save.
  318. func (wu *WhatsappUpdate) defaults() error {
  319. if _, ok := wu.mutation.UpdatedAt(); !ok {
  320. if whatsapp.UpdateDefaultUpdatedAt == nil {
  321. return fmt.Errorf("ent: uninitialized whatsapp.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
  322. }
  323. v := whatsapp.UpdateDefaultUpdatedAt()
  324. wu.mutation.SetUpdatedAt(v)
  325. }
  326. return nil
  327. }
  328. // check runs all checks and user-defined validators on the builder.
  329. func (wu *WhatsappUpdate) check() error {
  330. if _, ok := wu.mutation.AgentID(); wu.mutation.AgentCleared() && !ok {
  331. return errors.New(`ent: clearing a required unique edge "Whatsapp.agent"`)
  332. }
  333. return nil
  334. }
  335. func (wu *WhatsappUpdate) sqlSave(ctx context.Context) (n int, err error) {
  336. if err := wu.check(); err != nil {
  337. return n, err
  338. }
  339. _spec := sqlgraph.NewUpdateSpec(whatsapp.Table, whatsapp.Columns, sqlgraph.NewFieldSpec(whatsapp.FieldID, field.TypeUint64))
  340. if ps := wu.mutation.predicates; len(ps) > 0 {
  341. _spec.Predicate = func(selector *sql.Selector) {
  342. for i := range ps {
  343. ps[i](selector)
  344. }
  345. }
  346. }
  347. if value, ok := wu.mutation.UpdatedAt(); ok {
  348. _spec.SetField(whatsapp.FieldUpdatedAt, field.TypeTime, value)
  349. }
  350. if value, ok := wu.mutation.Status(); ok {
  351. _spec.SetField(whatsapp.FieldStatus, field.TypeUint8, value)
  352. }
  353. if value, ok := wu.mutation.AddedStatus(); ok {
  354. _spec.AddField(whatsapp.FieldStatus, field.TypeUint8, value)
  355. }
  356. if wu.mutation.StatusCleared() {
  357. _spec.ClearField(whatsapp.FieldStatus, field.TypeUint8)
  358. }
  359. if value, ok := wu.mutation.DeletedAt(); ok {
  360. _spec.SetField(whatsapp.FieldDeletedAt, field.TypeTime, value)
  361. }
  362. if wu.mutation.DeletedAtCleared() {
  363. _spec.ClearField(whatsapp.FieldDeletedAt, field.TypeTime)
  364. }
  365. if value, ok := wu.mutation.Ak(); ok {
  366. _spec.SetField(whatsapp.FieldAk, field.TypeString, value)
  367. }
  368. if wu.mutation.AkCleared() {
  369. _spec.ClearField(whatsapp.FieldAk, field.TypeString)
  370. }
  371. if value, ok := wu.mutation.Sk(); ok {
  372. _spec.SetField(whatsapp.FieldSk, field.TypeString, value)
  373. }
  374. if value, ok := wu.mutation.Callback(); ok {
  375. _spec.SetField(whatsapp.FieldCallback, field.TypeString, value)
  376. }
  377. if value, ok := wu.mutation.Account(); ok {
  378. _spec.SetField(whatsapp.FieldAccount, field.TypeString, value)
  379. }
  380. if value, ok := wu.mutation.Nickname(); ok {
  381. _spec.SetField(whatsapp.FieldNickname, field.TypeString, value)
  382. }
  383. if value, ok := wu.mutation.Phone(); ok {
  384. _spec.SetField(whatsapp.FieldPhone, field.TypeString, value)
  385. }
  386. if value, ok := wu.mutation.OrganizationID(); ok {
  387. _spec.SetField(whatsapp.FieldOrganizationID, field.TypeUint64, value)
  388. }
  389. if value, ok := wu.mutation.AddedOrganizationID(); ok {
  390. _spec.AddField(whatsapp.FieldOrganizationID, field.TypeUint64, value)
  391. }
  392. if wu.mutation.OrganizationIDCleared() {
  393. _spec.ClearField(whatsapp.FieldOrganizationID, field.TypeUint64)
  394. }
  395. if value, ok := wu.mutation.APIBase(); ok {
  396. _spec.SetField(whatsapp.FieldAPIBase, field.TypeString, value)
  397. }
  398. if wu.mutation.APIBaseCleared() {
  399. _spec.ClearField(whatsapp.FieldAPIBase, field.TypeString)
  400. }
  401. if value, ok := wu.mutation.APIKey(); ok {
  402. _spec.SetField(whatsapp.FieldAPIKey, field.TypeString, value)
  403. }
  404. if wu.mutation.APIKeyCleared() {
  405. _spec.ClearField(whatsapp.FieldAPIKey, field.TypeString)
  406. }
  407. if value, ok := wu.mutation.AllowList(); ok {
  408. _spec.SetField(whatsapp.FieldAllowList, field.TypeJSON, value)
  409. }
  410. if value, ok := wu.mutation.AppendedAllowList(); ok {
  411. _spec.AddModifier(func(u *sql.UpdateBuilder) {
  412. sqljson.Append(u, whatsapp.FieldAllowList, value)
  413. })
  414. }
  415. if wu.mutation.AllowListCleared() {
  416. _spec.ClearField(whatsapp.FieldAllowList, field.TypeJSON)
  417. }
  418. if value, ok := wu.mutation.GroupAllowList(); ok {
  419. _spec.SetField(whatsapp.FieldGroupAllowList, field.TypeJSON, value)
  420. }
  421. if value, ok := wu.mutation.AppendedGroupAllowList(); ok {
  422. _spec.AddModifier(func(u *sql.UpdateBuilder) {
  423. sqljson.Append(u, whatsapp.FieldGroupAllowList, value)
  424. })
  425. }
  426. if wu.mutation.GroupAllowListCleared() {
  427. _spec.ClearField(whatsapp.FieldGroupAllowList, field.TypeJSON)
  428. }
  429. if value, ok := wu.mutation.BlockList(); ok {
  430. _spec.SetField(whatsapp.FieldBlockList, field.TypeJSON, value)
  431. }
  432. if value, ok := wu.mutation.AppendedBlockList(); ok {
  433. _spec.AddModifier(func(u *sql.UpdateBuilder) {
  434. sqljson.Append(u, whatsapp.FieldBlockList, value)
  435. })
  436. }
  437. if wu.mutation.BlockListCleared() {
  438. _spec.ClearField(whatsapp.FieldBlockList, field.TypeJSON)
  439. }
  440. if value, ok := wu.mutation.GroupBlockList(); ok {
  441. _spec.SetField(whatsapp.FieldGroupBlockList, field.TypeJSON, value)
  442. }
  443. if value, ok := wu.mutation.AppendedGroupBlockList(); ok {
  444. _spec.AddModifier(func(u *sql.UpdateBuilder) {
  445. sqljson.Append(u, whatsapp.FieldGroupBlockList, value)
  446. })
  447. }
  448. if wu.mutation.GroupBlockListCleared() {
  449. _spec.ClearField(whatsapp.FieldGroupBlockList, field.TypeJSON)
  450. }
  451. if wu.mutation.AgentCleared() {
  452. edge := &sqlgraph.EdgeSpec{
  453. Rel: sqlgraph.M2O,
  454. Inverse: true,
  455. Table: whatsapp.AgentTable,
  456. Columns: []string{whatsapp.AgentColumn},
  457. Bidi: false,
  458. Target: &sqlgraph.EdgeTarget{
  459. IDSpec: sqlgraph.NewFieldSpec(agent.FieldID, field.TypeUint64),
  460. },
  461. }
  462. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  463. }
  464. if nodes := wu.mutation.AgentIDs(); len(nodes) > 0 {
  465. edge := &sqlgraph.EdgeSpec{
  466. Rel: sqlgraph.M2O,
  467. Inverse: true,
  468. Table: whatsapp.AgentTable,
  469. Columns: []string{whatsapp.AgentColumn},
  470. Bidi: false,
  471. Target: &sqlgraph.EdgeTarget{
  472. IDSpec: sqlgraph.NewFieldSpec(agent.FieldID, field.TypeUint64),
  473. },
  474. }
  475. for _, k := range nodes {
  476. edge.Target.Nodes = append(edge.Target.Nodes, k)
  477. }
  478. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  479. }
  480. if n, err = sqlgraph.UpdateNodes(ctx, wu.driver, _spec); err != nil {
  481. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  482. err = &NotFoundError{whatsapp.Label}
  483. } else if sqlgraph.IsConstraintError(err) {
  484. err = &ConstraintError{msg: err.Error(), wrap: err}
  485. }
  486. return 0, err
  487. }
  488. wu.mutation.done = true
  489. return n, nil
  490. }
  491. // WhatsappUpdateOne is the builder for updating a single Whatsapp entity.
  492. type WhatsappUpdateOne struct {
  493. config
  494. fields []string
  495. hooks []Hook
  496. mutation *WhatsappMutation
  497. }
  498. // SetUpdatedAt sets the "updated_at" field.
  499. func (wuo *WhatsappUpdateOne) SetUpdatedAt(t time.Time) *WhatsappUpdateOne {
  500. wuo.mutation.SetUpdatedAt(t)
  501. return wuo
  502. }
  503. // SetStatus sets the "status" field.
  504. func (wuo *WhatsappUpdateOne) SetStatus(u uint8) *WhatsappUpdateOne {
  505. wuo.mutation.ResetStatus()
  506. wuo.mutation.SetStatus(u)
  507. return wuo
  508. }
  509. // SetNillableStatus sets the "status" field if the given value is not nil.
  510. func (wuo *WhatsappUpdateOne) SetNillableStatus(u *uint8) *WhatsappUpdateOne {
  511. if u != nil {
  512. wuo.SetStatus(*u)
  513. }
  514. return wuo
  515. }
  516. // AddStatus adds u to the "status" field.
  517. func (wuo *WhatsappUpdateOne) AddStatus(u int8) *WhatsappUpdateOne {
  518. wuo.mutation.AddStatus(u)
  519. return wuo
  520. }
  521. // ClearStatus clears the value of the "status" field.
  522. func (wuo *WhatsappUpdateOne) ClearStatus() *WhatsappUpdateOne {
  523. wuo.mutation.ClearStatus()
  524. return wuo
  525. }
  526. // SetDeletedAt sets the "deleted_at" field.
  527. func (wuo *WhatsappUpdateOne) SetDeletedAt(t time.Time) *WhatsappUpdateOne {
  528. wuo.mutation.SetDeletedAt(t)
  529. return wuo
  530. }
  531. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  532. func (wuo *WhatsappUpdateOne) SetNillableDeletedAt(t *time.Time) *WhatsappUpdateOne {
  533. if t != nil {
  534. wuo.SetDeletedAt(*t)
  535. }
  536. return wuo
  537. }
  538. // ClearDeletedAt clears the value of the "deleted_at" field.
  539. func (wuo *WhatsappUpdateOne) ClearDeletedAt() *WhatsappUpdateOne {
  540. wuo.mutation.ClearDeletedAt()
  541. return wuo
  542. }
  543. // SetAk sets the "ak" field.
  544. func (wuo *WhatsappUpdateOne) SetAk(s string) *WhatsappUpdateOne {
  545. wuo.mutation.SetAk(s)
  546. return wuo
  547. }
  548. // SetNillableAk sets the "ak" field if the given value is not nil.
  549. func (wuo *WhatsappUpdateOne) SetNillableAk(s *string) *WhatsappUpdateOne {
  550. if s != nil {
  551. wuo.SetAk(*s)
  552. }
  553. return wuo
  554. }
  555. // ClearAk clears the value of the "ak" field.
  556. func (wuo *WhatsappUpdateOne) ClearAk() *WhatsappUpdateOne {
  557. wuo.mutation.ClearAk()
  558. return wuo
  559. }
  560. // SetSk sets the "sk" field.
  561. func (wuo *WhatsappUpdateOne) SetSk(s string) *WhatsappUpdateOne {
  562. wuo.mutation.SetSk(s)
  563. return wuo
  564. }
  565. // SetNillableSk sets the "sk" field if the given value is not nil.
  566. func (wuo *WhatsappUpdateOne) SetNillableSk(s *string) *WhatsappUpdateOne {
  567. if s != nil {
  568. wuo.SetSk(*s)
  569. }
  570. return wuo
  571. }
  572. // SetCallback sets the "callback" field.
  573. func (wuo *WhatsappUpdateOne) SetCallback(s string) *WhatsappUpdateOne {
  574. wuo.mutation.SetCallback(s)
  575. return wuo
  576. }
  577. // SetNillableCallback sets the "callback" field if the given value is not nil.
  578. func (wuo *WhatsappUpdateOne) SetNillableCallback(s *string) *WhatsappUpdateOne {
  579. if s != nil {
  580. wuo.SetCallback(*s)
  581. }
  582. return wuo
  583. }
  584. // SetAccount sets the "account" field.
  585. func (wuo *WhatsappUpdateOne) SetAccount(s string) *WhatsappUpdateOne {
  586. wuo.mutation.SetAccount(s)
  587. return wuo
  588. }
  589. // SetNillableAccount sets the "account" field if the given value is not nil.
  590. func (wuo *WhatsappUpdateOne) SetNillableAccount(s *string) *WhatsappUpdateOne {
  591. if s != nil {
  592. wuo.SetAccount(*s)
  593. }
  594. return wuo
  595. }
  596. // SetNickname sets the "nickname" field.
  597. func (wuo *WhatsappUpdateOne) SetNickname(s string) *WhatsappUpdateOne {
  598. wuo.mutation.SetNickname(s)
  599. return wuo
  600. }
  601. // SetNillableNickname sets the "nickname" field if the given value is not nil.
  602. func (wuo *WhatsappUpdateOne) SetNillableNickname(s *string) *WhatsappUpdateOne {
  603. if s != nil {
  604. wuo.SetNickname(*s)
  605. }
  606. return wuo
  607. }
  608. // SetPhone sets the "phone" field.
  609. func (wuo *WhatsappUpdateOne) SetPhone(s string) *WhatsappUpdateOne {
  610. wuo.mutation.SetPhone(s)
  611. return wuo
  612. }
  613. // SetNillablePhone sets the "phone" field if the given value is not nil.
  614. func (wuo *WhatsappUpdateOne) SetNillablePhone(s *string) *WhatsappUpdateOne {
  615. if s != nil {
  616. wuo.SetPhone(*s)
  617. }
  618. return wuo
  619. }
  620. // SetOrganizationID sets the "organization_id" field.
  621. func (wuo *WhatsappUpdateOne) SetOrganizationID(u uint64) *WhatsappUpdateOne {
  622. wuo.mutation.ResetOrganizationID()
  623. wuo.mutation.SetOrganizationID(u)
  624. return wuo
  625. }
  626. // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
  627. func (wuo *WhatsappUpdateOne) SetNillableOrganizationID(u *uint64) *WhatsappUpdateOne {
  628. if u != nil {
  629. wuo.SetOrganizationID(*u)
  630. }
  631. return wuo
  632. }
  633. // AddOrganizationID adds u to the "organization_id" field.
  634. func (wuo *WhatsappUpdateOne) AddOrganizationID(u int64) *WhatsappUpdateOne {
  635. wuo.mutation.AddOrganizationID(u)
  636. return wuo
  637. }
  638. // ClearOrganizationID clears the value of the "organization_id" field.
  639. func (wuo *WhatsappUpdateOne) ClearOrganizationID() *WhatsappUpdateOne {
  640. wuo.mutation.ClearOrganizationID()
  641. return wuo
  642. }
  643. // SetAgentID sets the "agent_id" field.
  644. func (wuo *WhatsappUpdateOne) SetAgentID(u uint64) *WhatsappUpdateOne {
  645. wuo.mutation.SetAgentID(u)
  646. return wuo
  647. }
  648. // SetNillableAgentID sets the "agent_id" field if the given value is not nil.
  649. func (wuo *WhatsappUpdateOne) SetNillableAgentID(u *uint64) *WhatsappUpdateOne {
  650. if u != nil {
  651. wuo.SetAgentID(*u)
  652. }
  653. return wuo
  654. }
  655. // SetAPIBase sets the "api_base" field.
  656. func (wuo *WhatsappUpdateOne) SetAPIBase(s string) *WhatsappUpdateOne {
  657. wuo.mutation.SetAPIBase(s)
  658. return wuo
  659. }
  660. // SetNillableAPIBase sets the "api_base" field if the given value is not nil.
  661. func (wuo *WhatsappUpdateOne) SetNillableAPIBase(s *string) *WhatsappUpdateOne {
  662. if s != nil {
  663. wuo.SetAPIBase(*s)
  664. }
  665. return wuo
  666. }
  667. // ClearAPIBase clears the value of the "api_base" field.
  668. func (wuo *WhatsappUpdateOne) ClearAPIBase() *WhatsappUpdateOne {
  669. wuo.mutation.ClearAPIBase()
  670. return wuo
  671. }
  672. // SetAPIKey sets the "api_key" field.
  673. func (wuo *WhatsappUpdateOne) SetAPIKey(s string) *WhatsappUpdateOne {
  674. wuo.mutation.SetAPIKey(s)
  675. return wuo
  676. }
  677. // SetNillableAPIKey sets the "api_key" field if the given value is not nil.
  678. func (wuo *WhatsappUpdateOne) SetNillableAPIKey(s *string) *WhatsappUpdateOne {
  679. if s != nil {
  680. wuo.SetAPIKey(*s)
  681. }
  682. return wuo
  683. }
  684. // ClearAPIKey clears the value of the "api_key" field.
  685. func (wuo *WhatsappUpdateOne) ClearAPIKey() *WhatsappUpdateOne {
  686. wuo.mutation.ClearAPIKey()
  687. return wuo
  688. }
  689. // SetAllowList sets the "allow_list" field.
  690. func (wuo *WhatsappUpdateOne) SetAllowList(s []string) *WhatsappUpdateOne {
  691. wuo.mutation.SetAllowList(s)
  692. return wuo
  693. }
  694. // AppendAllowList appends s to the "allow_list" field.
  695. func (wuo *WhatsappUpdateOne) AppendAllowList(s []string) *WhatsappUpdateOne {
  696. wuo.mutation.AppendAllowList(s)
  697. return wuo
  698. }
  699. // ClearAllowList clears the value of the "allow_list" field.
  700. func (wuo *WhatsappUpdateOne) ClearAllowList() *WhatsappUpdateOne {
  701. wuo.mutation.ClearAllowList()
  702. return wuo
  703. }
  704. // SetGroupAllowList sets the "group_allow_list" field.
  705. func (wuo *WhatsappUpdateOne) SetGroupAllowList(s []string) *WhatsappUpdateOne {
  706. wuo.mutation.SetGroupAllowList(s)
  707. return wuo
  708. }
  709. // AppendGroupAllowList appends s to the "group_allow_list" field.
  710. func (wuo *WhatsappUpdateOne) AppendGroupAllowList(s []string) *WhatsappUpdateOne {
  711. wuo.mutation.AppendGroupAllowList(s)
  712. return wuo
  713. }
  714. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  715. func (wuo *WhatsappUpdateOne) ClearGroupAllowList() *WhatsappUpdateOne {
  716. wuo.mutation.ClearGroupAllowList()
  717. return wuo
  718. }
  719. // SetBlockList sets the "block_list" field.
  720. func (wuo *WhatsappUpdateOne) SetBlockList(s []string) *WhatsappUpdateOne {
  721. wuo.mutation.SetBlockList(s)
  722. return wuo
  723. }
  724. // AppendBlockList appends s to the "block_list" field.
  725. func (wuo *WhatsappUpdateOne) AppendBlockList(s []string) *WhatsappUpdateOne {
  726. wuo.mutation.AppendBlockList(s)
  727. return wuo
  728. }
  729. // ClearBlockList clears the value of the "block_list" field.
  730. func (wuo *WhatsappUpdateOne) ClearBlockList() *WhatsappUpdateOne {
  731. wuo.mutation.ClearBlockList()
  732. return wuo
  733. }
  734. // SetGroupBlockList sets the "group_block_list" field.
  735. func (wuo *WhatsappUpdateOne) SetGroupBlockList(s []string) *WhatsappUpdateOne {
  736. wuo.mutation.SetGroupBlockList(s)
  737. return wuo
  738. }
  739. // AppendGroupBlockList appends s to the "group_block_list" field.
  740. func (wuo *WhatsappUpdateOne) AppendGroupBlockList(s []string) *WhatsappUpdateOne {
  741. wuo.mutation.AppendGroupBlockList(s)
  742. return wuo
  743. }
  744. // ClearGroupBlockList clears the value of the "group_block_list" field.
  745. func (wuo *WhatsappUpdateOne) ClearGroupBlockList() *WhatsappUpdateOne {
  746. wuo.mutation.ClearGroupBlockList()
  747. return wuo
  748. }
  749. // SetAgent sets the "agent" edge to the Agent entity.
  750. func (wuo *WhatsappUpdateOne) SetAgent(a *Agent) *WhatsappUpdateOne {
  751. return wuo.SetAgentID(a.ID)
  752. }
  753. // Mutation returns the WhatsappMutation object of the builder.
  754. func (wuo *WhatsappUpdateOne) Mutation() *WhatsappMutation {
  755. return wuo.mutation
  756. }
  757. // ClearAgent clears the "agent" edge to the Agent entity.
  758. func (wuo *WhatsappUpdateOne) ClearAgent() *WhatsappUpdateOne {
  759. wuo.mutation.ClearAgent()
  760. return wuo
  761. }
  762. // Where appends a list predicates to the WhatsappUpdate builder.
  763. func (wuo *WhatsappUpdateOne) Where(ps ...predicate.Whatsapp) *WhatsappUpdateOne {
  764. wuo.mutation.Where(ps...)
  765. return wuo
  766. }
  767. // Select allows selecting one or more fields (columns) of the returned entity.
  768. // The default is selecting all fields defined in the entity schema.
  769. func (wuo *WhatsappUpdateOne) Select(field string, fields ...string) *WhatsappUpdateOne {
  770. wuo.fields = append([]string{field}, fields...)
  771. return wuo
  772. }
  773. // Save executes the query and returns the updated Whatsapp entity.
  774. func (wuo *WhatsappUpdateOne) Save(ctx context.Context) (*Whatsapp, error) {
  775. if err := wuo.defaults(); err != nil {
  776. return nil, err
  777. }
  778. return withHooks(ctx, wuo.sqlSave, wuo.mutation, wuo.hooks)
  779. }
  780. // SaveX is like Save, but panics if an error occurs.
  781. func (wuo *WhatsappUpdateOne) SaveX(ctx context.Context) *Whatsapp {
  782. node, err := wuo.Save(ctx)
  783. if err != nil {
  784. panic(err)
  785. }
  786. return node
  787. }
  788. // Exec executes the query on the entity.
  789. func (wuo *WhatsappUpdateOne) Exec(ctx context.Context) error {
  790. _, err := wuo.Save(ctx)
  791. return err
  792. }
  793. // ExecX is like Exec, but panics if an error occurs.
  794. func (wuo *WhatsappUpdateOne) ExecX(ctx context.Context) {
  795. if err := wuo.Exec(ctx); err != nil {
  796. panic(err)
  797. }
  798. }
  799. // defaults sets the default values of the builder before save.
  800. func (wuo *WhatsappUpdateOne) defaults() error {
  801. if _, ok := wuo.mutation.UpdatedAt(); !ok {
  802. if whatsapp.UpdateDefaultUpdatedAt == nil {
  803. return fmt.Errorf("ent: uninitialized whatsapp.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
  804. }
  805. v := whatsapp.UpdateDefaultUpdatedAt()
  806. wuo.mutation.SetUpdatedAt(v)
  807. }
  808. return nil
  809. }
  810. // check runs all checks and user-defined validators on the builder.
  811. func (wuo *WhatsappUpdateOne) check() error {
  812. if _, ok := wuo.mutation.AgentID(); wuo.mutation.AgentCleared() && !ok {
  813. return errors.New(`ent: clearing a required unique edge "Whatsapp.agent"`)
  814. }
  815. return nil
  816. }
  817. func (wuo *WhatsappUpdateOne) sqlSave(ctx context.Context) (_node *Whatsapp, err error) {
  818. if err := wuo.check(); err != nil {
  819. return _node, err
  820. }
  821. _spec := sqlgraph.NewUpdateSpec(whatsapp.Table, whatsapp.Columns, sqlgraph.NewFieldSpec(whatsapp.FieldID, field.TypeUint64))
  822. id, ok := wuo.mutation.ID()
  823. if !ok {
  824. return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Whatsapp.id" for update`)}
  825. }
  826. _spec.Node.ID.Value = id
  827. if fields := wuo.fields; len(fields) > 0 {
  828. _spec.Node.Columns = make([]string, 0, len(fields))
  829. _spec.Node.Columns = append(_spec.Node.Columns, whatsapp.FieldID)
  830. for _, f := range fields {
  831. if !whatsapp.ValidColumn(f) {
  832. return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
  833. }
  834. if f != whatsapp.FieldID {
  835. _spec.Node.Columns = append(_spec.Node.Columns, f)
  836. }
  837. }
  838. }
  839. if ps := wuo.mutation.predicates; len(ps) > 0 {
  840. _spec.Predicate = func(selector *sql.Selector) {
  841. for i := range ps {
  842. ps[i](selector)
  843. }
  844. }
  845. }
  846. if value, ok := wuo.mutation.UpdatedAt(); ok {
  847. _spec.SetField(whatsapp.FieldUpdatedAt, field.TypeTime, value)
  848. }
  849. if value, ok := wuo.mutation.Status(); ok {
  850. _spec.SetField(whatsapp.FieldStatus, field.TypeUint8, value)
  851. }
  852. if value, ok := wuo.mutation.AddedStatus(); ok {
  853. _spec.AddField(whatsapp.FieldStatus, field.TypeUint8, value)
  854. }
  855. if wuo.mutation.StatusCleared() {
  856. _spec.ClearField(whatsapp.FieldStatus, field.TypeUint8)
  857. }
  858. if value, ok := wuo.mutation.DeletedAt(); ok {
  859. _spec.SetField(whatsapp.FieldDeletedAt, field.TypeTime, value)
  860. }
  861. if wuo.mutation.DeletedAtCleared() {
  862. _spec.ClearField(whatsapp.FieldDeletedAt, field.TypeTime)
  863. }
  864. if value, ok := wuo.mutation.Ak(); ok {
  865. _spec.SetField(whatsapp.FieldAk, field.TypeString, value)
  866. }
  867. if wuo.mutation.AkCleared() {
  868. _spec.ClearField(whatsapp.FieldAk, field.TypeString)
  869. }
  870. if value, ok := wuo.mutation.Sk(); ok {
  871. _spec.SetField(whatsapp.FieldSk, field.TypeString, value)
  872. }
  873. if value, ok := wuo.mutation.Callback(); ok {
  874. _spec.SetField(whatsapp.FieldCallback, field.TypeString, value)
  875. }
  876. if value, ok := wuo.mutation.Account(); ok {
  877. _spec.SetField(whatsapp.FieldAccount, field.TypeString, value)
  878. }
  879. if value, ok := wuo.mutation.Nickname(); ok {
  880. _spec.SetField(whatsapp.FieldNickname, field.TypeString, value)
  881. }
  882. if value, ok := wuo.mutation.Phone(); ok {
  883. _spec.SetField(whatsapp.FieldPhone, field.TypeString, value)
  884. }
  885. if value, ok := wuo.mutation.OrganizationID(); ok {
  886. _spec.SetField(whatsapp.FieldOrganizationID, field.TypeUint64, value)
  887. }
  888. if value, ok := wuo.mutation.AddedOrganizationID(); ok {
  889. _spec.AddField(whatsapp.FieldOrganizationID, field.TypeUint64, value)
  890. }
  891. if wuo.mutation.OrganizationIDCleared() {
  892. _spec.ClearField(whatsapp.FieldOrganizationID, field.TypeUint64)
  893. }
  894. if value, ok := wuo.mutation.APIBase(); ok {
  895. _spec.SetField(whatsapp.FieldAPIBase, field.TypeString, value)
  896. }
  897. if wuo.mutation.APIBaseCleared() {
  898. _spec.ClearField(whatsapp.FieldAPIBase, field.TypeString)
  899. }
  900. if value, ok := wuo.mutation.APIKey(); ok {
  901. _spec.SetField(whatsapp.FieldAPIKey, field.TypeString, value)
  902. }
  903. if wuo.mutation.APIKeyCleared() {
  904. _spec.ClearField(whatsapp.FieldAPIKey, field.TypeString)
  905. }
  906. if value, ok := wuo.mutation.AllowList(); ok {
  907. _spec.SetField(whatsapp.FieldAllowList, field.TypeJSON, value)
  908. }
  909. if value, ok := wuo.mutation.AppendedAllowList(); ok {
  910. _spec.AddModifier(func(u *sql.UpdateBuilder) {
  911. sqljson.Append(u, whatsapp.FieldAllowList, value)
  912. })
  913. }
  914. if wuo.mutation.AllowListCleared() {
  915. _spec.ClearField(whatsapp.FieldAllowList, field.TypeJSON)
  916. }
  917. if value, ok := wuo.mutation.GroupAllowList(); ok {
  918. _spec.SetField(whatsapp.FieldGroupAllowList, field.TypeJSON, value)
  919. }
  920. if value, ok := wuo.mutation.AppendedGroupAllowList(); ok {
  921. _spec.AddModifier(func(u *sql.UpdateBuilder) {
  922. sqljson.Append(u, whatsapp.FieldGroupAllowList, value)
  923. })
  924. }
  925. if wuo.mutation.GroupAllowListCleared() {
  926. _spec.ClearField(whatsapp.FieldGroupAllowList, field.TypeJSON)
  927. }
  928. if value, ok := wuo.mutation.BlockList(); ok {
  929. _spec.SetField(whatsapp.FieldBlockList, field.TypeJSON, value)
  930. }
  931. if value, ok := wuo.mutation.AppendedBlockList(); ok {
  932. _spec.AddModifier(func(u *sql.UpdateBuilder) {
  933. sqljson.Append(u, whatsapp.FieldBlockList, value)
  934. })
  935. }
  936. if wuo.mutation.BlockListCleared() {
  937. _spec.ClearField(whatsapp.FieldBlockList, field.TypeJSON)
  938. }
  939. if value, ok := wuo.mutation.GroupBlockList(); ok {
  940. _spec.SetField(whatsapp.FieldGroupBlockList, field.TypeJSON, value)
  941. }
  942. if value, ok := wuo.mutation.AppendedGroupBlockList(); ok {
  943. _spec.AddModifier(func(u *sql.UpdateBuilder) {
  944. sqljson.Append(u, whatsapp.FieldGroupBlockList, value)
  945. })
  946. }
  947. if wuo.mutation.GroupBlockListCleared() {
  948. _spec.ClearField(whatsapp.FieldGroupBlockList, field.TypeJSON)
  949. }
  950. if wuo.mutation.AgentCleared() {
  951. edge := &sqlgraph.EdgeSpec{
  952. Rel: sqlgraph.M2O,
  953. Inverse: true,
  954. Table: whatsapp.AgentTable,
  955. Columns: []string{whatsapp.AgentColumn},
  956. Bidi: false,
  957. Target: &sqlgraph.EdgeTarget{
  958. IDSpec: sqlgraph.NewFieldSpec(agent.FieldID, field.TypeUint64),
  959. },
  960. }
  961. _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
  962. }
  963. if nodes := wuo.mutation.AgentIDs(); len(nodes) > 0 {
  964. edge := &sqlgraph.EdgeSpec{
  965. Rel: sqlgraph.M2O,
  966. Inverse: true,
  967. Table: whatsapp.AgentTable,
  968. Columns: []string{whatsapp.AgentColumn},
  969. Bidi: false,
  970. Target: &sqlgraph.EdgeTarget{
  971. IDSpec: sqlgraph.NewFieldSpec(agent.FieldID, field.TypeUint64),
  972. },
  973. }
  974. for _, k := range nodes {
  975. edge.Target.Nodes = append(edge.Target.Nodes, k)
  976. }
  977. _spec.Edges.Add = append(_spec.Edges.Add, edge)
  978. }
  979. _node = &Whatsapp{config: wuo.config}
  980. _spec.Assign = _node.assignValues
  981. _spec.ScanValues = _node.scanValues
  982. if err = sqlgraph.UpdateNode(ctx, wuo.driver, _spec); err != nil {
  983. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  984. err = &NotFoundError{whatsapp.Label}
  985. } else if sqlgraph.IsConstraintError(err) {
  986. err = &ConstraintError{msg: err.Error(), wrap: err}
  987. }
  988. return nil, err
  989. }
  990. wuo.mutation.done = true
  991. return _node, nil
  992. }