addwechatfriendlog_update.go 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061
  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. // SetSource sets the "source" field.
  202. func (awflu *AddWechatFriendLogUpdate) SetSource(i int) *AddWechatFriendLogUpdate {
  203. awflu.mutation.ResetSource()
  204. awflu.mutation.SetSource(i)
  205. return awflu
  206. }
  207. // SetNillableSource sets the "source" field if the given value is not nil.
  208. func (awflu *AddWechatFriendLogUpdate) SetNillableSource(i *int) *AddWechatFriendLogUpdate {
  209. if i != nil {
  210. awflu.SetSource(*i)
  211. }
  212. return awflu
  213. }
  214. // AddSource adds i to the "source" field.
  215. func (awflu *AddWechatFriendLogUpdate) AddSource(i int) *AddWechatFriendLogUpdate {
  216. awflu.mutation.AddSource(i)
  217. return awflu
  218. }
  219. // ClearSource clears the value of the "source" field.
  220. func (awflu *AddWechatFriendLogUpdate) ClearSource() *AddWechatFriendLogUpdate {
  221. awflu.mutation.ClearSource()
  222. return awflu
  223. }
  224. // SetNickName sets the "nick_name" field.
  225. func (awflu *AddWechatFriendLogUpdate) SetNickName(s string) *AddWechatFriendLogUpdate {
  226. awflu.mutation.SetNickName(s)
  227. return awflu
  228. }
  229. // SetNillableNickName sets the "nick_name" field if the given value is not nil.
  230. func (awflu *AddWechatFriendLogUpdate) SetNillableNickName(s *string) *AddWechatFriendLogUpdate {
  231. if s != nil {
  232. awflu.SetNickName(*s)
  233. }
  234. return awflu
  235. }
  236. // ClearNickName clears the value of the "nick_name" field.
  237. func (awflu *AddWechatFriendLogUpdate) ClearNickName() *AddWechatFriendLogUpdate {
  238. awflu.mutation.ClearNickName()
  239. return awflu
  240. }
  241. // SetAvatar sets the "avatar" field.
  242. func (awflu *AddWechatFriendLogUpdate) SetAvatar(s string) *AddWechatFriendLogUpdate {
  243. awflu.mutation.SetAvatar(s)
  244. return awflu
  245. }
  246. // SetNillableAvatar sets the "avatar" field if the given value is not nil.
  247. func (awflu *AddWechatFriendLogUpdate) SetNillableAvatar(s *string) *AddWechatFriendLogUpdate {
  248. if s != nil {
  249. awflu.SetAvatar(*s)
  250. }
  251. return awflu
  252. }
  253. // ClearAvatar clears the value of the "avatar" field.
  254. func (awflu *AddWechatFriendLogUpdate) ClearAvatar() *AddWechatFriendLogUpdate {
  255. awflu.mutation.ClearAvatar()
  256. return awflu
  257. }
  258. // SetOrganizationID sets the "organization_id" field.
  259. func (awflu *AddWechatFriendLogUpdate) SetOrganizationID(i int64) *AddWechatFriendLogUpdate {
  260. awflu.mutation.ResetOrganizationID()
  261. awflu.mutation.SetOrganizationID(i)
  262. return awflu
  263. }
  264. // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
  265. func (awflu *AddWechatFriendLogUpdate) SetNillableOrganizationID(i *int64) *AddWechatFriendLogUpdate {
  266. if i != nil {
  267. awflu.SetOrganizationID(*i)
  268. }
  269. return awflu
  270. }
  271. // AddOrganizationID adds i to the "organization_id" field.
  272. func (awflu *AddWechatFriendLogUpdate) AddOrganizationID(i int64) *AddWechatFriendLogUpdate {
  273. awflu.mutation.AddOrganizationID(i)
  274. return awflu
  275. }
  276. // ClearOrganizationID clears the value of the "organization_id" field.
  277. func (awflu *AddWechatFriendLogUpdate) ClearOrganizationID() *AddWechatFriendLogUpdate {
  278. awflu.mutation.ClearOrganizationID()
  279. return awflu
  280. }
  281. // Mutation returns the AddWechatFriendLogMutation object of the builder.
  282. func (awflu *AddWechatFriendLogUpdate) Mutation() *AddWechatFriendLogMutation {
  283. return awflu.mutation
  284. }
  285. // Save executes the query and returns the number of nodes affected by the update operation.
  286. func (awflu *AddWechatFriendLogUpdate) Save(ctx context.Context) (int, error) {
  287. awflu.defaults()
  288. return withHooks(ctx, awflu.sqlSave, awflu.mutation, awflu.hooks)
  289. }
  290. // SaveX is like Save, but panics if an error occurs.
  291. func (awflu *AddWechatFriendLogUpdate) SaveX(ctx context.Context) int {
  292. affected, err := awflu.Save(ctx)
  293. if err != nil {
  294. panic(err)
  295. }
  296. return affected
  297. }
  298. // Exec executes the query.
  299. func (awflu *AddWechatFriendLogUpdate) Exec(ctx context.Context) error {
  300. _, err := awflu.Save(ctx)
  301. return err
  302. }
  303. // ExecX is like Exec, but panics if an error occurs.
  304. func (awflu *AddWechatFriendLogUpdate) ExecX(ctx context.Context) {
  305. if err := awflu.Exec(ctx); err != nil {
  306. panic(err)
  307. }
  308. }
  309. // defaults sets the default values of the builder before save.
  310. func (awflu *AddWechatFriendLogUpdate) defaults() {
  311. if _, ok := awflu.mutation.UpdatedAt(); !ok {
  312. v := addwechatfriendlog.UpdateDefaultUpdatedAt()
  313. awflu.mutation.SetUpdatedAt(v)
  314. }
  315. }
  316. // check runs all checks and user-defined validators on the builder.
  317. func (awflu *AddWechatFriendLogUpdate) check() error {
  318. if v, ok := awflu.mutation.OwnerWxID(); ok {
  319. if err := addwechatfriendlog.OwnerWxIDValidator(v); err != nil {
  320. return &ValidationError{Name: "owner_wx_id", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.owner_wx_id": %w`, err)}
  321. }
  322. }
  323. if v, ok := awflu.mutation.FindContent(); ok {
  324. if err := addwechatfriendlog.FindContentValidator(v); err != nil {
  325. return &ValidationError{Name: "find_content", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.find_content": %w`, err)}
  326. }
  327. }
  328. if v, ok := awflu.mutation.Message(); ok {
  329. if err := addwechatfriendlog.MessageValidator(v); err != nil {
  330. return &ValidationError{Name: "message", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.message": %w`, err)}
  331. }
  332. }
  333. if v, ok := awflu.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 v, ok := awflu.mutation.Avatar(); ok {
  339. if err := addwechatfriendlog.AvatarValidator(v); err != nil {
  340. return &ValidationError{Name: "avatar", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.avatar": %w`, err)}
  341. }
  342. }
  343. return nil
  344. }
  345. func (awflu *AddWechatFriendLogUpdate) sqlSave(ctx context.Context) (n int, err error) {
  346. if err := awflu.check(); err != nil {
  347. return n, err
  348. }
  349. _spec := sqlgraph.NewUpdateSpec(addwechatfriendlog.Table, addwechatfriendlog.Columns, sqlgraph.NewFieldSpec(addwechatfriendlog.FieldID, field.TypeInt64))
  350. if ps := awflu.mutation.predicates; len(ps) > 0 {
  351. _spec.Predicate = func(selector *sql.Selector) {
  352. for i := range ps {
  353. ps[i](selector)
  354. }
  355. }
  356. }
  357. if value, ok := awflu.mutation.OwnerWxID(); ok {
  358. _spec.SetField(addwechatfriendlog.FieldOwnerWxID, field.TypeString, value)
  359. }
  360. if value, ok := awflu.mutation.OwnerWxType(); ok {
  361. _spec.SetField(addwechatfriendlog.FieldOwnerWxType, field.TypeInt, value)
  362. }
  363. if value, ok := awflu.mutation.AddedOwnerWxType(); ok {
  364. _spec.AddField(addwechatfriendlog.FieldOwnerWxType, field.TypeInt, value)
  365. }
  366. if value, ok := awflu.mutation.FindContent(); ok {
  367. _spec.SetField(addwechatfriendlog.FieldFindContent, field.TypeString, value)
  368. }
  369. if value, ok := awflu.mutation.Message(); ok {
  370. _spec.SetField(addwechatfriendlog.FieldMessage, field.TypeString, value)
  371. }
  372. if value, ok := awflu.mutation.FindRequest(); ok {
  373. _spec.SetField(addwechatfriendlog.FieldFindRequest, field.TypeJSON, value)
  374. }
  375. if awflu.mutation.FindRequestCleared() {
  376. _spec.ClearField(addwechatfriendlog.FieldFindRequest, field.TypeJSON)
  377. }
  378. if value, ok := awflu.mutation.FindResult(); ok {
  379. _spec.SetField(addwechatfriendlog.FieldFindResult, field.TypeJSON, value)
  380. }
  381. if awflu.mutation.FindResultCleared() {
  382. _spec.ClearField(addwechatfriendlog.FieldFindResult, field.TypeJSON)
  383. }
  384. if value, ok := awflu.mutation.IsCanAdd(); ok {
  385. _spec.SetField(addwechatfriendlog.FieldIsCanAdd, field.TypeInt, value)
  386. }
  387. if value, ok := awflu.mutation.AddedIsCanAdd(); ok {
  388. _spec.AddField(addwechatfriendlog.FieldIsCanAdd, field.TypeInt, value)
  389. }
  390. if value, ok := awflu.mutation.TaskCount(); ok {
  391. _spec.SetField(addwechatfriendlog.FieldTaskCount, field.TypeInt, value)
  392. }
  393. if value, ok := awflu.mutation.AddedTaskCount(); ok {
  394. _spec.AddField(addwechatfriendlog.FieldTaskCount, field.TypeInt, value)
  395. }
  396. if value, ok := awflu.mutation.TaskID(); ok {
  397. _spec.SetField(addwechatfriendlog.FieldTaskID, field.TypeInt64, value)
  398. }
  399. if value, ok := awflu.mutation.AddedTaskID(); ok {
  400. _spec.AddField(addwechatfriendlog.FieldTaskID, field.TypeInt64, value)
  401. }
  402. if value, ok := awflu.mutation.AddRequest(); ok {
  403. _spec.SetField(addwechatfriendlog.FieldAddRequest, field.TypeJSON, value)
  404. }
  405. if awflu.mutation.AddRequestCleared() {
  406. _spec.ClearField(addwechatfriendlog.FieldAddRequest, field.TypeJSON)
  407. }
  408. if value, ok := awflu.mutation.AddResult(); ok {
  409. _spec.SetField(addwechatfriendlog.FieldAddResult, field.TypeJSON, value)
  410. }
  411. if awflu.mutation.AddResultCleared() {
  412. _spec.ClearField(addwechatfriendlog.FieldAddResult, field.TypeJSON)
  413. }
  414. if value, ok := awflu.mutation.CreatedAt(); ok {
  415. _spec.SetField(addwechatfriendlog.FieldCreatedAt, field.TypeInt64, value)
  416. }
  417. if value, ok := awflu.mutation.AddedCreatedAt(); ok {
  418. _spec.AddField(addwechatfriendlog.FieldCreatedAt, field.TypeInt64, value)
  419. }
  420. if value, ok := awflu.mutation.UpdatedAt(); ok {
  421. _spec.SetField(addwechatfriendlog.FieldUpdatedAt, field.TypeInt64, value)
  422. }
  423. if value, ok := awflu.mutation.AddedUpdatedAt(); ok {
  424. _spec.AddField(addwechatfriendlog.FieldUpdatedAt, field.TypeInt64, value)
  425. }
  426. if value, ok := awflu.mutation.Source(); ok {
  427. _spec.SetField(addwechatfriendlog.FieldSource, field.TypeInt, value)
  428. }
  429. if value, ok := awflu.mutation.AddedSource(); ok {
  430. _spec.AddField(addwechatfriendlog.FieldSource, field.TypeInt, value)
  431. }
  432. if awflu.mutation.SourceCleared() {
  433. _spec.ClearField(addwechatfriendlog.FieldSource, field.TypeInt)
  434. }
  435. if value, ok := awflu.mutation.NickName(); ok {
  436. _spec.SetField(addwechatfriendlog.FieldNickName, field.TypeString, value)
  437. }
  438. if awflu.mutation.NickNameCleared() {
  439. _spec.ClearField(addwechatfriendlog.FieldNickName, field.TypeString)
  440. }
  441. if value, ok := awflu.mutation.Avatar(); ok {
  442. _spec.SetField(addwechatfriendlog.FieldAvatar, field.TypeString, value)
  443. }
  444. if awflu.mutation.AvatarCleared() {
  445. _spec.ClearField(addwechatfriendlog.FieldAvatar, field.TypeString)
  446. }
  447. if value, ok := awflu.mutation.OrganizationID(); ok {
  448. _spec.SetField(addwechatfriendlog.FieldOrganizationID, field.TypeInt64, value)
  449. }
  450. if value, ok := awflu.mutation.AddedOrganizationID(); ok {
  451. _spec.AddField(addwechatfriendlog.FieldOrganizationID, field.TypeInt64, value)
  452. }
  453. if awflu.mutation.OrganizationIDCleared() {
  454. _spec.ClearField(addwechatfriendlog.FieldOrganizationID, field.TypeInt64)
  455. }
  456. if n, err = sqlgraph.UpdateNodes(ctx, awflu.driver, _spec); err != nil {
  457. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  458. err = &NotFoundError{addwechatfriendlog.Label}
  459. } else if sqlgraph.IsConstraintError(err) {
  460. err = &ConstraintError{msg: err.Error(), wrap: err}
  461. }
  462. return 0, err
  463. }
  464. awflu.mutation.done = true
  465. return n, nil
  466. }
  467. // AddWechatFriendLogUpdateOne is the builder for updating a single AddWechatFriendLog entity.
  468. type AddWechatFriendLogUpdateOne struct {
  469. config
  470. fields []string
  471. hooks []Hook
  472. mutation *AddWechatFriendLogMutation
  473. }
  474. // SetOwnerWxID sets the "owner_wx_id" field.
  475. func (awfluo *AddWechatFriendLogUpdateOne) SetOwnerWxID(s string) *AddWechatFriendLogUpdateOne {
  476. awfluo.mutation.SetOwnerWxID(s)
  477. return awfluo
  478. }
  479. // SetNillableOwnerWxID sets the "owner_wx_id" field if the given value is not nil.
  480. func (awfluo *AddWechatFriendLogUpdateOne) SetNillableOwnerWxID(s *string) *AddWechatFriendLogUpdateOne {
  481. if s != nil {
  482. awfluo.SetOwnerWxID(*s)
  483. }
  484. return awfluo
  485. }
  486. // SetOwnerWxType sets the "owner_wx_type" field.
  487. func (awfluo *AddWechatFriendLogUpdateOne) SetOwnerWxType(i int) *AddWechatFriendLogUpdateOne {
  488. awfluo.mutation.ResetOwnerWxType()
  489. awfluo.mutation.SetOwnerWxType(i)
  490. return awfluo
  491. }
  492. // SetNillableOwnerWxType sets the "owner_wx_type" field if the given value is not nil.
  493. func (awfluo *AddWechatFriendLogUpdateOne) SetNillableOwnerWxType(i *int) *AddWechatFriendLogUpdateOne {
  494. if i != nil {
  495. awfluo.SetOwnerWxType(*i)
  496. }
  497. return awfluo
  498. }
  499. // AddOwnerWxType adds i to the "owner_wx_type" field.
  500. func (awfluo *AddWechatFriendLogUpdateOne) AddOwnerWxType(i int) *AddWechatFriendLogUpdateOne {
  501. awfluo.mutation.AddOwnerWxType(i)
  502. return awfluo
  503. }
  504. // SetFindContent sets the "find_content" field.
  505. func (awfluo *AddWechatFriendLogUpdateOne) SetFindContent(s string) *AddWechatFriendLogUpdateOne {
  506. awfluo.mutation.SetFindContent(s)
  507. return awfluo
  508. }
  509. // SetNillableFindContent sets the "find_content" field if the given value is not nil.
  510. func (awfluo *AddWechatFriendLogUpdateOne) SetNillableFindContent(s *string) *AddWechatFriendLogUpdateOne {
  511. if s != nil {
  512. awfluo.SetFindContent(*s)
  513. }
  514. return awfluo
  515. }
  516. // SetMessage sets the "message" field.
  517. func (awfluo *AddWechatFriendLogUpdateOne) SetMessage(s string) *AddWechatFriendLogUpdateOne {
  518. awfluo.mutation.SetMessage(s)
  519. return awfluo
  520. }
  521. // SetNillableMessage sets the "message" field if the given value is not nil.
  522. func (awfluo *AddWechatFriendLogUpdateOne) SetNillableMessage(s *string) *AddWechatFriendLogUpdateOne {
  523. if s != nil {
  524. awfluo.SetMessage(*s)
  525. }
  526. return awfluo
  527. }
  528. // SetFindRequest sets the "find_request" field.
  529. func (awfluo *AddWechatFriendLogUpdateOne) SetFindRequest(m map[string]interface{}) *AddWechatFriendLogUpdateOne {
  530. awfluo.mutation.SetFindRequest(m)
  531. return awfluo
  532. }
  533. // ClearFindRequest clears the value of the "find_request" field.
  534. func (awfluo *AddWechatFriendLogUpdateOne) ClearFindRequest() *AddWechatFriendLogUpdateOne {
  535. awfluo.mutation.ClearFindRequest()
  536. return awfluo
  537. }
  538. // SetFindResult sets the "find_result" field.
  539. func (awfluo *AddWechatFriendLogUpdateOne) SetFindResult(m map[string]interface{}) *AddWechatFriendLogUpdateOne {
  540. awfluo.mutation.SetFindResult(m)
  541. return awfluo
  542. }
  543. // ClearFindResult clears the value of the "find_result" field.
  544. func (awfluo *AddWechatFriendLogUpdateOne) ClearFindResult() *AddWechatFriendLogUpdateOne {
  545. awfluo.mutation.ClearFindResult()
  546. return awfluo
  547. }
  548. // SetIsCanAdd sets the "is_can_add" field.
  549. func (awfluo *AddWechatFriendLogUpdateOne) SetIsCanAdd(i int) *AddWechatFriendLogUpdateOne {
  550. awfluo.mutation.ResetIsCanAdd()
  551. awfluo.mutation.SetIsCanAdd(i)
  552. return awfluo
  553. }
  554. // SetNillableIsCanAdd sets the "is_can_add" field if the given value is not nil.
  555. func (awfluo *AddWechatFriendLogUpdateOne) SetNillableIsCanAdd(i *int) *AddWechatFriendLogUpdateOne {
  556. if i != nil {
  557. awfluo.SetIsCanAdd(*i)
  558. }
  559. return awfluo
  560. }
  561. // AddIsCanAdd adds i to the "is_can_add" field.
  562. func (awfluo *AddWechatFriendLogUpdateOne) AddIsCanAdd(i int) *AddWechatFriendLogUpdateOne {
  563. awfluo.mutation.AddIsCanAdd(i)
  564. return awfluo
  565. }
  566. // SetTaskCount sets the "task_count" field.
  567. func (awfluo *AddWechatFriendLogUpdateOne) SetTaskCount(i int) *AddWechatFriendLogUpdateOne {
  568. awfluo.mutation.ResetTaskCount()
  569. awfluo.mutation.SetTaskCount(i)
  570. return awfluo
  571. }
  572. // SetNillableTaskCount sets the "task_count" field if the given value is not nil.
  573. func (awfluo *AddWechatFriendLogUpdateOne) SetNillableTaskCount(i *int) *AddWechatFriendLogUpdateOne {
  574. if i != nil {
  575. awfluo.SetTaskCount(*i)
  576. }
  577. return awfluo
  578. }
  579. // AddTaskCount adds i to the "task_count" field.
  580. func (awfluo *AddWechatFriendLogUpdateOne) AddTaskCount(i int) *AddWechatFriendLogUpdateOne {
  581. awfluo.mutation.AddTaskCount(i)
  582. return awfluo
  583. }
  584. // SetTaskID sets the "task_id" field.
  585. func (awfluo *AddWechatFriendLogUpdateOne) SetTaskID(i int64) *AddWechatFriendLogUpdateOne {
  586. awfluo.mutation.ResetTaskID()
  587. awfluo.mutation.SetTaskID(i)
  588. return awfluo
  589. }
  590. // SetNillableTaskID sets the "task_id" field if the given value is not nil.
  591. func (awfluo *AddWechatFriendLogUpdateOne) SetNillableTaskID(i *int64) *AddWechatFriendLogUpdateOne {
  592. if i != nil {
  593. awfluo.SetTaskID(*i)
  594. }
  595. return awfluo
  596. }
  597. // AddTaskID adds i to the "task_id" field.
  598. func (awfluo *AddWechatFriendLogUpdateOne) AddTaskID(i int64) *AddWechatFriendLogUpdateOne {
  599. awfluo.mutation.AddTaskID(i)
  600. return awfluo
  601. }
  602. // SetAddRequest sets the "add_request" field.
  603. func (awfluo *AddWechatFriendLogUpdateOne) SetAddRequest(m map[string]interface{}) *AddWechatFriendLogUpdateOne {
  604. awfluo.mutation.SetAddRequest(m)
  605. return awfluo
  606. }
  607. // ClearAddRequest clears the value of the "add_request" field.
  608. func (awfluo *AddWechatFriendLogUpdateOne) ClearAddRequest() *AddWechatFriendLogUpdateOne {
  609. awfluo.mutation.ClearAddRequest()
  610. return awfluo
  611. }
  612. // SetAddResult sets the "add_result" field.
  613. func (awfluo *AddWechatFriendLogUpdateOne) SetAddResult(m map[string]interface{}) *AddWechatFriendLogUpdateOne {
  614. awfluo.mutation.SetAddResult(m)
  615. return awfluo
  616. }
  617. // ClearAddResult clears the value of the "add_result" field.
  618. func (awfluo *AddWechatFriendLogUpdateOne) ClearAddResult() *AddWechatFriendLogUpdateOne {
  619. awfluo.mutation.ClearAddResult()
  620. return awfluo
  621. }
  622. // SetCreatedAt sets the "created_at" field.
  623. func (awfluo *AddWechatFriendLogUpdateOne) SetCreatedAt(i int64) *AddWechatFriendLogUpdateOne {
  624. awfluo.mutation.ResetCreatedAt()
  625. awfluo.mutation.SetCreatedAt(i)
  626. return awfluo
  627. }
  628. // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
  629. func (awfluo *AddWechatFriendLogUpdateOne) SetNillableCreatedAt(i *int64) *AddWechatFriendLogUpdateOne {
  630. if i != nil {
  631. awfluo.SetCreatedAt(*i)
  632. }
  633. return awfluo
  634. }
  635. // AddCreatedAt adds i to the "created_at" field.
  636. func (awfluo *AddWechatFriendLogUpdateOne) AddCreatedAt(i int64) *AddWechatFriendLogUpdateOne {
  637. awfluo.mutation.AddCreatedAt(i)
  638. return awfluo
  639. }
  640. // SetUpdatedAt sets the "updated_at" field.
  641. func (awfluo *AddWechatFriendLogUpdateOne) SetUpdatedAt(i int64) *AddWechatFriendLogUpdateOne {
  642. awfluo.mutation.ResetUpdatedAt()
  643. awfluo.mutation.SetUpdatedAt(i)
  644. return awfluo
  645. }
  646. // AddUpdatedAt adds i to the "updated_at" field.
  647. func (awfluo *AddWechatFriendLogUpdateOne) AddUpdatedAt(i int64) *AddWechatFriendLogUpdateOne {
  648. awfluo.mutation.AddUpdatedAt(i)
  649. return awfluo
  650. }
  651. // SetSource sets the "source" field.
  652. func (awfluo *AddWechatFriendLogUpdateOne) SetSource(i int) *AddWechatFriendLogUpdateOne {
  653. awfluo.mutation.ResetSource()
  654. awfluo.mutation.SetSource(i)
  655. return awfluo
  656. }
  657. // SetNillableSource sets the "source" field if the given value is not nil.
  658. func (awfluo *AddWechatFriendLogUpdateOne) SetNillableSource(i *int) *AddWechatFriendLogUpdateOne {
  659. if i != nil {
  660. awfluo.SetSource(*i)
  661. }
  662. return awfluo
  663. }
  664. // AddSource adds i to the "source" field.
  665. func (awfluo *AddWechatFriendLogUpdateOne) AddSource(i int) *AddWechatFriendLogUpdateOne {
  666. awfluo.mutation.AddSource(i)
  667. return awfluo
  668. }
  669. // ClearSource clears the value of the "source" field.
  670. func (awfluo *AddWechatFriendLogUpdateOne) ClearSource() *AddWechatFriendLogUpdateOne {
  671. awfluo.mutation.ClearSource()
  672. return awfluo
  673. }
  674. // SetNickName sets the "nick_name" field.
  675. func (awfluo *AddWechatFriendLogUpdateOne) SetNickName(s string) *AddWechatFriendLogUpdateOne {
  676. awfluo.mutation.SetNickName(s)
  677. return awfluo
  678. }
  679. // SetNillableNickName sets the "nick_name" field if the given value is not nil.
  680. func (awfluo *AddWechatFriendLogUpdateOne) SetNillableNickName(s *string) *AddWechatFriendLogUpdateOne {
  681. if s != nil {
  682. awfluo.SetNickName(*s)
  683. }
  684. return awfluo
  685. }
  686. // ClearNickName clears the value of the "nick_name" field.
  687. func (awfluo *AddWechatFriendLogUpdateOne) ClearNickName() *AddWechatFriendLogUpdateOne {
  688. awfluo.mutation.ClearNickName()
  689. return awfluo
  690. }
  691. // SetAvatar sets the "avatar" field.
  692. func (awfluo *AddWechatFriendLogUpdateOne) SetAvatar(s string) *AddWechatFriendLogUpdateOne {
  693. awfluo.mutation.SetAvatar(s)
  694. return awfluo
  695. }
  696. // SetNillableAvatar sets the "avatar" field if the given value is not nil.
  697. func (awfluo *AddWechatFriendLogUpdateOne) SetNillableAvatar(s *string) *AddWechatFriendLogUpdateOne {
  698. if s != nil {
  699. awfluo.SetAvatar(*s)
  700. }
  701. return awfluo
  702. }
  703. // ClearAvatar clears the value of the "avatar" field.
  704. func (awfluo *AddWechatFriendLogUpdateOne) ClearAvatar() *AddWechatFriendLogUpdateOne {
  705. awfluo.mutation.ClearAvatar()
  706. return awfluo
  707. }
  708. // SetOrganizationID sets the "organization_id" field.
  709. func (awfluo *AddWechatFriendLogUpdateOne) SetOrganizationID(i int64) *AddWechatFriendLogUpdateOne {
  710. awfluo.mutation.ResetOrganizationID()
  711. awfluo.mutation.SetOrganizationID(i)
  712. return awfluo
  713. }
  714. // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
  715. func (awfluo *AddWechatFriendLogUpdateOne) SetNillableOrganizationID(i *int64) *AddWechatFriendLogUpdateOne {
  716. if i != nil {
  717. awfluo.SetOrganizationID(*i)
  718. }
  719. return awfluo
  720. }
  721. // AddOrganizationID adds i to the "organization_id" field.
  722. func (awfluo *AddWechatFriendLogUpdateOne) AddOrganizationID(i int64) *AddWechatFriendLogUpdateOne {
  723. awfluo.mutation.AddOrganizationID(i)
  724. return awfluo
  725. }
  726. // ClearOrganizationID clears the value of the "organization_id" field.
  727. func (awfluo *AddWechatFriendLogUpdateOne) ClearOrganizationID() *AddWechatFriendLogUpdateOne {
  728. awfluo.mutation.ClearOrganizationID()
  729. return awfluo
  730. }
  731. // Mutation returns the AddWechatFriendLogMutation object of the builder.
  732. func (awfluo *AddWechatFriendLogUpdateOne) Mutation() *AddWechatFriendLogMutation {
  733. return awfluo.mutation
  734. }
  735. // Where appends a list predicates to the AddWechatFriendLogUpdate builder.
  736. func (awfluo *AddWechatFriendLogUpdateOne) Where(ps ...predicate.AddWechatFriendLog) *AddWechatFriendLogUpdateOne {
  737. awfluo.mutation.Where(ps...)
  738. return awfluo
  739. }
  740. // Select allows selecting one or more fields (columns) of the returned entity.
  741. // The default is selecting all fields defined in the entity schema.
  742. func (awfluo *AddWechatFriendLogUpdateOne) Select(field string, fields ...string) *AddWechatFriendLogUpdateOne {
  743. awfluo.fields = append([]string{field}, fields...)
  744. return awfluo
  745. }
  746. // Save executes the query and returns the updated AddWechatFriendLog entity.
  747. func (awfluo *AddWechatFriendLogUpdateOne) Save(ctx context.Context) (*AddWechatFriendLog, error) {
  748. awfluo.defaults()
  749. return withHooks(ctx, awfluo.sqlSave, awfluo.mutation, awfluo.hooks)
  750. }
  751. // SaveX is like Save, but panics if an error occurs.
  752. func (awfluo *AddWechatFriendLogUpdateOne) SaveX(ctx context.Context) *AddWechatFriendLog {
  753. node, err := awfluo.Save(ctx)
  754. if err != nil {
  755. panic(err)
  756. }
  757. return node
  758. }
  759. // Exec executes the query on the entity.
  760. func (awfluo *AddWechatFriendLogUpdateOne) Exec(ctx context.Context) error {
  761. _, err := awfluo.Save(ctx)
  762. return err
  763. }
  764. // ExecX is like Exec, but panics if an error occurs.
  765. func (awfluo *AddWechatFriendLogUpdateOne) ExecX(ctx context.Context) {
  766. if err := awfluo.Exec(ctx); err != nil {
  767. panic(err)
  768. }
  769. }
  770. // defaults sets the default values of the builder before save.
  771. func (awfluo *AddWechatFriendLogUpdateOne) defaults() {
  772. if _, ok := awfluo.mutation.UpdatedAt(); !ok {
  773. v := addwechatfriendlog.UpdateDefaultUpdatedAt()
  774. awfluo.mutation.SetUpdatedAt(v)
  775. }
  776. }
  777. // check runs all checks and user-defined validators on the builder.
  778. func (awfluo *AddWechatFriendLogUpdateOne) check() error {
  779. if v, ok := awfluo.mutation.OwnerWxID(); ok {
  780. if err := addwechatfriendlog.OwnerWxIDValidator(v); err != nil {
  781. return &ValidationError{Name: "owner_wx_id", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.owner_wx_id": %w`, err)}
  782. }
  783. }
  784. if v, ok := awfluo.mutation.FindContent(); ok {
  785. if err := addwechatfriendlog.FindContentValidator(v); err != nil {
  786. return &ValidationError{Name: "find_content", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.find_content": %w`, err)}
  787. }
  788. }
  789. if v, ok := awfluo.mutation.Message(); ok {
  790. if err := addwechatfriendlog.MessageValidator(v); err != nil {
  791. return &ValidationError{Name: "message", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.message": %w`, err)}
  792. }
  793. }
  794. if v, ok := awfluo.mutation.NickName(); ok {
  795. if err := addwechatfriendlog.NickNameValidator(v); err != nil {
  796. return &ValidationError{Name: "nick_name", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.nick_name": %w`, err)}
  797. }
  798. }
  799. if v, ok := awfluo.mutation.Avatar(); ok {
  800. if err := addwechatfriendlog.AvatarValidator(v); err != nil {
  801. return &ValidationError{Name: "avatar", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.avatar": %w`, err)}
  802. }
  803. }
  804. return nil
  805. }
  806. func (awfluo *AddWechatFriendLogUpdateOne) sqlSave(ctx context.Context) (_node *AddWechatFriendLog, err error) {
  807. if err := awfluo.check(); err != nil {
  808. return _node, err
  809. }
  810. _spec := sqlgraph.NewUpdateSpec(addwechatfriendlog.Table, addwechatfriendlog.Columns, sqlgraph.NewFieldSpec(addwechatfriendlog.FieldID, field.TypeInt64))
  811. id, ok := awfluo.mutation.ID()
  812. if !ok {
  813. return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "AddWechatFriendLog.id" for update`)}
  814. }
  815. _spec.Node.ID.Value = id
  816. if fields := awfluo.fields; len(fields) > 0 {
  817. _spec.Node.Columns = make([]string, 0, len(fields))
  818. _spec.Node.Columns = append(_spec.Node.Columns, addwechatfriendlog.FieldID)
  819. for _, f := range fields {
  820. if !addwechatfriendlog.ValidColumn(f) {
  821. return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
  822. }
  823. if f != addwechatfriendlog.FieldID {
  824. _spec.Node.Columns = append(_spec.Node.Columns, f)
  825. }
  826. }
  827. }
  828. if ps := awfluo.mutation.predicates; len(ps) > 0 {
  829. _spec.Predicate = func(selector *sql.Selector) {
  830. for i := range ps {
  831. ps[i](selector)
  832. }
  833. }
  834. }
  835. if value, ok := awfluo.mutation.OwnerWxID(); ok {
  836. _spec.SetField(addwechatfriendlog.FieldOwnerWxID, field.TypeString, value)
  837. }
  838. if value, ok := awfluo.mutation.OwnerWxType(); ok {
  839. _spec.SetField(addwechatfriendlog.FieldOwnerWxType, field.TypeInt, value)
  840. }
  841. if value, ok := awfluo.mutation.AddedOwnerWxType(); ok {
  842. _spec.AddField(addwechatfriendlog.FieldOwnerWxType, field.TypeInt, value)
  843. }
  844. if value, ok := awfluo.mutation.FindContent(); ok {
  845. _spec.SetField(addwechatfriendlog.FieldFindContent, field.TypeString, value)
  846. }
  847. if value, ok := awfluo.mutation.Message(); ok {
  848. _spec.SetField(addwechatfriendlog.FieldMessage, field.TypeString, value)
  849. }
  850. if value, ok := awfluo.mutation.FindRequest(); ok {
  851. _spec.SetField(addwechatfriendlog.FieldFindRequest, field.TypeJSON, value)
  852. }
  853. if awfluo.mutation.FindRequestCleared() {
  854. _spec.ClearField(addwechatfriendlog.FieldFindRequest, field.TypeJSON)
  855. }
  856. if value, ok := awfluo.mutation.FindResult(); ok {
  857. _spec.SetField(addwechatfriendlog.FieldFindResult, field.TypeJSON, value)
  858. }
  859. if awfluo.mutation.FindResultCleared() {
  860. _spec.ClearField(addwechatfriendlog.FieldFindResult, field.TypeJSON)
  861. }
  862. if value, ok := awfluo.mutation.IsCanAdd(); ok {
  863. _spec.SetField(addwechatfriendlog.FieldIsCanAdd, field.TypeInt, value)
  864. }
  865. if value, ok := awfluo.mutation.AddedIsCanAdd(); ok {
  866. _spec.AddField(addwechatfriendlog.FieldIsCanAdd, field.TypeInt, value)
  867. }
  868. if value, ok := awfluo.mutation.TaskCount(); ok {
  869. _spec.SetField(addwechatfriendlog.FieldTaskCount, field.TypeInt, value)
  870. }
  871. if value, ok := awfluo.mutation.AddedTaskCount(); ok {
  872. _spec.AddField(addwechatfriendlog.FieldTaskCount, field.TypeInt, value)
  873. }
  874. if value, ok := awfluo.mutation.TaskID(); ok {
  875. _spec.SetField(addwechatfriendlog.FieldTaskID, field.TypeInt64, value)
  876. }
  877. if value, ok := awfluo.mutation.AddedTaskID(); ok {
  878. _spec.AddField(addwechatfriendlog.FieldTaskID, field.TypeInt64, value)
  879. }
  880. if value, ok := awfluo.mutation.AddRequest(); ok {
  881. _spec.SetField(addwechatfriendlog.FieldAddRequest, field.TypeJSON, value)
  882. }
  883. if awfluo.mutation.AddRequestCleared() {
  884. _spec.ClearField(addwechatfriendlog.FieldAddRequest, field.TypeJSON)
  885. }
  886. if value, ok := awfluo.mutation.AddResult(); ok {
  887. _spec.SetField(addwechatfriendlog.FieldAddResult, field.TypeJSON, value)
  888. }
  889. if awfluo.mutation.AddResultCleared() {
  890. _spec.ClearField(addwechatfriendlog.FieldAddResult, field.TypeJSON)
  891. }
  892. if value, ok := awfluo.mutation.CreatedAt(); ok {
  893. _spec.SetField(addwechatfriendlog.FieldCreatedAt, field.TypeInt64, value)
  894. }
  895. if value, ok := awfluo.mutation.AddedCreatedAt(); ok {
  896. _spec.AddField(addwechatfriendlog.FieldCreatedAt, field.TypeInt64, value)
  897. }
  898. if value, ok := awfluo.mutation.UpdatedAt(); ok {
  899. _spec.SetField(addwechatfriendlog.FieldUpdatedAt, field.TypeInt64, value)
  900. }
  901. if value, ok := awfluo.mutation.AddedUpdatedAt(); ok {
  902. _spec.AddField(addwechatfriendlog.FieldUpdatedAt, field.TypeInt64, value)
  903. }
  904. if value, ok := awfluo.mutation.Source(); ok {
  905. _spec.SetField(addwechatfriendlog.FieldSource, field.TypeInt, value)
  906. }
  907. if value, ok := awfluo.mutation.AddedSource(); ok {
  908. _spec.AddField(addwechatfriendlog.FieldSource, field.TypeInt, value)
  909. }
  910. if awfluo.mutation.SourceCleared() {
  911. _spec.ClearField(addwechatfriendlog.FieldSource, field.TypeInt)
  912. }
  913. if value, ok := awfluo.mutation.NickName(); ok {
  914. _spec.SetField(addwechatfriendlog.FieldNickName, field.TypeString, value)
  915. }
  916. if awfluo.mutation.NickNameCleared() {
  917. _spec.ClearField(addwechatfriendlog.FieldNickName, field.TypeString)
  918. }
  919. if value, ok := awfluo.mutation.Avatar(); ok {
  920. _spec.SetField(addwechatfriendlog.FieldAvatar, field.TypeString, value)
  921. }
  922. if awfluo.mutation.AvatarCleared() {
  923. _spec.ClearField(addwechatfriendlog.FieldAvatar, field.TypeString)
  924. }
  925. if value, ok := awfluo.mutation.OrganizationID(); ok {
  926. _spec.SetField(addwechatfriendlog.FieldOrganizationID, field.TypeInt64, value)
  927. }
  928. if value, ok := awfluo.mutation.AddedOrganizationID(); ok {
  929. _spec.AddField(addwechatfriendlog.FieldOrganizationID, field.TypeInt64, value)
  930. }
  931. if awfluo.mutation.OrganizationIDCleared() {
  932. _spec.ClearField(addwechatfriendlog.FieldOrganizationID, field.TypeInt64)
  933. }
  934. _node = &AddWechatFriendLog{config: awfluo.config}
  935. _spec.Assign = _node.assignValues
  936. _spec.ScanValues = _node.scanValues
  937. if err = sqlgraph.UpdateNode(ctx, awfluo.driver, _spec); err != nil {
  938. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  939. err = &NotFoundError{addwechatfriendlog.Label}
  940. } else if sqlgraph.IsConstraintError(err) {
  941. err = &ConstraintError{msg: err.Error(), wrap: err}
  942. }
  943. return nil, err
  944. }
  945. awfluo.mutation.done = true
  946. return _node, nil
  947. }