addwechatfriendlog_create.go 44 KB

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