wx_create.go 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344
  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/server"
  9. "wechat-api/ent/wx"
  10. "entgo.io/ent/dialect/sql"
  11. "entgo.io/ent/dialect/sql/sqlgraph"
  12. "entgo.io/ent/schema/field"
  13. )
  14. // WxCreate is the builder for creating a Wx entity.
  15. type WxCreate struct {
  16. config
  17. mutation *WxMutation
  18. hooks []Hook
  19. conflict []sql.ConflictOption
  20. }
  21. // SetCreatedAt sets the "created_at" field.
  22. func (wc *WxCreate) SetCreatedAt(t time.Time) *WxCreate {
  23. wc.mutation.SetCreatedAt(t)
  24. return wc
  25. }
  26. // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
  27. func (wc *WxCreate) SetNillableCreatedAt(t *time.Time) *WxCreate {
  28. if t != nil {
  29. wc.SetCreatedAt(*t)
  30. }
  31. return wc
  32. }
  33. // SetUpdatedAt sets the "updated_at" field.
  34. func (wc *WxCreate) SetUpdatedAt(t time.Time) *WxCreate {
  35. wc.mutation.SetUpdatedAt(t)
  36. return wc
  37. }
  38. // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
  39. func (wc *WxCreate) SetNillableUpdatedAt(t *time.Time) *WxCreate {
  40. if t != nil {
  41. wc.SetUpdatedAt(*t)
  42. }
  43. return wc
  44. }
  45. // SetStatus sets the "status" field.
  46. func (wc *WxCreate) SetStatus(u uint8) *WxCreate {
  47. wc.mutation.SetStatus(u)
  48. return wc
  49. }
  50. // SetNillableStatus sets the "status" field if the given value is not nil.
  51. func (wc *WxCreate) SetNillableStatus(u *uint8) *WxCreate {
  52. if u != nil {
  53. wc.SetStatus(*u)
  54. }
  55. return wc
  56. }
  57. // SetDeletedAt sets the "deleted_at" field.
  58. func (wc *WxCreate) SetDeletedAt(t time.Time) *WxCreate {
  59. wc.mutation.SetDeletedAt(t)
  60. return wc
  61. }
  62. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  63. func (wc *WxCreate) SetNillableDeletedAt(t *time.Time) *WxCreate {
  64. if t != nil {
  65. wc.SetDeletedAt(*t)
  66. }
  67. return wc
  68. }
  69. // SetServerID sets the "server_id" field.
  70. func (wc *WxCreate) SetServerID(u uint64) *WxCreate {
  71. wc.mutation.SetServerID(u)
  72. return wc
  73. }
  74. // SetNillableServerID sets the "server_id" field if the given value is not nil.
  75. func (wc *WxCreate) SetNillableServerID(u *uint64) *WxCreate {
  76. if u != nil {
  77. wc.SetServerID(*u)
  78. }
  79. return wc
  80. }
  81. // SetPort sets the "port" field.
  82. func (wc *WxCreate) SetPort(s string) *WxCreate {
  83. wc.mutation.SetPort(s)
  84. return wc
  85. }
  86. // SetNillablePort sets the "port" field if the given value is not nil.
  87. func (wc *WxCreate) SetNillablePort(s *string) *WxCreate {
  88. if s != nil {
  89. wc.SetPort(*s)
  90. }
  91. return wc
  92. }
  93. // SetProcessID sets the "process_id" field.
  94. func (wc *WxCreate) SetProcessID(s string) *WxCreate {
  95. wc.mutation.SetProcessID(s)
  96. return wc
  97. }
  98. // SetNillableProcessID sets the "process_id" field if the given value is not nil.
  99. func (wc *WxCreate) SetNillableProcessID(s *string) *WxCreate {
  100. if s != nil {
  101. wc.SetProcessID(*s)
  102. }
  103. return wc
  104. }
  105. // SetCallback sets the "callback" field.
  106. func (wc *WxCreate) SetCallback(s string) *WxCreate {
  107. wc.mutation.SetCallback(s)
  108. return wc
  109. }
  110. // SetNillableCallback sets the "callback" field if the given value is not nil.
  111. func (wc *WxCreate) SetNillableCallback(s *string) *WxCreate {
  112. if s != nil {
  113. wc.SetCallback(*s)
  114. }
  115. return wc
  116. }
  117. // SetWxid sets the "wxid" field.
  118. func (wc *WxCreate) SetWxid(s string) *WxCreate {
  119. wc.mutation.SetWxid(s)
  120. return wc
  121. }
  122. // SetNillableWxid sets the "wxid" field if the given value is not nil.
  123. func (wc *WxCreate) SetNillableWxid(s *string) *WxCreate {
  124. if s != nil {
  125. wc.SetWxid(*s)
  126. }
  127. return wc
  128. }
  129. // SetAccount sets the "account" field.
  130. func (wc *WxCreate) SetAccount(s string) *WxCreate {
  131. wc.mutation.SetAccount(s)
  132. return wc
  133. }
  134. // SetNillableAccount sets the "account" field if the given value is not nil.
  135. func (wc *WxCreate) SetNillableAccount(s *string) *WxCreate {
  136. if s != nil {
  137. wc.SetAccount(*s)
  138. }
  139. return wc
  140. }
  141. // SetNickname sets the "nickname" field.
  142. func (wc *WxCreate) SetNickname(s string) *WxCreate {
  143. wc.mutation.SetNickname(s)
  144. return wc
  145. }
  146. // SetNillableNickname sets the "nickname" field if the given value is not nil.
  147. func (wc *WxCreate) SetNillableNickname(s *string) *WxCreate {
  148. if s != nil {
  149. wc.SetNickname(*s)
  150. }
  151. return wc
  152. }
  153. // SetTel sets the "tel" field.
  154. func (wc *WxCreate) SetTel(s string) *WxCreate {
  155. wc.mutation.SetTel(s)
  156. return wc
  157. }
  158. // SetNillableTel sets the "tel" field if the given value is not nil.
  159. func (wc *WxCreate) SetNillableTel(s *string) *WxCreate {
  160. if s != nil {
  161. wc.SetTel(*s)
  162. }
  163. return wc
  164. }
  165. // SetHeadBig sets the "head_big" field.
  166. func (wc *WxCreate) SetHeadBig(s string) *WxCreate {
  167. wc.mutation.SetHeadBig(s)
  168. return wc
  169. }
  170. // SetNillableHeadBig sets the "head_big" field if the given value is not nil.
  171. func (wc *WxCreate) SetNillableHeadBig(s *string) *WxCreate {
  172. if s != nil {
  173. wc.SetHeadBig(*s)
  174. }
  175. return wc
  176. }
  177. // SetID sets the "id" field.
  178. func (wc *WxCreate) SetID(u uint64) *WxCreate {
  179. wc.mutation.SetID(u)
  180. return wc
  181. }
  182. // SetServer sets the "server" edge to the Server entity.
  183. func (wc *WxCreate) SetServer(s *Server) *WxCreate {
  184. return wc.SetServerID(s.ID)
  185. }
  186. // Mutation returns the WxMutation object of the builder.
  187. func (wc *WxCreate) Mutation() *WxMutation {
  188. return wc.mutation
  189. }
  190. // Save creates the Wx in the database.
  191. func (wc *WxCreate) Save(ctx context.Context) (*Wx, error) {
  192. if err := wc.defaults(); err != nil {
  193. return nil, err
  194. }
  195. return withHooks(ctx, wc.sqlSave, wc.mutation, wc.hooks)
  196. }
  197. // SaveX calls Save and panics if Save returns an error.
  198. func (wc *WxCreate) SaveX(ctx context.Context) *Wx {
  199. v, err := wc.Save(ctx)
  200. if err != nil {
  201. panic(err)
  202. }
  203. return v
  204. }
  205. // Exec executes the query.
  206. func (wc *WxCreate) Exec(ctx context.Context) error {
  207. _, err := wc.Save(ctx)
  208. return err
  209. }
  210. // ExecX is like Exec, but panics if an error occurs.
  211. func (wc *WxCreate) ExecX(ctx context.Context) {
  212. if err := wc.Exec(ctx); err != nil {
  213. panic(err)
  214. }
  215. }
  216. // defaults sets the default values of the builder before save.
  217. func (wc *WxCreate) defaults() error {
  218. if _, ok := wc.mutation.CreatedAt(); !ok {
  219. if wx.DefaultCreatedAt == nil {
  220. return fmt.Errorf("ent: uninitialized wx.DefaultCreatedAt (forgotten import ent/runtime?)")
  221. }
  222. v := wx.DefaultCreatedAt()
  223. wc.mutation.SetCreatedAt(v)
  224. }
  225. if _, ok := wc.mutation.UpdatedAt(); !ok {
  226. if wx.DefaultUpdatedAt == nil {
  227. return fmt.Errorf("ent: uninitialized wx.DefaultUpdatedAt (forgotten import ent/runtime?)")
  228. }
  229. v := wx.DefaultUpdatedAt()
  230. wc.mutation.SetUpdatedAt(v)
  231. }
  232. if _, ok := wc.mutation.Status(); !ok {
  233. v := wx.DefaultStatus
  234. wc.mutation.SetStatus(v)
  235. }
  236. if _, ok := wc.mutation.ServerID(); !ok {
  237. v := wx.DefaultServerID
  238. wc.mutation.SetServerID(v)
  239. }
  240. if _, ok := wc.mutation.Port(); !ok {
  241. v := wx.DefaultPort
  242. wc.mutation.SetPort(v)
  243. }
  244. if _, ok := wc.mutation.ProcessID(); !ok {
  245. v := wx.DefaultProcessID
  246. wc.mutation.SetProcessID(v)
  247. }
  248. if _, ok := wc.mutation.Callback(); !ok {
  249. v := wx.DefaultCallback
  250. wc.mutation.SetCallback(v)
  251. }
  252. if _, ok := wc.mutation.Wxid(); !ok {
  253. v := wx.DefaultWxid
  254. wc.mutation.SetWxid(v)
  255. }
  256. if _, ok := wc.mutation.Account(); !ok {
  257. v := wx.DefaultAccount
  258. wc.mutation.SetAccount(v)
  259. }
  260. if _, ok := wc.mutation.Nickname(); !ok {
  261. v := wx.DefaultNickname
  262. wc.mutation.SetNickname(v)
  263. }
  264. if _, ok := wc.mutation.Tel(); !ok {
  265. v := wx.DefaultTel
  266. wc.mutation.SetTel(v)
  267. }
  268. if _, ok := wc.mutation.HeadBig(); !ok {
  269. v := wx.DefaultHeadBig
  270. wc.mutation.SetHeadBig(v)
  271. }
  272. return nil
  273. }
  274. // check runs all checks and user-defined validators on the builder.
  275. func (wc *WxCreate) check() error {
  276. if _, ok := wc.mutation.CreatedAt(); !ok {
  277. return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Wx.created_at"`)}
  278. }
  279. if _, ok := wc.mutation.UpdatedAt(); !ok {
  280. return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Wx.updated_at"`)}
  281. }
  282. if _, ok := wc.mutation.Port(); !ok {
  283. return &ValidationError{Name: "port", err: errors.New(`ent: missing required field "Wx.port"`)}
  284. }
  285. if _, ok := wc.mutation.ProcessID(); !ok {
  286. return &ValidationError{Name: "process_id", err: errors.New(`ent: missing required field "Wx.process_id"`)}
  287. }
  288. if _, ok := wc.mutation.Callback(); !ok {
  289. return &ValidationError{Name: "callback", err: errors.New(`ent: missing required field "Wx.callback"`)}
  290. }
  291. if _, ok := wc.mutation.Wxid(); !ok {
  292. return &ValidationError{Name: "wxid", err: errors.New(`ent: missing required field "Wx.wxid"`)}
  293. }
  294. if _, ok := wc.mutation.Account(); !ok {
  295. return &ValidationError{Name: "account", err: errors.New(`ent: missing required field "Wx.account"`)}
  296. }
  297. if _, ok := wc.mutation.Nickname(); !ok {
  298. return &ValidationError{Name: "nickname", err: errors.New(`ent: missing required field "Wx.nickname"`)}
  299. }
  300. if _, ok := wc.mutation.Tel(); !ok {
  301. return &ValidationError{Name: "tel", err: errors.New(`ent: missing required field "Wx.tel"`)}
  302. }
  303. if _, ok := wc.mutation.HeadBig(); !ok {
  304. return &ValidationError{Name: "head_big", err: errors.New(`ent: missing required field "Wx.head_big"`)}
  305. }
  306. return nil
  307. }
  308. func (wc *WxCreate) sqlSave(ctx context.Context) (*Wx, error) {
  309. if err := wc.check(); err != nil {
  310. return nil, err
  311. }
  312. _node, _spec := wc.createSpec()
  313. if err := sqlgraph.CreateNode(ctx, wc.driver, _spec); err != nil {
  314. if sqlgraph.IsConstraintError(err) {
  315. err = &ConstraintError{msg: err.Error(), wrap: err}
  316. }
  317. return nil, err
  318. }
  319. if _spec.ID.Value != _node.ID {
  320. id := _spec.ID.Value.(int64)
  321. _node.ID = uint64(id)
  322. }
  323. wc.mutation.id = &_node.ID
  324. wc.mutation.done = true
  325. return _node, nil
  326. }
  327. func (wc *WxCreate) createSpec() (*Wx, *sqlgraph.CreateSpec) {
  328. var (
  329. _node = &Wx{config: wc.config}
  330. _spec = sqlgraph.NewCreateSpec(wx.Table, sqlgraph.NewFieldSpec(wx.FieldID, field.TypeUint64))
  331. )
  332. _spec.OnConflict = wc.conflict
  333. if id, ok := wc.mutation.ID(); ok {
  334. _node.ID = id
  335. _spec.ID.Value = id
  336. }
  337. if value, ok := wc.mutation.CreatedAt(); ok {
  338. _spec.SetField(wx.FieldCreatedAt, field.TypeTime, value)
  339. _node.CreatedAt = value
  340. }
  341. if value, ok := wc.mutation.UpdatedAt(); ok {
  342. _spec.SetField(wx.FieldUpdatedAt, field.TypeTime, value)
  343. _node.UpdatedAt = value
  344. }
  345. if value, ok := wc.mutation.Status(); ok {
  346. _spec.SetField(wx.FieldStatus, field.TypeUint8, value)
  347. _node.Status = value
  348. }
  349. if value, ok := wc.mutation.DeletedAt(); ok {
  350. _spec.SetField(wx.FieldDeletedAt, field.TypeTime, value)
  351. _node.DeletedAt = value
  352. }
  353. if value, ok := wc.mutation.Port(); ok {
  354. _spec.SetField(wx.FieldPort, field.TypeString, value)
  355. _node.Port = value
  356. }
  357. if value, ok := wc.mutation.ProcessID(); ok {
  358. _spec.SetField(wx.FieldProcessID, field.TypeString, value)
  359. _node.ProcessID = value
  360. }
  361. if value, ok := wc.mutation.Callback(); ok {
  362. _spec.SetField(wx.FieldCallback, field.TypeString, value)
  363. _node.Callback = value
  364. }
  365. if value, ok := wc.mutation.Wxid(); ok {
  366. _spec.SetField(wx.FieldWxid, field.TypeString, value)
  367. _node.Wxid = value
  368. }
  369. if value, ok := wc.mutation.Account(); ok {
  370. _spec.SetField(wx.FieldAccount, field.TypeString, value)
  371. _node.Account = value
  372. }
  373. if value, ok := wc.mutation.Nickname(); ok {
  374. _spec.SetField(wx.FieldNickname, field.TypeString, value)
  375. _node.Nickname = value
  376. }
  377. if value, ok := wc.mutation.Tel(); ok {
  378. _spec.SetField(wx.FieldTel, field.TypeString, value)
  379. _node.Tel = value
  380. }
  381. if value, ok := wc.mutation.HeadBig(); ok {
  382. _spec.SetField(wx.FieldHeadBig, field.TypeString, value)
  383. _node.HeadBig = value
  384. }
  385. if nodes := wc.mutation.ServerIDs(); len(nodes) > 0 {
  386. edge := &sqlgraph.EdgeSpec{
  387. Rel: sqlgraph.M2O,
  388. Inverse: true,
  389. Table: wx.ServerTable,
  390. Columns: []string{wx.ServerColumn},
  391. Bidi: false,
  392. Target: &sqlgraph.EdgeTarget{
  393. IDSpec: sqlgraph.NewFieldSpec(server.FieldID, field.TypeUint64),
  394. },
  395. }
  396. for _, k := range nodes {
  397. edge.Target.Nodes = append(edge.Target.Nodes, k)
  398. }
  399. _node.ServerID = nodes[0]
  400. _spec.Edges = append(_spec.Edges, edge)
  401. }
  402. return _node, _spec
  403. }
  404. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  405. // of the `INSERT` statement. For example:
  406. //
  407. // client.Wx.Create().
  408. // SetCreatedAt(v).
  409. // OnConflict(
  410. // // Update the row with the new values
  411. // // the was proposed for insertion.
  412. // sql.ResolveWithNewValues(),
  413. // ).
  414. // // Override some of the fields with custom
  415. // // update values.
  416. // Update(func(u *ent.WxUpsert) {
  417. // SetCreatedAt(v+v).
  418. // }).
  419. // Exec(ctx)
  420. func (wc *WxCreate) OnConflict(opts ...sql.ConflictOption) *WxUpsertOne {
  421. wc.conflict = opts
  422. return &WxUpsertOne{
  423. create: wc,
  424. }
  425. }
  426. // OnConflictColumns calls `OnConflict` and configures the columns
  427. // as conflict target. Using this option is equivalent to using:
  428. //
  429. // client.Wx.Create().
  430. // OnConflict(sql.ConflictColumns(columns...)).
  431. // Exec(ctx)
  432. func (wc *WxCreate) OnConflictColumns(columns ...string) *WxUpsertOne {
  433. wc.conflict = append(wc.conflict, sql.ConflictColumns(columns...))
  434. return &WxUpsertOne{
  435. create: wc,
  436. }
  437. }
  438. type (
  439. // WxUpsertOne is the builder for "upsert"-ing
  440. // one Wx node.
  441. WxUpsertOne struct {
  442. create *WxCreate
  443. }
  444. // WxUpsert is the "OnConflict" setter.
  445. WxUpsert struct {
  446. *sql.UpdateSet
  447. }
  448. )
  449. // SetUpdatedAt sets the "updated_at" field.
  450. func (u *WxUpsert) SetUpdatedAt(v time.Time) *WxUpsert {
  451. u.Set(wx.FieldUpdatedAt, v)
  452. return u
  453. }
  454. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  455. func (u *WxUpsert) UpdateUpdatedAt() *WxUpsert {
  456. u.SetExcluded(wx.FieldUpdatedAt)
  457. return u
  458. }
  459. // SetStatus sets the "status" field.
  460. func (u *WxUpsert) SetStatus(v uint8) *WxUpsert {
  461. u.Set(wx.FieldStatus, v)
  462. return u
  463. }
  464. // UpdateStatus sets the "status" field to the value that was provided on create.
  465. func (u *WxUpsert) UpdateStatus() *WxUpsert {
  466. u.SetExcluded(wx.FieldStatus)
  467. return u
  468. }
  469. // AddStatus adds v to the "status" field.
  470. func (u *WxUpsert) AddStatus(v uint8) *WxUpsert {
  471. u.Add(wx.FieldStatus, v)
  472. return u
  473. }
  474. // ClearStatus clears the value of the "status" field.
  475. func (u *WxUpsert) ClearStatus() *WxUpsert {
  476. u.SetNull(wx.FieldStatus)
  477. return u
  478. }
  479. // SetDeletedAt sets the "deleted_at" field.
  480. func (u *WxUpsert) SetDeletedAt(v time.Time) *WxUpsert {
  481. u.Set(wx.FieldDeletedAt, v)
  482. return u
  483. }
  484. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  485. func (u *WxUpsert) UpdateDeletedAt() *WxUpsert {
  486. u.SetExcluded(wx.FieldDeletedAt)
  487. return u
  488. }
  489. // ClearDeletedAt clears the value of the "deleted_at" field.
  490. func (u *WxUpsert) ClearDeletedAt() *WxUpsert {
  491. u.SetNull(wx.FieldDeletedAt)
  492. return u
  493. }
  494. // SetServerID sets the "server_id" field.
  495. func (u *WxUpsert) SetServerID(v uint64) *WxUpsert {
  496. u.Set(wx.FieldServerID, v)
  497. return u
  498. }
  499. // UpdateServerID sets the "server_id" field to the value that was provided on create.
  500. func (u *WxUpsert) UpdateServerID() *WxUpsert {
  501. u.SetExcluded(wx.FieldServerID)
  502. return u
  503. }
  504. // ClearServerID clears the value of the "server_id" field.
  505. func (u *WxUpsert) ClearServerID() *WxUpsert {
  506. u.SetNull(wx.FieldServerID)
  507. return u
  508. }
  509. // SetPort sets the "port" field.
  510. func (u *WxUpsert) SetPort(v string) *WxUpsert {
  511. u.Set(wx.FieldPort, v)
  512. return u
  513. }
  514. // UpdatePort sets the "port" field to the value that was provided on create.
  515. func (u *WxUpsert) UpdatePort() *WxUpsert {
  516. u.SetExcluded(wx.FieldPort)
  517. return u
  518. }
  519. // SetProcessID sets the "process_id" field.
  520. func (u *WxUpsert) SetProcessID(v string) *WxUpsert {
  521. u.Set(wx.FieldProcessID, v)
  522. return u
  523. }
  524. // UpdateProcessID sets the "process_id" field to the value that was provided on create.
  525. func (u *WxUpsert) UpdateProcessID() *WxUpsert {
  526. u.SetExcluded(wx.FieldProcessID)
  527. return u
  528. }
  529. // SetCallback sets the "callback" field.
  530. func (u *WxUpsert) SetCallback(v string) *WxUpsert {
  531. u.Set(wx.FieldCallback, v)
  532. return u
  533. }
  534. // UpdateCallback sets the "callback" field to the value that was provided on create.
  535. func (u *WxUpsert) UpdateCallback() *WxUpsert {
  536. u.SetExcluded(wx.FieldCallback)
  537. return u
  538. }
  539. // SetWxid sets the "wxid" field.
  540. func (u *WxUpsert) SetWxid(v string) *WxUpsert {
  541. u.Set(wx.FieldWxid, v)
  542. return u
  543. }
  544. // UpdateWxid sets the "wxid" field to the value that was provided on create.
  545. func (u *WxUpsert) UpdateWxid() *WxUpsert {
  546. u.SetExcluded(wx.FieldWxid)
  547. return u
  548. }
  549. // SetAccount sets the "account" field.
  550. func (u *WxUpsert) SetAccount(v string) *WxUpsert {
  551. u.Set(wx.FieldAccount, v)
  552. return u
  553. }
  554. // UpdateAccount sets the "account" field to the value that was provided on create.
  555. func (u *WxUpsert) UpdateAccount() *WxUpsert {
  556. u.SetExcluded(wx.FieldAccount)
  557. return u
  558. }
  559. // SetNickname sets the "nickname" field.
  560. func (u *WxUpsert) SetNickname(v string) *WxUpsert {
  561. u.Set(wx.FieldNickname, v)
  562. return u
  563. }
  564. // UpdateNickname sets the "nickname" field to the value that was provided on create.
  565. func (u *WxUpsert) UpdateNickname() *WxUpsert {
  566. u.SetExcluded(wx.FieldNickname)
  567. return u
  568. }
  569. // SetTel sets the "tel" field.
  570. func (u *WxUpsert) SetTel(v string) *WxUpsert {
  571. u.Set(wx.FieldTel, v)
  572. return u
  573. }
  574. // UpdateTel sets the "tel" field to the value that was provided on create.
  575. func (u *WxUpsert) UpdateTel() *WxUpsert {
  576. u.SetExcluded(wx.FieldTel)
  577. return u
  578. }
  579. // SetHeadBig sets the "head_big" field.
  580. func (u *WxUpsert) SetHeadBig(v string) *WxUpsert {
  581. u.Set(wx.FieldHeadBig, v)
  582. return u
  583. }
  584. // UpdateHeadBig sets the "head_big" field to the value that was provided on create.
  585. func (u *WxUpsert) UpdateHeadBig() *WxUpsert {
  586. u.SetExcluded(wx.FieldHeadBig)
  587. return u
  588. }
  589. // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
  590. // Using this option is equivalent to using:
  591. //
  592. // client.Wx.Create().
  593. // OnConflict(
  594. // sql.ResolveWithNewValues(),
  595. // sql.ResolveWith(func(u *sql.UpdateSet) {
  596. // u.SetIgnore(wx.FieldID)
  597. // }),
  598. // ).
  599. // Exec(ctx)
  600. func (u *WxUpsertOne) UpdateNewValues() *WxUpsertOne {
  601. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  602. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  603. if _, exists := u.create.mutation.ID(); exists {
  604. s.SetIgnore(wx.FieldID)
  605. }
  606. if _, exists := u.create.mutation.CreatedAt(); exists {
  607. s.SetIgnore(wx.FieldCreatedAt)
  608. }
  609. }))
  610. return u
  611. }
  612. // Ignore sets each column to itself in case of conflict.
  613. // Using this option is equivalent to using:
  614. //
  615. // client.Wx.Create().
  616. // OnConflict(sql.ResolveWithIgnore()).
  617. // Exec(ctx)
  618. func (u *WxUpsertOne) Ignore() *WxUpsertOne {
  619. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  620. return u
  621. }
  622. // DoNothing configures the conflict_action to `DO NOTHING`.
  623. // Supported only by SQLite and PostgreSQL.
  624. func (u *WxUpsertOne) DoNothing() *WxUpsertOne {
  625. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  626. return u
  627. }
  628. // Update allows overriding fields `UPDATE` values. See the WxCreate.OnConflict
  629. // documentation for more info.
  630. func (u *WxUpsertOne) Update(set func(*WxUpsert)) *WxUpsertOne {
  631. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  632. set(&WxUpsert{UpdateSet: update})
  633. }))
  634. return u
  635. }
  636. // SetUpdatedAt sets the "updated_at" field.
  637. func (u *WxUpsertOne) SetUpdatedAt(v time.Time) *WxUpsertOne {
  638. return u.Update(func(s *WxUpsert) {
  639. s.SetUpdatedAt(v)
  640. })
  641. }
  642. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  643. func (u *WxUpsertOne) UpdateUpdatedAt() *WxUpsertOne {
  644. return u.Update(func(s *WxUpsert) {
  645. s.UpdateUpdatedAt()
  646. })
  647. }
  648. // SetStatus sets the "status" field.
  649. func (u *WxUpsertOne) SetStatus(v uint8) *WxUpsertOne {
  650. return u.Update(func(s *WxUpsert) {
  651. s.SetStatus(v)
  652. })
  653. }
  654. // AddStatus adds v to the "status" field.
  655. func (u *WxUpsertOne) AddStatus(v uint8) *WxUpsertOne {
  656. return u.Update(func(s *WxUpsert) {
  657. s.AddStatus(v)
  658. })
  659. }
  660. // UpdateStatus sets the "status" field to the value that was provided on create.
  661. func (u *WxUpsertOne) UpdateStatus() *WxUpsertOne {
  662. return u.Update(func(s *WxUpsert) {
  663. s.UpdateStatus()
  664. })
  665. }
  666. // ClearStatus clears the value of the "status" field.
  667. func (u *WxUpsertOne) ClearStatus() *WxUpsertOne {
  668. return u.Update(func(s *WxUpsert) {
  669. s.ClearStatus()
  670. })
  671. }
  672. // SetDeletedAt sets the "deleted_at" field.
  673. func (u *WxUpsertOne) SetDeletedAt(v time.Time) *WxUpsertOne {
  674. return u.Update(func(s *WxUpsert) {
  675. s.SetDeletedAt(v)
  676. })
  677. }
  678. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  679. func (u *WxUpsertOne) UpdateDeletedAt() *WxUpsertOne {
  680. return u.Update(func(s *WxUpsert) {
  681. s.UpdateDeletedAt()
  682. })
  683. }
  684. // ClearDeletedAt clears the value of the "deleted_at" field.
  685. func (u *WxUpsertOne) ClearDeletedAt() *WxUpsertOne {
  686. return u.Update(func(s *WxUpsert) {
  687. s.ClearDeletedAt()
  688. })
  689. }
  690. // SetServerID sets the "server_id" field.
  691. func (u *WxUpsertOne) SetServerID(v uint64) *WxUpsertOne {
  692. return u.Update(func(s *WxUpsert) {
  693. s.SetServerID(v)
  694. })
  695. }
  696. // UpdateServerID sets the "server_id" field to the value that was provided on create.
  697. func (u *WxUpsertOne) UpdateServerID() *WxUpsertOne {
  698. return u.Update(func(s *WxUpsert) {
  699. s.UpdateServerID()
  700. })
  701. }
  702. // ClearServerID clears the value of the "server_id" field.
  703. func (u *WxUpsertOne) ClearServerID() *WxUpsertOne {
  704. return u.Update(func(s *WxUpsert) {
  705. s.ClearServerID()
  706. })
  707. }
  708. // SetPort sets the "port" field.
  709. func (u *WxUpsertOne) SetPort(v string) *WxUpsertOne {
  710. return u.Update(func(s *WxUpsert) {
  711. s.SetPort(v)
  712. })
  713. }
  714. // UpdatePort sets the "port" field to the value that was provided on create.
  715. func (u *WxUpsertOne) UpdatePort() *WxUpsertOne {
  716. return u.Update(func(s *WxUpsert) {
  717. s.UpdatePort()
  718. })
  719. }
  720. // SetProcessID sets the "process_id" field.
  721. func (u *WxUpsertOne) SetProcessID(v string) *WxUpsertOne {
  722. return u.Update(func(s *WxUpsert) {
  723. s.SetProcessID(v)
  724. })
  725. }
  726. // UpdateProcessID sets the "process_id" field to the value that was provided on create.
  727. func (u *WxUpsertOne) UpdateProcessID() *WxUpsertOne {
  728. return u.Update(func(s *WxUpsert) {
  729. s.UpdateProcessID()
  730. })
  731. }
  732. // SetCallback sets the "callback" field.
  733. func (u *WxUpsertOne) SetCallback(v string) *WxUpsertOne {
  734. return u.Update(func(s *WxUpsert) {
  735. s.SetCallback(v)
  736. })
  737. }
  738. // UpdateCallback sets the "callback" field to the value that was provided on create.
  739. func (u *WxUpsertOne) UpdateCallback() *WxUpsertOne {
  740. return u.Update(func(s *WxUpsert) {
  741. s.UpdateCallback()
  742. })
  743. }
  744. // SetWxid sets the "wxid" field.
  745. func (u *WxUpsertOne) SetWxid(v string) *WxUpsertOne {
  746. return u.Update(func(s *WxUpsert) {
  747. s.SetWxid(v)
  748. })
  749. }
  750. // UpdateWxid sets the "wxid" field to the value that was provided on create.
  751. func (u *WxUpsertOne) UpdateWxid() *WxUpsertOne {
  752. return u.Update(func(s *WxUpsert) {
  753. s.UpdateWxid()
  754. })
  755. }
  756. // SetAccount sets the "account" field.
  757. func (u *WxUpsertOne) SetAccount(v string) *WxUpsertOne {
  758. return u.Update(func(s *WxUpsert) {
  759. s.SetAccount(v)
  760. })
  761. }
  762. // UpdateAccount sets the "account" field to the value that was provided on create.
  763. func (u *WxUpsertOne) UpdateAccount() *WxUpsertOne {
  764. return u.Update(func(s *WxUpsert) {
  765. s.UpdateAccount()
  766. })
  767. }
  768. // SetNickname sets the "nickname" field.
  769. func (u *WxUpsertOne) SetNickname(v string) *WxUpsertOne {
  770. return u.Update(func(s *WxUpsert) {
  771. s.SetNickname(v)
  772. })
  773. }
  774. // UpdateNickname sets the "nickname" field to the value that was provided on create.
  775. func (u *WxUpsertOne) UpdateNickname() *WxUpsertOne {
  776. return u.Update(func(s *WxUpsert) {
  777. s.UpdateNickname()
  778. })
  779. }
  780. // SetTel sets the "tel" field.
  781. func (u *WxUpsertOne) SetTel(v string) *WxUpsertOne {
  782. return u.Update(func(s *WxUpsert) {
  783. s.SetTel(v)
  784. })
  785. }
  786. // UpdateTel sets the "tel" field to the value that was provided on create.
  787. func (u *WxUpsertOne) UpdateTel() *WxUpsertOne {
  788. return u.Update(func(s *WxUpsert) {
  789. s.UpdateTel()
  790. })
  791. }
  792. // SetHeadBig sets the "head_big" field.
  793. func (u *WxUpsertOne) SetHeadBig(v string) *WxUpsertOne {
  794. return u.Update(func(s *WxUpsert) {
  795. s.SetHeadBig(v)
  796. })
  797. }
  798. // UpdateHeadBig sets the "head_big" field to the value that was provided on create.
  799. func (u *WxUpsertOne) UpdateHeadBig() *WxUpsertOne {
  800. return u.Update(func(s *WxUpsert) {
  801. s.UpdateHeadBig()
  802. })
  803. }
  804. // Exec executes the query.
  805. func (u *WxUpsertOne) Exec(ctx context.Context) error {
  806. if len(u.create.conflict) == 0 {
  807. return errors.New("ent: missing options for WxCreate.OnConflict")
  808. }
  809. return u.create.Exec(ctx)
  810. }
  811. // ExecX is like Exec, but panics if an error occurs.
  812. func (u *WxUpsertOne) ExecX(ctx context.Context) {
  813. if err := u.create.Exec(ctx); err != nil {
  814. panic(err)
  815. }
  816. }
  817. // Exec executes the UPSERT query and returns the inserted/updated ID.
  818. func (u *WxUpsertOne) ID(ctx context.Context) (id uint64, err error) {
  819. node, err := u.create.Save(ctx)
  820. if err != nil {
  821. return id, err
  822. }
  823. return node.ID, nil
  824. }
  825. // IDX is like ID, but panics if an error occurs.
  826. func (u *WxUpsertOne) IDX(ctx context.Context) uint64 {
  827. id, err := u.ID(ctx)
  828. if err != nil {
  829. panic(err)
  830. }
  831. return id
  832. }
  833. // WxCreateBulk is the builder for creating many Wx entities in bulk.
  834. type WxCreateBulk struct {
  835. config
  836. err error
  837. builders []*WxCreate
  838. conflict []sql.ConflictOption
  839. }
  840. // Save creates the Wx entities in the database.
  841. func (wcb *WxCreateBulk) Save(ctx context.Context) ([]*Wx, error) {
  842. if wcb.err != nil {
  843. return nil, wcb.err
  844. }
  845. specs := make([]*sqlgraph.CreateSpec, len(wcb.builders))
  846. nodes := make([]*Wx, len(wcb.builders))
  847. mutators := make([]Mutator, len(wcb.builders))
  848. for i := range wcb.builders {
  849. func(i int, root context.Context) {
  850. builder := wcb.builders[i]
  851. builder.defaults()
  852. var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
  853. mutation, ok := m.(*WxMutation)
  854. if !ok {
  855. return nil, fmt.Errorf("unexpected mutation type %T", m)
  856. }
  857. if err := builder.check(); err != nil {
  858. return nil, err
  859. }
  860. builder.mutation = mutation
  861. var err error
  862. nodes[i], specs[i] = builder.createSpec()
  863. if i < len(mutators)-1 {
  864. _, err = mutators[i+1].Mutate(root, wcb.builders[i+1].mutation)
  865. } else {
  866. spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
  867. spec.OnConflict = wcb.conflict
  868. // Invoke the actual operation on the latest mutation in the chain.
  869. if err = sqlgraph.BatchCreate(ctx, wcb.driver, spec); err != nil {
  870. if sqlgraph.IsConstraintError(err) {
  871. err = &ConstraintError{msg: err.Error(), wrap: err}
  872. }
  873. }
  874. }
  875. if err != nil {
  876. return nil, err
  877. }
  878. mutation.id = &nodes[i].ID
  879. if specs[i].ID.Value != nil && nodes[i].ID == 0 {
  880. id := specs[i].ID.Value.(int64)
  881. nodes[i].ID = uint64(id)
  882. }
  883. mutation.done = true
  884. return nodes[i], nil
  885. })
  886. for i := len(builder.hooks) - 1; i >= 0; i-- {
  887. mut = builder.hooks[i](mut)
  888. }
  889. mutators[i] = mut
  890. }(i, ctx)
  891. }
  892. if len(mutators) > 0 {
  893. if _, err := mutators[0].Mutate(ctx, wcb.builders[0].mutation); err != nil {
  894. return nil, err
  895. }
  896. }
  897. return nodes, nil
  898. }
  899. // SaveX is like Save, but panics if an error occurs.
  900. func (wcb *WxCreateBulk) SaveX(ctx context.Context) []*Wx {
  901. v, err := wcb.Save(ctx)
  902. if err != nil {
  903. panic(err)
  904. }
  905. return v
  906. }
  907. // Exec executes the query.
  908. func (wcb *WxCreateBulk) Exec(ctx context.Context) error {
  909. _, err := wcb.Save(ctx)
  910. return err
  911. }
  912. // ExecX is like Exec, but panics if an error occurs.
  913. func (wcb *WxCreateBulk) ExecX(ctx context.Context) {
  914. if err := wcb.Exec(ctx); err != nil {
  915. panic(err)
  916. }
  917. }
  918. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  919. // of the `INSERT` statement. For example:
  920. //
  921. // client.Wx.CreateBulk(builders...).
  922. // OnConflict(
  923. // // Update the row with the new values
  924. // // the was proposed for insertion.
  925. // sql.ResolveWithNewValues(),
  926. // ).
  927. // // Override some of the fields with custom
  928. // // update values.
  929. // Update(func(u *ent.WxUpsert) {
  930. // SetCreatedAt(v+v).
  931. // }).
  932. // Exec(ctx)
  933. func (wcb *WxCreateBulk) OnConflict(opts ...sql.ConflictOption) *WxUpsertBulk {
  934. wcb.conflict = opts
  935. return &WxUpsertBulk{
  936. create: wcb,
  937. }
  938. }
  939. // OnConflictColumns calls `OnConflict` and configures the columns
  940. // as conflict target. Using this option is equivalent to using:
  941. //
  942. // client.Wx.Create().
  943. // OnConflict(sql.ConflictColumns(columns...)).
  944. // Exec(ctx)
  945. func (wcb *WxCreateBulk) OnConflictColumns(columns ...string) *WxUpsertBulk {
  946. wcb.conflict = append(wcb.conflict, sql.ConflictColumns(columns...))
  947. return &WxUpsertBulk{
  948. create: wcb,
  949. }
  950. }
  951. // WxUpsertBulk is the builder for "upsert"-ing
  952. // a bulk of Wx nodes.
  953. type WxUpsertBulk struct {
  954. create *WxCreateBulk
  955. }
  956. // UpdateNewValues updates the mutable fields using the new values that
  957. // were set on create. Using this option is equivalent to using:
  958. //
  959. // client.Wx.Create().
  960. // OnConflict(
  961. // sql.ResolveWithNewValues(),
  962. // sql.ResolveWith(func(u *sql.UpdateSet) {
  963. // u.SetIgnore(wx.FieldID)
  964. // }),
  965. // ).
  966. // Exec(ctx)
  967. func (u *WxUpsertBulk) UpdateNewValues() *WxUpsertBulk {
  968. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  969. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  970. for _, b := range u.create.builders {
  971. if _, exists := b.mutation.ID(); exists {
  972. s.SetIgnore(wx.FieldID)
  973. }
  974. if _, exists := b.mutation.CreatedAt(); exists {
  975. s.SetIgnore(wx.FieldCreatedAt)
  976. }
  977. }
  978. }))
  979. return u
  980. }
  981. // Ignore sets each column to itself in case of conflict.
  982. // Using this option is equivalent to using:
  983. //
  984. // client.Wx.Create().
  985. // OnConflict(sql.ResolveWithIgnore()).
  986. // Exec(ctx)
  987. func (u *WxUpsertBulk) Ignore() *WxUpsertBulk {
  988. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  989. return u
  990. }
  991. // DoNothing configures the conflict_action to `DO NOTHING`.
  992. // Supported only by SQLite and PostgreSQL.
  993. func (u *WxUpsertBulk) DoNothing() *WxUpsertBulk {
  994. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  995. return u
  996. }
  997. // Update allows overriding fields `UPDATE` values. See the WxCreateBulk.OnConflict
  998. // documentation for more info.
  999. func (u *WxUpsertBulk) Update(set func(*WxUpsert)) *WxUpsertBulk {
  1000. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  1001. set(&WxUpsert{UpdateSet: update})
  1002. }))
  1003. return u
  1004. }
  1005. // SetUpdatedAt sets the "updated_at" field.
  1006. func (u *WxUpsertBulk) SetUpdatedAt(v time.Time) *WxUpsertBulk {
  1007. return u.Update(func(s *WxUpsert) {
  1008. s.SetUpdatedAt(v)
  1009. })
  1010. }
  1011. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  1012. func (u *WxUpsertBulk) UpdateUpdatedAt() *WxUpsertBulk {
  1013. return u.Update(func(s *WxUpsert) {
  1014. s.UpdateUpdatedAt()
  1015. })
  1016. }
  1017. // SetStatus sets the "status" field.
  1018. func (u *WxUpsertBulk) SetStatus(v uint8) *WxUpsertBulk {
  1019. return u.Update(func(s *WxUpsert) {
  1020. s.SetStatus(v)
  1021. })
  1022. }
  1023. // AddStatus adds v to the "status" field.
  1024. func (u *WxUpsertBulk) AddStatus(v uint8) *WxUpsertBulk {
  1025. return u.Update(func(s *WxUpsert) {
  1026. s.AddStatus(v)
  1027. })
  1028. }
  1029. // UpdateStatus sets the "status" field to the value that was provided on create.
  1030. func (u *WxUpsertBulk) UpdateStatus() *WxUpsertBulk {
  1031. return u.Update(func(s *WxUpsert) {
  1032. s.UpdateStatus()
  1033. })
  1034. }
  1035. // ClearStatus clears the value of the "status" field.
  1036. func (u *WxUpsertBulk) ClearStatus() *WxUpsertBulk {
  1037. return u.Update(func(s *WxUpsert) {
  1038. s.ClearStatus()
  1039. })
  1040. }
  1041. // SetDeletedAt sets the "deleted_at" field.
  1042. func (u *WxUpsertBulk) SetDeletedAt(v time.Time) *WxUpsertBulk {
  1043. return u.Update(func(s *WxUpsert) {
  1044. s.SetDeletedAt(v)
  1045. })
  1046. }
  1047. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  1048. func (u *WxUpsertBulk) UpdateDeletedAt() *WxUpsertBulk {
  1049. return u.Update(func(s *WxUpsert) {
  1050. s.UpdateDeletedAt()
  1051. })
  1052. }
  1053. // ClearDeletedAt clears the value of the "deleted_at" field.
  1054. func (u *WxUpsertBulk) ClearDeletedAt() *WxUpsertBulk {
  1055. return u.Update(func(s *WxUpsert) {
  1056. s.ClearDeletedAt()
  1057. })
  1058. }
  1059. // SetServerID sets the "server_id" field.
  1060. func (u *WxUpsertBulk) SetServerID(v uint64) *WxUpsertBulk {
  1061. return u.Update(func(s *WxUpsert) {
  1062. s.SetServerID(v)
  1063. })
  1064. }
  1065. // UpdateServerID sets the "server_id" field to the value that was provided on create.
  1066. func (u *WxUpsertBulk) UpdateServerID() *WxUpsertBulk {
  1067. return u.Update(func(s *WxUpsert) {
  1068. s.UpdateServerID()
  1069. })
  1070. }
  1071. // ClearServerID clears the value of the "server_id" field.
  1072. func (u *WxUpsertBulk) ClearServerID() *WxUpsertBulk {
  1073. return u.Update(func(s *WxUpsert) {
  1074. s.ClearServerID()
  1075. })
  1076. }
  1077. // SetPort sets the "port" field.
  1078. func (u *WxUpsertBulk) SetPort(v string) *WxUpsertBulk {
  1079. return u.Update(func(s *WxUpsert) {
  1080. s.SetPort(v)
  1081. })
  1082. }
  1083. // UpdatePort sets the "port" field to the value that was provided on create.
  1084. func (u *WxUpsertBulk) UpdatePort() *WxUpsertBulk {
  1085. return u.Update(func(s *WxUpsert) {
  1086. s.UpdatePort()
  1087. })
  1088. }
  1089. // SetProcessID sets the "process_id" field.
  1090. func (u *WxUpsertBulk) SetProcessID(v string) *WxUpsertBulk {
  1091. return u.Update(func(s *WxUpsert) {
  1092. s.SetProcessID(v)
  1093. })
  1094. }
  1095. // UpdateProcessID sets the "process_id" field to the value that was provided on create.
  1096. func (u *WxUpsertBulk) UpdateProcessID() *WxUpsertBulk {
  1097. return u.Update(func(s *WxUpsert) {
  1098. s.UpdateProcessID()
  1099. })
  1100. }
  1101. // SetCallback sets the "callback" field.
  1102. func (u *WxUpsertBulk) SetCallback(v string) *WxUpsertBulk {
  1103. return u.Update(func(s *WxUpsert) {
  1104. s.SetCallback(v)
  1105. })
  1106. }
  1107. // UpdateCallback sets the "callback" field to the value that was provided on create.
  1108. func (u *WxUpsertBulk) UpdateCallback() *WxUpsertBulk {
  1109. return u.Update(func(s *WxUpsert) {
  1110. s.UpdateCallback()
  1111. })
  1112. }
  1113. // SetWxid sets the "wxid" field.
  1114. func (u *WxUpsertBulk) SetWxid(v string) *WxUpsertBulk {
  1115. return u.Update(func(s *WxUpsert) {
  1116. s.SetWxid(v)
  1117. })
  1118. }
  1119. // UpdateWxid sets the "wxid" field to the value that was provided on create.
  1120. func (u *WxUpsertBulk) UpdateWxid() *WxUpsertBulk {
  1121. return u.Update(func(s *WxUpsert) {
  1122. s.UpdateWxid()
  1123. })
  1124. }
  1125. // SetAccount sets the "account" field.
  1126. func (u *WxUpsertBulk) SetAccount(v string) *WxUpsertBulk {
  1127. return u.Update(func(s *WxUpsert) {
  1128. s.SetAccount(v)
  1129. })
  1130. }
  1131. // UpdateAccount sets the "account" field to the value that was provided on create.
  1132. func (u *WxUpsertBulk) UpdateAccount() *WxUpsertBulk {
  1133. return u.Update(func(s *WxUpsert) {
  1134. s.UpdateAccount()
  1135. })
  1136. }
  1137. // SetNickname sets the "nickname" field.
  1138. func (u *WxUpsertBulk) SetNickname(v string) *WxUpsertBulk {
  1139. return u.Update(func(s *WxUpsert) {
  1140. s.SetNickname(v)
  1141. })
  1142. }
  1143. // UpdateNickname sets the "nickname" field to the value that was provided on create.
  1144. func (u *WxUpsertBulk) UpdateNickname() *WxUpsertBulk {
  1145. return u.Update(func(s *WxUpsert) {
  1146. s.UpdateNickname()
  1147. })
  1148. }
  1149. // SetTel sets the "tel" field.
  1150. func (u *WxUpsertBulk) SetTel(v string) *WxUpsertBulk {
  1151. return u.Update(func(s *WxUpsert) {
  1152. s.SetTel(v)
  1153. })
  1154. }
  1155. // UpdateTel sets the "tel" field to the value that was provided on create.
  1156. func (u *WxUpsertBulk) UpdateTel() *WxUpsertBulk {
  1157. return u.Update(func(s *WxUpsert) {
  1158. s.UpdateTel()
  1159. })
  1160. }
  1161. // SetHeadBig sets the "head_big" field.
  1162. func (u *WxUpsertBulk) SetHeadBig(v string) *WxUpsertBulk {
  1163. return u.Update(func(s *WxUpsert) {
  1164. s.SetHeadBig(v)
  1165. })
  1166. }
  1167. // UpdateHeadBig sets the "head_big" field to the value that was provided on create.
  1168. func (u *WxUpsertBulk) UpdateHeadBig() *WxUpsertBulk {
  1169. return u.Update(func(s *WxUpsert) {
  1170. s.UpdateHeadBig()
  1171. })
  1172. }
  1173. // Exec executes the query.
  1174. func (u *WxUpsertBulk) Exec(ctx context.Context) error {
  1175. if u.create.err != nil {
  1176. return u.create.err
  1177. }
  1178. for i, b := range u.create.builders {
  1179. if len(b.conflict) != 0 {
  1180. return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the WxCreateBulk instead", i)
  1181. }
  1182. }
  1183. if len(u.create.conflict) == 0 {
  1184. return errors.New("ent: missing options for WxCreateBulk.OnConflict")
  1185. }
  1186. return u.create.Exec(ctx)
  1187. }
  1188. // ExecX is like Exec, but panics if an error occurs.
  1189. func (u *WxUpsertBulk) ExecX(ctx context.Context) {
  1190. if err := u.create.Exec(ctx); err != nil {
  1191. panic(err)
  1192. }
  1193. }