addwechatfriendlog_update.go 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793
  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. "wechat-api/ent/predicate"
  9. "entgo.io/ent/dialect/sql"
  10. "entgo.io/ent/dialect/sql/sqlgraph"
  11. "entgo.io/ent/schema/field"
  12. )
  13. // AddWechatFriendLogUpdate is the builder for updating AddWechatFriendLog entities.
  14. type AddWechatFriendLogUpdate struct {
  15. config
  16. hooks []Hook
  17. mutation *AddWechatFriendLogMutation
  18. }
  19. // Where appends a list predicates to the AddWechatFriendLogUpdate builder.
  20. func (awflu *AddWechatFriendLogUpdate) Where(ps ...predicate.AddWechatFriendLog) *AddWechatFriendLogUpdate {
  21. awflu.mutation.Where(ps...)
  22. return awflu
  23. }
  24. // SetOwnerWxID sets the "owner_wx_id" field.
  25. func (awflu *AddWechatFriendLogUpdate) SetOwnerWxID(s string) *AddWechatFriendLogUpdate {
  26. awflu.mutation.SetOwnerWxID(s)
  27. return awflu
  28. }
  29. // SetNillableOwnerWxID sets the "owner_wx_id" field if the given value is not nil.
  30. func (awflu *AddWechatFriendLogUpdate) SetNillableOwnerWxID(s *string) *AddWechatFriendLogUpdate {
  31. if s != nil {
  32. awflu.SetOwnerWxID(*s)
  33. }
  34. return awflu
  35. }
  36. // SetOwnerWxType sets the "owner_wx_type" field.
  37. func (awflu *AddWechatFriendLogUpdate) SetOwnerWxType(i int) *AddWechatFriendLogUpdate {
  38. awflu.mutation.ResetOwnerWxType()
  39. awflu.mutation.SetOwnerWxType(i)
  40. return awflu
  41. }
  42. // SetNillableOwnerWxType sets the "owner_wx_type" field if the given value is not nil.
  43. func (awflu *AddWechatFriendLogUpdate) SetNillableOwnerWxType(i *int) *AddWechatFriendLogUpdate {
  44. if i != nil {
  45. awflu.SetOwnerWxType(*i)
  46. }
  47. return awflu
  48. }
  49. // AddOwnerWxType adds i to the "owner_wx_type" field.
  50. func (awflu *AddWechatFriendLogUpdate) AddOwnerWxType(i int) *AddWechatFriendLogUpdate {
  51. awflu.mutation.AddOwnerWxType(i)
  52. return awflu
  53. }
  54. // SetFindContent sets the "find_content" field.
  55. func (awflu *AddWechatFriendLogUpdate) SetFindContent(s string) *AddWechatFriendLogUpdate {
  56. awflu.mutation.SetFindContent(s)
  57. return awflu
  58. }
  59. // SetNillableFindContent sets the "find_content" field if the given value is not nil.
  60. func (awflu *AddWechatFriendLogUpdate) SetNillableFindContent(s *string) *AddWechatFriendLogUpdate {
  61. if s != nil {
  62. awflu.SetFindContent(*s)
  63. }
  64. return awflu
  65. }
  66. // SetMessage sets the "message" field.
  67. func (awflu *AddWechatFriendLogUpdate) SetMessage(s string) *AddWechatFriendLogUpdate {
  68. awflu.mutation.SetMessage(s)
  69. return awflu
  70. }
  71. // SetNillableMessage sets the "message" field if the given value is not nil.
  72. func (awflu *AddWechatFriendLogUpdate) SetNillableMessage(s *string) *AddWechatFriendLogUpdate {
  73. if s != nil {
  74. awflu.SetMessage(*s)
  75. }
  76. return awflu
  77. }
  78. // SetFindRequest sets the "find_request" field.
  79. func (awflu *AddWechatFriendLogUpdate) SetFindRequest(m map[string]interface{}) *AddWechatFriendLogUpdate {
  80. awflu.mutation.SetFindRequest(m)
  81. return awflu
  82. }
  83. // ClearFindRequest clears the value of the "find_request" field.
  84. func (awflu *AddWechatFriendLogUpdate) ClearFindRequest() *AddWechatFriendLogUpdate {
  85. awflu.mutation.ClearFindRequest()
  86. return awflu
  87. }
  88. // SetFindResult sets the "find_result" field.
  89. func (awflu *AddWechatFriendLogUpdate) SetFindResult(m map[string]interface{}) *AddWechatFriendLogUpdate {
  90. awflu.mutation.SetFindResult(m)
  91. return awflu
  92. }
  93. // ClearFindResult clears the value of the "find_result" field.
  94. func (awflu *AddWechatFriendLogUpdate) ClearFindResult() *AddWechatFriendLogUpdate {
  95. awflu.mutation.ClearFindResult()
  96. return awflu
  97. }
  98. // SetIsCanAdd sets the "is_can_add" field.
  99. func (awflu *AddWechatFriendLogUpdate) SetIsCanAdd(i int) *AddWechatFriendLogUpdate {
  100. awflu.mutation.ResetIsCanAdd()
  101. awflu.mutation.SetIsCanAdd(i)
  102. return awflu
  103. }
  104. // SetNillableIsCanAdd sets the "is_can_add" field if the given value is not nil.
  105. func (awflu *AddWechatFriendLogUpdate) SetNillableIsCanAdd(i *int) *AddWechatFriendLogUpdate {
  106. if i != nil {
  107. awflu.SetIsCanAdd(*i)
  108. }
  109. return awflu
  110. }
  111. // AddIsCanAdd adds i to the "is_can_add" field.
  112. func (awflu *AddWechatFriendLogUpdate) AddIsCanAdd(i int) *AddWechatFriendLogUpdate {
  113. awflu.mutation.AddIsCanAdd(i)
  114. return awflu
  115. }
  116. // SetTaskCount sets the "task_count" field.
  117. func (awflu *AddWechatFriendLogUpdate) SetTaskCount(i int) *AddWechatFriendLogUpdate {
  118. awflu.mutation.ResetTaskCount()
  119. awflu.mutation.SetTaskCount(i)
  120. return awflu
  121. }
  122. // SetNillableTaskCount sets the "task_count" field if the given value is not nil.
  123. func (awflu *AddWechatFriendLogUpdate) SetNillableTaskCount(i *int) *AddWechatFriendLogUpdate {
  124. if i != nil {
  125. awflu.SetTaskCount(*i)
  126. }
  127. return awflu
  128. }
  129. // AddTaskCount adds i to the "task_count" field.
  130. func (awflu *AddWechatFriendLogUpdate) AddTaskCount(i int) *AddWechatFriendLogUpdate {
  131. awflu.mutation.AddTaskCount(i)
  132. return awflu
  133. }
  134. // SetTaskID sets the "task_id" field.
  135. func (awflu *AddWechatFriendLogUpdate) SetTaskID(i int64) *AddWechatFriendLogUpdate {
  136. awflu.mutation.ResetTaskID()
  137. awflu.mutation.SetTaskID(i)
  138. return awflu
  139. }
  140. // SetNillableTaskID sets the "task_id" field if the given value is not nil.
  141. func (awflu *AddWechatFriendLogUpdate) SetNillableTaskID(i *int64) *AddWechatFriendLogUpdate {
  142. if i != nil {
  143. awflu.SetTaskID(*i)
  144. }
  145. return awflu
  146. }
  147. // AddTaskID adds i to the "task_id" field.
  148. func (awflu *AddWechatFriendLogUpdate) AddTaskID(i int64) *AddWechatFriendLogUpdate {
  149. awflu.mutation.AddTaskID(i)
  150. return awflu
  151. }
  152. // SetAddRequest sets the "add_request" field.
  153. func (awflu *AddWechatFriendLogUpdate) SetAddRequest(m map[string]interface{}) *AddWechatFriendLogUpdate {
  154. awflu.mutation.SetAddRequest(m)
  155. return awflu
  156. }
  157. // ClearAddRequest clears the value of the "add_request" field.
  158. func (awflu *AddWechatFriendLogUpdate) ClearAddRequest() *AddWechatFriendLogUpdate {
  159. awflu.mutation.ClearAddRequest()
  160. return awflu
  161. }
  162. // SetAddResult sets the "add_result" field.
  163. func (awflu *AddWechatFriendLogUpdate) SetAddResult(m map[string]interface{}) *AddWechatFriendLogUpdate {
  164. awflu.mutation.SetAddResult(m)
  165. return awflu
  166. }
  167. // ClearAddResult clears the value of the "add_result" field.
  168. func (awflu *AddWechatFriendLogUpdate) ClearAddResult() *AddWechatFriendLogUpdate {
  169. awflu.mutation.ClearAddResult()
  170. return awflu
  171. }
  172. // SetCreatedAt sets the "created_at" field.
  173. func (awflu *AddWechatFriendLogUpdate) SetCreatedAt(i int64) *AddWechatFriendLogUpdate {
  174. awflu.mutation.ResetCreatedAt()
  175. awflu.mutation.SetCreatedAt(i)
  176. return awflu
  177. }
  178. // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
  179. func (awflu *AddWechatFriendLogUpdate) SetNillableCreatedAt(i *int64) *AddWechatFriendLogUpdate {
  180. if i != nil {
  181. awflu.SetCreatedAt(*i)
  182. }
  183. return awflu
  184. }
  185. // AddCreatedAt adds i to the "created_at" field.
  186. func (awflu *AddWechatFriendLogUpdate) AddCreatedAt(i int64) *AddWechatFriendLogUpdate {
  187. awflu.mutation.AddCreatedAt(i)
  188. return awflu
  189. }
  190. // SetUpdatedAt sets the "updated_at" field.
  191. func (awflu *AddWechatFriendLogUpdate) SetUpdatedAt(i int64) *AddWechatFriendLogUpdate {
  192. awflu.mutation.ResetUpdatedAt()
  193. awflu.mutation.SetUpdatedAt(i)
  194. return awflu
  195. }
  196. // AddUpdatedAt adds i to the "updated_at" field.
  197. func (awflu *AddWechatFriendLogUpdate) AddUpdatedAt(i int64) *AddWechatFriendLogUpdate {
  198. awflu.mutation.AddUpdatedAt(i)
  199. return awflu
  200. }
  201. // Mutation returns the AddWechatFriendLogMutation object of the builder.
  202. func (awflu *AddWechatFriendLogUpdate) Mutation() *AddWechatFriendLogMutation {
  203. return awflu.mutation
  204. }
  205. // Save executes the query and returns the number of nodes affected by the update operation.
  206. func (awflu *AddWechatFriendLogUpdate) Save(ctx context.Context) (int, error) {
  207. awflu.defaults()
  208. return withHooks(ctx, awflu.sqlSave, awflu.mutation, awflu.hooks)
  209. }
  210. // SaveX is like Save, but panics if an error occurs.
  211. func (awflu *AddWechatFriendLogUpdate) SaveX(ctx context.Context) int {
  212. affected, err := awflu.Save(ctx)
  213. if err != nil {
  214. panic(err)
  215. }
  216. return affected
  217. }
  218. // Exec executes the query.
  219. func (awflu *AddWechatFriendLogUpdate) Exec(ctx context.Context) error {
  220. _, err := awflu.Save(ctx)
  221. return err
  222. }
  223. // ExecX is like Exec, but panics if an error occurs.
  224. func (awflu *AddWechatFriendLogUpdate) ExecX(ctx context.Context) {
  225. if err := awflu.Exec(ctx); err != nil {
  226. panic(err)
  227. }
  228. }
  229. // defaults sets the default values of the builder before save.
  230. func (awflu *AddWechatFriendLogUpdate) defaults() {
  231. if _, ok := awflu.mutation.UpdatedAt(); !ok {
  232. v := addwechatfriendlog.UpdateDefaultUpdatedAt()
  233. awflu.mutation.SetUpdatedAt(v)
  234. }
  235. }
  236. // check runs all checks and user-defined validators on the builder.
  237. func (awflu *AddWechatFriendLogUpdate) check() error {
  238. if v, ok := awflu.mutation.OwnerWxID(); ok {
  239. if err := addwechatfriendlog.OwnerWxIDValidator(v); err != nil {
  240. return &ValidationError{Name: "owner_wx_id", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.owner_wx_id": %w`, err)}
  241. }
  242. }
  243. if v, ok := awflu.mutation.FindContent(); ok {
  244. if err := addwechatfriendlog.FindContentValidator(v); err != nil {
  245. return &ValidationError{Name: "find_content", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.find_content": %w`, err)}
  246. }
  247. }
  248. if v, ok := awflu.mutation.Message(); ok {
  249. if err := addwechatfriendlog.MessageValidator(v); err != nil {
  250. return &ValidationError{Name: "message", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.message": %w`, err)}
  251. }
  252. }
  253. return nil
  254. }
  255. func (awflu *AddWechatFriendLogUpdate) sqlSave(ctx context.Context) (n int, err error) {
  256. if err := awflu.check(); err != nil {
  257. return n, err
  258. }
  259. _spec := sqlgraph.NewUpdateSpec(addwechatfriendlog.Table, addwechatfriendlog.Columns, sqlgraph.NewFieldSpec(addwechatfriendlog.FieldID, field.TypeInt64))
  260. if ps := awflu.mutation.predicates; len(ps) > 0 {
  261. _spec.Predicate = func(selector *sql.Selector) {
  262. for i := range ps {
  263. ps[i](selector)
  264. }
  265. }
  266. }
  267. if value, ok := awflu.mutation.OwnerWxID(); ok {
  268. _spec.SetField(addwechatfriendlog.FieldOwnerWxID, field.TypeString, value)
  269. }
  270. if value, ok := awflu.mutation.OwnerWxType(); ok {
  271. _spec.SetField(addwechatfriendlog.FieldOwnerWxType, field.TypeInt, value)
  272. }
  273. if value, ok := awflu.mutation.AddedOwnerWxType(); ok {
  274. _spec.AddField(addwechatfriendlog.FieldOwnerWxType, field.TypeInt, value)
  275. }
  276. if value, ok := awflu.mutation.FindContent(); ok {
  277. _spec.SetField(addwechatfriendlog.FieldFindContent, field.TypeString, value)
  278. }
  279. if value, ok := awflu.mutation.Message(); ok {
  280. _spec.SetField(addwechatfriendlog.FieldMessage, field.TypeString, value)
  281. }
  282. if value, ok := awflu.mutation.FindRequest(); ok {
  283. _spec.SetField(addwechatfriendlog.FieldFindRequest, field.TypeJSON, value)
  284. }
  285. if awflu.mutation.FindRequestCleared() {
  286. _spec.ClearField(addwechatfriendlog.FieldFindRequest, field.TypeJSON)
  287. }
  288. if value, ok := awflu.mutation.FindResult(); ok {
  289. _spec.SetField(addwechatfriendlog.FieldFindResult, field.TypeJSON, value)
  290. }
  291. if awflu.mutation.FindResultCleared() {
  292. _spec.ClearField(addwechatfriendlog.FieldFindResult, field.TypeJSON)
  293. }
  294. if value, ok := awflu.mutation.IsCanAdd(); ok {
  295. _spec.SetField(addwechatfriendlog.FieldIsCanAdd, field.TypeInt, value)
  296. }
  297. if value, ok := awflu.mutation.AddedIsCanAdd(); ok {
  298. _spec.AddField(addwechatfriendlog.FieldIsCanAdd, field.TypeInt, value)
  299. }
  300. if value, ok := awflu.mutation.TaskCount(); ok {
  301. _spec.SetField(addwechatfriendlog.FieldTaskCount, field.TypeInt, value)
  302. }
  303. if value, ok := awflu.mutation.AddedTaskCount(); ok {
  304. _spec.AddField(addwechatfriendlog.FieldTaskCount, field.TypeInt, value)
  305. }
  306. if value, ok := awflu.mutation.TaskID(); ok {
  307. _spec.SetField(addwechatfriendlog.FieldTaskID, field.TypeInt64, value)
  308. }
  309. if value, ok := awflu.mutation.AddedTaskID(); ok {
  310. _spec.AddField(addwechatfriendlog.FieldTaskID, field.TypeInt64, value)
  311. }
  312. if value, ok := awflu.mutation.AddRequest(); ok {
  313. _spec.SetField(addwechatfriendlog.FieldAddRequest, field.TypeJSON, value)
  314. }
  315. if awflu.mutation.AddRequestCleared() {
  316. _spec.ClearField(addwechatfriendlog.FieldAddRequest, field.TypeJSON)
  317. }
  318. if value, ok := awflu.mutation.AddResult(); ok {
  319. _spec.SetField(addwechatfriendlog.FieldAddResult, field.TypeJSON, value)
  320. }
  321. if awflu.mutation.AddResultCleared() {
  322. _spec.ClearField(addwechatfriendlog.FieldAddResult, field.TypeJSON)
  323. }
  324. if value, ok := awflu.mutation.CreatedAt(); ok {
  325. _spec.SetField(addwechatfriendlog.FieldCreatedAt, field.TypeInt64, value)
  326. }
  327. if value, ok := awflu.mutation.AddedCreatedAt(); ok {
  328. _spec.AddField(addwechatfriendlog.FieldCreatedAt, field.TypeInt64, value)
  329. }
  330. if value, ok := awflu.mutation.UpdatedAt(); ok {
  331. _spec.SetField(addwechatfriendlog.FieldUpdatedAt, field.TypeInt64, value)
  332. }
  333. if value, ok := awflu.mutation.AddedUpdatedAt(); ok {
  334. _spec.AddField(addwechatfriendlog.FieldUpdatedAt, field.TypeInt64, value)
  335. }
  336. if n, err = sqlgraph.UpdateNodes(ctx, awflu.driver, _spec); err != nil {
  337. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  338. err = &NotFoundError{addwechatfriendlog.Label}
  339. } else if sqlgraph.IsConstraintError(err) {
  340. err = &ConstraintError{msg: err.Error(), wrap: err}
  341. }
  342. return 0, err
  343. }
  344. awflu.mutation.done = true
  345. return n, nil
  346. }
  347. // AddWechatFriendLogUpdateOne is the builder for updating a single AddWechatFriendLog entity.
  348. type AddWechatFriendLogUpdateOne struct {
  349. config
  350. fields []string
  351. hooks []Hook
  352. mutation *AddWechatFriendLogMutation
  353. }
  354. // SetOwnerWxID sets the "owner_wx_id" field.
  355. func (awfluo *AddWechatFriendLogUpdateOne) SetOwnerWxID(s string) *AddWechatFriendLogUpdateOne {
  356. awfluo.mutation.SetOwnerWxID(s)
  357. return awfluo
  358. }
  359. // SetNillableOwnerWxID sets the "owner_wx_id" field if the given value is not nil.
  360. func (awfluo *AddWechatFriendLogUpdateOne) SetNillableOwnerWxID(s *string) *AddWechatFriendLogUpdateOne {
  361. if s != nil {
  362. awfluo.SetOwnerWxID(*s)
  363. }
  364. return awfluo
  365. }
  366. // SetOwnerWxType sets the "owner_wx_type" field.
  367. func (awfluo *AddWechatFriendLogUpdateOne) SetOwnerWxType(i int) *AddWechatFriendLogUpdateOne {
  368. awfluo.mutation.ResetOwnerWxType()
  369. awfluo.mutation.SetOwnerWxType(i)
  370. return awfluo
  371. }
  372. // SetNillableOwnerWxType sets the "owner_wx_type" field if the given value is not nil.
  373. func (awfluo *AddWechatFriendLogUpdateOne) SetNillableOwnerWxType(i *int) *AddWechatFriendLogUpdateOne {
  374. if i != nil {
  375. awfluo.SetOwnerWxType(*i)
  376. }
  377. return awfluo
  378. }
  379. // AddOwnerWxType adds i to the "owner_wx_type" field.
  380. func (awfluo *AddWechatFriendLogUpdateOne) AddOwnerWxType(i int) *AddWechatFriendLogUpdateOne {
  381. awfluo.mutation.AddOwnerWxType(i)
  382. return awfluo
  383. }
  384. // SetFindContent sets the "find_content" field.
  385. func (awfluo *AddWechatFriendLogUpdateOne) SetFindContent(s string) *AddWechatFriendLogUpdateOne {
  386. awfluo.mutation.SetFindContent(s)
  387. return awfluo
  388. }
  389. // SetNillableFindContent sets the "find_content" field if the given value is not nil.
  390. func (awfluo *AddWechatFriendLogUpdateOne) SetNillableFindContent(s *string) *AddWechatFriendLogUpdateOne {
  391. if s != nil {
  392. awfluo.SetFindContent(*s)
  393. }
  394. return awfluo
  395. }
  396. // SetMessage sets the "message" field.
  397. func (awfluo *AddWechatFriendLogUpdateOne) SetMessage(s string) *AddWechatFriendLogUpdateOne {
  398. awfluo.mutation.SetMessage(s)
  399. return awfluo
  400. }
  401. // SetNillableMessage sets the "message" field if the given value is not nil.
  402. func (awfluo *AddWechatFriendLogUpdateOne) SetNillableMessage(s *string) *AddWechatFriendLogUpdateOne {
  403. if s != nil {
  404. awfluo.SetMessage(*s)
  405. }
  406. return awfluo
  407. }
  408. // SetFindRequest sets the "find_request" field.
  409. func (awfluo *AddWechatFriendLogUpdateOne) SetFindRequest(m map[string]interface{}) *AddWechatFriendLogUpdateOne {
  410. awfluo.mutation.SetFindRequest(m)
  411. return awfluo
  412. }
  413. // ClearFindRequest clears the value of the "find_request" field.
  414. func (awfluo *AddWechatFriendLogUpdateOne) ClearFindRequest() *AddWechatFriendLogUpdateOne {
  415. awfluo.mutation.ClearFindRequest()
  416. return awfluo
  417. }
  418. // SetFindResult sets the "find_result" field.
  419. func (awfluo *AddWechatFriendLogUpdateOne) SetFindResult(m map[string]interface{}) *AddWechatFriendLogUpdateOne {
  420. awfluo.mutation.SetFindResult(m)
  421. return awfluo
  422. }
  423. // ClearFindResult clears the value of the "find_result" field.
  424. func (awfluo *AddWechatFriendLogUpdateOne) ClearFindResult() *AddWechatFriendLogUpdateOne {
  425. awfluo.mutation.ClearFindResult()
  426. return awfluo
  427. }
  428. // SetIsCanAdd sets the "is_can_add" field.
  429. func (awfluo *AddWechatFriendLogUpdateOne) SetIsCanAdd(i int) *AddWechatFriendLogUpdateOne {
  430. awfluo.mutation.ResetIsCanAdd()
  431. awfluo.mutation.SetIsCanAdd(i)
  432. return awfluo
  433. }
  434. // SetNillableIsCanAdd sets the "is_can_add" field if the given value is not nil.
  435. func (awfluo *AddWechatFriendLogUpdateOne) SetNillableIsCanAdd(i *int) *AddWechatFriendLogUpdateOne {
  436. if i != nil {
  437. awfluo.SetIsCanAdd(*i)
  438. }
  439. return awfluo
  440. }
  441. // AddIsCanAdd adds i to the "is_can_add" field.
  442. func (awfluo *AddWechatFriendLogUpdateOne) AddIsCanAdd(i int) *AddWechatFriendLogUpdateOne {
  443. awfluo.mutation.AddIsCanAdd(i)
  444. return awfluo
  445. }
  446. // SetTaskCount sets the "task_count" field.
  447. func (awfluo *AddWechatFriendLogUpdateOne) SetTaskCount(i int) *AddWechatFriendLogUpdateOne {
  448. awfluo.mutation.ResetTaskCount()
  449. awfluo.mutation.SetTaskCount(i)
  450. return awfluo
  451. }
  452. // SetNillableTaskCount sets the "task_count" field if the given value is not nil.
  453. func (awfluo *AddWechatFriendLogUpdateOne) SetNillableTaskCount(i *int) *AddWechatFriendLogUpdateOne {
  454. if i != nil {
  455. awfluo.SetTaskCount(*i)
  456. }
  457. return awfluo
  458. }
  459. // AddTaskCount adds i to the "task_count" field.
  460. func (awfluo *AddWechatFriendLogUpdateOne) AddTaskCount(i int) *AddWechatFriendLogUpdateOne {
  461. awfluo.mutation.AddTaskCount(i)
  462. return awfluo
  463. }
  464. // SetTaskID sets the "task_id" field.
  465. func (awfluo *AddWechatFriendLogUpdateOne) SetTaskID(i int64) *AddWechatFriendLogUpdateOne {
  466. awfluo.mutation.ResetTaskID()
  467. awfluo.mutation.SetTaskID(i)
  468. return awfluo
  469. }
  470. // SetNillableTaskID sets the "task_id" field if the given value is not nil.
  471. func (awfluo *AddWechatFriendLogUpdateOne) SetNillableTaskID(i *int64) *AddWechatFriendLogUpdateOne {
  472. if i != nil {
  473. awfluo.SetTaskID(*i)
  474. }
  475. return awfluo
  476. }
  477. // AddTaskID adds i to the "task_id" field.
  478. func (awfluo *AddWechatFriendLogUpdateOne) AddTaskID(i int64) *AddWechatFriendLogUpdateOne {
  479. awfluo.mutation.AddTaskID(i)
  480. return awfluo
  481. }
  482. // SetAddRequest sets the "add_request" field.
  483. func (awfluo *AddWechatFriendLogUpdateOne) SetAddRequest(m map[string]interface{}) *AddWechatFriendLogUpdateOne {
  484. awfluo.mutation.SetAddRequest(m)
  485. return awfluo
  486. }
  487. // ClearAddRequest clears the value of the "add_request" field.
  488. func (awfluo *AddWechatFriendLogUpdateOne) ClearAddRequest() *AddWechatFriendLogUpdateOne {
  489. awfluo.mutation.ClearAddRequest()
  490. return awfluo
  491. }
  492. // SetAddResult sets the "add_result" field.
  493. func (awfluo *AddWechatFriendLogUpdateOne) SetAddResult(m map[string]interface{}) *AddWechatFriendLogUpdateOne {
  494. awfluo.mutation.SetAddResult(m)
  495. return awfluo
  496. }
  497. // ClearAddResult clears the value of the "add_result" field.
  498. func (awfluo *AddWechatFriendLogUpdateOne) ClearAddResult() *AddWechatFriendLogUpdateOne {
  499. awfluo.mutation.ClearAddResult()
  500. return awfluo
  501. }
  502. // SetCreatedAt sets the "created_at" field.
  503. func (awfluo *AddWechatFriendLogUpdateOne) SetCreatedAt(i int64) *AddWechatFriendLogUpdateOne {
  504. awfluo.mutation.ResetCreatedAt()
  505. awfluo.mutation.SetCreatedAt(i)
  506. return awfluo
  507. }
  508. // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
  509. func (awfluo *AddWechatFriendLogUpdateOne) SetNillableCreatedAt(i *int64) *AddWechatFriendLogUpdateOne {
  510. if i != nil {
  511. awfluo.SetCreatedAt(*i)
  512. }
  513. return awfluo
  514. }
  515. // AddCreatedAt adds i to the "created_at" field.
  516. func (awfluo *AddWechatFriendLogUpdateOne) AddCreatedAt(i int64) *AddWechatFriendLogUpdateOne {
  517. awfluo.mutation.AddCreatedAt(i)
  518. return awfluo
  519. }
  520. // SetUpdatedAt sets the "updated_at" field.
  521. func (awfluo *AddWechatFriendLogUpdateOne) SetUpdatedAt(i int64) *AddWechatFriendLogUpdateOne {
  522. awfluo.mutation.ResetUpdatedAt()
  523. awfluo.mutation.SetUpdatedAt(i)
  524. return awfluo
  525. }
  526. // AddUpdatedAt adds i to the "updated_at" field.
  527. func (awfluo *AddWechatFriendLogUpdateOne) AddUpdatedAt(i int64) *AddWechatFriendLogUpdateOne {
  528. awfluo.mutation.AddUpdatedAt(i)
  529. return awfluo
  530. }
  531. // Mutation returns the AddWechatFriendLogMutation object of the builder.
  532. func (awfluo *AddWechatFriendLogUpdateOne) Mutation() *AddWechatFriendLogMutation {
  533. return awfluo.mutation
  534. }
  535. // Where appends a list predicates to the AddWechatFriendLogUpdate builder.
  536. func (awfluo *AddWechatFriendLogUpdateOne) Where(ps ...predicate.AddWechatFriendLog) *AddWechatFriendLogUpdateOne {
  537. awfluo.mutation.Where(ps...)
  538. return awfluo
  539. }
  540. // Select allows selecting one or more fields (columns) of the returned entity.
  541. // The default is selecting all fields defined in the entity schema.
  542. func (awfluo *AddWechatFriendLogUpdateOne) Select(field string, fields ...string) *AddWechatFriendLogUpdateOne {
  543. awfluo.fields = append([]string{field}, fields...)
  544. return awfluo
  545. }
  546. // Save executes the query and returns the updated AddWechatFriendLog entity.
  547. func (awfluo *AddWechatFriendLogUpdateOne) Save(ctx context.Context) (*AddWechatFriendLog, error) {
  548. awfluo.defaults()
  549. return withHooks(ctx, awfluo.sqlSave, awfluo.mutation, awfluo.hooks)
  550. }
  551. // SaveX is like Save, but panics if an error occurs.
  552. func (awfluo *AddWechatFriendLogUpdateOne) SaveX(ctx context.Context) *AddWechatFriendLog {
  553. node, err := awfluo.Save(ctx)
  554. if err != nil {
  555. panic(err)
  556. }
  557. return node
  558. }
  559. // Exec executes the query on the entity.
  560. func (awfluo *AddWechatFriendLogUpdateOne) Exec(ctx context.Context) error {
  561. _, err := awfluo.Save(ctx)
  562. return err
  563. }
  564. // ExecX is like Exec, but panics if an error occurs.
  565. func (awfluo *AddWechatFriendLogUpdateOne) ExecX(ctx context.Context) {
  566. if err := awfluo.Exec(ctx); err != nil {
  567. panic(err)
  568. }
  569. }
  570. // defaults sets the default values of the builder before save.
  571. func (awfluo *AddWechatFriendLogUpdateOne) defaults() {
  572. if _, ok := awfluo.mutation.UpdatedAt(); !ok {
  573. v := addwechatfriendlog.UpdateDefaultUpdatedAt()
  574. awfluo.mutation.SetUpdatedAt(v)
  575. }
  576. }
  577. // check runs all checks and user-defined validators on the builder.
  578. func (awfluo *AddWechatFriendLogUpdateOne) check() error {
  579. if v, ok := awfluo.mutation.OwnerWxID(); ok {
  580. if err := addwechatfriendlog.OwnerWxIDValidator(v); err != nil {
  581. return &ValidationError{Name: "owner_wx_id", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.owner_wx_id": %w`, err)}
  582. }
  583. }
  584. if v, ok := awfluo.mutation.FindContent(); ok {
  585. if err := addwechatfriendlog.FindContentValidator(v); err != nil {
  586. return &ValidationError{Name: "find_content", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.find_content": %w`, err)}
  587. }
  588. }
  589. if v, ok := awfluo.mutation.Message(); ok {
  590. if err := addwechatfriendlog.MessageValidator(v); err != nil {
  591. return &ValidationError{Name: "message", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.message": %w`, err)}
  592. }
  593. }
  594. return nil
  595. }
  596. func (awfluo *AddWechatFriendLogUpdateOne) sqlSave(ctx context.Context) (_node *AddWechatFriendLog, err error) {
  597. if err := awfluo.check(); err != nil {
  598. return _node, err
  599. }
  600. _spec := sqlgraph.NewUpdateSpec(addwechatfriendlog.Table, addwechatfriendlog.Columns, sqlgraph.NewFieldSpec(addwechatfriendlog.FieldID, field.TypeInt64))
  601. id, ok := awfluo.mutation.ID()
  602. if !ok {
  603. return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "AddWechatFriendLog.id" for update`)}
  604. }
  605. _spec.Node.ID.Value = id
  606. if fields := awfluo.fields; len(fields) > 0 {
  607. _spec.Node.Columns = make([]string, 0, len(fields))
  608. _spec.Node.Columns = append(_spec.Node.Columns, addwechatfriendlog.FieldID)
  609. for _, f := range fields {
  610. if !addwechatfriendlog.ValidColumn(f) {
  611. return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
  612. }
  613. if f != addwechatfriendlog.FieldID {
  614. _spec.Node.Columns = append(_spec.Node.Columns, f)
  615. }
  616. }
  617. }
  618. if ps := awfluo.mutation.predicates; len(ps) > 0 {
  619. _spec.Predicate = func(selector *sql.Selector) {
  620. for i := range ps {
  621. ps[i](selector)
  622. }
  623. }
  624. }
  625. if value, ok := awfluo.mutation.OwnerWxID(); ok {
  626. _spec.SetField(addwechatfriendlog.FieldOwnerWxID, field.TypeString, value)
  627. }
  628. if value, ok := awfluo.mutation.OwnerWxType(); ok {
  629. _spec.SetField(addwechatfriendlog.FieldOwnerWxType, field.TypeInt, value)
  630. }
  631. if value, ok := awfluo.mutation.AddedOwnerWxType(); ok {
  632. _spec.AddField(addwechatfriendlog.FieldOwnerWxType, field.TypeInt, value)
  633. }
  634. if value, ok := awfluo.mutation.FindContent(); ok {
  635. _spec.SetField(addwechatfriendlog.FieldFindContent, field.TypeString, value)
  636. }
  637. if value, ok := awfluo.mutation.Message(); ok {
  638. _spec.SetField(addwechatfriendlog.FieldMessage, field.TypeString, value)
  639. }
  640. if value, ok := awfluo.mutation.FindRequest(); ok {
  641. _spec.SetField(addwechatfriendlog.FieldFindRequest, field.TypeJSON, value)
  642. }
  643. if awfluo.mutation.FindRequestCleared() {
  644. _spec.ClearField(addwechatfriendlog.FieldFindRequest, field.TypeJSON)
  645. }
  646. if value, ok := awfluo.mutation.FindResult(); ok {
  647. _spec.SetField(addwechatfriendlog.FieldFindResult, field.TypeJSON, value)
  648. }
  649. if awfluo.mutation.FindResultCleared() {
  650. _spec.ClearField(addwechatfriendlog.FieldFindResult, field.TypeJSON)
  651. }
  652. if value, ok := awfluo.mutation.IsCanAdd(); ok {
  653. _spec.SetField(addwechatfriendlog.FieldIsCanAdd, field.TypeInt, value)
  654. }
  655. if value, ok := awfluo.mutation.AddedIsCanAdd(); ok {
  656. _spec.AddField(addwechatfriendlog.FieldIsCanAdd, field.TypeInt, value)
  657. }
  658. if value, ok := awfluo.mutation.TaskCount(); ok {
  659. _spec.SetField(addwechatfriendlog.FieldTaskCount, field.TypeInt, value)
  660. }
  661. if value, ok := awfluo.mutation.AddedTaskCount(); ok {
  662. _spec.AddField(addwechatfriendlog.FieldTaskCount, field.TypeInt, value)
  663. }
  664. if value, ok := awfluo.mutation.TaskID(); ok {
  665. _spec.SetField(addwechatfriendlog.FieldTaskID, field.TypeInt64, value)
  666. }
  667. if value, ok := awfluo.mutation.AddedTaskID(); ok {
  668. _spec.AddField(addwechatfriendlog.FieldTaskID, field.TypeInt64, value)
  669. }
  670. if value, ok := awfluo.mutation.AddRequest(); ok {
  671. _spec.SetField(addwechatfriendlog.FieldAddRequest, field.TypeJSON, value)
  672. }
  673. if awfluo.mutation.AddRequestCleared() {
  674. _spec.ClearField(addwechatfriendlog.FieldAddRequest, field.TypeJSON)
  675. }
  676. if value, ok := awfluo.mutation.AddResult(); ok {
  677. _spec.SetField(addwechatfriendlog.FieldAddResult, field.TypeJSON, value)
  678. }
  679. if awfluo.mutation.AddResultCleared() {
  680. _spec.ClearField(addwechatfriendlog.FieldAddResult, field.TypeJSON)
  681. }
  682. if value, ok := awfluo.mutation.CreatedAt(); ok {
  683. _spec.SetField(addwechatfriendlog.FieldCreatedAt, field.TypeInt64, value)
  684. }
  685. if value, ok := awfluo.mutation.AddedCreatedAt(); ok {
  686. _spec.AddField(addwechatfriendlog.FieldCreatedAt, field.TypeInt64, value)
  687. }
  688. if value, ok := awfluo.mutation.UpdatedAt(); ok {
  689. _spec.SetField(addwechatfriendlog.FieldUpdatedAt, field.TypeInt64, value)
  690. }
  691. if value, ok := awfluo.mutation.AddedUpdatedAt(); ok {
  692. _spec.AddField(addwechatfriendlog.FieldUpdatedAt, field.TypeInt64, value)
  693. }
  694. _node = &AddWechatFriendLog{config: awfluo.config}
  695. _spec.Assign = _node.assignValues
  696. _spec.ScanValues = _node.scanValues
  697. if err = sqlgraph.UpdateNode(ctx, awfluo.driver, _spec); err != nil {
  698. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  699. err = &NotFoundError{addwechatfriendlog.Label}
  700. } else if sqlgraph.IsConstraintError(err) {
  701. err = &ConstraintError{msg: err.Error(), wrap: err}
  702. }
  703. return nil, err
  704. }
  705. awfluo.mutation.done = true
  706. return _node, nil
  707. }