addwechatfriendlog_create.go 58 KB

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