addwechatfriendlog_create.go 42 KB

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