xunjiservice_create.go 35 KB

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