aliyunavatar_create.go 36 KB

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