wx_create.go 38 KB

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