wx_update.go 32 KB

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