addwechatfriendlog_create.go 47 KB

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