wx_create.go 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "time"
  8. "wechat-api/ent/agent"
  9. "wechat-api/ent/server"
  10. "wechat-api/ent/wx"
  11. "entgo.io/ent/dialect/sql"
  12. "entgo.io/ent/dialect/sql/sqlgraph"
  13. "entgo.io/ent/schema/field"
  14. )
  15. // WxCreate is the builder for creating a Wx entity.
  16. type WxCreate struct {
  17. config
  18. mutation *WxMutation
  19. hooks []Hook
  20. conflict []sql.ConflictOption
  21. }
  22. // SetCreatedAt sets the "created_at" field.
  23. func (wc *WxCreate) SetCreatedAt(t time.Time) *WxCreate {
  24. wc.mutation.SetCreatedAt(t)
  25. return wc
  26. }
  27. // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
  28. func (wc *WxCreate) SetNillableCreatedAt(t *time.Time) *WxCreate {
  29. if t != nil {
  30. wc.SetCreatedAt(*t)
  31. }
  32. return wc
  33. }
  34. // SetUpdatedAt sets the "updated_at" field.
  35. func (wc *WxCreate) SetUpdatedAt(t time.Time) *WxCreate {
  36. wc.mutation.SetUpdatedAt(t)
  37. return wc
  38. }
  39. // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
  40. func (wc *WxCreate) SetNillableUpdatedAt(t *time.Time) *WxCreate {
  41. if t != nil {
  42. wc.SetUpdatedAt(*t)
  43. }
  44. return wc
  45. }
  46. // SetStatus sets the "status" field.
  47. func (wc *WxCreate) SetStatus(u uint8) *WxCreate {
  48. wc.mutation.SetStatus(u)
  49. return wc
  50. }
  51. // SetNillableStatus sets the "status" field if the given value is not nil.
  52. func (wc *WxCreate) SetNillableStatus(u *uint8) *WxCreate {
  53. if u != nil {
  54. wc.SetStatus(*u)
  55. }
  56. return wc
  57. }
  58. // SetDeletedAt sets the "deleted_at" field.
  59. func (wc *WxCreate) SetDeletedAt(t time.Time) *WxCreate {
  60. wc.mutation.SetDeletedAt(t)
  61. return wc
  62. }
  63. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  64. func (wc *WxCreate) SetNillableDeletedAt(t *time.Time) *WxCreate {
  65. if t != nil {
  66. wc.SetDeletedAt(*t)
  67. }
  68. return wc
  69. }
  70. // SetServerID sets the "server_id" field.
  71. func (wc *WxCreate) SetServerID(u uint64) *WxCreate {
  72. wc.mutation.SetServerID(u)
  73. return wc
  74. }
  75. // SetNillableServerID sets the "server_id" field if the given value is not nil.
  76. func (wc *WxCreate) SetNillableServerID(u *uint64) *WxCreate {
  77. if u != nil {
  78. wc.SetServerID(*u)
  79. }
  80. return wc
  81. }
  82. // SetPort sets the "port" field.
  83. func (wc *WxCreate) SetPort(s string) *WxCreate {
  84. wc.mutation.SetPort(s)
  85. return wc
  86. }
  87. // SetNillablePort sets the "port" field if the given value is not nil.
  88. func (wc *WxCreate) SetNillablePort(s *string) *WxCreate {
  89. if s != nil {
  90. wc.SetPort(*s)
  91. }
  92. return wc
  93. }
  94. // SetProcessID sets the "process_id" field.
  95. func (wc *WxCreate) SetProcessID(s string) *WxCreate {
  96. wc.mutation.SetProcessID(s)
  97. return wc
  98. }
  99. // SetNillableProcessID sets the "process_id" field if the given value is not nil.
  100. func (wc *WxCreate) SetNillableProcessID(s *string) *WxCreate {
  101. if s != nil {
  102. wc.SetProcessID(*s)
  103. }
  104. return wc
  105. }
  106. // SetCallback sets the "callback" field.
  107. func (wc *WxCreate) SetCallback(s string) *WxCreate {
  108. wc.mutation.SetCallback(s)
  109. return wc
  110. }
  111. // SetNillableCallback sets the "callback" field if the given value is not nil.
  112. func (wc *WxCreate) SetNillableCallback(s *string) *WxCreate {
  113. if s != nil {
  114. wc.SetCallback(*s)
  115. }
  116. return wc
  117. }
  118. // SetWxid sets the "wxid" field.
  119. func (wc *WxCreate) SetWxid(s string) *WxCreate {
  120. wc.mutation.SetWxid(s)
  121. return wc
  122. }
  123. // SetNillableWxid sets the "wxid" field if the given value is not nil.
  124. func (wc *WxCreate) SetNillableWxid(s *string) *WxCreate {
  125. if s != nil {
  126. wc.SetWxid(*s)
  127. }
  128. return wc
  129. }
  130. // SetAccount sets the "account" field.
  131. func (wc *WxCreate) SetAccount(s string) *WxCreate {
  132. wc.mutation.SetAccount(s)
  133. return wc
  134. }
  135. // SetNillableAccount sets the "account" field if the given value is not nil.
  136. func (wc *WxCreate) SetNillableAccount(s *string) *WxCreate {
  137. if s != nil {
  138. wc.SetAccount(*s)
  139. }
  140. return wc
  141. }
  142. // SetNickname sets the "nickname" field.
  143. func (wc *WxCreate) SetNickname(s string) *WxCreate {
  144. wc.mutation.SetNickname(s)
  145. return wc
  146. }
  147. // SetNillableNickname sets the "nickname" field if the given value is not nil.
  148. func (wc *WxCreate) SetNillableNickname(s *string) *WxCreate {
  149. if s != nil {
  150. wc.SetNickname(*s)
  151. }
  152. return wc
  153. }
  154. // SetTel sets the "tel" field.
  155. func (wc *WxCreate) SetTel(s string) *WxCreate {
  156. wc.mutation.SetTel(s)
  157. return wc
  158. }
  159. // SetNillableTel sets the "tel" field if the given value is not nil.
  160. func (wc *WxCreate) SetNillableTel(s *string) *WxCreate {
  161. if s != nil {
  162. wc.SetTel(*s)
  163. }
  164. return wc
  165. }
  166. // SetHeadBig sets the "head_big" field.
  167. func (wc *WxCreate) SetHeadBig(s string) *WxCreate {
  168. wc.mutation.SetHeadBig(s)
  169. return wc
  170. }
  171. // SetNillableHeadBig sets the "head_big" field if the given value is not nil.
  172. func (wc *WxCreate) SetNillableHeadBig(s *string) *WxCreate {
  173. if s != nil {
  174. wc.SetHeadBig(*s)
  175. }
  176. return wc
  177. }
  178. // SetOrganizationID sets the "organization_id" field.
  179. func (wc *WxCreate) SetOrganizationID(u uint64) *WxCreate {
  180. wc.mutation.SetOrganizationID(u)
  181. return wc
  182. }
  183. // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
  184. func (wc *WxCreate) SetNillableOrganizationID(u *uint64) *WxCreate {
  185. if u != nil {
  186. wc.SetOrganizationID(*u)
  187. }
  188. return wc
  189. }
  190. // SetAgentID sets the "agent_id" field.
  191. func (wc *WxCreate) SetAgentID(u uint64) *WxCreate {
  192. wc.mutation.SetAgentID(u)
  193. return wc
  194. }
  195. // SetNillableAgentID sets the "agent_id" field if the given value is not nil.
  196. func (wc *WxCreate) SetNillableAgentID(u *uint64) *WxCreate {
  197. if u != nil {
  198. wc.SetAgentID(*u)
  199. }
  200. return wc
  201. }
  202. // SetAPIBase sets the "api_base" field.
  203. func (wc *WxCreate) SetAPIBase(s string) *WxCreate {
  204. wc.mutation.SetAPIBase(s)
  205. return wc
  206. }
  207. // SetNillableAPIBase sets the "api_base" field if the given value is not nil.
  208. func (wc *WxCreate) SetNillableAPIBase(s *string) *WxCreate {
  209. if s != nil {
  210. wc.SetAPIBase(*s)
  211. }
  212. return wc
  213. }
  214. // SetAPIKey sets the "api_key" field.
  215. func (wc *WxCreate) SetAPIKey(s string) *WxCreate {
  216. wc.mutation.SetAPIKey(s)
  217. return wc
  218. }
  219. // SetNillableAPIKey sets the "api_key" field if the given value is not nil.
  220. func (wc *WxCreate) SetNillableAPIKey(s *string) *WxCreate {
  221. if s != nil {
  222. wc.SetAPIKey(*s)
  223. }
  224. return wc
  225. }
  226. // SetAllowList sets the "allow_list" field.
  227. func (wc *WxCreate) SetAllowList(s []string) *WxCreate {
  228. wc.mutation.SetAllowList(s)
  229. return wc
  230. }
  231. // SetGroupAllowList sets the "group_allow_list" field.
  232. func (wc *WxCreate) SetGroupAllowList(s []string) *WxCreate {
  233. wc.mutation.SetGroupAllowList(s)
  234. return wc
  235. }
  236. // SetBlockList sets the "block_list" field.
  237. func (wc *WxCreate) SetBlockList(s []string) *WxCreate {
  238. wc.mutation.SetBlockList(s)
  239. return wc
  240. }
  241. // SetGroupBlockList sets the "group_block_list" field.
  242. func (wc *WxCreate) SetGroupBlockList(s []string) *WxCreate {
  243. wc.mutation.SetGroupBlockList(s)
  244. return wc
  245. }
  246. // SetID sets the "id" field.
  247. func (wc *WxCreate) SetID(u uint64) *WxCreate {
  248. wc.mutation.SetID(u)
  249. return wc
  250. }
  251. // SetServer sets the "server" edge to the Server entity.
  252. func (wc *WxCreate) SetServer(s *Server) *WxCreate {
  253. return wc.SetServerID(s.ID)
  254. }
  255. // SetAgent sets the "agent" edge to the Agent entity.
  256. func (wc *WxCreate) SetAgent(a *Agent) *WxCreate {
  257. return wc.SetAgentID(a.ID)
  258. }
  259. // Mutation returns the WxMutation object of the builder.
  260. func (wc *WxCreate) Mutation() *WxMutation {
  261. return wc.mutation
  262. }
  263. // Save creates the Wx in the database.
  264. func (wc *WxCreate) Save(ctx context.Context) (*Wx, error) {
  265. if err := wc.defaults(); err != nil {
  266. return nil, err
  267. }
  268. return withHooks(ctx, wc.sqlSave, wc.mutation, wc.hooks)
  269. }
  270. // SaveX calls Save and panics if Save returns an error.
  271. func (wc *WxCreate) SaveX(ctx context.Context) *Wx {
  272. v, err := wc.Save(ctx)
  273. if err != nil {
  274. panic(err)
  275. }
  276. return v
  277. }
  278. // Exec executes the query.
  279. func (wc *WxCreate) Exec(ctx context.Context) error {
  280. _, err := wc.Save(ctx)
  281. return err
  282. }
  283. // ExecX is like Exec, but panics if an error occurs.
  284. func (wc *WxCreate) ExecX(ctx context.Context) {
  285. if err := wc.Exec(ctx); err != nil {
  286. panic(err)
  287. }
  288. }
  289. // defaults sets the default values of the builder before save.
  290. func (wc *WxCreate) defaults() error {
  291. if _, ok := wc.mutation.CreatedAt(); !ok {
  292. if wx.DefaultCreatedAt == nil {
  293. return fmt.Errorf("ent: uninitialized wx.DefaultCreatedAt (forgotten import ent/runtime?)")
  294. }
  295. v := wx.DefaultCreatedAt()
  296. wc.mutation.SetCreatedAt(v)
  297. }
  298. if _, ok := wc.mutation.UpdatedAt(); !ok {
  299. if wx.DefaultUpdatedAt == nil {
  300. return fmt.Errorf("ent: uninitialized wx.DefaultUpdatedAt (forgotten import ent/runtime?)")
  301. }
  302. v := wx.DefaultUpdatedAt()
  303. wc.mutation.SetUpdatedAt(v)
  304. }
  305. if _, ok := wc.mutation.Status(); !ok {
  306. v := wx.DefaultStatus
  307. wc.mutation.SetStatus(v)
  308. }
  309. if _, ok := wc.mutation.ServerID(); !ok {
  310. v := wx.DefaultServerID
  311. wc.mutation.SetServerID(v)
  312. }
  313. if _, ok := wc.mutation.Port(); !ok {
  314. v := wx.DefaultPort
  315. wc.mutation.SetPort(v)
  316. }
  317. if _, ok := wc.mutation.ProcessID(); !ok {
  318. v := wx.DefaultProcessID
  319. wc.mutation.SetProcessID(v)
  320. }
  321. if _, ok := wc.mutation.Callback(); !ok {
  322. v := wx.DefaultCallback
  323. wc.mutation.SetCallback(v)
  324. }
  325. if _, ok := wc.mutation.Wxid(); !ok {
  326. v := wx.DefaultWxid
  327. wc.mutation.SetWxid(v)
  328. }
  329. if _, ok := wc.mutation.Account(); !ok {
  330. v := wx.DefaultAccount
  331. wc.mutation.SetAccount(v)
  332. }
  333. if _, ok := wc.mutation.Nickname(); !ok {
  334. v := wx.DefaultNickname
  335. wc.mutation.SetNickname(v)
  336. }
  337. if _, ok := wc.mutation.Tel(); !ok {
  338. v := wx.DefaultTel
  339. wc.mutation.SetTel(v)
  340. }
  341. if _, ok := wc.mutation.HeadBig(); !ok {
  342. v := wx.DefaultHeadBig
  343. wc.mutation.SetHeadBig(v)
  344. }
  345. if _, ok := wc.mutation.OrganizationID(); !ok {
  346. v := wx.DefaultOrganizationID
  347. wc.mutation.SetOrganizationID(v)
  348. }
  349. if _, ok := wc.mutation.AgentID(); !ok {
  350. v := wx.DefaultAgentID
  351. wc.mutation.SetAgentID(v)
  352. }
  353. if _, ok := wc.mutation.APIBase(); !ok {
  354. v := wx.DefaultAPIBase
  355. wc.mutation.SetAPIBase(v)
  356. }
  357. if _, ok := wc.mutation.APIKey(); !ok {
  358. v := wx.DefaultAPIKey
  359. wc.mutation.SetAPIKey(v)
  360. }
  361. return nil
  362. }
  363. // check runs all checks and user-defined validators on the builder.
  364. func (wc *WxCreate) check() error {
  365. if _, ok := wc.mutation.CreatedAt(); !ok {
  366. return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Wx.created_at"`)}
  367. }
  368. if _, ok := wc.mutation.UpdatedAt(); !ok {
  369. return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Wx.updated_at"`)}
  370. }
  371. if _, ok := wc.mutation.Port(); !ok {
  372. return &ValidationError{Name: "port", err: errors.New(`ent: missing required field "Wx.port"`)}
  373. }
  374. if _, ok := wc.mutation.ProcessID(); !ok {
  375. return &ValidationError{Name: "process_id", err: errors.New(`ent: missing required field "Wx.process_id"`)}
  376. }
  377. if _, ok := wc.mutation.Callback(); !ok {
  378. return &ValidationError{Name: "callback", err: errors.New(`ent: missing required field "Wx.callback"`)}
  379. }
  380. if _, ok := wc.mutation.Wxid(); !ok {
  381. return &ValidationError{Name: "wxid", err: errors.New(`ent: missing required field "Wx.wxid"`)}
  382. }
  383. if _, ok := wc.mutation.Account(); !ok {
  384. return &ValidationError{Name: "account", err: errors.New(`ent: missing required field "Wx.account"`)}
  385. }
  386. if _, ok := wc.mutation.Nickname(); !ok {
  387. return &ValidationError{Name: "nickname", err: errors.New(`ent: missing required field "Wx.nickname"`)}
  388. }
  389. if _, ok := wc.mutation.Tel(); !ok {
  390. return &ValidationError{Name: "tel", err: errors.New(`ent: missing required field "Wx.tel"`)}
  391. }
  392. if _, ok := wc.mutation.HeadBig(); !ok {
  393. return &ValidationError{Name: "head_big", err: errors.New(`ent: missing required field "Wx.head_big"`)}
  394. }
  395. if _, ok := wc.mutation.AgentID(); !ok {
  396. return &ValidationError{Name: "agent_id", err: errors.New(`ent: missing required field "Wx.agent_id"`)}
  397. }
  398. if _, ok := wc.mutation.AllowList(); !ok {
  399. return &ValidationError{Name: "allow_list", err: errors.New(`ent: missing required field "Wx.allow_list"`)}
  400. }
  401. if _, ok := wc.mutation.GroupAllowList(); !ok {
  402. return &ValidationError{Name: "group_allow_list", err: errors.New(`ent: missing required field "Wx.group_allow_list"`)}
  403. }
  404. if _, ok := wc.mutation.BlockList(); !ok {
  405. return &ValidationError{Name: "block_list", err: errors.New(`ent: missing required field "Wx.block_list"`)}
  406. }
  407. if _, ok := wc.mutation.GroupBlockList(); !ok {
  408. return &ValidationError{Name: "group_block_list", err: errors.New(`ent: missing required field "Wx.group_block_list"`)}
  409. }
  410. if _, ok := wc.mutation.AgentID(); !ok {
  411. return &ValidationError{Name: "agent", err: errors.New(`ent: missing required edge "Wx.agent"`)}
  412. }
  413. return nil
  414. }
  415. func (wc *WxCreate) sqlSave(ctx context.Context) (*Wx, error) {
  416. if err := wc.check(); err != nil {
  417. return nil, err
  418. }
  419. _node, _spec := wc.createSpec()
  420. if err := sqlgraph.CreateNode(ctx, wc.driver, _spec); err != nil {
  421. if sqlgraph.IsConstraintError(err) {
  422. err = &ConstraintError{msg: err.Error(), wrap: err}
  423. }
  424. return nil, err
  425. }
  426. if _spec.ID.Value != _node.ID {
  427. id := _spec.ID.Value.(int64)
  428. _node.ID = uint64(id)
  429. }
  430. wc.mutation.id = &_node.ID
  431. wc.mutation.done = true
  432. return _node, nil
  433. }
  434. func (wc *WxCreate) createSpec() (*Wx, *sqlgraph.CreateSpec) {
  435. var (
  436. _node = &Wx{config: wc.config}
  437. _spec = sqlgraph.NewCreateSpec(wx.Table, sqlgraph.NewFieldSpec(wx.FieldID, field.TypeUint64))
  438. )
  439. _spec.OnConflict = wc.conflict
  440. if id, ok := wc.mutation.ID(); ok {
  441. _node.ID = id
  442. _spec.ID.Value = id
  443. }
  444. if value, ok := wc.mutation.CreatedAt(); ok {
  445. _spec.SetField(wx.FieldCreatedAt, field.TypeTime, value)
  446. _node.CreatedAt = value
  447. }
  448. if value, ok := wc.mutation.UpdatedAt(); ok {
  449. _spec.SetField(wx.FieldUpdatedAt, field.TypeTime, value)
  450. _node.UpdatedAt = value
  451. }
  452. if value, ok := wc.mutation.Status(); ok {
  453. _spec.SetField(wx.FieldStatus, field.TypeUint8, value)
  454. _node.Status = value
  455. }
  456. if value, ok := wc.mutation.DeletedAt(); ok {
  457. _spec.SetField(wx.FieldDeletedAt, field.TypeTime, value)
  458. _node.DeletedAt = value
  459. }
  460. if value, ok := wc.mutation.Port(); ok {
  461. _spec.SetField(wx.FieldPort, field.TypeString, value)
  462. _node.Port = value
  463. }
  464. if value, ok := wc.mutation.ProcessID(); ok {
  465. _spec.SetField(wx.FieldProcessID, field.TypeString, value)
  466. _node.ProcessID = value
  467. }
  468. if value, ok := wc.mutation.Callback(); ok {
  469. _spec.SetField(wx.FieldCallback, field.TypeString, value)
  470. _node.Callback = value
  471. }
  472. if value, ok := wc.mutation.Wxid(); ok {
  473. _spec.SetField(wx.FieldWxid, field.TypeString, value)
  474. _node.Wxid = value
  475. }
  476. if value, ok := wc.mutation.Account(); ok {
  477. _spec.SetField(wx.FieldAccount, field.TypeString, value)
  478. _node.Account = value
  479. }
  480. if value, ok := wc.mutation.Nickname(); ok {
  481. _spec.SetField(wx.FieldNickname, field.TypeString, value)
  482. _node.Nickname = value
  483. }
  484. if value, ok := wc.mutation.Tel(); ok {
  485. _spec.SetField(wx.FieldTel, field.TypeString, value)
  486. _node.Tel = value
  487. }
  488. if value, ok := wc.mutation.HeadBig(); ok {
  489. _spec.SetField(wx.FieldHeadBig, field.TypeString, value)
  490. _node.HeadBig = value
  491. }
  492. if value, ok := wc.mutation.OrganizationID(); ok {
  493. _spec.SetField(wx.FieldOrganizationID, field.TypeUint64, value)
  494. _node.OrganizationID = value
  495. }
  496. if value, ok := wc.mutation.APIBase(); ok {
  497. _spec.SetField(wx.FieldAPIBase, field.TypeString, value)
  498. _node.APIBase = value
  499. }
  500. if value, ok := wc.mutation.APIKey(); ok {
  501. _spec.SetField(wx.FieldAPIKey, field.TypeString, value)
  502. _node.APIKey = value
  503. }
  504. if value, ok := wc.mutation.AllowList(); ok {
  505. _spec.SetField(wx.FieldAllowList, field.TypeJSON, value)
  506. _node.AllowList = value
  507. }
  508. if value, ok := wc.mutation.GroupAllowList(); ok {
  509. _spec.SetField(wx.FieldGroupAllowList, field.TypeJSON, value)
  510. _node.GroupAllowList = value
  511. }
  512. if value, ok := wc.mutation.BlockList(); ok {
  513. _spec.SetField(wx.FieldBlockList, field.TypeJSON, value)
  514. _node.BlockList = value
  515. }
  516. if value, ok := wc.mutation.GroupBlockList(); ok {
  517. _spec.SetField(wx.FieldGroupBlockList, field.TypeJSON, value)
  518. _node.GroupBlockList = value
  519. }
  520. if nodes := wc.mutation.ServerIDs(); len(nodes) > 0 {
  521. edge := &sqlgraph.EdgeSpec{
  522. Rel: sqlgraph.M2O,
  523. Inverse: true,
  524. Table: wx.ServerTable,
  525. Columns: []string{wx.ServerColumn},
  526. Bidi: false,
  527. Target: &sqlgraph.EdgeTarget{
  528. IDSpec: sqlgraph.NewFieldSpec(server.FieldID, field.TypeUint64),
  529. },
  530. }
  531. for _, k := range nodes {
  532. edge.Target.Nodes = append(edge.Target.Nodes, k)
  533. }
  534. _node.ServerID = nodes[0]
  535. _spec.Edges = append(_spec.Edges, edge)
  536. }
  537. if nodes := wc.mutation.AgentIDs(); len(nodes) > 0 {
  538. edge := &sqlgraph.EdgeSpec{
  539. Rel: sqlgraph.M2O,
  540. Inverse: true,
  541. Table: wx.AgentTable,
  542. Columns: []string{wx.AgentColumn},
  543. Bidi: false,
  544. Target: &sqlgraph.EdgeTarget{
  545. IDSpec: sqlgraph.NewFieldSpec(agent.FieldID, field.TypeUint64),
  546. },
  547. }
  548. for _, k := range nodes {
  549. edge.Target.Nodes = append(edge.Target.Nodes, k)
  550. }
  551. _node.AgentID = nodes[0]
  552. _spec.Edges = append(_spec.Edges, edge)
  553. }
  554. return _node, _spec
  555. }
  556. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  557. // of the `INSERT` statement. For example:
  558. //
  559. // client.Wx.Create().
  560. // SetCreatedAt(v).
  561. // OnConflict(
  562. // // Update the row with the new values
  563. // // the was proposed for insertion.
  564. // sql.ResolveWithNewValues(),
  565. // ).
  566. // // Override some of the fields with custom
  567. // // update values.
  568. // Update(func(u *ent.WxUpsert) {
  569. // SetCreatedAt(v+v).
  570. // }).
  571. // Exec(ctx)
  572. func (wc *WxCreate) OnConflict(opts ...sql.ConflictOption) *WxUpsertOne {
  573. wc.conflict = opts
  574. return &WxUpsertOne{
  575. create: wc,
  576. }
  577. }
  578. // OnConflictColumns calls `OnConflict` and configures the columns
  579. // as conflict target. Using this option is equivalent to using:
  580. //
  581. // client.Wx.Create().
  582. // OnConflict(sql.ConflictColumns(columns...)).
  583. // Exec(ctx)
  584. func (wc *WxCreate) OnConflictColumns(columns ...string) *WxUpsertOne {
  585. wc.conflict = append(wc.conflict, sql.ConflictColumns(columns...))
  586. return &WxUpsertOne{
  587. create: wc,
  588. }
  589. }
  590. type (
  591. // WxUpsertOne is the builder for "upsert"-ing
  592. // one Wx node.
  593. WxUpsertOne struct {
  594. create *WxCreate
  595. }
  596. // WxUpsert is the "OnConflict" setter.
  597. WxUpsert struct {
  598. *sql.UpdateSet
  599. }
  600. )
  601. // SetUpdatedAt sets the "updated_at" field.
  602. func (u *WxUpsert) SetUpdatedAt(v time.Time) *WxUpsert {
  603. u.Set(wx.FieldUpdatedAt, v)
  604. return u
  605. }
  606. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  607. func (u *WxUpsert) UpdateUpdatedAt() *WxUpsert {
  608. u.SetExcluded(wx.FieldUpdatedAt)
  609. return u
  610. }
  611. // SetStatus sets the "status" field.
  612. func (u *WxUpsert) SetStatus(v uint8) *WxUpsert {
  613. u.Set(wx.FieldStatus, v)
  614. return u
  615. }
  616. // UpdateStatus sets the "status" field to the value that was provided on create.
  617. func (u *WxUpsert) UpdateStatus() *WxUpsert {
  618. u.SetExcluded(wx.FieldStatus)
  619. return u
  620. }
  621. // AddStatus adds v to the "status" field.
  622. func (u *WxUpsert) AddStatus(v uint8) *WxUpsert {
  623. u.Add(wx.FieldStatus, v)
  624. return u
  625. }
  626. // ClearStatus clears the value of the "status" field.
  627. func (u *WxUpsert) ClearStatus() *WxUpsert {
  628. u.SetNull(wx.FieldStatus)
  629. return u
  630. }
  631. // SetDeletedAt sets the "deleted_at" field.
  632. func (u *WxUpsert) SetDeletedAt(v time.Time) *WxUpsert {
  633. u.Set(wx.FieldDeletedAt, v)
  634. return u
  635. }
  636. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  637. func (u *WxUpsert) UpdateDeletedAt() *WxUpsert {
  638. u.SetExcluded(wx.FieldDeletedAt)
  639. return u
  640. }
  641. // ClearDeletedAt clears the value of the "deleted_at" field.
  642. func (u *WxUpsert) ClearDeletedAt() *WxUpsert {
  643. u.SetNull(wx.FieldDeletedAt)
  644. return u
  645. }
  646. // SetServerID sets the "server_id" field.
  647. func (u *WxUpsert) SetServerID(v uint64) *WxUpsert {
  648. u.Set(wx.FieldServerID, v)
  649. return u
  650. }
  651. // UpdateServerID sets the "server_id" field to the value that was provided on create.
  652. func (u *WxUpsert) UpdateServerID() *WxUpsert {
  653. u.SetExcluded(wx.FieldServerID)
  654. return u
  655. }
  656. // ClearServerID clears the value of the "server_id" field.
  657. func (u *WxUpsert) ClearServerID() *WxUpsert {
  658. u.SetNull(wx.FieldServerID)
  659. return u
  660. }
  661. // SetPort sets the "port" field.
  662. func (u *WxUpsert) SetPort(v string) *WxUpsert {
  663. u.Set(wx.FieldPort, v)
  664. return u
  665. }
  666. // UpdatePort sets the "port" field to the value that was provided on create.
  667. func (u *WxUpsert) UpdatePort() *WxUpsert {
  668. u.SetExcluded(wx.FieldPort)
  669. return u
  670. }
  671. // SetProcessID sets the "process_id" field.
  672. func (u *WxUpsert) SetProcessID(v string) *WxUpsert {
  673. u.Set(wx.FieldProcessID, v)
  674. return u
  675. }
  676. // UpdateProcessID sets the "process_id" field to the value that was provided on create.
  677. func (u *WxUpsert) UpdateProcessID() *WxUpsert {
  678. u.SetExcluded(wx.FieldProcessID)
  679. return u
  680. }
  681. // SetCallback sets the "callback" field.
  682. func (u *WxUpsert) SetCallback(v string) *WxUpsert {
  683. u.Set(wx.FieldCallback, v)
  684. return u
  685. }
  686. // UpdateCallback sets the "callback" field to the value that was provided on create.
  687. func (u *WxUpsert) UpdateCallback() *WxUpsert {
  688. u.SetExcluded(wx.FieldCallback)
  689. return u
  690. }
  691. // SetWxid sets the "wxid" field.
  692. func (u *WxUpsert) SetWxid(v string) *WxUpsert {
  693. u.Set(wx.FieldWxid, v)
  694. return u
  695. }
  696. // UpdateWxid sets the "wxid" field to the value that was provided on create.
  697. func (u *WxUpsert) UpdateWxid() *WxUpsert {
  698. u.SetExcluded(wx.FieldWxid)
  699. return u
  700. }
  701. // SetAccount sets the "account" field.
  702. func (u *WxUpsert) SetAccount(v string) *WxUpsert {
  703. u.Set(wx.FieldAccount, v)
  704. return u
  705. }
  706. // UpdateAccount sets the "account" field to the value that was provided on create.
  707. func (u *WxUpsert) UpdateAccount() *WxUpsert {
  708. u.SetExcluded(wx.FieldAccount)
  709. return u
  710. }
  711. // SetNickname sets the "nickname" field.
  712. func (u *WxUpsert) SetNickname(v string) *WxUpsert {
  713. u.Set(wx.FieldNickname, v)
  714. return u
  715. }
  716. // UpdateNickname sets the "nickname" field to the value that was provided on create.
  717. func (u *WxUpsert) UpdateNickname() *WxUpsert {
  718. u.SetExcluded(wx.FieldNickname)
  719. return u
  720. }
  721. // SetTel sets the "tel" field.
  722. func (u *WxUpsert) SetTel(v string) *WxUpsert {
  723. u.Set(wx.FieldTel, v)
  724. return u
  725. }
  726. // UpdateTel sets the "tel" field to the value that was provided on create.
  727. func (u *WxUpsert) UpdateTel() *WxUpsert {
  728. u.SetExcluded(wx.FieldTel)
  729. return u
  730. }
  731. // SetHeadBig sets the "head_big" field.
  732. func (u *WxUpsert) SetHeadBig(v string) *WxUpsert {
  733. u.Set(wx.FieldHeadBig, v)
  734. return u
  735. }
  736. // UpdateHeadBig sets the "head_big" field to the value that was provided on create.
  737. func (u *WxUpsert) UpdateHeadBig() *WxUpsert {
  738. u.SetExcluded(wx.FieldHeadBig)
  739. return u
  740. }
  741. // SetOrganizationID sets the "organization_id" field.
  742. func (u *WxUpsert) SetOrganizationID(v uint64) *WxUpsert {
  743. u.Set(wx.FieldOrganizationID, v)
  744. return u
  745. }
  746. // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
  747. func (u *WxUpsert) UpdateOrganizationID() *WxUpsert {
  748. u.SetExcluded(wx.FieldOrganizationID)
  749. return u
  750. }
  751. // AddOrganizationID adds v to the "organization_id" field.
  752. func (u *WxUpsert) AddOrganizationID(v uint64) *WxUpsert {
  753. u.Add(wx.FieldOrganizationID, v)
  754. return u
  755. }
  756. // ClearOrganizationID clears the value of the "organization_id" field.
  757. func (u *WxUpsert) ClearOrganizationID() *WxUpsert {
  758. u.SetNull(wx.FieldOrganizationID)
  759. return u
  760. }
  761. // SetAgentID sets the "agent_id" field.
  762. func (u *WxUpsert) SetAgentID(v uint64) *WxUpsert {
  763. u.Set(wx.FieldAgentID, v)
  764. return u
  765. }
  766. // UpdateAgentID sets the "agent_id" field to the value that was provided on create.
  767. func (u *WxUpsert) UpdateAgentID() *WxUpsert {
  768. u.SetExcluded(wx.FieldAgentID)
  769. return u
  770. }
  771. // SetAPIBase sets the "api_base" field.
  772. func (u *WxUpsert) SetAPIBase(v string) *WxUpsert {
  773. u.Set(wx.FieldAPIBase, v)
  774. return u
  775. }
  776. // UpdateAPIBase sets the "api_base" field to the value that was provided on create.
  777. func (u *WxUpsert) UpdateAPIBase() *WxUpsert {
  778. u.SetExcluded(wx.FieldAPIBase)
  779. return u
  780. }
  781. // ClearAPIBase clears the value of the "api_base" field.
  782. func (u *WxUpsert) ClearAPIBase() *WxUpsert {
  783. u.SetNull(wx.FieldAPIBase)
  784. return u
  785. }
  786. // SetAPIKey sets the "api_key" field.
  787. func (u *WxUpsert) SetAPIKey(v string) *WxUpsert {
  788. u.Set(wx.FieldAPIKey, v)
  789. return u
  790. }
  791. // UpdateAPIKey sets the "api_key" field to the value that was provided on create.
  792. func (u *WxUpsert) UpdateAPIKey() *WxUpsert {
  793. u.SetExcluded(wx.FieldAPIKey)
  794. return u
  795. }
  796. // ClearAPIKey clears the value of the "api_key" field.
  797. func (u *WxUpsert) ClearAPIKey() *WxUpsert {
  798. u.SetNull(wx.FieldAPIKey)
  799. return u
  800. }
  801. // SetAllowList sets the "allow_list" field.
  802. func (u *WxUpsert) SetAllowList(v []string) *WxUpsert {
  803. u.Set(wx.FieldAllowList, v)
  804. return u
  805. }
  806. // UpdateAllowList sets the "allow_list" field to the value that was provided on create.
  807. func (u *WxUpsert) UpdateAllowList() *WxUpsert {
  808. u.SetExcluded(wx.FieldAllowList)
  809. return u
  810. }
  811. // SetGroupAllowList sets the "group_allow_list" field.
  812. func (u *WxUpsert) SetGroupAllowList(v []string) *WxUpsert {
  813. u.Set(wx.FieldGroupAllowList, v)
  814. return u
  815. }
  816. // UpdateGroupAllowList sets the "group_allow_list" field to the value that was provided on create.
  817. func (u *WxUpsert) UpdateGroupAllowList() *WxUpsert {
  818. u.SetExcluded(wx.FieldGroupAllowList)
  819. return u
  820. }
  821. // SetBlockList sets the "block_list" field.
  822. func (u *WxUpsert) SetBlockList(v []string) *WxUpsert {
  823. u.Set(wx.FieldBlockList, v)
  824. return u
  825. }
  826. // UpdateBlockList sets the "block_list" field to the value that was provided on create.
  827. func (u *WxUpsert) UpdateBlockList() *WxUpsert {
  828. u.SetExcluded(wx.FieldBlockList)
  829. return u
  830. }
  831. // SetGroupBlockList sets the "group_block_list" field.
  832. func (u *WxUpsert) SetGroupBlockList(v []string) *WxUpsert {
  833. u.Set(wx.FieldGroupBlockList, v)
  834. return u
  835. }
  836. // UpdateGroupBlockList sets the "group_block_list" field to the value that was provided on create.
  837. func (u *WxUpsert) UpdateGroupBlockList() *WxUpsert {
  838. u.SetExcluded(wx.FieldGroupBlockList)
  839. return u
  840. }
  841. // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
  842. // Using this option is equivalent to using:
  843. //
  844. // client.Wx.Create().
  845. // OnConflict(
  846. // sql.ResolveWithNewValues(),
  847. // sql.ResolveWith(func(u *sql.UpdateSet) {
  848. // u.SetIgnore(wx.FieldID)
  849. // }),
  850. // ).
  851. // Exec(ctx)
  852. func (u *WxUpsertOne) UpdateNewValues() *WxUpsertOne {
  853. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  854. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  855. if _, exists := u.create.mutation.ID(); exists {
  856. s.SetIgnore(wx.FieldID)
  857. }
  858. if _, exists := u.create.mutation.CreatedAt(); exists {
  859. s.SetIgnore(wx.FieldCreatedAt)
  860. }
  861. }))
  862. return u
  863. }
  864. // Ignore sets each column to itself in case of conflict.
  865. // Using this option is equivalent to using:
  866. //
  867. // client.Wx.Create().
  868. // OnConflict(sql.ResolveWithIgnore()).
  869. // Exec(ctx)
  870. func (u *WxUpsertOne) Ignore() *WxUpsertOne {
  871. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  872. return u
  873. }
  874. // DoNothing configures the conflict_action to `DO NOTHING`.
  875. // Supported only by SQLite and PostgreSQL.
  876. func (u *WxUpsertOne) DoNothing() *WxUpsertOne {
  877. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  878. return u
  879. }
  880. // Update allows overriding fields `UPDATE` values. See the WxCreate.OnConflict
  881. // documentation for more info.
  882. func (u *WxUpsertOne) Update(set func(*WxUpsert)) *WxUpsertOne {
  883. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  884. set(&WxUpsert{UpdateSet: update})
  885. }))
  886. return u
  887. }
  888. // SetUpdatedAt sets the "updated_at" field.
  889. func (u *WxUpsertOne) SetUpdatedAt(v time.Time) *WxUpsertOne {
  890. return u.Update(func(s *WxUpsert) {
  891. s.SetUpdatedAt(v)
  892. })
  893. }
  894. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  895. func (u *WxUpsertOne) UpdateUpdatedAt() *WxUpsertOne {
  896. return u.Update(func(s *WxUpsert) {
  897. s.UpdateUpdatedAt()
  898. })
  899. }
  900. // SetStatus sets the "status" field.
  901. func (u *WxUpsertOne) SetStatus(v uint8) *WxUpsertOne {
  902. return u.Update(func(s *WxUpsert) {
  903. s.SetStatus(v)
  904. })
  905. }
  906. // AddStatus adds v to the "status" field.
  907. func (u *WxUpsertOne) AddStatus(v uint8) *WxUpsertOne {
  908. return u.Update(func(s *WxUpsert) {
  909. s.AddStatus(v)
  910. })
  911. }
  912. // UpdateStatus sets the "status" field to the value that was provided on create.
  913. func (u *WxUpsertOne) UpdateStatus() *WxUpsertOne {
  914. return u.Update(func(s *WxUpsert) {
  915. s.UpdateStatus()
  916. })
  917. }
  918. // ClearStatus clears the value of the "status" field.
  919. func (u *WxUpsertOne) ClearStatus() *WxUpsertOne {
  920. return u.Update(func(s *WxUpsert) {
  921. s.ClearStatus()
  922. })
  923. }
  924. // SetDeletedAt sets the "deleted_at" field.
  925. func (u *WxUpsertOne) SetDeletedAt(v time.Time) *WxUpsertOne {
  926. return u.Update(func(s *WxUpsert) {
  927. s.SetDeletedAt(v)
  928. })
  929. }
  930. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  931. func (u *WxUpsertOne) UpdateDeletedAt() *WxUpsertOne {
  932. return u.Update(func(s *WxUpsert) {
  933. s.UpdateDeletedAt()
  934. })
  935. }
  936. // ClearDeletedAt clears the value of the "deleted_at" field.
  937. func (u *WxUpsertOne) ClearDeletedAt() *WxUpsertOne {
  938. return u.Update(func(s *WxUpsert) {
  939. s.ClearDeletedAt()
  940. })
  941. }
  942. // SetServerID sets the "server_id" field.
  943. func (u *WxUpsertOne) SetServerID(v uint64) *WxUpsertOne {
  944. return u.Update(func(s *WxUpsert) {
  945. s.SetServerID(v)
  946. })
  947. }
  948. // UpdateServerID sets the "server_id" field to the value that was provided on create.
  949. func (u *WxUpsertOne) UpdateServerID() *WxUpsertOne {
  950. return u.Update(func(s *WxUpsert) {
  951. s.UpdateServerID()
  952. })
  953. }
  954. // ClearServerID clears the value of the "server_id" field.
  955. func (u *WxUpsertOne) ClearServerID() *WxUpsertOne {
  956. return u.Update(func(s *WxUpsert) {
  957. s.ClearServerID()
  958. })
  959. }
  960. // SetPort sets the "port" field.
  961. func (u *WxUpsertOne) SetPort(v string) *WxUpsertOne {
  962. return u.Update(func(s *WxUpsert) {
  963. s.SetPort(v)
  964. })
  965. }
  966. // UpdatePort sets the "port" field to the value that was provided on create.
  967. func (u *WxUpsertOne) UpdatePort() *WxUpsertOne {
  968. return u.Update(func(s *WxUpsert) {
  969. s.UpdatePort()
  970. })
  971. }
  972. // SetProcessID sets the "process_id" field.
  973. func (u *WxUpsertOne) SetProcessID(v string) *WxUpsertOne {
  974. return u.Update(func(s *WxUpsert) {
  975. s.SetProcessID(v)
  976. })
  977. }
  978. // UpdateProcessID sets the "process_id" field to the value that was provided on create.
  979. func (u *WxUpsertOne) UpdateProcessID() *WxUpsertOne {
  980. return u.Update(func(s *WxUpsert) {
  981. s.UpdateProcessID()
  982. })
  983. }
  984. // SetCallback sets the "callback" field.
  985. func (u *WxUpsertOne) SetCallback(v string) *WxUpsertOne {
  986. return u.Update(func(s *WxUpsert) {
  987. s.SetCallback(v)
  988. })
  989. }
  990. // UpdateCallback sets the "callback" field to the value that was provided on create.
  991. func (u *WxUpsertOne) UpdateCallback() *WxUpsertOne {
  992. return u.Update(func(s *WxUpsert) {
  993. s.UpdateCallback()
  994. })
  995. }
  996. // SetWxid sets the "wxid" field.
  997. func (u *WxUpsertOne) SetWxid(v string) *WxUpsertOne {
  998. return u.Update(func(s *WxUpsert) {
  999. s.SetWxid(v)
  1000. })
  1001. }
  1002. // UpdateWxid sets the "wxid" field to the value that was provided on create.
  1003. func (u *WxUpsertOne) UpdateWxid() *WxUpsertOne {
  1004. return u.Update(func(s *WxUpsert) {
  1005. s.UpdateWxid()
  1006. })
  1007. }
  1008. // SetAccount sets the "account" field.
  1009. func (u *WxUpsertOne) SetAccount(v string) *WxUpsertOne {
  1010. return u.Update(func(s *WxUpsert) {
  1011. s.SetAccount(v)
  1012. })
  1013. }
  1014. // UpdateAccount sets the "account" field to the value that was provided on create.
  1015. func (u *WxUpsertOne) UpdateAccount() *WxUpsertOne {
  1016. return u.Update(func(s *WxUpsert) {
  1017. s.UpdateAccount()
  1018. })
  1019. }
  1020. // SetNickname sets the "nickname" field.
  1021. func (u *WxUpsertOne) SetNickname(v string) *WxUpsertOne {
  1022. return u.Update(func(s *WxUpsert) {
  1023. s.SetNickname(v)
  1024. })
  1025. }
  1026. // UpdateNickname sets the "nickname" field to the value that was provided on create.
  1027. func (u *WxUpsertOne) UpdateNickname() *WxUpsertOne {
  1028. return u.Update(func(s *WxUpsert) {
  1029. s.UpdateNickname()
  1030. })
  1031. }
  1032. // SetTel sets the "tel" field.
  1033. func (u *WxUpsertOne) SetTel(v string) *WxUpsertOne {
  1034. return u.Update(func(s *WxUpsert) {
  1035. s.SetTel(v)
  1036. })
  1037. }
  1038. // UpdateTel sets the "tel" field to the value that was provided on create.
  1039. func (u *WxUpsertOne) UpdateTel() *WxUpsertOne {
  1040. return u.Update(func(s *WxUpsert) {
  1041. s.UpdateTel()
  1042. })
  1043. }
  1044. // SetHeadBig sets the "head_big" field.
  1045. func (u *WxUpsertOne) SetHeadBig(v string) *WxUpsertOne {
  1046. return u.Update(func(s *WxUpsert) {
  1047. s.SetHeadBig(v)
  1048. })
  1049. }
  1050. // UpdateHeadBig sets the "head_big" field to the value that was provided on create.
  1051. func (u *WxUpsertOne) UpdateHeadBig() *WxUpsertOne {
  1052. return u.Update(func(s *WxUpsert) {
  1053. s.UpdateHeadBig()
  1054. })
  1055. }
  1056. // SetOrganizationID sets the "organization_id" field.
  1057. func (u *WxUpsertOne) SetOrganizationID(v uint64) *WxUpsertOne {
  1058. return u.Update(func(s *WxUpsert) {
  1059. s.SetOrganizationID(v)
  1060. })
  1061. }
  1062. // AddOrganizationID adds v to the "organization_id" field.
  1063. func (u *WxUpsertOne) AddOrganizationID(v uint64) *WxUpsertOne {
  1064. return u.Update(func(s *WxUpsert) {
  1065. s.AddOrganizationID(v)
  1066. })
  1067. }
  1068. // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
  1069. func (u *WxUpsertOne) UpdateOrganizationID() *WxUpsertOne {
  1070. return u.Update(func(s *WxUpsert) {
  1071. s.UpdateOrganizationID()
  1072. })
  1073. }
  1074. // ClearOrganizationID clears the value of the "organization_id" field.
  1075. func (u *WxUpsertOne) ClearOrganizationID() *WxUpsertOne {
  1076. return u.Update(func(s *WxUpsert) {
  1077. s.ClearOrganizationID()
  1078. })
  1079. }
  1080. // SetAgentID sets the "agent_id" field.
  1081. func (u *WxUpsertOne) SetAgentID(v uint64) *WxUpsertOne {
  1082. return u.Update(func(s *WxUpsert) {
  1083. s.SetAgentID(v)
  1084. })
  1085. }
  1086. // UpdateAgentID sets the "agent_id" field to the value that was provided on create.
  1087. func (u *WxUpsertOne) UpdateAgentID() *WxUpsertOne {
  1088. return u.Update(func(s *WxUpsert) {
  1089. s.UpdateAgentID()
  1090. })
  1091. }
  1092. // SetAPIBase sets the "api_base" field.
  1093. func (u *WxUpsertOne) SetAPIBase(v string) *WxUpsertOne {
  1094. return u.Update(func(s *WxUpsert) {
  1095. s.SetAPIBase(v)
  1096. })
  1097. }
  1098. // UpdateAPIBase sets the "api_base" field to the value that was provided on create.
  1099. func (u *WxUpsertOne) UpdateAPIBase() *WxUpsertOne {
  1100. return u.Update(func(s *WxUpsert) {
  1101. s.UpdateAPIBase()
  1102. })
  1103. }
  1104. // ClearAPIBase clears the value of the "api_base" field.
  1105. func (u *WxUpsertOne) ClearAPIBase() *WxUpsertOne {
  1106. return u.Update(func(s *WxUpsert) {
  1107. s.ClearAPIBase()
  1108. })
  1109. }
  1110. // SetAPIKey sets the "api_key" field.
  1111. func (u *WxUpsertOne) SetAPIKey(v string) *WxUpsertOne {
  1112. return u.Update(func(s *WxUpsert) {
  1113. s.SetAPIKey(v)
  1114. })
  1115. }
  1116. // UpdateAPIKey sets the "api_key" field to the value that was provided on create.
  1117. func (u *WxUpsertOne) UpdateAPIKey() *WxUpsertOne {
  1118. return u.Update(func(s *WxUpsert) {
  1119. s.UpdateAPIKey()
  1120. })
  1121. }
  1122. // ClearAPIKey clears the value of the "api_key" field.
  1123. func (u *WxUpsertOne) ClearAPIKey() *WxUpsertOne {
  1124. return u.Update(func(s *WxUpsert) {
  1125. s.ClearAPIKey()
  1126. })
  1127. }
  1128. // SetAllowList sets the "allow_list" field.
  1129. func (u *WxUpsertOne) SetAllowList(v []string) *WxUpsertOne {
  1130. return u.Update(func(s *WxUpsert) {
  1131. s.SetAllowList(v)
  1132. })
  1133. }
  1134. // UpdateAllowList sets the "allow_list" field to the value that was provided on create.
  1135. func (u *WxUpsertOne) UpdateAllowList() *WxUpsertOne {
  1136. return u.Update(func(s *WxUpsert) {
  1137. s.UpdateAllowList()
  1138. })
  1139. }
  1140. // SetGroupAllowList sets the "group_allow_list" field.
  1141. func (u *WxUpsertOne) SetGroupAllowList(v []string) *WxUpsertOne {
  1142. return u.Update(func(s *WxUpsert) {
  1143. s.SetGroupAllowList(v)
  1144. })
  1145. }
  1146. // UpdateGroupAllowList sets the "group_allow_list" field to the value that was provided on create.
  1147. func (u *WxUpsertOne) UpdateGroupAllowList() *WxUpsertOne {
  1148. return u.Update(func(s *WxUpsert) {
  1149. s.UpdateGroupAllowList()
  1150. })
  1151. }
  1152. // SetBlockList sets the "block_list" field.
  1153. func (u *WxUpsertOne) SetBlockList(v []string) *WxUpsertOne {
  1154. return u.Update(func(s *WxUpsert) {
  1155. s.SetBlockList(v)
  1156. })
  1157. }
  1158. // UpdateBlockList sets the "block_list" field to the value that was provided on create.
  1159. func (u *WxUpsertOne) UpdateBlockList() *WxUpsertOne {
  1160. return u.Update(func(s *WxUpsert) {
  1161. s.UpdateBlockList()
  1162. })
  1163. }
  1164. // SetGroupBlockList sets the "group_block_list" field.
  1165. func (u *WxUpsertOne) SetGroupBlockList(v []string) *WxUpsertOne {
  1166. return u.Update(func(s *WxUpsert) {
  1167. s.SetGroupBlockList(v)
  1168. })
  1169. }
  1170. // UpdateGroupBlockList sets the "group_block_list" field to the value that was provided on create.
  1171. func (u *WxUpsertOne) UpdateGroupBlockList() *WxUpsertOne {
  1172. return u.Update(func(s *WxUpsert) {
  1173. s.UpdateGroupBlockList()
  1174. })
  1175. }
  1176. // Exec executes the query.
  1177. func (u *WxUpsertOne) Exec(ctx context.Context) error {
  1178. if len(u.create.conflict) == 0 {
  1179. return errors.New("ent: missing options for WxCreate.OnConflict")
  1180. }
  1181. return u.create.Exec(ctx)
  1182. }
  1183. // ExecX is like Exec, but panics if an error occurs.
  1184. func (u *WxUpsertOne) ExecX(ctx context.Context) {
  1185. if err := u.create.Exec(ctx); err != nil {
  1186. panic(err)
  1187. }
  1188. }
  1189. // Exec executes the UPSERT query and returns the inserted/updated ID.
  1190. func (u *WxUpsertOne) ID(ctx context.Context) (id uint64, err error) {
  1191. node, err := u.create.Save(ctx)
  1192. if err != nil {
  1193. return id, err
  1194. }
  1195. return node.ID, nil
  1196. }
  1197. // IDX is like ID, but panics if an error occurs.
  1198. func (u *WxUpsertOne) IDX(ctx context.Context) uint64 {
  1199. id, err := u.ID(ctx)
  1200. if err != nil {
  1201. panic(err)
  1202. }
  1203. return id
  1204. }
  1205. // WxCreateBulk is the builder for creating many Wx entities in bulk.
  1206. type WxCreateBulk struct {
  1207. config
  1208. err error
  1209. builders []*WxCreate
  1210. conflict []sql.ConflictOption
  1211. }
  1212. // Save creates the Wx entities in the database.
  1213. func (wcb *WxCreateBulk) Save(ctx context.Context) ([]*Wx, error) {
  1214. if wcb.err != nil {
  1215. return nil, wcb.err
  1216. }
  1217. specs := make([]*sqlgraph.CreateSpec, len(wcb.builders))
  1218. nodes := make([]*Wx, len(wcb.builders))
  1219. mutators := make([]Mutator, len(wcb.builders))
  1220. for i := range wcb.builders {
  1221. func(i int, root context.Context) {
  1222. builder := wcb.builders[i]
  1223. builder.defaults()
  1224. var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
  1225. mutation, ok := m.(*WxMutation)
  1226. if !ok {
  1227. return nil, fmt.Errorf("unexpected mutation type %T", m)
  1228. }
  1229. if err := builder.check(); err != nil {
  1230. return nil, err
  1231. }
  1232. builder.mutation = mutation
  1233. var err error
  1234. nodes[i], specs[i] = builder.createSpec()
  1235. if i < len(mutators)-1 {
  1236. _, err = mutators[i+1].Mutate(root, wcb.builders[i+1].mutation)
  1237. } else {
  1238. spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
  1239. spec.OnConflict = wcb.conflict
  1240. // Invoke the actual operation on the latest mutation in the chain.
  1241. if err = sqlgraph.BatchCreate(ctx, wcb.driver, spec); err != nil {
  1242. if sqlgraph.IsConstraintError(err) {
  1243. err = &ConstraintError{msg: err.Error(), wrap: err}
  1244. }
  1245. }
  1246. }
  1247. if err != nil {
  1248. return nil, err
  1249. }
  1250. mutation.id = &nodes[i].ID
  1251. if specs[i].ID.Value != nil && nodes[i].ID == 0 {
  1252. id := specs[i].ID.Value.(int64)
  1253. nodes[i].ID = uint64(id)
  1254. }
  1255. mutation.done = true
  1256. return nodes[i], nil
  1257. })
  1258. for i := len(builder.hooks) - 1; i >= 0; i-- {
  1259. mut = builder.hooks[i](mut)
  1260. }
  1261. mutators[i] = mut
  1262. }(i, ctx)
  1263. }
  1264. if len(mutators) > 0 {
  1265. if _, err := mutators[0].Mutate(ctx, wcb.builders[0].mutation); err != nil {
  1266. return nil, err
  1267. }
  1268. }
  1269. return nodes, nil
  1270. }
  1271. // SaveX is like Save, but panics if an error occurs.
  1272. func (wcb *WxCreateBulk) SaveX(ctx context.Context) []*Wx {
  1273. v, err := wcb.Save(ctx)
  1274. if err != nil {
  1275. panic(err)
  1276. }
  1277. return v
  1278. }
  1279. // Exec executes the query.
  1280. func (wcb *WxCreateBulk) Exec(ctx context.Context) error {
  1281. _, err := wcb.Save(ctx)
  1282. return err
  1283. }
  1284. // ExecX is like Exec, but panics if an error occurs.
  1285. func (wcb *WxCreateBulk) ExecX(ctx context.Context) {
  1286. if err := wcb.Exec(ctx); err != nil {
  1287. panic(err)
  1288. }
  1289. }
  1290. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  1291. // of the `INSERT` statement. For example:
  1292. //
  1293. // client.Wx.CreateBulk(builders...).
  1294. // OnConflict(
  1295. // // Update the row with the new values
  1296. // // the was proposed for insertion.
  1297. // sql.ResolveWithNewValues(),
  1298. // ).
  1299. // // Override some of the fields with custom
  1300. // // update values.
  1301. // Update(func(u *ent.WxUpsert) {
  1302. // SetCreatedAt(v+v).
  1303. // }).
  1304. // Exec(ctx)
  1305. func (wcb *WxCreateBulk) OnConflict(opts ...sql.ConflictOption) *WxUpsertBulk {
  1306. wcb.conflict = opts
  1307. return &WxUpsertBulk{
  1308. create: wcb,
  1309. }
  1310. }
  1311. // OnConflictColumns calls `OnConflict` and configures the columns
  1312. // as conflict target. Using this option is equivalent to using:
  1313. //
  1314. // client.Wx.Create().
  1315. // OnConflict(sql.ConflictColumns(columns...)).
  1316. // Exec(ctx)
  1317. func (wcb *WxCreateBulk) OnConflictColumns(columns ...string) *WxUpsertBulk {
  1318. wcb.conflict = append(wcb.conflict, sql.ConflictColumns(columns...))
  1319. return &WxUpsertBulk{
  1320. create: wcb,
  1321. }
  1322. }
  1323. // WxUpsertBulk is the builder for "upsert"-ing
  1324. // a bulk of Wx nodes.
  1325. type WxUpsertBulk struct {
  1326. create *WxCreateBulk
  1327. }
  1328. // UpdateNewValues updates the mutable fields using the new values that
  1329. // were set on create. Using this option is equivalent to using:
  1330. //
  1331. // client.Wx.Create().
  1332. // OnConflict(
  1333. // sql.ResolveWithNewValues(),
  1334. // sql.ResolveWith(func(u *sql.UpdateSet) {
  1335. // u.SetIgnore(wx.FieldID)
  1336. // }),
  1337. // ).
  1338. // Exec(ctx)
  1339. func (u *WxUpsertBulk) UpdateNewValues() *WxUpsertBulk {
  1340. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  1341. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  1342. for _, b := range u.create.builders {
  1343. if _, exists := b.mutation.ID(); exists {
  1344. s.SetIgnore(wx.FieldID)
  1345. }
  1346. if _, exists := b.mutation.CreatedAt(); exists {
  1347. s.SetIgnore(wx.FieldCreatedAt)
  1348. }
  1349. }
  1350. }))
  1351. return u
  1352. }
  1353. // Ignore sets each column to itself in case of conflict.
  1354. // Using this option is equivalent to using:
  1355. //
  1356. // client.Wx.Create().
  1357. // OnConflict(sql.ResolveWithIgnore()).
  1358. // Exec(ctx)
  1359. func (u *WxUpsertBulk) Ignore() *WxUpsertBulk {
  1360. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  1361. return u
  1362. }
  1363. // DoNothing configures the conflict_action to `DO NOTHING`.
  1364. // Supported only by SQLite and PostgreSQL.
  1365. func (u *WxUpsertBulk) DoNothing() *WxUpsertBulk {
  1366. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  1367. return u
  1368. }
  1369. // Update allows overriding fields `UPDATE` values. See the WxCreateBulk.OnConflict
  1370. // documentation for more info.
  1371. func (u *WxUpsertBulk) Update(set func(*WxUpsert)) *WxUpsertBulk {
  1372. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  1373. set(&WxUpsert{UpdateSet: update})
  1374. }))
  1375. return u
  1376. }
  1377. // SetUpdatedAt sets the "updated_at" field.
  1378. func (u *WxUpsertBulk) SetUpdatedAt(v time.Time) *WxUpsertBulk {
  1379. return u.Update(func(s *WxUpsert) {
  1380. s.SetUpdatedAt(v)
  1381. })
  1382. }
  1383. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  1384. func (u *WxUpsertBulk) UpdateUpdatedAt() *WxUpsertBulk {
  1385. return u.Update(func(s *WxUpsert) {
  1386. s.UpdateUpdatedAt()
  1387. })
  1388. }
  1389. // SetStatus sets the "status" field.
  1390. func (u *WxUpsertBulk) SetStatus(v uint8) *WxUpsertBulk {
  1391. return u.Update(func(s *WxUpsert) {
  1392. s.SetStatus(v)
  1393. })
  1394. }
  1395. // AddStatus adds v to the "status" field.
  1396. func (u *WxUpsertBulk) AddStatus(v uint8) *WxUpsertBulk {
  1397. return u.Update(func(s *WxUpsert) {
  1398. s.AddStatus(v)
  1399. })
  1400. }
  1401. // UpdateStatus sets the "status" field to the value that was provided on create.
  1402. func (u *WxUpsertBulk) UpdateStatus() *WxUpsertBulk {
  1403. return u.Update(func(s *WxUpsert) {
  1404. s.UpdateStatus()
  1405. })
  1406. }
  1407. // ClearStatus clears the value of the "status" field.
  1408. func (u *WxUpsertBulk) ClearStatus() *WxUpsertBulk {
  1409. return u.Update(func(s *WxUpsert) {
  1410. s.ClearStatus()
  1411. })
  1412. }
  1413. // SetDeletedAt sets the "deleted_at" field.
  1414. func (u *WxUpsertBulk) SetDeletedAt(v time.Time) *WxUpsertBulk {
  1415. return u.Update(func(s *WxUpsert) {
  1416. s.SetDeletedAt(v)
  1417. })
  1418. }
  1419. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  1420. func (u *WxUpsertBulk) UpdateDeletedAt() *WxUpsertBulk {
  1421. return u.Update(func(s *WxUpsert) {
  1422. s.UpdateDeletedAt()
  1423. })
  1424. }
  1425. // ClearDeletedAt clears the value of the "deleted_at" field.
  1426. func (u *WxUpsertBulk) ClearDeletedAt() *WxUpsertBulk {
  1427. return u.Update(func(s *WxUpsert) {
  1428. s.ClearDeletedAt()
  1429. })
  1430. }
  1431. // SetServerID sets the "server_id" field.
  1432. func (u *WxUpsertBulk) SetServerID(v uint64) *WxUpsertBulk {
  1433. return u.Update(func(s *WxUpsert) {
  1434. s.SetServerID(v)
  1435. })
  1436. }
  1437. // UpdateServerID sets the "server_id" field to the value that was provided on create.
  1438. func (u *WxUpsertBulk) UpdateServerID() *WxUpsertBulk {
  1439. return u.Update(func(s *WxUpsert) {
  1440. s.UpdateServerID()
  1441. })
  1442. }
  1443. // ClearServerID clears the value of the "server_id" field.
  1444. func (u *WxUpsertBulk) ClearServerID() *WxUpsertBulk {
  1445. return u.Update(func(s *WxUpsert) {
  1446. s.ClearServerID()
  1447. })
  1448. }
  1449. // SetPort sets the "port" field.
  1450. func (u *WxUpsertBulk) SetPort(v string) *WxUpsertBulk {
  1451. return u.Update(func(s *WxUpsert) {
  1452. s.SetPort(v)
  1453. })
  1454. }
  1455. // UpdatePort sets the "port" field to the value that was provided on create.
  1456. func (u *WxUpsertBulk) UpdatePort() *WxUpsertBulk {
  1457. return u.Update(func(s *WxUpsert) {
  1458. s.UpdatePort()
  1459. })
  1460. }
  1461. // SetProcessID sets the "process_id" field.
  1462. func (u *WxUpsertBulk) SetProcessID(v string) *WxUpsertBulk {
  1463. return u.Update(func(s *WxUpsert) {
  1464. s.SetProcessID(v)
  1465. })
  1466. }
  1467. // UpdateProcessID sets the "process_id" field to the value that was provided on create.
  1468. func (u *WxUpsertBulk) UpdateProcessID() *WxUpsertBulk {
  1469. return u.Update(func(s *WxUpsert) {
  1470. s.UpdateProcessID()
  1471. })
  1472. }
  1473. // SetCallback sets the "callback" field.
  1474. func (u *WxUpsertBulk) SetCallback(v string) *WxUpsertBulk {
  1475. return u.Update(func(s *WxUpsert) {
  1476. s.SetCallback(v)
  1477. })
  1478. }
  1479. // UpdateCallback sets the "callback" field to the value that was provided on create.
  1480. func (u *WxUpsertBulk) UpdateCallback() *WxUpsertBulk {
  1481. return u.Update(func(s *WxUpsert) {
  1482. s.UpdateCallback()
  1483. })
  1484. }
  1485. // SetWxid sets the "wxid" field.
  1486. func (u *WxUpsertBulk) SetWxid(v string) *WxUpsertBulk {
  1487. return u.Update(func(s *WxUpsert) {
  1488. s.SetWxid(v)
  1489. })
  1490. }
  1491. // UpdateWxid sets the "wxid" field to the value that was provided on create.
  1492. func (u *WxUpsertBulk) UpdateWxid() *WxUpsertBulk {
  1493. return u.Update(func(s *WxUpsert) {
  1494. s.UpdateWxid()
  1495. })
  1496. }
  1497. // SetAccount sets the "account" field.
  1498. func (u *WxUpsertBulk) SetAccount(v string) *WxUpsertBulk {
  1499. return u.Update(func(s *WxUpsert) {
  1500. s.SetAccount(v)
  1501. })
  1502. }
  1503. // UpdateAccount sets the "account" field to the value that was provided on create.
  1504. func (u *WxUpsertBulk) UpdateAccount() *WxUpsertBulk {
  1505. return u.Update(func(s *WxUpsert) {
  1506. s.UpdateAccount()
  1507. })
  1508. }
  1509. // SetNickname sets the "nickname" field.
  1510. func (u *WxUpsertBulk) SetNickname(v string) *WxUpsertBulk {
  1511. return u.Update(func(s *WxUpsert) {
  1512. s.SetNickname(v)
  1513. })
  1514. }
  1515. // UpdateNickname sets the "nickname" field to the value that was provided on create.
  1516. func (u *WxUpsertBulk) UpdateNickname() *WxUpsertBulk {
  1517. return u.Update(func(s *WxUpsert) {
  1518. s.UpdateNickname()
  1519. })
  1520. }
  1521. // SetTel sets the "tel" field.
  1522. func (u *WxUpsertBulk) SetTel(v string) *WxUpsertBulk {
  1523. return u.Update(func(s *WxUpsert) {
  1524. s.SetTel(v)
  1525. })
  1526. }
  1527. // UpdateTel sets the "tel" field to the value that was provided on create.
  1528. func (u *WxUpsertBulk) UpdateTel() *WxUpsertBulk {
  1529. return u.Update(func(s *WxUpsert) {
  1530. s.UpdateTel()
  1531. })
  1532. }
  1533. // SetHeadBig sets the "head_big" field.
  1534. func (u *WxUpsertBulk) SetHeadBig(v string) *WxUpsertBulk {
  1535. return u.Update(func(s *WxUpsert) {
  1536. s.SetHeadBig(v)
  1537. })
  1538. }
  1539. // UpdateHeadBig sets the "head_big" field to the value that was provided on create.
  1540. func (u *WxUpsertBulk) UpdateHeadBig() *WxUpsertBulk {
  1541. return u.Update(func(s *WxUpsert) {
  1542. s.UpdateHeadBig()
  1543. })
  1544. }
  1545. // SetOrganizationID sets the "organization_id" field.
  1546. func (u *WxUpsertBulk) SetOrganizationID(v uint64) *WxUpsertBulk {
  1547. return u.Update(func(s *WxUpsert) {
  1548. s.SetOrganizationID(v)
  1549. })
  1550. }
  1551. // AddOrganizationID adds v to the "organization_id" field.
  1552. func (u *WxUpsertBulk) AddOrganizationID(v uint64) *WxUpsertBulk {
  1553. return u.Update(func(s *WxUpsert) {
  1554. s.AddOrganizationID(v)
  1555. })
  1556. }
  1557. // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
  1558. func (u *WxUpsertBulk) UpdateOrganizationID() *WxUpsertBulk {
  1559. return u.Update(func(s *WxUpsert) {
  1560. s.UpdateOrganizationID()
  1561. })
  1562. }
  1563. // ClearOrganizationID clears the value of the "organization_id" field.
  1564. func (u *WxUpsertBulk) ClearOrganizationID() *WxUpsertBulk {
  1565. return u.Update(func(s *WxUpsert) {
  1566. s.ClearOrganizationID()
  1567. })
  1568. }
  1569. // SetAgentID sets the "agent_id" field.
  1570. func (u *WxUpsertBulk) SetAgentID(v uint64) *WxUpsertBulk {
  1571. return u.Update(func(s *WxUpsert) {
  1572. s.SetAgentID(v)
  1573. })
  1574. }
  1575. // UpdateAgentID sets the "agent_id" field to the value that was provided on create.
  1576. func (u *WxUpsertBulk) UpdateAgentID() *WxUpsertBulk {
  1577. return u.Update(func(s *WxUpsert) {
  1578. s.UpdateAgentID()
  1579. })
  1580. }
  1581. // SetAPIBase sets the "api_base" field.
  1582. func (u *WxUpsertBulk) SetAPIBase(v string) *WxUpsertBulk {
  1583. return u.Update(func(s *WxUpsert) {
  1584. s.SetAPIBase(v)
  1585. })
  1586. }
  1587. // UpdateAPIBase sets the "api_base" field to the value that was provided on create.
  1588. func (u *WxUpsertBulk) UpdateAPIBase() *WxUpsertBulk {
  1589. return u.Update(func(s *WxUpsert) {
  1590. s.UpdateAPIBase()
  1591. })
  1592. }
  1593. // ClearAPIBase clears the value of the "api_base" field.
  1594. func (u *WxUpsertBulk) ClearAPIBase() *WxUpsertBulk {
  1595. return u.Update(func(s *WxUpsert) {
  1596. s.ClearAPIBase()
  1597. })
  1598. }
  1599. // SetAPIKey sets the "api_key" field.
  1600. func (u *WxUpsertBulk) SetAPIKey(v string) *WxUpsertBulk {
  1601. return u.Update(func(s *WxUpsert) {
  1602. s.SetAPIKey(v)
  1603. })
  1604. }
  1605. // UpdateAPIKey sets the "api_key" field to the value that was provided on create.
  1606. func (u *WxUpsertBulk) UpdateAPIKey() *WxUpsertBulk {
  1607. return u.Update(func(s *WxUpsert) {
  1608. s.UpdateAPIKey()
  1609. })
  1610. }
  1611. // ClearAPIKey clears the value of the "api_key" field.
  1612. func (u *WxUpsertBulk) ClearAPIKey() *WxUpsertBulk {
  1613. return u.Update(func(s *WxUpsert) {
  1614. s.ClearAPIKey()
  1615. })
  1616. }
  1617. // SetAllowList sets the "allow_list" field.
  1618. func (u *WxUpsertBulk) SetAllowList(v []string) *WxUpsertBulk {
  1619. return u.Update(func(s *WxUpsert) {
  1620. s.SetAllowList(v)
  1621. })
  1622. }
  1623. // UpdateAllowList sets the "allow_list" field to the value that was provided on create.
  1624. func (u *WxUpsertBulk) UpdateAllowList() *WxUpsertBulk {
  1625. return u.Update(func(s *WxUpsert) {
  1626. s.UpdateAllowList()
  1627. })
  1628. }
  1629. // SetGroupAllowList sets the "group_allow_list" field.
  1630. func (u *WxUpsertBulk) SetGroupAllowList(v []string) *WxUpsertBulk {
  1631. return u.Update(func(s *WxUpsert) {
  1632. s.SetGroupAllowList(v)
  1633. })
  1634. }
  1635. // UpdateGroupAllowList sets the "group_allow_list" field to the value that was provided on create.
  1636. func (u *WxUpsertBulk) UpdateGroupAllowList() *WxUpsertBulk {
  1637. return u.Update(func(s *WxUpsert) {
  1638. s.UpdateGroupAllowList()
  1639. })
  1640. }
  1641. // SetBlockList sets the "block_list" field.
  1642. func (u *WxUpsertBulk) SetBlockList(v []string) *WxUpsertBulk {
  1643. return u.Update(func(s *WxUpsert) {
  1644. s.SetBlockList(v)
  1645. })
  1646. }
  1647. // UpdateBlockList sets the "block_list" field to the value that was provided on create.
  1648. func (u *WxUpsertBulk) UpdateBlockList() *WxUpsertBulk {
  1649. return u.Update(func(s *WxUpsert) {
  1650. s.UpdateBlockList()
  1651. })
  1652. }
  1653. // SetGroupBlockList sets the "group_block_list" field.
  1654. func (u *WxUpsertBulk) SetGroupBlockList(v []string) *WxUpsertBulk {
  1655. return u.Update(func(s *WxUpsert) {
  1656. s.SetGroupBlockList(v)
  1657. })
  1658. }
  1659. // UpdateGroupBlockList sets the "group_block_list" field to the value that was provided on create.
  1660. func (u *WxUpsertBulk) UpdateGroupBlockList() *WxUpsertBulk {
  1661. return u.Update(func(s *WxUpsert) {
  1662. s.UpdateGroupBlockList()
  1663. })
  1664. }
  1665. // Exec executes the query.
  1666. func (u *WxUpsertBulk) Exec(ctx context.Context) error {
  1667. if u.create.err != nil {
  1668. return u.create.err
  1669. }
  1670. for i, b := range u.create.builders {
  1671. if len(b.conflict) != 0 {
  1672. return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the WxCreateBulk instead", i)
  1673. }
  1674. }
  1675. if len(u.create.conflict) == 0 {
  1676. return errors.New("ent: missing options for WxCreateBulk.OnConflict")
  1677. }
  1678. return u.create.Exec(ctx)
  1679. }
  1680. // ExecX is like Exec, but panics if an error occurs.
  1681. func (u *WxUpsertBulk) ExecX(ctx context.Context) {
  1682. if err := u.create.Exec(ctx); err != nil {
  1683. panic(err)
  1684. }
  1685. }