usagestatistichour_update.go 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "time"
  8. "wechat-api/ent/custom_types"
  9. "wechat-api/ent/predicate"
  10. "wechat-api/ent/usagestatistichour"
  11. "entgo.io/ent/dialect/sql"
  12. "entgo.io/ent/dialect/sql/sqlgraph"
  13. "entgo.io/ent/dialect/sql/sqljson"
  14. "entgo.io/ent/schema/field"
  15. )
  16. // UsageStatisticHourUpdate is the builder for updating UsageStatisticHour entities.
  17. type UsageStatisticHourUpdate struct {
  18. config
  19. hooks []Hook
  20. mutation *UsageStatisticHourMutation
  21. }
  22. // Where appends a list predicates to the UsageStatisticHourUpdate builder.
  23. func (ushu *UsageStatisticHourUpdate) Where(ps ...predicate.UsageStatisticHour) *UsageStatisticHourUpdate {
  24. ushu.mutation.Where(ps...)
  25. return ushu
  26. }
  27. // SetUpdatedAt sets the "updated_at" field.
  28. func (ushu *UsageStatisticHourUpdate) SetUpdatedAt(t time.Time) *UsageStatisticHourUpdate {
  29. ushu.mutation.SetUpdatedAt(t)
  30. return ushu
  31. }
  32. // SetStatus sets the "status" field.
  33. func (ushu *UsageStatisticHourUpdate) SetStatus(u uint8) *UsageStatisticHourUpdate {
  34. ushu.mutation.ResetStatus()
  35. ushu.mutation.SetStatus(u)
  36. return ushu
  37. }
  38. // SetNillableStatus sets the "status" field if the given value is not nil.
  39. func (ushu *UsageStatisticHourUpdate) SetNillableStatus(u *uint8) *UsageStatisticHourUpdate {
  40. if u != nil {
  41. ushu.SetStatus(*u)
  42. }
  43. return ushu
  44. }
  45. // AddStatus adds u to the "status" field.
  46. func (ushu *UsageStatisticHourUpdate) AddStatus(u int8) *UsageStatisticHourUpdate {
  47. ushu.mutation.AddStatus(u)
  48. return ushu
  49. }
  50. // ClearStatus clears the value of the "status" field.
  51. func (ushu *UsageStatisticHourUpdate) ClearStatus() *UsageStatisticHourUpdate {
  52. ushu.mutation.ClearStatus()
  53. return ushu
  54. }
  55. // SetDeletedAt sets the "deleted_at" field.
  56. func (ushu *UsageStatisticHourUpdate) SetDeletedAt(t time.Time) *UsageStatisticHourUpdate {
  57. ushu.mutation.SetDeletedAt(t)
  58. return ushu
  59. }
  60. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  61. func (ushu *UsageStatisticHourUpdate) SetNillableDeletedAt(t *time.Time) *UsageStatisticHourUpdate {
  62. if t != nil {
  63. ushu.SetDeletedAt(*t)
  64. }
  65. return ushu
  66. }
  67. // ClearDeletedAt clears the value of the "deleted_at" field.
  68. func (ushu *UsageStatisticHourUpdate) ClearDeletedAt() *UsageStatisticHourUpdate {
  69. ushu.mutation.ClearDeletedAt()
  70. return ushu
  71. }
  72. // SetAddtime sets the "addtime" field.
  73. func (ushu *UsageStatisticHourUpdate) SetAddtime(u uint64) *UsageStatisticHourUpdate {
  74. ushu.mutation.ResetAddtime()
  75. ushu.mutation.SetAddtime(u)
  76. return ushu
  77. }
  78. // SetNillableAddtime sets the "addtime" field if the given value is not nil.
  79. func (ushu *UsageStatisticHourUpdate) SetNillableAddtime(u *uint64) *UsageStatisticHourUpdate {
  80. if u != nil {
  81. ushu.SetAddtime(*u)
  82. }
  83. return ushu
  84. }
  85. // AddAddtime adds u to the "addtime" field.
  86. func (ushu *UsageStatisticHourUpdate) AddAddtime(u int64) *UsageStatisticHourUpdate {
  87. ushu.mutation.AddAddtime(u)
  88. return ushu
  89. }
  90. // SetType sets the "type" field.
  91. func (ushu *UsageStatisticHourUpdate) SetType(i int) *UsageStatisticHourUpdate {
  92. ushu.mutation.ResetType()
  93. ushu.mutation.SetType(i)
  94. return ushu
  95. }
  96. // SetNillableType sets the "type" field if the given value is not nil.
  97. func (ushu *UsageStatisticHourUpdate) SetNillableType(i *int) *UsageStatisticHourUpdate {
  98. if i != nil {
  99. ushu.SetType(*i)
  100. }
  101. return ushu
  102. }
  103. // AddType adds i to the "type" field.
  104. func (ushu *UsageStatisticHourUpdate) AddType(i int) *UsageStatisticHourUpdate {
  105. ushu.mutation.AddType(i)
  106. return ushu
  107. }
  108. // SetBotID sets the "bot_id" field.
  109. func (ushu *UsageStatisticHourUpdate) SetBotID(s string) *UsageStatisticHourUpdate {
  110. ushu.mutation.SetBotID(s)
  111. return ushu
  112. }
  113. // SetNillableBotID sets the "bot_id" field if the given value is not nil.
  114. func (ushu *UsageStatisticHourUpdate) SetNillableBotID(s *string) *UsageStatisticHourUpdate {
  115. if s != nil {
  116. ushu.SetBotID(*s)
  117. }
  118. return ushu
  119. }
  120. // ClearBotID clears the value of the "bot_id" field.
  121. func (ushu *UsageStatisticHourUpdate) ClearBotID() *UsageStatisticHourUpdate {
  122. ushu.mutation.ClearBotID()
  123. return ushu
  124. }
  125. // SetOrganizationID sets the "organization_id" field.
  126. func (ushu *UsageStatisticHourUpdate) SetOrganizationID(u uint64) *UsageStatisticHourUpdate {
  127. ushu.mutation.ResetOrganizationID()
  128. ushu.mutation.SetOrganizationID(u)
  129. return ushu
  130. }
  131. // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
  132. func (ushu *UsageStatisticHourUpdate) SetNillableOrganizationID(u *uint64) *UsageStatisticHourUpdate {
  133. if u != nil {
  134. ushu.SetOrganizationID(*u)
  135. }
  136. return ushu
  137. }
  138. // AddOrganizationID adds u to the "organization_id" field.
  139. func (ushu *UsageStatisticHourUpdate) AddOrganizationID(u int64) *UsageStatisticHourUpdate {
  140. ushu.mutation.AddOrganizationID(u)
  141. return ushu
  142. }
  143. // ClearOrganizationID clears the value of the "organization_id" field.
  144. func (ushu *UsageStatisticHourUpdate) ClearOrganizationID() *UsageStatisticHourUpdate {
  145. ushu.mutation.ClearOrganizationID()
  146. return ushu
  147. }
  148. // SetAiResponse sets the "ai_response" field.
  149. func (ushu *UsageStatisticHourUpdate) SetAiResponse(u uint64) *UsageStatisticHourUpdate {
  150. ushu.mutation.ResetAiResponse()
  151. ushu.mutation.SetAiResponse(u)
  152. return ushu
  153. }
  154. // SetNillableAiResponse sets the "ai_response" field if the given value is not nil.
  155. func (ushu *UsageStatisticHourUpdate) SetNillableAiResponse(u *uint64) *UsageStatisticHourUpdate {
  156. if u != nil {
  157. ushu.SetAiResponse(*u)
  158. }
  159. return ushu
  160. }
  161. // AddAiResponse adds u to the "ai_response" field.
  162. func (ushu *UsageStatisticHourUpdate) AddAiResponse(u int64) *UsageStatisticHourUpdate {
  163. ushu.mutation.AddAiResponse(u)
  164. return ushu
  165. }
  166. // SetSopRun sets the "sop_run" field.
  167. func (ushu *UsageStatisticHourUpdate) SetSopRun(u uint64) *UsageStatisticHourUpdate {
  168. ushu.mutation.ResetSopRun()
  169. ushu.mutation.SetSopRun(u)
  170. return ushu
  171. }
  172. // SetNillableSopRun sets the "sop_run" field if the given value is not nil.
  173. func (ushu *UsageStatisticHourUpdate) SetNillableSopRun(u *uint64) *UsageStatisticHourUpdate {
  174. if u != nil {
  175. ushu.SetSopRun(*u)
  176. }
  177. return ushu
  178. }
  179. // AddSopRun adds u to the "sop_run" field.
  180. func (ushu *UsageStatisticHourUpdate) AddSopRun(u int64) *UsageStatisticHourUpdate {
  181. ushu.mutation.AddSopRun(u)
  182. return ushu
  183. }
  184. // SetTotalFriend sets the "total_friend" field.
  185. func (ushu *UsageStatisticHourUpdate) SetTotalFriend(u uint64) *UsageStatisticHourUpdate {
  186. ushu.mutation.ResetTotalFriend()
  187. ushu.mutation.SetTotalFriend(u)
  188. return ushu
  189. }
  190. // SetNillableTotalFriend sets the "total_friend" field if the given value is not nil.
  191. func (ushu *UsageStatisticHourUpdate) SetNillableTotalFriend(u *uint64) *UsageStatisticHourUpdate {
  192. if u != nil {
  193. ushu.SetTotalFriend(*u)
  194. }
  195. return ushu
  196. }
  197. // AddTotalFriend adds u to the "total_friend" field.
  198. func (ushu *UsageStatisticHourUpdate) AddTotalFriend(u int64) *UsageStatisticHourUpdate {
  199. ushu.mutation.AddTotalFriend(u)
  200. return ushu
  201. }
  202. // SetTotalGroup sets the "total_group" field.
  203. func (ushu *UsageStatisticHourUpdate) SetTotalGroup(u uint64) *UsageStatisticHourUpdate {
  204. ushu.mutation.ResetTotalGroup()
  205. ushu.mutation.SetTotalGroup(u)
  206. return ushu
  207. }
  208. // SetNillableTotalGroup sets the "total_group" field if the given value is not nil.
  209. func (ushu *UsageStatisticHourUpdate) SetNillableTotalGroup(u *uint64) *UsageStatisticHourUpdate {
  210. if u != nil {
  211. ushu.SetTotalGroup(*u)
  212. }
  213. return ushu
  214. }
  215. // AddTotalGroup adds u to the "total_group" field.
  216. func (ushu *UsageStatisticHourUpdate) AddTotalGroup(u int64) *UsageStatisticHourUpdate {
  217. ushu.mutation.AddTotalGroup(u)
  218. return ushu
  219. }
  220. // SetAccountBalance sets the "account_balance" field.
  221. func (ushu *UsageStatisticHourUpdate) SetAccountBalance(u uint64) *UsageStatisticHourUpdate {
  222. ushu.mutation.ResetAccountBalance()
  223. ushu.mutation.SetAccountBalance(u)
  224. return ushu
  225. }
  226. // SetNillableAccountBalance sets the "account_balance" field if the given value is not nil.
  227. func (ushu *UsageStatisticHourUpdate) SetNillableAccountBalance(u *uint64) *UsageStatisticHourUpdate {
  228. if u != nil {
  229. ushu.SetAccountBalance(*u)
  230. }
  231. return ushu
  232. }
  233. // AddAccountBalance adds u to the "account_balance" field.
  234. func (ushu *UsageStatisticHourUpdate) AddAccountBalance(u int64) *UsageStatisticHourUpdate {
  235. ushu.mutation.AddAccountBalance(u)
  236. return ushu
  237. }
  238. // SetConsumeToken sets the "consume_token" field.
  239. func (ushu *UsageStatisticHourUpdate) SetConsumeToken(u uint64) *UsageStatisticHourUpdate {
  240. ushu.mutation.ResetConsumeToken()
  241. ushu.mutation.SetConsumeToken(u)
  242. return ushu
  243. }
  244. // SetNillableConsumeToken sets the "consume_token" field if the given value is not nil.
  245. func (ushu *UsageStatisticHourUpdate) SetNillableConsumeToken(u *uint64) *UsageStatisticHourUpdate {
  246. if u != nil {
  247. ushu.SetConsumeToken(*u)
  248. }
  249. return ushu
  250. }
  251. // AddConsumeToken adds u to the "consume_token" field.
  252. func (ushu *UsageStatisticHourUpdate) AddConsumeToken(u int64) *UsageStatisticHourUpdate {
  253. ushu.mutation.AddConsumeToken(u)
  254. return ushu
  255. }
  256. // SetActiveUser sets the "active_user" field.
  257. func (ushu *UsageStatisticHourUpdate) SetActiveUser(u uint64) *UsageStatisticHourUpdate {
  258. ushu.mutation.ResetActiveUser()
  259. ushu.mutation.SetActiveUser(u)
  260. return ushu
  261. }
  262. // SetNillableActiveUser sets the "active_user" field if the given value is not nil.
  263. func (ushu *UsageStatisticHourUpdate) SetNillableActiveUser(u *uint64) *UsageStatisticHourUpdate {
  264. if u != nil {
  265. ushu.SetActiveUser(*u)
  266. }
  267. return ushu
  268. }
  269. // AddActiveUser adds u to the "active_user" field.
  270. func (ushu *UsageStatisticHourUpdate) AddActiveUser(u int64) *UsageStatisticHourUpdate {
  271. ushu.mutation.AddActiveUser(u)
  272. return ushu
  273. }
  274. // SetNewUser sets the "new_user" field.
  275. func (ushu *UsageStatisticHourUpdate) SetNewUser(i int64) *UsageStatisticHourUpdate {
  276. ushu.mutation.ResetNewUser()
  277. ushu.mutation.SetNewUser(i)
  278. return ushu
  279. }
  280. // SetNillableNewUser sets the "new_user" field if the given value is not nil.
  281. func (ushu *UsageStatisticHourUpdate) SetNillableNewUser(i *int64) *UsageStatisticHourUpdate {
  282. if i != nil {
  283. ushu.SetNewUser(*i)
  284. }
  285. return ushu
  286. }
  287. // AddNewUser adds i to the "new_user" field.
  288. func (ushu *UsageStatisticHourUpdate) AddNewUser(i int64) *UsageStatisticHourUpdate {
  289. ushu.mutation.AddNewUser(i)
  290. return ushu
  291. }
  292. // SetLabelDist sets the "label_dist" field.
  293. func (ushu *UsageStatisticHourUpdate) SetLabelDist(ctd []custom_types.LabelDist) *UsageStatisticHourUpdate {
  294. ushu.mutation.SetLabelDist(ctd)
  295. return ushu
  296. }
  297. // AppendLabelDist appends ctd to the "label_dist" field.
  298. func (ushu *UsageStatisticHourUpdate) AppendLabelDist(ctd []custom_types.LabelDist) *UsageStatisticHourUpdate {
  299. ushu.mutation.AppendLabelDist(ctd)
  300. return ushu
  301. }
  302. // Mutation returns the UsageStatisticHourMutation object of the builder.
  303. func (ushu *UsageStatisticHourUpdate) Mutation() *UsageStatisticHourMutation {
  304. return ushu.mutation
  305. }
  306. // Save executes the query and returns the number of nodes affected by the update operation.
  307. func (ushu *UsageStatisticHourUpdate) Save(ctx context.Context) (int, error) {
  308. if err := ushu.defaults(); err != nil {
  309. return 0, err
  310. }
  311. return withHooks(ctx, ushu.sqlSave, ushu.mutation, ushu.hooks)
  312. }
  313. // SaveX is like Save, but panics if an error occurs.
  314. func (ushu *UsageStatisticHourUpdate) SaveX(ctx context.Context) int {
  315. affected, err := ushu.Save(ctx)
  316. if err != nil {
  317. panic(err)
  318. }
  319. return affected
  320. }
  321. // Exec executes the query.
  322. func (ushu *UsageStatisticHourUpdate) Exec(ctx context.Context) error {
  323. _, err := ushu.Save(ctx)
  324. return err
  325. }
  326. // ExecX is like Exec, but panics if an error occurs.
  327. func (ushu *UsageStatisticHourUpdate) ExecX(ctx context.Context) {
  328. if err := ushu.Exec(ctx); err != nil {
  329. panic(err)
  330. }
  331. }
  332. // defaults sets the default values of the builder before save.
  333. func (ushu *UsageStatisticHourUpdate) defaults() error {
  334. if _, ok := ushu.mutation.UpdatedAt(); !ok {
  335. if usagestatistichour.UpdateDefaultUpdatedAt == nil {
  336. return fmt.Errorf("ent: uninitialized usagestatistichour.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
  337. }
  338. v := usagestatistichour.UpdateDefaultUpdatedAt()
  339. ushu.mutation.SetUpdatedAt(v)
  340. }
  341. return nil
  342. }
  343. func (ushu *UsageStatisticHourUpdate) sqlSave(ctx context.Context) (n int, err error) {
  344. _spec := sqlgraph.NewUpdateSpec(usagestatistichour.Table, usagestatistichour.Columns, sqlgraph.NewFieldSpec(usagestatistichour.FieldID, field.TypeUint64))
  345. if ps := ushu.mutation.predicates; len(ps) > 0 {
  346. _spec.Predicate = func(selector *sql.Selector) {
  347. for i := range ps {
  348. ps[i](selector)
  349. }
  350. }
  351. }
  352. if value, ok := ushu.mutation.UpdatedAt(); ok {
  353. _spec.SetField(usagestatistichour.FieldUpdatedAt, field.TypeTime, value)
  354. }
  355. if value, ok := ushu.mutation.Status(); ok {
  356. _spec.SetField(usagestatistichour.FieldStatus, field.TypeUint8, value)
  357. }
  358. if value, ok := ushu.mutation.AddedStatus(); ok {
  359. _spec.AddField(usagestatistichour.FieldStatus, field.TypeUint8, value)
  360. }
  361. if ushu.mutation.StatusCleared() {
  362. _spec.ClearField(usagestatistichour.FieldStatus, field.TypeUint8)
  363. }
  364. if value, ok := ushu.mutation.DeletedAt(); ok {
  365. _spec.SetField(usagestatistichour.FieldDeletedAt, field.TypeTime, value)
  366. }
  367. if ushu.mutation.DeletedAtCleared() {
  368. _spec.ClearField(usagestatistichour.FieldDeletedAt, field.TypeTime)
  369. }
  370. if value, ok := ushu.mutation.Addtime(); ok {
  371. _spec.SetField(usagestatistichour.FieldAddtime, field.TypeUint64, value)
  372. }
  373. if value, ok := ushu.mutation.AddedAddtime(); ok {
  374. _spec.AddField(usagestatistichour.FieldAddtime, field.TypeUint64, value)
  375. }
  376. if value, ok := ushu.mutation.GetType(); ok {
  377. _spec.SetField(usagestatistichour.FieldType, field.TypeInt, value)
  378. }
  379. if value, ok := ushu.mutation.AddedType(); ok {
  380. _spec.AddField(usagestatistichour.FieldType, field.TypeInt, value)
  381. }
  382. if value, ok := ushu.mutation.BotID(); ok {
  383. _spec.SetField(usagestatistichour.FieldBotID, field.TypeString, value)
  384. }
  385. if ushu.mutation.BotIDCleared() {
  386. _spec.ClearField(usagestatistichour.FieldBotID, field.TypeString)
  387. }
  388. if value, ok := ushu.mutation.OrganizationID(); ok {
  389. _spec.SetField(usagestatistichour.FieldOrganizationID, field.TypeUint64, value)
  390. }
  391. if value, ok := ushu.mutation.AddedOrganizationID(); ok {
  392. _spec.AddField(usagestatistichour.FieldOrganizationID, field.TypeUint64, value)
  393. }
  394. if ushu.mutation.OrganizationIDCleared() {
  395. _spec.ClearField(usagestatistichour.FieldOrganizationID, field.TypeUint64)
  396. }
  397. if value, ok := ushu.mutation.AiResponse(); ok {
  398. _spec.SetField(usagestatistichour.FieldAiResponse, field.TypeUint64, value)
  399. }
  400. if value, ok := ushu.mutation.AddedAiResponse(); ok {
  401. _spec.AddField(usagestatistichour.FieldAiResponse, field.TypeUint64, value)
  402. }
  403. if value, ok := ushu.mutation.SopRun(); ok {
  404. _spec.SetField(usagestatistichour.FieldSopRun, field.TypeUint64, value)
  405. }
  406. if value, ok := ushu.mutation.AddedSopRun(); ok {
  407. _spec.AddField(usagestatistichour.FieldSopRun, field.TypeUint64, value)
  408. }
  409. if value, ok := ushu.mutation.TotalFriend(); ok {
  410. _spec.SetField(usagestatistichour.FieldTotalFriend, field.TypeUint64, value)
  411. }
  412. if value, ok := ushu.mutation.AddedTotalFriend(); ok {
  413. _spec.AddField(usagestatistichour.FieldTotalFriend, field.TypeUint64, value)
  414. }
  415. if value, ok := ushu.mutation.TotalGroup(); ok {
  416. _spec.SetField(usagestatistichour.FieldTotalGroup, field.TypeUint64, value)
  417. }
  418. if value, ok := ushu.mutation.AddedTotalGroup(); ok {
  419. _spec.AddField(usagestatistichour.FieldTotalGroup, field.TypeUint64, value)
  420. }
  421. if value, ok := ushu.mutation.AccountBalance(); ok {
  422. _spec.SetField(usagestatistichour.FieldAccountBalance, field.TypeUint64, value)
  423. }
  424. if value, ok := ushu.mutation.AddedAccountBalance(); ok {
  425. _spec.AddField(usagestatistichour.FieldAccountBalance, field.TypeUint64, value)
  426. }
  427. if value, ok := ushu.mutation.ConsumeToken(); ok {
  428. _spec.SetField(usagestatistichour.FieldConsumeToken, field.TypeUint64, value)
  429. }
  430. if value, ok := ushu.mutation.AddedConsumeToken(); ok {
  431. _spec.AddField(usagestatistichour.FieldConsumeToken, field.TypeUint64, value)
  432. }
  433. if value, ok := ushu.mutation.ActiveUser(); ok {
  434. _spec.SetField(usagestatistichour.FieldActiveUser, field.TypeUint64, value)
  435. }
  436. if value, ok := ushu.mutation.AddedActiveUser(); ok {
  437. _spec.AddField(usagestatistichour.FieldActiveUser, field.TypeUint64, value)
  438. }
  439. if value, ok := ushu.mutation.NewUser(); ok {
  440. _spec.SetField(usagestatistichour.FieldNewUser, field.TypeInt64, value)
  441. }
  442. if value, ok := ushu.mutation.AddedNewUser(); ok {
  443. _spec.AddField(usagestatistichour.FieldNewUser, field.TypeInt64, value)
  444. }
  445. if value, ok := ushu.mutation.LabelDist(); ok {
  446. _spec.SetField(usagestatistichour.FieldLabelDist, field.TypeJSON, value)
  447. }
  448. if value, ok := ushu.mutation.AppendedLabelDist(); ok {
  449. _spec.AddModifier(func(u *sql.UpdateBuilder) {
  450. sqljson.Append(u, usagestatistichour.FieldLabelDist, value)
  451. })
  452. }
  453. if n, err = sqlgraph.UpdateNodes(ctx, ushu.driver, _spec); err != nil {
  454. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  455. err = &NotFoundError{usagestatistichour.Label}
  456. } else if sqlgraph.IsConstraintError(err) {
  457. err = &ConstraintError{msg: err.Error(), wrap: err}
  458. }
  459. return 0, err
  460. }
  461. ushu.mutation.done = true
  462. return n, nil
  463. }
  464. // UsageStatisticHourUpdateOne is the builder for updating a single UsageStatisticHour entity.
  465. type UsageStatisticHourUpdateOne struct {
  466. config
  467. fields []string
  468. hooks []Hook
  469. mutation *UsageStatisticHourMutation
  470. }
  471. // SetUpdatedAt sets the "updated_at" field.
  472. func (ushuo *UsageStatisticHourUpdateOne) SetUpdatedAt(t time.Time) *UsageStatisticHourUpdateOne {
  473. ushuo.mutation.SetUpdatedAt(t)
  474. return ushuo
  475. }
  476. // SetStatus sets the "status" field.
  477. func (ushuo *UsageStatisticHourUpdateOne) SetStatus(u uint8) *UsageStatisticHourUpdateOne {
  478. ushuo.mutation.ResetStatus()
  479. ushuo.mutation.SetStatus(u)
  480. return ushuo
  481. }
  482. // SetNillableStatus sets the "status" field if the given value is not nil.
  483. func (ushuo *UsageStatisticHourUpdateOne) SetNillableStatus(u *uint8) *UsageStatisticHourUpdateOne {
  484. if u != nil {
  485. ushuo.SetStatus(*u)
  486. }
  487. return ushuo
  488. }
  489. // AddStatus adds u to the "status" field.
  490. func (ushuo *UsageStatisticHourUpdateOne) AddStatus(u int8) *UsageStatisticHourUpdateOne {
  491. ushuo.mutation.AddStatus(u)
  492. return ushuo
  493. }
  494. // ClearStatus clears the value of the "status" field.
  495. func (ushuo *UsageStatisticHourUpdateOne) ClearStatus() *UsageStatisticHourUpdateOne {
  496. ushuo.mutation.ClearStatus()
  497. return ushuo
  498. }
  499. // SetDeletedAt sets the "deleted_at" field.
  500. func (ushuo *UsageStatisticHourUpdateOne) SetDeletedAt(t time.Time) *UsageStatisticHourUpdateOne {
  501. ushuo.mutation.SetDeletedAt(t)
  502. return ushuo
  503. }
  504. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  505. func (ushuo *UsageStatisticHourUpdateOne) SetNillableDeletedAt(t *time.Time) *UsageStatisticHourUpdateOne {
  506. if t != nil {
  507. ushuo.SetDeletedAt(*t)
  508. }
  509. return ushuo
  510. }
  511. // ClearDeletedAt clears the value of the "deleted_at" field.
  512. func (ushuo *UsageStatisticHourUpdateOne) ClearDeletedAt() *UsageStatisticHourUpdateOne {
  513. ushuo.mutation.ClearDeletedAt()
  514. return ushuo
  515. }
  516. // SetAddtime sets the "addtime" field.
  517. func (ushuo *UsageStatisticHourUpdateOne) SetAddtime(u uint64) *UsageStatisticHourUpdateOne {
  518. ushuo.mutation.ResetAddtime()
  519. ushuo.mutation.SetAddtime(u)
  520. return ushuo
  521. }
  522. // SetNillableAddtime sets the "addtime" field if the given value is not nil.
  523. func (ushuo *UsageStatisticHourUpdateOne) SetNillableAddtime(u *uint64) *UsageStatisticHourUpdateOne {
  524. if u != nil {
  525. ushuo.SetAddtime(*u)
  526. }
  527. return ushuo
  528. }
  529. // AddAddtime adds u to the "addtime" field.
  530. func (ushuo *UsageStatisticHourUpdateOne) AddAddtime(u int64) *UsageStatisticHourUpdateOne {
  531. ushuo.mutation.AddAddtime(u)
  532. return ushuo
  533. }
  534. // SetType sets the "type" field.
  535. func (ushuo *UsageStatisticHourUpdateOne) SetType(i int) *UsageStatisticHourUpdateOne {
  536. ushuo.mutation.ResetType()
  537. ushuo.mutation.SetType(i)
  538. return ushuo
  539. }
  540. // SetNillableType sets the "type" field if the given value is not nil.
  541. func (ushuo *UsageStatisticHourUpdateOne) SetNillableType(i *int) *UsageStatisticHourUpdateOne {
  542. if i != nil {
  543. ushuo.SetType(*i)
  544. }
  545. return ushuo
  546. }
  547. // AddType adds i to the "type" field.
  548. func (ushuo *UsageStatisticHourUpdateOne) AddType(i int) *UsageStatisticHourUpdateOne {
  549. ushuo.mutation.AddType(i)
  550. return ushuo
  551. }
  552. // SetBotID sets the "bot_id" field.
  553. func (ushuo *UsageStatisticHourUpdateOne) SetBotID(s string) *UsageStatisticHourUpdateOne {
  554. ushuo.mutation.SetBotID(s)
  555. return ushuo
  556. }
  557. // SetNillableBotID sets the "bot_id" field if the given value is not nil.
  558. func (ushuo *UsageStatisticHourUpdateOne) SetNillableBotID(s *string) *UsageStatisticHourUpdateOne {
  559. if s != nil {
  560. ushuo.SetBotID(*s)
  561. }
  562. return ushuo
  563. }
  564. // ClearBotID clears the value of the "bot_id" field.
  565. func (ushuo *UsageStatisticHourUpdateOne) ClearBotID() *UsageStatisticHourUpdateOne {
  566. ushuo.mutation.ClearBotID()
  567. return ushuo
  568. }
  569. // SetOrganizationID sets the "organization_id" field.
  570. func (ushuo *UsageStatisticHourUpdateOne) SetOrganizationID(u uint64) *UsageStatisticHourUpdateOne {
  571. ushuo.mutation.ResetOrganizationID()
  572. ushuo.mutation.SetOrganizationID(u)
  573. return ushuo
  574. }
  575. // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
  576. func (ushuo *UsageStatisticHourUpdateOne) SetNillableOrganizationID(u *uint64) *UsageStatisticHourUpdateOne {
  577. if u != nil {
  578. ushuo.SetOrganizationID(*u)
  579. }
  580. return ushuo
  581. }
  582. // AddOrganizationID adds u to the "organization_id" field.
  583. func (ushuo *UsageStatisticHourUpdateOne) AddOrganizationID(u int64) *UsageStatisticHourUpdateOne {
  584. ushuo.mutation.AddOrganizationID(u)
  585. return ushuo
  586. }
  587. // ClearOrganizationID clears the value of the "organization_id" field.
  588. func (ushuo *UsageStatisticHourUpdateOne) ClearOrganizationID() *UsageStatisticHourUpdateOne {
  589. ushuo.mutation.ClearOrganizationID()
  590. return ushuo
  591. }
  592. // SetAiResponse sets the "ai_response" field.
  593. func (ushuo *UsageStatisticHourUpdateOne) SetAiResponse(u uint64) *UsageStatisticHourUpdateOne {
  594. ushuo.mutation.ResetAiResponse()
  595. ushuo.mutation.SetAiResponse(u)
  596. return ushuo
  597. }
  598. // SetNillableAiResponse sets the "ai_response" field if the given value is not nil.
  599. func (ushuo *UsageStatisticHourUpdateOne) SetNillableAiResponse(u *uint64) *UsageStatisticHourUpdateOne {
  600. if u != nil {
  601. ushuo.SetAiResponse(*u)
  602. }
  603. return ushuo
  604. }
  605. // AddAiResponse adds u to the "ai_response" field.
  606. func (ushuo *UsageStatisticHourUpdateOne) AddAiResponse(u int64) *UsageStatisticHourUpdateOne {
  607. ushuo.mutation.AddAiResponse(u)
  608. return ushuo
  609. }
  610. // SetSopRun sets the "sop_run" field.
  611. func (ushuo *UsageStatisticHourUpdateOne) SetSopRun(u uint64) *UsageStatisticHourUpdateOne {
  612. ushuo.mutation.ResetSopRun()
  613. ushuo.mutation.SetSopRun(u)
  614. return ushuo
  615. }
  616. // SetNillableSopRun sets the "sop_run" field if the given value is not nil.
  617. func (ushuo *UsageStatisticHourUpdateOne) SetNillableSopRun(u *uint64) *UsageStatisticHourUpdateOne {
  618. if u != nil {
  619. ushuo.SetSopRun(*u)
  620. }
  621. return ushuo
  622. }
  623. // AddSopRun adds u to the "sop_run" field.
  624. func (ushuo *UsageStatisticHourUpdateOne) AddSopRun(u int64) *UsageStatisticHourUpdateOne {
  625. ushuo.mutation.AddSopRun(u)
  626. return ushuo
  627. }
  628. // SetTotalFriend sets the "total_friend" field.
  629. func (ushuo *UsageStatisticHourUpdateOne) SetTotalFriend(u uint64) *UsageStatisticHourUpdateOne {
  630. ushuo.mutation.ResetTotalFriend()
  631. ushuo.mutation.SetTotalFriend(u)
  632. return ushuo
  633. }
  634. // SetNillableTotalFriend sets the "total_friend" field if the given value is not nil.
  635. func (ushuo *UsageStatisticHourUpdateOne) SetNillableTotalFriend(u *uint64) *UsageStatisticHourUpdateOne {
  636. if u != nil {
  637. ushuo.SetTotalFriend(*u)
  638. }
  639. return ushuo
  640. }
  641. // AddTotalFriend adds u to the "total_friend" field.
  642. func (ushuo *UsageStatisticHourUpdateOne) AddTotalFriend(u int64) *UsageStatisticHourUpdateOne {
  643. ushuo.mutation.AddTotalFriend(u)
  644. return ushuo
  645. }
  646. // SetTotalGroup sets the "total_group" field.
  647. func (ushuo *UsageStatisticHourUpdateOne) SetTotalGroup(u uint64) *UsageStatisticHourUpdateOne {
  648. ushuo.mutation.ResetTotalGroup()
  649. ushuo.mutation.SetTotalGroup(u)
  650. return ushuo
  651. }
  652. // SetNillableTotalGroup sets the "total_group" field if the given value is not nil.
  653. func (ushuo *UsageStatisticHourUpdateOne) SetNillableTotalGroup(u *uint64) *UsageStatisticHourUpdateOne {
  654. if u != nil {
  655. ushuo.SetTotalGroup(*u)
  656. }
  657. return ushuo
  658. }
  659. // AddTotalGroup adds u to the "total_group" field.
  660. func (ushuo *UsageStatisticHourUpdateOne) AddTotalGroup(u int64) *UsageStatisticHourUpdateOne {
  661. ushuo.mutation.AddTotalGroup(u)
  662. return ushuo
  663. }
  664. // SetAccountBalance sets the "account_balance" field.
  665. func (ushuo *UsageStatisticHourUpdateOne) SetAccountBalance(u uint64) *UsageStatisticHourUpdateOne {
  666. ushuo.mutation.ResetAccountBalance()
  667. ushuo.mutation.SetAccountBalance(u)
  668. return ushuo
  669. }
  670. // SetNillableAccountBalance sets the "account_balance" field if the given value is not nil.
  671. func (ushuo *UsageStatisticHourUpdateOne) SetNillableAccountBalance(u *uint64) *UsageStatisticHourUpdateOne {
  672. if u != nil {
  673. ushuo.SetAccountBalance(*u)
  674. }
  675. return ushuo
  676. }
  677. // AddAccountBalance adds u to the "account_balance" field.
  678. func (ushuo *UsageStatisticHourUpdateOne) AddAccountBalance(u int64) *UsageStatisticHourUpdateOne {
  679. ushuo.mutation.AddAccountBalance(u)
  680. return ushuo
  681. }
  682. // SetConsumeToken sets the "consume_token" field.
  683. func (ushuo *UsageStatisticHourUpdateOne) SetConsumeToken(u uint64) *UsageStatisticHourUpdateOne {
  684. ushuo.mutation.ResetConsumeToken()
  685. ushuo.mutation.SetConsumeToken(u)
  686. return ushuo
  687. }
  688. // SetNillableConsumeToken sets the "consume_token" field if the given value is not nil.
  689. func (ushuo *UsageStatisticHourUpdateOne) SetNillableConsumeToken(u *uint64) *UsageStatisticHourUpdateOne {
  690. if u != nil {
  691. ushuo.SetConsumeToken(*u)
  692. }
  693. return ushuo
  694. }
  695. // AddConsumeToken adds u to the "consume_token" field.
  696. func (ushuo *UsageStatisticHourUpdateOne) AddConsumeToken(u int64) *UsageStatisticHourUpdateOne {
  697. ushuo.mutation.AddConsumeToken(u)
  698. return ushuo
  699. }
  700. // SetActiveUser sets the "active_user" field.
  701. func (ushuo *UsageStatisticHourUpdateOne) SetActiveUser(u uint64) *UsageStatisticHourUpdateOne {
  702. ushuo.mutation.ResetActiveUser()
  703. ushuo.mutation.SetActiveUser(u)
  704. return ushuo
  705. }
  706. // SetNillableActiveUser sets the "active_user" field if the given value is not nil.
  707. func (ushuo *UsageStatisticHourUpdateOne) SetNillableActiveUser(u *uint64) *UsageStatisticHourUpdateOne {
  708. if u != nil {
  709. ushuo.SetActiveUser(*u)
  710. }
  711. return ushuo
  712. }
  713. // AddActiveUser adds u to the "active_user" field.
  714. func (ushuo *UsageStatisticHourUpdateOne) AddActiveUser(u int64) *UsageStatisticHourUpdateOne {
  715. ushuo.mutation.AddActiveUser(u)
  716. return ushuo
  717. }
  718. // SetNewUser sets the "new_user" field.
  719. func (ushuo *UsageStatisticHourUpdateOne) SetNewUser(i int64) *UsageStatisticHourUpdateOne {
  720. ushuo.mutation.ResetNewUser()
  721. ushuo.mutation.SetNewUser(i)
  722. return ushuo
  723. }
  724. // SetNillableNewUser sets the "new_user" field if the given value is not nil.
  725. func (ushuo *UsageStatisticHourUpdateOne) SetNillableNewUser(i *int64) *UsageStatisticHourUpdateOne {
  726. if i != nil {
  727. ushuo.SetNewUser(*i)
  728. }
  729. return ushuo
  730. }
  731. // AddNewUser adds i to the "new_user" field.
  732. func (ushuo *UsageStatisticHourUpdateOne) AddNewUser(i int64) *UsageStatisticHourUpdateOne {
  733. ushuo.mutation.AddNewUser(i)
  734. return ushuo
  735. }
  736. // SetLabelDist sets the "label_dist" field.
  737. func (ushuo *UsageStatisticHourUpdateOne) SetLabelDist(ctd []custom_types.LabelDist) *UsageStatisticHourUpdateOne {
  738. ushuo.mutation.SetLabelDist(ctd)
  739. return ushuo
  740. }
  741. // AppendLabelDist appends ctd to the "label_dist" field.
  742. func (ushuo *UsageStatisticHourUpdateOne) AppendLabelDist(ctd []custom_types.LabelDist) *UsageStatisticHourUpdateOne {
  743. ushuo.mutation.AppendLabelDist(ctd)
  744. return ushuo
  745. }
  746. // Mutation returns the UsageStatisticHourMutation object of the builder.
  747. func (ushuo *UsageStatisticHourUpdateOne) Mutation() *UsageStatisticHourMutation {
  748. return ushuo.mutation
  749. }
  750. // Where appends a list predicates to the UsageStatisticHourUpdate builder.
  751. func (ushuo *UsageStatisticHourUpdateOne) Where(ps ...predicate.UsageStatisticHour) *UsageStatisticHourUpdateOne {
  752. ushuo.mutation.Where(ps...)
  753. return ushuo
  754. }
  755. // Select allows selecting one or more fields (columns) of the returned entity.
  756. // The default is selecting all fields defined in the entity schema.
  757. func (ushuo *UsageStatisticHourUpdateOne) Select(field string, fields ...string) *UsageStatisticHourUpdateOne {
  758. ushuo.fields = append([]string{field}, fields...)
  759. return ushuo
  760. }
  761. // Save executes the query and returns the updated UsageStatisticHour entity.
  762. func (ushuo *UsageStatisticHourUpdateOne) Save(ctx context.Context) (*UsageStatisticHour, error) {
  763. if err := ushuo.defaults(); err != nil {
  764. return nil, err
  765. }
  766. return withHooks(ctx, ushuo.sqlSave, ushuo.mutation, ushuo.hooks)
  767. }
  768. // SaveX is like Save, but panics if an error occurs.
  769. func (ushuo *UsageStatisticHourUpdateOne) SaveX(ctx context.Context) *UsageStatisticHour {
  770. node, err := ushuo.Save(ctx)
  771. if err != nil {
  772. panic(err)
  773. }
  774. return node
  775. }
  776. // Exec executes the query on the entity.
  777. func (ushuo *UsageStatisticHourUpdateOne) Exec(ctx context.Context) error {
  778. _, err := ushuo.Save(ctx)
  779. return err
  780. }
  781. // ExecX is like Exec, but panics if an error occurs.
  782. func (ushuo *UsageStatisticHourUpdateOne) ExecX(ctx context.Context) {
  783. if err := ushuo.Exec(ctx); err != nil {
  784. panic(err)
  785. }
  786. }
  787. // defaults sets the default values of the builder before save.
  788. func (ushuo *UsageStatisticHourUpdateOne) defaults() error {
  789. if _, ok := ushuo.mutation.UpdatedAt(); !ok {
  790. if usagestatistichour.UpdateDefaultUpdatedAt == nil {
  791. return fmt.Errorf("ent: uninitialized usagestatistichour.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
  792. }
  793. v := usagestatistichour.UpdateDefaultUpdatedAt()
  794. ushuo.mutation.SetUpdatedAt(v)
  795. }
  796. return nil
  797. }
  798. func (ushuo *UsageStatisticHourUpdateOne) sqlSave(ctx context.Context) (_node *UsageStatisticHour, err error) {
  799. _spec := sqlgraph.NewUpdateSpec(usagestatistichour.Table, usagestatistichour.Columns, sqlgraph.NewFieldSpec(usagestatistichour.FieldID, field.TypeUint64))
  800. id, ok := ushuo.mutation.ID()
  801. if !ok {
  802. return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "UsageStatisticHour.id" for update`)}
  803. }
  804. _spec.Node.ID.Value = id
  805. if fields := ushuo.fields; len(fields) > 0 {
  806. _spec.Node.Columns = make([]string, 0, len(fields))
  807. _spec.Node.Columns = append(_spec.Node.Columns, usagestatistichour.FieldID)
  808. for _, f := range fields {
  809. if !usagestatistichour.ValidColumn(f) {
  810. return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
  811. }
  812. if f != usagestatistichour.FieldID {
  813. _spec.Node.Columns = append(_spec.Node.Columns, f)
  814. }
  815. }
  816. }
  817. if ps := ushuo.mutation.predicates; len(ps) > 0 {
  818. _spec.Predicate = func(selector *sql.Selector) {
  819. for i := range ps {
  820. ps[i](selector)
  821. }
  822. }
  823. }
  824. if value, ok := ushuo.mutation.UpdatedAt(); ok {
  825. _spec.SetField(usagestatistichour.FieldUpdatedAt, field.TypeTime, value)
  826. }
  827. if value, ok := ushuo.mutation.Status(); ok {
  828. _spec.SetField(usagestatistichour.FieldStatus, field.TypeUint8, value)
  829. }
  830. if value, ok := ushuo.mutation.AddedStatus(); ok {
  831. _spec.AddField(usagestatistichour.FieldStatus, field.TypeUint8, value)
  832. }
  833. if ushuo.mutation.StatusCleared() {
  834. _spec.ClearField(usagestatistichour.FieldStatus, field.TypeUint8)
  835. }
  836. if value, ok := ushuo.mutation.DeletedAt(); ok {
  837. _spec.SetField(usagestatistichour.FieldDeletedAt, field.TypeTime, value)
  838. }
  839. if ushuo.mutation.DeletedAtCleared() {
  840. _spec.ClearField(usagestatistichour.FieldDeletedAt, field.TypeTime)
  841. }
  842. if value, ok := ushuo.mutation.Addtime(); ok {
  843. _spec.SetField(usagestatistichour.FieldAddtime, field.TypeUint64, value)
  844. }
  845. if value, ok := ushuo.mutation.AddedAddtime(); ok {
  846. _spec.AddField(usagestatistichour.FieldAddtime, field.TypeUint64, value)
  847. }
  848. if value, ok := ushuo.mutation.GetType(); ok {
  849. _spec.SetField(usagestatistichour.FieldType, field.TypeInt, value)
  850. }
  851. if value, ok := ushuo.mutation.AddedType(); ok {
  852. _spec.AddField(usagestatistichour.FieldType, field.TypeInt, value)
  853. }
  854. if value, ok := ushuo.mutation.BotID(); ok {
  855. _spec.SetField(usagestatistichour.FieldBotID, field.TypeString, value)
  856. }
  857. if ushuo.mutation.BotIDCleared() {
  858. _spec.ClearField(usagestatistichour.FieldBotID, field.TypeString)
  859. }
  860. if value, ok := ushuo.mutation.OrganizationID(); ok {
  861. _spec.SetField(usagestatistichour.FieldOrganizationID, field.TypeUint64, value)
  862. }
  863. if value, ok := ushuo.mutation.AddedOrganizationID(); ok {
  864. _spec.AddField(usagestatistichour.FieldOrganizationID, field.TypeUint64, value)
  865. }
  866. if ushuo.mutation.OrganizationIDCleared() {
  867. _spec.ClearField(usagestatistichour.FieldOrganizationID, field.TypeUint64)
  868. }
  869. if value, ok := ushuo.mutation.AiResponse(); ok {
  870. _spec.SetField(usagestatistichour.FieldAiResponse, field.TypeUint64, value)
  871. }
  872. if value, ok := ushuo.mutation.AddedAiResponse(); ok {
  873. _spec.AddField(usagestatistichour.FieldAiResponse, field.TypeUint64, value)
  874. }
  875. if value, ok := ushuo.mutation.SopRun(); ok {
  876. _spec.SetField(usagestatistichour.FieldSopRun, field.TypeUint64, value)
  877. }
  878. if value, ok := ushuo.mutation.AddedSopRun(); ok {
  879. _spec.AddField(usagestatistichour.FieldSopRun, field.TypeUint64, value)
  880. }
  881. if value, ok := ushuo.mutation.TotalFriend(); ok {
  882. _spec.SetField(usagestatistichour.FieldTotalFriend, field.TypeUint64, value)
  883. }
  884. if value, ok := ushuo.mutation.AddedTotalFriend(); ok {
  885. _spec.AddField(usagestatistichour.FieldTotalFriend, field.TypeUint64, value)
  886. }
  887. if value, ok := ushuo.mutation.TotalGroup(); ok {
  888. _spec.SetField(usagestatistichour.FieldTotalGroup, field.TypeUint64, value)
  889. }
  890. if value, ok := ushuo.mutation.AddedTotalGroup(); ok {
  891. _spec.AddField(usagestatistichour.FieldTotalGroup, field.TypeUint64, value)
  892. }
  893. if value, ok := ushuo.mutation.AccountBalance(); ok {
  894. _spec.SetField(usagestatistichour.FieldAccountBalance, field.TypeUint64, value)
  895. }
  896. if value, ok := ushuo.mutation.AddedAccountBalance(); ok {
  897. _spec.AddField(usagestatistichour.FieldAccountBalance, field.TypeUint64, value)
  898. }
  899. if value, ok := ushuo.mutation.ConsumeToken(); ok {
  900. _spec.SetField(usagestatistichour.FieldConsumeToken, field.TypeUint64, value)
  901. }
  902. if value, ok := ushuo.mutation.AddedConsumeToken(); ok {
  903. _spec.AddField(usagestatistichour.FieldConsumeToken, field.TypeUint64, value)
  904. }
  905. if value, ok := ushuo.mutation.ActiveUser(); ok {
  906. _spec.SetField(usagestatistichour.FieldActiveUser, field.TypeUint64, value)
  907. }
  908. if value, ok := ushuo.mutation.AddedActiveUser(); ok {
  909. _spec.AddField(usagestatistichour.FieldActiveUser, field.TypeUint64, value)
  910. }
  911. if value, ok := ushuo.mutation.NewUser(); ok {
  912. _spec.SetField(usagestatistichour.FieldNewUser, field.TypeInt64, value)
  913. }
  914. if value, ok := ushuo.mutation.AddedNewUser(); ok {
  915. _spec.AddField(usagestatistichour.FieldNewUser, field.TypeInt64, value)
  916. }
  917. if value, ok := ushuo.mutation.LabelDist(); ok {
  918. _spec.SetField(usagestatistichour.FieldLabelDist, field.TypeJSON, value)
  919. }
  920. if value, ok := ushuo.mutation.AppendedLabelDist(); ok {
  921. _spec.AddModifier(func(u *sql.UpdateBuilder) {
  922. sqljson.Append(u, usagestatistichour.FieldLabelDist, value)
  923. })
  924. }
  925. _node = &UsageStatisticHour{config: ushuo.config}
  926. _spec.Assign = _node.assignValues
  927. _spec.ScanValues = _node.scanValues
  928. if err = sqlgraph.UpdateNode(ctx, ushuo.driver, _spec); err != nil {
  929. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  930. err = &NotFoundError{usagestatistichour.Label}
  931. } else if sqlgraph.IsConstraintError(err) {
  932. err = &ConstraintError{msg: err.Error(), wrap: err}
  933. }
  934. return nil, err
  935. }
  936. ushuo.mutation.done = true
  937. return _node, nil
  938. }