wx_create.go 53 KB

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