usagestatistichour_update.go 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126
  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. // SetConsumeCoin sets the "consume_coin" field.
  303. func (ushu *UsageStatisticHourUpdate) SetConsumeCoin(u uint64) *UsageStatisticHourUpdate {
  304. ushu.mutation.ResetConsumeCoin()
  305. ushu.mutation.SetConsumeCoin(u)
  306. return ushu
  307. }
  308. // SetNillableConsumeCoin sets the "consume_coin" field if the given value is not nil.
  309. func (ushu *UsageStatisticHourUpdate) SetNillableConsumeCoin(u *uint64) *UsageStatisticHourUpdate {
  310. if u != nil {
  311. ushu.SetConsumeCoin(*u)
  312. }
  313. return ushu
  314. }
  315. // AddConsumeCoin adds u to the "consume_coin" field.
  316. func (ushu *UsageStatisticHourUpdate) AddConsumeCoin(u int64) *UsageStatisticHourUpdate {
  317. ushu.mutation.AddConsumeCoin(u)
  318. return ushu
  319. }
  320. // ClearConsumeCoin clears the value of the "consume_coin" field.
  321. func (ushu *UsageStatisticHourUpdate) ClearConsumeCoin() *UsageStatisticHourUpdate {
  322. ushu.mutation.ClearConsumeCoin()
  323. return ushu
  324. }
  325. // Mutation returns the UsageStatisticHourMutation object of the builder.
  326. func (ushu *UsageStatisticHourUpdate) Mutation() *UsageStatisticHourMutation {
  327. return ushu.mutation
  328. }
  329. // Save executes the query and returns the number of nodes affected by the update operation.
  330. func (ushu *UsageStatisticHourUpdate) Save(ctx context.Context) (int, error) {
  331. if err := ushu.defaults(); err != nil {
  332. return 0, err
  333. }
  334. return withHooks(ctx, ushu.sqlSave, ushu.mutation, ushu.hooks)
  335. }
  336. // SaveX is like Save, but panics if an error occurs.
  337. func (ushu *UsageStatisticHourUpdate) SaveX(ctx context.Context) int {
  338. affected, err := ushu.Save(ctx)
  339. if err != nil {
  340. panic(err)
  341. }
  342. return affected
  343. }
  344. // Exec executes the query.
  345. func (ushu *UsageStatisticHourUpdate) Exec(ctx context.Context) error {
  346. _, err := ushu.Save(ctx)
  347. return err
  348. }
  349. // ExecX is like Exec, but panics if an error occurs.
  350. func (ushu *UsageStatisticHourUpdate) ExecX(ctx context.Context) {
  351. if err := ushu.Exec(ctx); err != nil {
  352. panic(err)
  353. }
  354. }
  355. // defaults sets the default values of the builder before save.
  356. func (ushu *UsageStatisticHourUpdate) defaults() error {
  357. if _, ok := ushu.mutation.UpdatedAt(); !ok {
  358. if usagestatistichour.UpdateDefaultUpdatedAt == nil {
  359. return fmt.Errorf("ent: uninitialized usagestatistichour.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
  360. }
  361. v := usagestatistichour.UpdateDefaultUpdatedAt()
  362. ushu.mutation.SetUpdatedAt(v)
  363. }
  364. return nil
  365. }
  366. func (ushu *UsageStatisticHourUpdate) sqlSave(ctx context.Context) (n int, err error) {
  367. _spec := sqlgraph.NewUpdateSpec(usagestatistichour.Table, usagestatistichour.Columns, sqlgraph.NewFieldSpec(usagestatistichour.FieldID, field.TypeUint64))
  368. if ps := ushu.mutation.predicates; len(ps) > 0 {
  369. _spec.Predicate = func(selector *sql.Selector) {
  370. for i := range ps {
  371. ps[i](selector)
  372. }
  373. }
  374. }
  375. if value, ok := ushu.mutation.UpdatedAt(); ok {
  376. _spec.SetField(usagestatistichour.FieldUpdatedAt, field.TypeTime, value)
  377. }
  378. if value, ok := ushu.mutation.Status(); ok {
  379. _spec.SetField(usagestatistichour.FieldStatus, field.TypeUint8, value)
  380. }
  381. if value, ok := ushu.mutation.AddedStatus(); ok {
  382. _spec.AddField(usagestatistichour.FieldStatus, field.TypeUint8, value)
  383. }
  384. if ushu.mutation.StatusCleared() {
  385. _spec.ClearField(usagestatistichour.FieldStatus, field.TypeUint8)
  386. }
  387. if value, ok := ushu.mutation.DeletedAt(); ok {
  388. _spec.SetField(usagestatistichour.FieldDeletedAt, field.TypeTime, value)
  389. }
  390. if ushu.mutation.DeletedAtCleared() {
  391. _spec.ClearField(usagestatistichour.FieldDeletedAt, field.TypeTime)
  392. }
  393. if value, ok := ushu.mutation.Addtime(); ok {
  394. _spec.SetField(usagestatistichour.FieldAddtime, field.TypeUint64, value)
  395. }
  396. if value, ok := ushu.mutation.AddedAddtime(); ok {
  397. _spec.AddField(usagestatistichour.FieldAddtime, field.TypeUint64, value)
  398. }
  399. if value, ok := ushu.mutation.GetType(); ok {
  400. _spec.SetField(usagestatistichour.FieldType, field.TypeInt, value)
  401. }
  402. if value, ok := ushu.mutation.AddedType(); ok {
  403. _spec.AddField(usagestatistichour.FieldType, field.TypeInt, value)
  404. }
  405. if value, ok := ushu.mutation.BotID(); ok {
  406. _spec.SetField(usagestatistichour.FieldBotID, field.TypeString, value)
  407. }
  408. if ushu.mutation.BotIDCleared() {
  409. _spec.ClearField(usagestatistichour.FieldBotID, field.TypeString)
  410. }
  411. if value, ok := ushu.mutation.OrganizationID(); ok {
  412. _spec.SetField(usagestatistichour.FieldOrganizationID, field.TypeUint64, value)
  413. }
  414. if value, ok := ushu.mutation.AddedOrganizationID(); ok {
  415. _spec.AddField(usagestatistichour.FieldOrganizationID, field.TypeUint64, value)
  416. }
  417. if ushu.mutation.OrganizationIDCleared() {
  418. _spec.ClearField(usagestatistichour.FieldOrganizationID, field.TypeUint64)
  419. }
  420. if value, ok := ushu.mutation.AiResponse(); ok {
  421. _spec.SetField(usagestatistichour.FieldAiResponse, field.TypeUint64, value)
  422. }
  423. if value, ok := ushu.mutation.AddedAiResponse(); ok {
  424. _spec.AddField(usagestatistichour.FieldAiResponse, field.TypeUint64, value)
  425. }
  426. if value, ok := ushu.mutation.SopRun(); ok {
  427. _spec.SetField(usagestatistichour.FieldSopRun, field.TypeUint64, value)
  428. }
  429. if value, ok := ushu.mutation.AddedSopRun(); ok {
  430. _spec.AddField(usagestatistichour.FieldSopRun, field.TypeUint64, value)
  431. }
  432. if value, ok := ushu.mutation.TotalFriend(); ok {
  433. _spec.SetField(usagestatistichour.FieldTotalFriend, field.TypeUint64, value)
  434. }
  435. if value, ok := ushu.mutation.AddedTotalFriend(); ok {
  436. _spec.AddField(usagestatistichour.FieldTotalFriend, field.TypeUint64, value)
  437. }
  438. if value, ok := ushu.mutation.TotalGroup(); ok {
  439. _spec.SetField(usagestatistichour.FieldTotalGroup, field.TypeUint64, value)
  440. }
  441. if value, ok := ushu.mutation.AddedTotalGroup(); ok {
  442. _spec.AddField(usagestatistichour.FieldTotalGroup, field.TypeUint64, value)
  443. }
  444. if value, ok := ushu.mutation.AccountBalance(); ok {
  445. _spec.SetField(usagestatistichour.FieldAccountBalance, field.TypeUint64, value)
  446. }
  447. if value, ok := ushu.mutation.AddedAccountBalance(); ok {
  448. _spec.AddField(usagestatistichour.FieldAccountBalance, field.TypeUint64, value)
  449. }
  450. if value, ok := ushu.mutation.ConsumeToken(); ok {
  451. _spec.SetField(usagestatistichour.FieldConsumeToken, field.TypeUint64, value)
  452. }
  453. if value, ok := ushu.mutation.AddedConsumeToken(); ok {
  454. _spec.AddField(usagestatistichour.FieldConsumeToken, field.TypeUint64, value)
  455. }
  456. if value, ok := ushu.mutation.ActiveUser(); ok {
  457. _spec.SetField(usagestatistichour.FieldActiveUser, field.TypeUint64, value)
  458. }
  459. if value, ok := ushu.mutation.AddedActiveUser(); ok {
  460. _spec.AddField(usagestatistichour.FieldActiveUser, field.TypeUint64, value)
  461. }
  462. if value, ok := ushu.mutation.NewUser(); ok {
  463. _spec.SetField(usagestatistichour.FieldNewUser, field.TypeInt64, value)
  464. }
  465. if value, ok := ushu.mutation.AddedNewUser(); ok {
  466. _spec.AddField(usagestatistichour.FieldNewUser, field.TypeInt64, value)
  467. }
  468. if value, ok := ushu.mutation.LabelDist(); ok {
  469. _spec.SetField(usagestatistichour.FieldLabelDist, field.TypeJSON, value)
  470. }
  471. if value, ok := ushu.mutation.AppendedLabelDist(); ok {
  472. _spec.AddModifier(func(u *sql.UpdateBuilder) {
  473. sqljson.Append(u, usagestatistichour.FieldLabelDist, value)
  474. })
  475. }
  476. if value, ok := ushu.mutation.ConsumeCoin(); ok {
  477. _spec.SetField(usagestatistichour.FieldConsumeCoin, field.TypeUint64, value)
  478. }
  479. if value, ok := ushu.mutation.AddedConsumeCoin(); ok {
  480. _spec.AddField(usagestatistichour.FieldConsumeCoin, field.TypeUint64, value)
  481. }
  482. if ushu.mutation.ConsumeCoinCleared() {
  483. _spec.ClearField(usagestatistichour.FieldConsumeCoin, field.TypeUint64)
  484. }
  485. if n, err = sqlgraph.UpdateNodes(ctx, ushu.driver, _spec); err != nil {
  486. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  487. err = &NotFoundError{usagestatistichour.Label}
  488. } else if sqlgraph.IsConstraintError(err) {
  489. err = &ConstraintError{msg: err.Error(), wrap: err}
  490. }
  491. return 0, err
  492. }
  493. ushu.mutation.done = true
  494. return n, nil
  495. }
  496. // UsageStatisticHourUpdateOne is the builder for updating a single UsageStatisticHour entity.
  497. type UsageStatisticHourUpdateOne struct {
  498. config
  499. fields []string
  500. hooks []Hook
  501. mutation *UsageStatisticHourMutation
  502. }
  503. // SetUpdatedAt sets the "updated_at" field.
  504. func (ushuo *UsageStatisticHourUpdateOne) SetUpdatedAt(t time.Time) *UsageStatisticHourUpdateOne {
  505. ushuo.mutation.SetUpdatedAt(t)
  506. return ushuo
  507. }
  508. // SetStatus sets the "status" field.
  509. func (ushuo *UsageStatisticHourUpdateOne) SetStatus(u uint8) *UsageStatisticHourUpdateOne {
  510. ushuo.mutation.ResetStatus()
  511. ushuo.mutation.SetStatus(u)
  512. return ushuo
  513. }
  514. // SetNillableStatus sets the "status" field if the given value is not nil.
  515. func (ushuo *UsageStatisticHourUpdateOne) SetNillableStatus(u *uint8) *UsageStatisticHourUpdateOne {
  516. if u != nil {
  517. ushuo.SetStatus(*u)
  518. }
  519. return ushuo
  520. }
  521. // AddStatus adds u to the "status" field.
  522. func (ushuo *UsageStatisticHourUpdateOne) AddStatus(u int8) *UsageStatisticHourUpdateOne {
  523. ushuo.mutation.AddStatus(u)
  524. return ushuo
  525. }
  526. // ClearStatus clears the value of the "status" field.
  527. func (ushuo *UsageStatisticHourUpdateOne) ClearStatus() *UsageStatisticHourUpdateOne {
  528. ushuo.mutation.ClearStatus()
  529. return ushuo
  530. }
  531. // SetDeletedAt sets the "deleted_at" field.
  532. func (ushuo *UsageStatisticHourUpdateOne) SetDeletedAt(t time.Time) *UsageStatisticHourUpdateOne {
  533. ushuo.mutation.SetDeletedAt(t)
  534. return ushuo
  535. }
  536. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  537. func (ushuo *UsageStatisticHourUpdateOne) SetNillableDeletedAt(t *time.Time) *UsageStatisticHourUpdateOne {
  538. if t != nil {
  539. ushuo.SetDeletedAt(*t)
  540. }
  541. return ushuo
  542. }
  543. // ClearDeletedAt clears the value of the "deleted_at" field.
  544. func (ushuo *UsageStatisticHourUpdateOne) ClearDeletedAt() *UsageStatisticHourUpdateOne {
  545. ushuo.mutation.ClearDeletedAt()
  546. return ushuo
  547. }
  548. // SetAddtime sets the "addtime" field.
  549. func (ushuo *UsageStatisticHourUpdateOne) SetAddtime(u uint64) *UsageStatisticHourUpdateOne {
  550. ushuo.mutation.ResetAddtime()
  551. ushuo.mutation.SetAddtime(u)
  552. return ushuo
  553. }
  554. // SetNillableAddtime sets the "addtime" field if the given value is not nil.
  555. func (ushuo *UsageStatisticHourUpdateOne) SetNillableAddtime(u *uint64) *UsageStatisticHourUpdateOne {
  556. if u != nil {
  557. ushuo.SetAddtime(*u)
  558. }
  559. return ushuo
  560. }
  561. // AddAddtime adds u to the "addtime" field.
  562. func (ushuo *UsageStatisticHourUpdateOne) AddAddtime(u int64) *UsageStatisticHourUpdateOne {
  563. ushuo.mutation.AddAddtime(u)
  564. return ushuo
  565. }
  566. // SetType sets the "type" field.
  567. func (ushuo *UsageStatisticHourUpdateOne) SetType(i int) *UsageStatisticHourUpdateOne {
  568. ushuo.mutation.ResetType()
  569. ushuo.mutation.SetType(i)
  570. return ushuo
  571. }
  572. // SetNillableType sets the "type" field if the given value is not nil.
  573. func (ushuo *UsageStatisticHourUpdateOne) SetNillableType(i *int) *UsageStatisticHourUpdateOne {
  574. if i != nil {
  575. ushuo.SetType(*i)
  576. }
  577. return ushuo
  578. }
  579. // AddType adds i to the "type" field.
  580. func (ushuo *UsageStatisticHourUpdateOne) AddType(i int) *UsageStatisticHourUpdateOne {
  581. ushuo.mutation.AddType(i)
  582. return ushuo
  583. }
  584. // SetBotID sets the "bot_id" field.
  585. func (ushuo *UsageStatisticHourUpdateOne) SetBotID(s string) *UsageStatisticHourUpdateOne {
  586. ushuo.mutation.SetBotID(s)
  587. return ushuo
  588. }
  589. // SetNillableBotID sets the "bot_id" field if the given value is not nil.
  590. func (ushuo *UsageStatisticHourUpdateOne) SetNillableBotID(s *string) *UsageStatisticHourUpdateOne {
  591. if s != nil {
  592. ushuo.SetBotID(*s)
  593. }
  594. return ushuo
  595. }
  596. // ClearBotID clears the value of the "bot_id" field.
  597. func (ushuo *UsageStatisticHourUpdateOne) ClearBotID() *UsageStatisticHourUpdateOne {
  598. ushuo.mutation.ClearBotID()
  599. return ushuo
  600. }
  601. // SetOrganizationID sets the "organization_id" field.
  602. func (ushuo *UsageStatisticHourUpdateOne) SetOrganizationID(u uint64) *UsageStatisticHourUpdateOne {
  603. ushuo.mutation.ResetOrganizationID()
  604. ushuo.mutation.SetOrganizationID(u)
  605. return ushuo
  606. }
  607. // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
  608. func (ushuo *UsageStatisticHourUpdateOne) SetNillableOrganizationID(u *uint64) *UsageStatisticHourUpdateOne {
  609. if u != nil {
  610. ushuo.SetOrganizationID(*u)
  611. }
  612. return ushuo
  613. }
  614. // AddOrganizationID adds u to the "organization_id" field.
  615. func (ushuo *UsageStatisticHourUpdateOne) AddOrganizationID(u int64) *UsageStatisticHourUpdateOne {
  616. ushuo.mutation.AddOrganizationID(u)
  617. return ushuo
  618. }
  619. // ClearOrganizationID clears the value of the "organization_id" field.
  620. func (ushuo *UsageStatisticHourUpdateOne) ClearOrganizationID() *UsageStatisticHourUpdateOne {
  621. ushuo.mutation.ClearOrganizationID()
  622. return ushuo
  623. }
  624. // SetAiResponse sets the "ai_response" field.
  625. func (ushuo *UsageStatisticHourUpdateOne) SetAiResponse(u uint64) *UsageStatisticHourUpdateOne {
  626. ushuo.mutation.ResetAiResponse()
  627. ushuo.mutation.SetAiResponse(u)
  628. return ushuo
  629. }
  630. // SetNillableAiResponse sets the "ai_response" field if the given value is not nil.
  631. func (ushuo *UsageStatisticHourUpdateOne) SetNillableAiResponse(u *uint64) *UsageStatisticHourUpdateOne {
  632. if u != nil {
  633. ushuo.SetAiResponse(*u)
  634. }
  635. return ushuo
  636. }
  637. // AddAiResponse adds u to the "ai_response" field.
  638. func (ushuo *UsageStatisticHourUpdateOne) AddAiResponse(u int64) *UsageStatisticHourUpdateOne {
  639. ushuo.mutation.AddAiResponse(u)
  640. return ushuo
  641. }
  642. // SetSopRun sets the "sop_run" field.
  643. func (ushuo *UsageStatisticHourUpdateOne) SetSopRun(u uint64) *UsageStatisticHourUpdateOne {
  644. ushuo.mutation.ResetSopRun()
  645. ushuo.mutation.SetSopRun(u)
  646. return ushuo
  647. }
  648. // SetNillableSopRun sets the "sop_run" field if the given value is not nil.
  649. func (ushuo *UsageStatisticHourUpdateOne) SetNillableSopRun(u *uint64) *UsageStatisticHourUpdateOne {
  650. if u != nil {
  651. ushuo.SetSopRun(*u)
  652. }
  653. return ushuo
  654. }
  655. // AddSopRun adds u to the "sop_run" field.
  656. func (ushuo *UsageStatisticHourUpdateOne) AddSopRun(u int64) *UsageStatisticHourUpdateOne {
  657. ushuo.mutation.AddSopRun(u)
  658. return ushuo
  659. }
  660. // SetTotalFriend sets the "total_friend" field.
  661. func (ushuo *UsageStatisticHourUpdateOne) SetTotalFriend(u uint64) *UsageStatisticHourUpdateOne {
  662. ushuo.mutation.ResetTotalFriend()
  663. ushuo.mutation.SetTotalFriend(u)
  664. return ushuo
  665. }
  666. // SetNillableTotalFriend sets the "total_friend" field if the given value is not nil.
  667. func (ushuo *UsageStatisticHourUpdateOne) SetNillableTotalFriend(u *uint64) *UsageStatisticHourUpdateOne {
  668. if u != nil {
  669. ushuo.SetTotalFriend(*u)
  670. }
  671. return ushuo
  672. }
  673. // AddTotalFriend adds u to the "total_friend" field.
  674. func (ushuo *UsageStatisticHourUpdateOne) AddTotalFriend(u int64) *UsageStatisticHourUpdateOne {
  675. ushuo.mutation.AddTotalFriend(u)
  676. return ushuo
  677. }
  678. // SetTotalGroup sets the "total_group" field.
  679. func (ushuo *UsageStatisticHourUpdateOne) SetTotalGroup(u uint64) *UsageStatisticHourUpdateOne {
  680. ushuo.mutation.ResetTotalGroup()
  681. ushuo.mutation.SetTotalGroup(u)
  682. return ushuo
  683. }
  684. // SetNillableTotalGroup sets the "total_group" field if the given value is not nil.
  685. func (ushuo *UsageStatisticHourUpdateOne) SetNillableTotalGroup(u *uint64) *UsageStatisticHourUpdateOne {
  686. if u != nil {
  687. ushuo.SetTotalGroup(*u)
  688. }
  689. return ushuo
  690. }
  691. // AddTotalGroup adds u to the "total_group" field.
  692. func (ushuo *UsageStatisticHourUpdateOne) AddTotalGroup(u int64) *UsageStatisticHourUpdateOne {
  693. ushuo.mutation.AddTotalGroup(u)
  694. return ushuo
  695. }
  696. // SetAccountBalance sets the "account_balance" field.
  697. func (ushuo *UsageStatisticHourUpdateOne) SetAccountBalance(u uint64) *UsageStatisticHourUpdateOne {
  698. ushuo.mutation.ResetAccountBalance()
  699. ushuo.mutation.SetAccountBalance(u)
  700. return ushuo
  701. }
  702. // SetNillableAccountBalance sets the "account_balance" field if the given value is not nil.
  703. func (ushuo *UsageStatisticHourUpdateOne) SetNillableAccountBalance(u *uint64) *UsageStatisticHourUpdateOne {
  704. if u != nil {
  705. ushuo.SetAccountBalance(*u)
  706. }
  707. return ushuo
  708. }
  709. // AddAccountBalance adds u to the "account_balance" field.
  710. func (ushuo *UsageStatisticHourUpdateOne) AddAccountBalance(u int64) *UsageStatisticHourUpdateOne {
  711. ushuo.mutation.AddAccountBalance(u)
  712. return ushuo
  713. }
  714. // SetConsumeToken sets the "consume_token" field.
  715. func (ushuo *UsageStatisticHourUpdateOne) SetConsumeToken(u uint64) *UsageStatisticHourUpdateOne {
  716. ushuo.mutation.ResetConsumeToken()
  717. ushuo.mutation.SetConsumeToken(u)
  718. return ushuo
  719. }
  720. // SetNillableConsumeToken sets the "consume_token" field if the given value is not nil.
  721. func (ushuo *UsageStatisticHourUpdateOne) SetNillableConsumeToken(u *uint64) *UsageStatisticHourUpdateOne {
  722. if u != nil {
  723. ushuo.SetConsumeToken(*u)
  724. }
  725. return ushuo
  726. }
  727. // AddConsumeToken adds u to the "consume_token" field.
  728. func (ushuo *UsageStatisticHourUpdateOne) AddConsumeToken(u int64) *UsageStatisticHourUpdateOne {
  729. ushuo.mutation.AddConsumeToken(u)
  730. return ushuo
  731. }
  732. // SetActiveUser sets the "active_user" field.
  733. func (ushuo *UsageStatisticHourUpdateOne) SetActiveUser(u uint64) *UsageStatisticHourUpdateOne {
  734. ushuo.mutation.ResetActiveUser()
  735. ushuo.mutation.SetActiveUser(u)
  736. return ushuo
  737. }
  738. // SetNillableActiveUser sets the "active_user" field if the given value is not nil.
  739. func (ushuo *UsageStatisticHourUpdateOne) SetNillableActiveUser(u *uint64) *UsageStatisticHourUpdateOne {
  740. if u != nil {
  741. ushuo.SetActiveUser(*u)
  742. }
  743. return ushuo
  744. }
  745. // AddActiveUser adds u to the "active_user" field.
  746. func (ushuo *UsageStatisticHourUpdateOne) AddActiveUser(u int64) *UsageStatisticHourUpdateOne {
  747. ushuo.mutation.AddActiveUser(u)
  748. return ushuo
  749. }
  750. // SetNewUser sets the "new_user" field.
  751. func (ushuo *UsageStatisticHourUpdateOne) SetNewUser(i int64) *UsageStatisticHourUpdateOne {
  752. ushuo.mutation.ResetNewUser()
  753. ushuo.mutation.SetNewUser(i)
  754. return ushuo
  755. }
  756. // SetNillableNewUser sets the "new_user" field if the given value is not nil.
  757. func (ushuo *UsageStatisticHourUpdateOne) SetNillableNewUser(i *int64) *UsageStatisticHourUpdateOne {
  758. if i != nil {
  759. ushuo.SetNewUser(*i)
  760. }
  761. return ushuo
  762. }
  763. // AddNewUser adds i to the "new_user" field.
  764. func (ushuo *UsageStatisticHourUpdateOne) AddNewUser(i int64) *UsageStatisticHourUpdateOne {
  765. ushuo.mutation.AddNewUser(i)
  766. return ushuo
  767. }
  768. // SetLabelDist sets the "label_dist" field.
  769. func (ushuo *UsageStatisticHourUpdateOne) SetLabelDist(ctd []custom_types.LabelDist) *UsageStatisticHourUpdateOne {
  770. ushuo.mutation.SetLabelDist(ctd)
  771. return ushuo
  772. }
  773. // AppendLabelDist appends ctd to the "label_dist" field.
  774. func (ushuo *UsageStatisticHourUpdateOne) AppendLabelDist(ctd []custom_types.LabelDist) *UsageStatisticHourUpdateOne {
  775. ushuo.mutation.AppendLabelDist(ctd)
  776. return ushuo
  777. }
  778. // SetConsumeCoin sets the "consume_coin" field.
  779. func (ushuo *UsageStatisticHourUpdateOne) SetConsumeCoin(u uint64) *UsageStatisticHourUpdateOne {
  780. ushuo.mutation.ResetConsumeCoin()
  781. ushuo.mutation.SetConsumeCoin(u)
  782. return ushuo
  783. }
  784. // SetNillableConsumeCoin sets the "consume_coin" field if the given value is not nil.
  785. func (ushuo *UsageStatisticHourUpdateOne) SetNillableConsumeCoin(u *uint64) *UsageStatisticHourUpdateOne {
  786. if u != nil {
  787. ushuo.SetConsumeCoin(*u)
  788. }
  789. return ushuo
  790. }
  791. // AddConsumeCoin adds u to the "consume_coin" field.
  792. func (ushuo *UsageStatisticHourUpdateOne) AddConsumeCoin(u int64) *UsageStatisticHourUpdateOne {
  793. ushuo.mutation.AddConsumeCoin(u)
  794. return ushuo
  795. }
  796. // ClearConsumeCoin clears the value of the "consume_coin" field.
  797. func (ushuo *UsageStatisticHourUpdateOne) ClearConsumeCoin() *UsageStatisticHourUpdateOne {
  798. ushuo.mutation.ClearConsumeCoin()
  799. return ushuo
  800. }
  801. // Mutation returns the UsageStatisticHourMutation object of the builder.
  802. func (ushuo *UsageStatisticHourUpdateOne) Mutation() *UsageStatisticHourMutation {
  803. return ushuo.mutation
  804. }
  805. // Where appends a list predicates to the UsageStatisticHourUpdate builder.
  806. func (ushuo *UsageStatisticHourUpdateOne) Where(ps ...predicate.UsageStatisticHour) *UsageStatisticHourUpdateOne {
  807. ushuo.mutation.Where(ps...)
  808. return ushuo
  809. }
  810. // Select allows selecting one or more fields (columns) of the returned entity.
  811. // The default is selecting all fields defined in the entity schema.
  812. func (ushuo *UsageStatisticHourUpdateOne) Select(field string, fields ...string) *UsageStatisticHourUpdateOne {
  813. ushuo.fields = append([]string{field}, fields...)
  814. return ushuo
  815. }
  816. // Save executes the query and returns the updated UsageStatisticHour entity.
  817. func (ushuo *UsageStatisticHourUpdateOne) Save(ctx context.Context) (*UsageStatisticHour, error) {
  818. if err := ushuo.defaults(); err != nil {
  819. return nil, err
  820. }
  821. return withHooks(ctx, ushuo.sqlSave, ushuo.mutation, ushuo.hooks)
  822. }
  823. // SaveX is like Save, but panics if an error occurs.
  824. func (ushuo *UsageStatisticHourUpdateOne) SaveX(ctx context.Context) *UsageStatisticHour {
  825. node, err := ushuo.Save(ctx)
  826. if err != nil {
  827. panic(err)
  828. }
  829. return node
  830. }
  831. // Exec executes the query on the entity.
  832. func (ushuo *UsageStatisticHourUpdateOne) Exec(ctx context.Context) error {
  833. _, err := ushuo.Save(ctx)
  834. return err
  835. }
  836. // ExecX is like Exec, but panics if an error occurs.
  837. func (ushuo *UsageStatisticHourUpdateOne) ExecX(ctx context.Context) {
  838. if err := ushuo.Exec(ctx); err != nil {
  839. panic(err)
  840. }
  841. }
  842. // defaults sets the default values of the builder before save.
  843. func (ushuo *UsageStatisticHourUpdateOne) defaults() error {
  844. if _, ok := ushuo.mutation.UpdatedAt(); !ok {
  845. if usagestatistichour.UpdateDefaultUpdatedAt == nil {
  846. return fmt.Errorf("ent: uninitialized usagestatistichour.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
  847. }
  848. v := usagestatistichour.UpdateDefaultUpdatedAt()
  849. ushuo.mutation.SetUpdatedAt(v)
  850. }
  851. return nil
  852. }
  853. func (ushuo *UsageStatisticHourUpdateOne) sqlSave(ctx context.Context) (_node *UsageStatisticHour, err error) {
  854. _spec := sqlgraph.NewUpdateSpec(usagestatistichour.Table, usagestatistichour.Columns, sqlgraph.NewFieldSpec(usagestatistichour.FieldID, field.TypeUint64))
  855. id, ok := ushuo.mutation.ID()
  856. if !ok {
  857. return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "UsageStatisticHour.id" for update`)}
  858. }
  859. _spec.Node.ID.Value = id
  860. if fields := ushuo.fields; len(fields) > 0 {
  861. _spec.Node.Columns = make([]string, 0, len(fields))
  862. _spec.Node.Columns = append(_spec.Node.Columns, usagestatistichour.FieldID)
  863. for _, f := range fields {
  864. if !usagestatistichour.ValidColumn(f) {
  865. return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
  866. }
  867. if f != usagestatistichour.FieldID {
  868. _spec.Node.Columns = append(_spec.Node.Columns, f)
  869. }
  870. }
  871. }
  872. if ps := ushuo.mutation.predicates; len(ps) > 0 {
  873. _spec.Predicate = func(selector *sql.Selector) {
  874. for i := range ps {
  875. ps[i](selector)
  876. }
  877. }
  878. }
  879. if value, ok := ushuo.mutation.UpdatedAt(); ok {
  880. _spec.SetField(usagestatistichour.FieldUpdatedAt, field.TypeTime, value)
  881. }
  882. if value, ok := ushuo.mutation.Status(); ok {
  883. _spec.SetField(usagestatistichour.FieldStatus, field.TypeUint8, value)
  884. }
  885. if value, ok := ushuo.mutation.AddedStatus(); ok {
  886. _spec.AddField(usagestatistichour.FieldStatus, field.TypeUint8, value)
  887. }
  888. if ushuo.mutation.StatusCleared() {
  889. _spec.ClearField(usagestatistichour.FieldStatus, field.TypeUint8)
  890. }
  891. if value, ok := ushuo.mutation.DeletedAt(); ok {
  892. _spec.SetField(usagestatistichour.FieldDeletedAt, field.TypeTime, value)
  893. }
  894. if ushuo.mutation.DeletedAtCleared() {
  895. _spec.ClearField(usagestatistichour.FieldDeletedAt, field.TypeTime)
  896. }
  897. if value, ok := ushuo.mutation.Addtime(); ok {
  898. _spec.SetField(usagestatistichour.FieldAddtime, field.TypeUint64, value)
  899. }
  900. if value, ok := ushuo.mutation.AddedAddtime(); ok {
  901. _spec.AddField(usagestatistichour.FieldAddtime, field.TypeUint64, value)
  902. }
  903. if value, ok := ushuo.mutation.GetType(); ok {
  904. _spec.SetField(usagestatistichour.FieldType, field.TypeInt, value)
  905. }
  906. if value, ok := ushuo.mutation.AddedType(); ok {
  907. _spec.AddField(usagestatistichour.FieldType, field.TypeInt, value)
  908. }
  909. if value, ok := ushuo.mutation.BotID(); ok {
  910. _spec.SetField(usagestatistichour.FieldBotID, field.TypeString, value)
  911. }
  912. if ushuo.mutation.BotIDCleared() {
  913. _spec.ClearField(usagestatistichour.FieldBotID, field.TypeString)
  914. }
  915. if value, ok := ushuo.mutation.OrganizationID(); ok {
  916. _spec.SetField(usagestatistichour.FieldOrganizationID, field.TypeUint64, value)
  917. }
  918. if value, ok := ushuo.mutation.AddedOrganizationID(); ok {
  919. _spec.AddField(usagestatistichour.FieldOrganizationID, field.TypeUint64, value)
  920. }
  921. if ushuo.mutation.OrganizationIDCleared() {
  922. _spec.ClearField(usagestatistichour.FieldOrganizationID, field.TypeUint64)
  923. }
  924. if value, ok := ushuo.mutation.AiResponse(); ok {
  925. _spec.SetField(usagestatistichour.FieldAiResponse, field.TypeUint64, value)
  926. }
  927. if value, ok := ushuo.mutation.AddedAiResponse(); ok {
  928. _spec.AddField(usagestatistichour.FieldAiResponse, field.TypeUint64, value)
  929. }
  930. if value, ok := ushuo.mutation.SopRun(); ok {
  931. _spec.SetField(usagestatistichour.FieldSopRun, field.TypeUint64, value)
  932. }
  933. if value, ok := ushuo.mutation.AddedSopRun(); ok {
  934. _spec.AddField(usagestatistichour.FieldSopRun, field.TypeUint64, value)
  935. }
  936. if value, ok := ushuo.mutation.TotalFriend(); ok {
  937. _spec.SetField(usagestatistichour.FieldTotalFriend, field.TypeUint64, value)
  938. }
  939. if value, ok := ushuo.mutation.AddedTotalFriend(); ok {
  940. _spec.AddField(usagestatistichour.FieldTotalFriend, field.TypeUint64, value)
  941. }
  942. if value, ok := ushuo.mutation.TotalGroup(); ok {
  943. _spec.SetField(usagestatistichour.FieldTotalGroup, field.TypeUint64, value)
  944. }
  945. if value, ok := ushuo.mutation.AddedTotalGroup(); ok {
  946. _spec.AddField(usagestatistichour.FieldTotalGroup, field.TypeUint64, value)
  947. }
  948. if value, ok := ushuo.mutation.AccountBalance(); ok {
  949. _spec.SetField(usagestatistichour.FieldAccountBalance, field.TypeUint64, value)
  950. }
  951. if value, ok := ushuo.mutation.AddedAccountBalance(); ok {
  952. _spec.AddField(usagestatistichour.FieldAccountBalance, field.TypeUint64, value)
  953. }
  954. if value, ok := ushuo.mutation.ConsumeToken(); ok {
  955. _spec.SetField(usagestatistichour.FieldConsumeToken, field.TypeUint64, value)
  956. }
  957. if value, ok := ushuo.mutation.AddedConsumeToken(); ok {
  958. _spec.AddField(usagestatistichour.FieldConsumeToken, field.TypeUint64, value)
  959. }
  960. if value, ok := ushuo.mutation.ActiveUser(); ok {
  961. _spec.SetField(usagestatistichour.FieldActiveUser, field.TypeUint64, value)
  962. }
  963. if value, ok := ushuo.mutation.AddedActiveUser(); ok {
  964. _spec.AddField(usagestatistichour.FieldActiveUser, field.TypeUint64, value)
  965. }
  966. if value, ok := ushuo.mutation.NewUser(); ok {
  967. _spec.SetField(usagestatistichour.FieldNewUser, field.TypeInt64, value)
  968. }
  969. if value, ok := ushuo.mutation.AddedNewUser(); ok {
  970. _spec.AddField(usagestatistichour.FieldNewUser, field.TypeInt64, value)
  971. }
  972. if value, ok := ushuo.mutation.LabelDist(); ok {
  973. _spec.SetField(usagestatistichour.FieldLabelDist, field.TypeJSON, value)
  974. }
  975. if value, ok := ushuo.mutation.AppendedLabelDist(); ok {
  976. _spec.AddModifier(func(u *sql.UpdateBuilder) {
  977. sqljson.Append(u, usagestatistichour.FieldLabelDist, value)
  978. })
  979. }
  980. if value, ok := ushuo.mutation.ConsumeCoin(); ok {
  981. _spec.SetField(usagestatistichour.FieldConsumeCoin, field.TypeUint64, value)
  982. }
  983. if value, ok := ushuo.mutation.AddedConsumeCoin(); ok {
  984. _spec.AddField(usagestatistichour.FieldConsumeCoin, field.TypeUint64, value)
  985. }
  986. if ushuo.mutation.ConsumeCoinCleared() {
  987. _spec.ClearField(usagestatistichour.FieldConsumeCoin, field.TypeUint64)
  988. }
  989. _node = &UsageStatisticHour{config: ushuo.config}
  990. _spec.Assign = _node.assignValues
  991. _spec.ScanValues = _node.scanValues
  992. if err = sqlgraph.UpdateNode(ctx, ushuo.driver, _spec); err != nil {
  993. if _, ok := err.(*sqlgraph.NotFoundError); ok {
  994. err = &NotFoundError{usagestatistichour.Label}
  995. } else if sqlgraph.IsConstraintError(err) {
  996. err = &ConstraintError{msg: err.Error(), wrap: err}
  997. }
  998. return nil, err
  999. }
  1000. ushuo.mutation.done = true
  1001. return _node, nil
  1002. }