usagestatistichour_create.go 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683
  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/usagestatistichour"
  10. "entgo.io/ent/dialect/sql"
  11. "entgo.io/ent/dialect/sql/sqlgraph"
  12. "entgo.io/ent/schema/field"
  13. )
  14. // UsageStatisticHourCreate is the builder for creating a UsageStatisticHour entity.
  15. type UsageStatisticHourCreate struct {
  16. config
  17. mutation *UsageStatisticHourMutation
  18. hooks []Hook
  19. conflict []sql.ConflictOption
  20. }
  21. // SetCreatedAt sets the "created_at" field.
  22. func (ushc *UsageStatisticHourCreate) SetCreatedAt(t time.Time) *UsageStatisticHourCreate {
  23. ushc.mutation.SetCreatedAt(t)
  24. return ushc
  25. }
  26. // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
  27. func (ushc *UsageStatisticHourCreate) SetNillableCreatedAt(t *time.Time) *UsageStatisticHourCreate {
  28. if t != nil {
  29. ushc.SetCreatedAt(*t)
  30. }
  31. return ushc
  32. }
  33. // SetUpdatedAt sets the "updated_at" field.
  34. func (ushc *UsageStatisticHourCreate) SetUpdatedAt(t time.Time) *UsageStatisticHourCreate {
  35. ushc.mutation.SetUpdatedAt(t)
  36. return ushc
  37. }
  38. // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
  39. func (ushc *UsageStatisticHourCreate) SetNillableUpdatedAt(t *time.Time) *UsageStatisticHourCreate {
  40. if t != nil {
  41. ushc.SetUpdatedAt(*t)
  42. }
  43. return ushc
  44. }
  45. // SetStatus sets the "status" field.
  46. func (ushc *UsageStatisticHourCreate) SetStatus(u uint8) *UsageStatisticHourCreate {
  47. ushc.mutation.SetStatus(u)
  48. return ushc
  49. }
  50. // SetNillableStatus sets the "status" field if the given value is not nil.
  51. func (ushc *UsageStatisticHourCreate) SetNillableStatus(u *uint8) *UsageStatisticHourCreate {
  52. if u != nil {
  53. ushc.SetStatus(*u)
  54. }
  55. return ushc
  56. }
  57. // SetDeletedAt sets the "deleted_at" field.
  58. func (ushc *UsageStatisticHourCreate) SetDeletedAt(t time.Time) *UsageStatisticHourCreate {
  59. ushc.mutation.SetDeletedAt(t)
  60. return ushc
  61. }
  62. // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
  63. func (ushc *UsageStatisticHourCreate) SetNillableDeletedAt(t *time.Time) *UsageStatisticHourCreate {
  64. if t != nil {
  65. ushc.SetDeletedAt(*t)
  66. }
  67. return ushc
  68. }
  69. // SetAddtime sets the "addtime" field.
  70. func (ushc *UsageStatisticHourCreate) SetAddtime(u uint64) *UsageStatisticHourCreate {
  71. ushc.mutation.SetAddtime(u)
  72. return ushc
  73. }
  74. // SetType sets the "type" field.
  75. func (ushc *UsageStatisticHourCreate) SetType(i int) *UsageStatisticHourCreate {
  76. ushc.mutation.SetType(i)
  77. return ushc
  78. }
  79. // SetBotID sets the "bot_id" field.
  80. func (ushc *UsageStatisticHourCreate) SetBotID(s string) *UsageStatisticHourCreate {
  81. ushc.mutation.SetBotID(s)
  82. return ushc
  83. }
  84. // SetNillableBotID sets the "bot_id" field if the given value is not nil.
  85. func (ushc *UsageStatisticHourCreate) SetNillableBotID(s *string) *UsageStatisticHourCreate {
  86. if s != nil {
  87. ushc.SetBotID(*s)
  88. }
  89. return ushc
  90. }
  91. // SetOrganizationID sets the "organization_id" field.
  92. func (ushc *UsageStatisticHourCreate) SetOrganizationID(u uint64) *UsageStatisticHourCreate {
  93. ushc.mutation.SetOrganizationID(u)
  94. return ushc
  95. }
  96. // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
  97. func (ushc *UsageStatisticHourCreate) SetNillableOrganizationID(u *uint64) *UsageStatisticHourCreate {
  98. if u != nil {
  99. ushc.SetOrganizationID(*u)
  100. }
  101. return ushc
  102. }
  103. // SetAiResponse sets the "ai_response" field.
  104. func (ushc *UsageStatisticHourCreate) SetAiResponse(u uint64) *UsageStatisticHourCreate {
  105. ushc.mutation.SetAiResponse(u)
  106. return ushc
  107. }
  108. // SetSopRun sets the "sop_run" field.
  109. func (ushc *UsageStatisticHourCreate) SetSopRun(u uint64) *UsageStatisticHourCreate {
  110. ushc.mutation.SetSopRun(u)
  111. return ushc
  112. }
  113. // SetTotalFriend sets the "total_friend" field.
  114. func (ushc *UsageStatisticHourCreate) SetTotalFriend(u uint64) *UsageStatisticHourCreate {
  115. ushc.mutation.SetTotalFriend(u)
  116. return ushc
  117. }
  118. // SetTotalGroup sets the "total_group" field.
  119. func (ushc *UsageStatisticHourCreate) SetTotalGroup(u uint64) *UsageStatisticHourCreate {
  120. ushc.mutation.SetTotalGroup(u)
  121. return ushc
  122. }
  123. // SetAccountBalance sets the "account_balance" field.
  124. func (ushc *UsageStatisticHourCreate) SetAccountBalance(u uint64) *UsageStatisticHourCreate {
  125. ushc.mutation.SetAccountBalance(u)
  126. return ushc
  127. }
  128. // SetConsumeToken sets the "consume_token" field.
  129. func (ushc *UsageStatisticHourCreate) SetConsumeToken(u uint64) *UsageStatisticHourCreate {
  130. ushc.mutation.SetConsumeToken(u)
  131. return ushc
  132. }
  133. // SetActiveUser sets the "active_user" field.
  134. func (ushc *UsageStatisticHourCreate) SetActiveUser(u uint64) *UsageStatisticHourCreate {
  135. ushc.mutation.SetActiveUser(u)
  136. return ushc
  137. }
  138. // SetNewUser sets the "new_user" field.
  139. func (ushc *UsageStatisticHourCreate) SetNewUser(i int64) *UsageStatisticHourCreate {
  140. ushc.mutation.SetNewUser(i)
  141. return ushc
  142. }
  143. // SetLabelDist sets the "label_dist" field.
  144. func (ushc *UsageStatisticHourCreate) SetLabelDist(ctd []custom_types.LabelDist) *UsageStatisticHourCreate {
  145. ushc.mutation.SetLabelDist(ctd)
  146. return ushc
  147. }
  148. // SetID sets the "id" field.
  149. func (ushc *UsageStatisticHourCreate) SetID(u uint64) *UsageStatisticHourCreate {
  150. ushc.mutation.SetID(u)
  151. return ushc
  152. }
  153. // Mutation returns the UsageStatisticHourMutation object of the builder.
  154. func (ushc *UsageStatisticHourCreate) Mutation() *UsageStatisticHourMutation {
  155. return ushc.mutation
  156. }
  157. // Save creates the UsageStatisticHour in the database.
  158. func (ushc *UsageStatisticHourCreate) Save(ctx context.Context) (*UsageStatisticHour, error) {
  159. if err := ushc.defaults(); err != nil {
  160. return nil, err
  161. }
  162. return withHooks(ctx, ushc.sqlSave, ushc.mutation, ushc.hooks)
  163. }
  164. // SaveX calls Save and panics if Save returns an error.
  165. func (ushc *UsageStatisticHourCreate) SaveX(ctx context.Context) *UsageStatisticHour {
  166. v, err := ushc.Save(ctx)
  167. if err != nil {
  168. panic(err)
  169. }
  170. return v
  171. }
  172. // Exec executes the query.
  173. func (ushc *UsageStatisticHourCreate) Exec(ctx context.Context) error {
  174. _, err := ushc.Save(ctx)
  175. return err
  176. }
  177. // ExecX is like Exec, but panics if an error occurs.
  178. func (ushc *UsageStatisticHourCreate) ExecX(ctx context.Context) {
  179. if err := ushc.Exec(ctx); err != nil {
  180. panic(err)
  181. }
  182. }
  183. // defaults sets the default values of the builder before save.
  184. func (ushc *UsageStatisticHourCreate) defaults() error {
  185. if _, ok := ushc.mutation.CreatedAt(); !ok {
  186. if usagestatistichour.DefaultCreatedAt == nil {
  187. return fmt.Errorf("ent: uninitialized usagestatistichour.DefaultCreatedAt (forgotten import ent/runtime?)")
  188. }
  189. v := usagestatistichour.DefaultCreatedAt()
  190. ushc.mutation.SetCreatedAt(v)
  191. }
  192. if _, ok := ushc.mutation.UpdatedAt(); !ok {
  193. if usagestatistichour.DefaultUpdatedAt == nil {
  194. return fmt.Errorf("ent: uninitialized usagestatistichour.DefaultUpdatedAt (forgotten import ent/runtime?)")
  195. }
  196. v := usagestatistichour.DefaultUpdatedAt()
  197. ushc.mutation.SetUpdatedAt(v)
  198. }
  199. if _, ok := ushc.mutation.Status(); !ok {
  200. v := usagestatistichour.DefaultStatus
  201. ushc.mutation.SetStatus(v)
  202. }
  203. return nil
  204. }
  205. // check runs all checks and user-defined validators on the builder.
  206. func (ushc *UsageStatisticHourCreate) check() error {
  207. if _, ok := ushc.mutation.CreatedAt(); !ok {
  208. return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "UsageStatisticHour.created_at"`)}
  209. }
  210. if _, ok := ushc.mutation.UpdatedAt(); !ok {
  211. return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "UsageStatisticHour.updated_at"`)}
  212. }
  213. if _, ok := ushc.mutation.Addtime(); !ok {
  214. return &ValidationError{Name: "addtime", err: errors.New(`ent: missing required field "UsageStatisticHour.addtime"`)}
  215. }
  216. if _, ok := ushc.mutation.GetType(); !ok {
  217. return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "UsageStatisticHour.type"`)}
  218. }
  219. if _, ok := ushc.mutation.AiResponse(); !ok {
  220. return &ValidationError{Name: "ai_response", err: errors.New(`ent: missing required field "UsageStatisticHour.ai_response"`)}
  221. }
  222. if _, ok := ushc.mutation.SopRun(); !ok {
  223. return &ValidationError{Name: "sop_run", err: errors.New(`ent: missing required field "UsageStatisticHour.sop_run"`)}
  224. }
  225. if _, ok := ushc.mutation.TotalFriend(); !ok {
  226. return &ValidationError{Name: "total_friend", err: errors.New(`ent: missing required field "UsageStatisticHour.total_friend"`)}
  227. }
  228. if _, ok := ushc.mutation.TotalGroup(); !ok {
  229. return &ValidationError{Name: "total_group", err: errors.New(`ent: missing required field "UsageStatisticHour.total_group"`)}
  230. }
  231. if _, ok := ushc.mutation.AccountBalance(); !ok {
  232. return &ValidationError{Name: "account_balance", err: errors.New(`ent: missing required field "UsageStatisticHour.account_balance"`)}
  233. }
  234. if _, ok := ushc.mutation.ConsumeToken(); !ok {
  235. return &ValidationError{Name: "consume_token", err: errors.New(`ent: missing required field "UsageStatisticHour.consume_token"`)}
  236. }
  237. if _, ok := ushc.mutation.ActiveUser(); !ok {
  238. return &ValidationError{Name: "active_user", err: errors.New(`ent: missing required field "UsageStatisticHour.active_user"`)}
  239. }
  240. if _, ok := ushc.mutation.NewUser(); !ok {
  241. return &ValidationError{Name: "new_user", err: errors.New(`ent: missing required field "UsageStatisticHour.new_user"`)}
  242. }
  243. if _, ok := ushc.mutation.LabelDist(); !ok {
  244. return &ValidationError{Name: "label_dist", err: errors.New(`ent: missing required field "UsageStatisticHour.label_dist"`)}
  245. }
  246. return nil
  247. }
  248. func (ushc *UsageStatisticHourCreate) sqlSave(ctx context.Context) (*UsageStatisticHour, error) {
  249. if err := ushc.check(); err != nil {
  250. return nil, err
  251. }
  252. _node, _spec := ushc.createSpec()
  253. if err := sqlgraph.CreateNode(ctx, ushc.driver, _spec); err != nil {
  254. if sqlgraph.IsConstraintError(err) {
  255. err = &ConstraintError{msg: err.Error(), wrap: err}
  256. }
  257. return nil, err
  258. }
  259. if _spec.ID.Value != _node.ID {
  260. id := _spec.ID.Value.(int64)
  261. _node.ID = uint64(id)
  262. }
  263. ushc.mutation.id = &_node.ID
  264. ushc.mutation.done = true
  265. return _node, nil
  266. }
  267. func (ushc *UsageStatisticHourCreate) createSpec() (*UsageStatisticHour, *sqlgraph.CreateSpec) {
  268. var (
  269. _node = &UsageStatisticHour{config: ushc.config}
  270. _spec = sqlgraph.NewCreateSpec(usagestatistichour.Table, sqlgraph.NewFieldSpec(usagestatistichour.FieldID, field.TypeUint64))
  271. )
  272. _spec.OnConflict = ushc.conflict
  273. if id, ok := ushc.mutation.ID(); ok {
  274. _node.ID = id
  275. _spec.ID.Value = id
  276. }
  277. if value, ok := ushc.mutation.CreatedAt(); ok {
  278. _spec.SetField(usagestatistichour.FieldCreatedAt, field.TypeTime, value)
  279. _node.CreatedAt = value
  280. }
  281. if value, ok := ushc.mutation.UpdatedAt(); ok {
  282. _spec.SetField(usagestatistichour.FieldUpdatedAt, field.TypeTime, value)
  283. _node.UpdatedAt = value
  284. }
  285. if value, ok := ushc.mutation.Status(); ok {
  286. _spec.SetField(usagestatistichour.FieldStatus, field.TypeUint8, value)
  287. _node.Status = value
  288. }
  289. if value, ok := ushc.mutation.DeletedAt(); ok {
  290. _spec.SetField(usagestatistichour.FieldDeletedAt, field.TypeTime, value)
  291. _node.DeletedAt = value
  292. }
  293. if value, ok := ushc.mutation.Addtime(); ok {
  294. _spec.SetField(usagestatistichour.FieldAddtime, field.TypeUint64, value)
  295. _node.Addtime = value
  296. }
  297. if value, ok := ushc.mutation.GetType(); ok {
  298. _spec.SetField(usagestatistichour.FieldType, field.TypeInt, value)
  299. _node.Type = value
  300. }
  301. if value, ok := ushc.mutation.BotID(); ok {
  302. _spec.SetField(usagestatistichour.FieldBotID, field.TypeString, value)
  303. _node.BotID = value
  304. }
  305. if value, ok := ushc.mutation.OrganizationID(); ok {
  306. _spec.SetField(usagestatistichour.FieldOrganizationID, field.TypeUint64, value)
  307. _node.OrganizationID = value
  308. }
  309. if value, ok := ushc.mutation.AiResponse(); ok {
  310. _spec.SetField(usagestatistichour.FieldAiResponse, field.TypeUint64, value)
  311. _node.AiResponse = value
  312. }
  313. if value, ok := ushc.mutation.SopRun(); ok {
  314. _spec.SetField(usagestatistichour.FieldSopRun, field.TypeUint64, value)
  315. _node.SopRun = value
  316. }
  317. if value, ok := ushc.mutation.TotalFriend(); ok {
  318. _spec.SetField(usagestatistichour.FieldTotalFriend, field.TypeUint64, value)
  319. _node.TotalFriend = value
  320. }
  321. if value, ok := ushc.mutation.TotalGroup(); ok {
  322. _spec.SetField(usagestatistichour.FieldTotalGroup, field.TypeUint64, value)
  323. _node.TotalGroup = value
  324. }
  325. if value, ok := ushc.mutation.AccountBalance(); ok {
  326. _spec.SetField(usagestatistichour.FieldAccountBalance, field.TypeUint64, value)
  327. _node.AccountBalance = value
  328. }
  329. if value, ok := ushc.mutation.ConsumeToken(); ok {
  330. _spec.SetField(usagestatistichour.FieldConsumeToken, field.TypeUint64, value)
  331. _node.ConsumeToken = value
  332. }
  333. if value, ok := ushc.mutation.ActiveUser(); ok {
  334. _spec.SetField(usagestatistichour.FieldActiveUser, field.TypeUint64, value)
  335. _node.ActiveUser = value
  336. }
  337. if value, ok := ushc.mutation.NewUser(); ok {
  338. _spec.SetField(usagestatistichour.FieldNewUser, field.TypeInt64, value)
  339. _node.NewUser = value
  340. }
  341. if value, ok := ushc.mutation.LabelDist(); ok {
  342. _spec.SetField(usagestatistichour.FieldLabelDist, field.TypeJSON, value)
  343. _node.LabelDist = value
  344. }
  345. return _node, _spec
  346. }
  347. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  348. // of the `INSERT` statement. For example:
  349. //
  350. // client.UsageStatisticHour.Create().
  351. // SetCreatedAt(v).
  352. // OnConflict(
  353. // // Update the row with the new values
  354. // // the was proposed for insertion.
  355. // sql.ResolveWithNewValues(),
  356. // ).
  357. // // Override some of the fields with custom
  358. // // update values.
  359. // Update(func(u *ent.UsageStatisticHourUpsert) {
  360. // SetCreatedAt(v+v).
  361. // }).
  362. // Exec(ctx)
  363. func (ushc *UsageStatisticHourCreate) OnConflict(opts ...sql.ConflictOption) *UsageStatisticHourUpsertOne {
  364. ushc.conflict = opts
  365. return &UsageStatisticHourUpsertOne{
  366. create: ushc,
  367. }
  368. }
  369. // OnConflictColumns calls `OnConflict` and configures the columns
  370. // as conflict target. Using this option is equivalent to using:
  371. //
  372. // client.UsageStatisticHour.Create().
  373. // OnConflict(sql.ConflictColumns(columns...)).
  374. // Exec(ctx)
  375. func (ushc *UsageStatisticHourCreate) OnConflictColumns(columns ...string) *UsageStatisticHourUpsertOne {
  376. ushc.conflict = append(ushc.conflict, sql.ConflictColumns(columns...))
  377. return &UsageStatisticHourUpsertOne{
  378. create: ushc,
  379. }
  380. }
  381. type (
  382. // UsageStatisticHourUpsertOne is the builder for "upsert"-ing
  383. // one UsageStatisticHour node.
  384. UsageStatisticHourUpsertOne struct {
  385. create *UsageStatisticHourCreate
  386. }
  387. // UsageStatisticHourUpsert is the "OnConflict" setter.
  388. UsageStatisticHourUpsert struct {
  389. *sql.UpdateSet
  390. }
  391. )
  392. // SetUpdatedAt sets the "updated_at" field.
  393. func (u *UsageStatisticHourUpsert) SetUpdatedAt(v time.Time) *UsageStatisticHourUpsert {
  394. u.Set(usagestatistichour.FieldUpdatedAt, v)
  395. return u
  396. }
  397. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  398. func (u *UsageStatisticHourUpsert) UpdateUpdatedAt() *UsageStatisticHourUpsert {
  399. u.SetExcluded(usagestatistichour.FieldUpdatedAt)
  400. return u
  401. }
  402. // SetStatus sets the "status" field.
  403. func (u *UsageStatisticHourUpsert) SetStatus(v uint8) *UsageStatisticHourUpsert {
  404. u.Set(usagestatistichour.FieldStatus, v)
  405. return u
  406. }
  407. // UpdateStatus sets the "status" field to the value that was provided on create.
  408. func (u *UsageStatisticHourUpsert) UpdateStatus() *UsageStatisticHourUpsert {
  409. u.SetExcluded(usagestatistichour.FieldStatus)
  410. return u
  411. }
  412. // AddStatus adds v to the "status" field.
  413. func (u *UsageStatisticHourUpsert) AddStatus(v uint8) *UsageStatisticHourUpsert {
  414. u.Add(usagestatistichour.FieldStatus, v)
  415. return u
  416. }
  417. // ClearStatus clears the value of the "status" field.
  418. func (u *UsageStatisticHourUpsert) ClearStatus() *UsageStatisticHourUpsert {
  419. u.SetNull(usagestatistichour.FieldStatus)
  420. return u
  421. }
  422. // SetDeletedAt sets the "deleted_at" field.
  423. func (u *UsageStatisticHourUpsert) SetDeletedAt(v time.Time) *UsageStatisticHourUpsert {
  424. u.Set(usagestatistichour.FieldDeletedAt, v)
  425. return u
  426. }
  427. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  428. func (u *UsageStatisticHourUpsert) UpdateDeletedAt() *UsageStatisticHourUpsert {
  429. u.SetExcluded(usagestatistichour.FieldDeletedAt)
  430. return u
  431. }
  432. // ClearDeletedAt clears the value of the "deleted_at" field.
  433. func (u *UsageStatisticHourUpsert) ClearDeletedAt() *UsageStatisticHourUpsert {
  434. u.SetNull(usagestatistichour.FieldDeletedAt)
  435. return u
  436. }
  437. // SetAddtime sets the "addtime" field.
  438. func (u *UsageStatisticHourUpsert) SetAddtime(v uint64) *UsageStatisticHourUpsert {
  439. u.Set(usagestatistichour.FieldAddtime, v)
  440. return u
  441. }
  442. // UpdateAddtime sets the "addtime" field to the value that was provided on create.
  443. func (u *UsageStatisticHourUpsert) UpdateAddtime() *UsageStatisticHourUpsert {
  444. u.SetExcluded(usagestatistichour.FieldAddtime)
  445. return u
  446. }
  447. // AddAddtime adds v to the "addtime" field.
  448. func (u *UsageStatisticHourUpsert) AddAddtime(v uint64) *UsageStatisticHourUpsert {
  449. u.Add(usagestatistichour.FieldAddtime, v)
  450. return u
  451. }
  452. // SetType sets the "type" field.
  453. func (u *UsageStatisticHourUpsert) SetType(v int) *UsageStatisticHourUpsert {
  454. u.Set(usagestatistichour.FieldType, v)
  455. return u
  456. }
  457. // UpdateType sets the "type" field to the value that was provided on create.
  458. func (u *UsageStatisticHourUpsert) UpdateType() *UsageStatisticHourUpsert {
  459. u.SetExcluded(usagestatistichour.FieldType)
  460. return u
  461. }
  462. // AddType adds v to the "type" field.
  463. func (u *UsageStatisticHourUpsert) AddType(v int) *UsageStatisticHourUpsert {
  464. u.Add(usagestatistichour.FieldType, v)
  465. return u
  466. }
  467. // SetBotID sets the "bot_id" field.
  468. func (u *UsageStatisticHourUpsert) SetBotID(v string) *UsageStatisticHourUpsert {
  469. u.Set(usagestatistichour.FieldBotID, v)
  470. return u
  471. }
  472. // UpdateBotID sets the "bot_id" field to the value that was provided on create.
  473. func (u *UsageStatisticHourUpsert) UpdateBotID() *UsageStatisticHourUpsert {
  474. u.SetExcluded(usagestatistichour.FieldBotID)
  475. return u
  476. }
  477. // ClearBotID clears the value of the "bot_id" field.
  478. func (u *UsageStatisticHourUpsert) ClearBotID() *UsageStatisticHourUpsert {
  479. u.SetNull(usagestatistichour.FieldBotID)
  480. return u
  481. }
  482. // SetOrganizationID sets the "organization_id" field.
  483. func (u *UsageStatisticHourUpsert) SetOrganizationID(v uint64) *UsageStatisticHourUpsert {
  484. u.Set(usagestatistichour.FieldOrganizationID, v)
  485. return u
  486. }
  487. // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
  488. func (u *UsageStatisticHourUpsert) UpdateOrganizationID() *UsageStatisticHourUpsert {
  489. u.SetExcluded(usagestatistichour.FieldOrganizationID)
  490. return u
  491. }
  492. // AddOrganizationID adds v to the "organization_id" field.
  493. func (u *UsageStatisticHourUpsert) AddOrganizationID(v uint64) *UsageStatisticHourUpsert {
  494. u.Add(usagestatistichour.FieldOrganizationID, v)
  495. return u
  496. }
  497. // ClearOrganizationID clears the value of the "organization_id" field.
  498. func (u *UsageStatisticHourUpsert) ClearOrganizationID() *UsageStatisticHourUpsert {
  499. u.SetNull(usagestatistichour.FieldOrganizationID)
  500. return u
  501. }
  502. // SetAiResponse sets the "ai_response" field.
  503. func (u *UsageStatisticHourUpsert) SetAiResponse(v uint64) *UsageStatisticHourUpsert {
  504. u.Set(usagestatistichour.FieldAiResponse, v)
  505. return u
  506. }
  507. // UpdateAiResponse sets the "ai_response" field to the value that was provided on create.
  508. func (u *UsageStatisticHourUpsert) UpdateAiResponse() *UsageStatisticHourUpsert {
  509. u.SetExcluded(usagestatistichour.FieldAiResponse)
  510. return u
  511. }
  512. // AddAiResponse adds v to the "ai_response" field.
  513. func (u *UsageStatisticHourUpsert) AddAiResponse(v uint64) *UsageStatisticHourUpsert {
  514. u.Add(usagestatistichour.FieldAiResponse, v)
  515. return u
  516. }
  517. // SetSopRun sets the "sop_run" field.
  518. func (u *UsageStatisticHourUpsert) SetSopRun(v uint64) *UsageStatisticHourUpsert {
  519. u.Set(usagestatistichour.FieldSopRun, v)
  520. return u
  521. }
  522. // UpdateSopRun sets the "sop_run" field to the value that was provided on create.
  523. func (u *UsageStatisticHourUpsert) UpdateSopRun() *UsageStatisticHourUpsert {
  524. u.SetExcluded(usagestatistichour.FieldSopRun)
  525. return u
  526. }
  527. // AddSopRun adds v to the "sop_run" field.
  528. func (u *UsageStatisticHourUpsert) AddSopRun(v uint64) *UsageStatisticHourUpsert {
  529. u.Add(usagestatistichour.FieldSopRun, v)
  530. return u
  531. }
  532. // SetTotalFriend sets the "total_friend" field.
  533. func (u *UsageStatisticHourUpsert) SetTotalFriend(v uint64) *UsageStatisticHourUpsert {
  534. u.Set(usagestatistichour.FieldTotalFriend, v)
  535. return u
  536. }
  537. // UpdateTotalFriend sets the "total_friend" field to the value that was provided on create.
  538. func (u *UsageStatisticHourUpsert) UpdateTotalFriend() *UsageStatisticHourUpsert {
  539. u.SetExcluded(usagestatistichour.FieldTotalFriend)
  540. return u
  541. }
  542. // AddTotalFriend adds v to the "total_friend" field.
  543. func (u *UsageStatisticHourUpsert) AddTotalFriend(v uint64) *UsageStatisticHourUpsert {
  544. u.Add(usagestatistichour.FieldTotalFriend, v)
  545. return u
  546. }
  547. // SetTotalGroup sets the "total_group" field.
  548. func (u *UsageStatisticHourUpsert) SetTotalGroup(v uint64) *UsageStatisticHourUpsert {
  549. u.Set(usagestatistichour.FieldTotalGroup, v)
  550. return u
  551. }
  552. // UpdateTotalGroup sets the "total_group" field to the value that was provided on create.
  553. func (u *UsageStatisticHourUpsert) UpdateTotalGroup() *UsageStatisticHourUpsert {
  554. u.SetExcluded(usagestatistichour.FieldTotalGroup)
  555. return u
  556. }
  557. // AddTotalGroup adds v to the "total_group" field.
  558. func (u *UsageStatisticHourUpsert) AddTotalGroup(v uint64) *UsageStatisticHourUpsert {
  559. u.Add(usagestatistichour.FieldTotalGroup, v)
  560. return u
  561. }
  562. // SetAccountBalance sets the "account_balance" field.
  563. func (u *UsageStatisticHourUpsert) SetAccountBalance(v uint64) *UsageStatisticHourUpsert {
  564. u.Set(usagestatistichour.FieldAccountBalance, v)
  565. return u
  566. }
  567. // UpdateAccountBalance sets the "account_balance" field to the value that was provided on create.
  568. func (u *UsageStatisticHourUpsert) UpdateAccountBalance() *UsageStatisticHourUpsert {
  569. u.SetExcluded(usagestatistichour.FieldAccountBalance)
  570. return u
  571. }
  572. // AddAccountBalance adds v to the "account_balance" field.
  573. func (u *UsageStatisticHourUpsert) AddAccountBalance(v uint64) *UsageStatisticHourUpsert {
  574. u.Add(usagestatistichour.FieldAccountBalance, v)
  575. return u
  576. }
  577. // SetConsumeToken sets the "consume_token" field.
  578. func (u *UsageStatisticHourUpsert) SetConsumeToken(v uint64) *UsageStatisticHourUpsert {
  579. u.Set(usagestatistichour.FieldConsumeToken, v)
  580. return u
  581. }
  582. // UpdateConsumeToken sets the "consume_token" field to the value that was provided on create.
  583. func (u *UsageStatisticHourUpsert) UpdateConsumeToken() *UsageStatisticHourUpsert {
  584. u.SetExcluded(usagestatistichour.FieldConsumeToken)
  585. return u
  586. }
  587. // AddConsumeToken adds v to the "consume_token" field.
  588. func (u *UsageStatisticHourUpsert) AddConsumeToken(v uint64) *UsageStatisticHourUpsert {
  589. u.Add(usagestatistichour.FieldConsumeToken, v)
  590. return u
  591. }
  592. // SetActiveUser sets the "active_user" field.
  593. func (u *UsageStatisticHourUpsert) SetActiveUser(v uint64) *UsageStatisticHourUpsert {
  594. u.Set(usagestatistichour.FieldActiveUser, v)
  595. return u
  596. }
  597. // UpdateActiveUser sets the "active_user" field to the value that was provided on create.
  598. func (u *UsageStatisticHourUpsert) UpdateActiveUser() *UsageStatisticHourUpsert {
  599. u.SetExcluded(usagestatistichour.FieldActiveUser)
  600. return u
  601. }
  602. // AddActiveUser adds v to the "active_user" field.
  603. func (u *UsageStatisticHourUpsert) AddActiveUser(v uint64) *UsageStatisticHourUpsert {
  604. u.Add(usagestatistichour.FieldActiveUser, v)
  605. return u
  606. }
  607. // SetNewUser sets the "new_user" field.
  608. func (u *UsageStatisticHourUpsert) SetNewUser(v int64) *UsageStatisticHourUpsert {
  609. u.Set(usagestatistichour.FieldNewUser, v)
  610. return u
  611. }
  612. // UpdateNewUser sets the "new_user" field to the value that was provided on create.
  613. func (u *UsageStatisticHourUpsert) UpdateNewUser() *UsageStatisticHourUpsert {
  614. u.SetExcluded(usagestatistichour.FieldNewUser)
  615. return u
  616. }
  617. // AddNewUser adds v to the "new_user" field.
  618. func (u *UsageStatisticHourUpsert) AddNewUser(v int64) *UsageStatisticHourUpsert {
  619. u.Add(usagestatistichour.FieldNewUser, v)
  620. return u
  621. }
  622. // SetLabelDist sets the "label_dist" field.
  623. func (u *UsageStatisticHourUpsert) SetLabelDist(v []custom_types.LabelDist) *UsageStatisticHourUpsert {
  624. u.Set(usagestatistichour.FieldLabelDist, v)
  625. return u
  626. }
  627. // UpdateLabelDist sets the "label_dist" field to the value that was provided on create.
  628. func (u *UsageStatisticHourUpsert) UpdateLabelDist() *UsageStatisticHourUpsert {
  629. u.SetExcluded(usagestatistichour.FieldLabelDist)
  630. return u
  631. }
  632. // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
  633. // Using this option is equivalent to using:
  634. //
  635. // client.UsageStatisticHour.Create().
  636. // OnConflict(
  637. // sql.ResolveWithNewValues(),
  638. // sql.ResolveWith(func(u *sql.UpdateSet) {
  639. // u.SetIgnore(usagestatistichour.FieldID)
  640. // }),
  641. // ).
  642. // Exec(ctx)
  643. func (u *UsageStatisticHourUpsertOne) UpdateNewValues() *UsageStatisticHourUpsertOne {
  644. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  645. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  646. if _, exists := u.create.mutation.ID(); exists {
  647. s.SetIgnore(usagestatistichour.FieldID)
  648. }
  649. if _, exists := u.create.mutation.CreatedAt(); exists {
  650. s.SetIgnore(usagestatistichour.FieldCreatedAt)
  651. }
  652. }))
  653. return u
  654. }
  655. // Ignore sets each column to itself in case of conflict.
  656. // Using this option is equivalent to using:
  657. //
  658. // client.UsageStatisticHour.Create().
  659. // OnConflict(sql.ResolveWithIgnore()).
  660. // Exec(ctx)
  661. func (u *UsageStatisticHourUpsertOne) Ignore() *UsageStatisticHourUpsertOne {
  662. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  663. return u
  664. }
  665. // DoNothing configures the conflict_action to `DO NOTHING`.
  666. // Supported only by SQLite and PostgreSQL.
  667. func (u *UsageStatisticHourUpsertOne) DoNothing() *UsageStatisticHourUpsertOne {
  668. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  669. return u
  670. }
  671. // Update allows overriding fields `UPDATE` values. See the UsageStatisticHourCreate.OnConflict
  672. // documentation for more info.
  673. func (u *UsageStatisticHourUpsertOne) Update(set func(*UsageStatisticHourUpsert)) *UsageStatisticHourUpsertOne {
  674. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  675. set(&UsageStatisticHourUpsert{UpdateSet: update})
  676. }))
  677. return u
  678. }
  679. // SetUpdatedAt sets the "updated_at" field.
  680. func (u *UsageStatisticHourUpsertOne) SetUpdatedAt(v time.Time) *UsageStatisticHourUpsertOne {
  681. return u.Update(func(s *UsageStatisticHourUpsert) {
  682. s.SetUpdatedAt(v)
  683. })
  684. }
  685. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  686. func (u *UsageStatisticHourUpsertOne) UpdateUpdatedAt() *UsageStatisticHourUpsertOne {
  687. return u.Update(func(s *UsageStatisticHourUpsert) {
  688. s.UpdateUpdatedAt()
  689. })
  690. }
  691. // SetStatus sets the "status" field.
  692. func (u *UsageStatisticHourUpsertOne) SetStatus(v uint8) *UsageStatisticHourUpsertOne {
  693. return u.Update(func(s *UsageStatisticHourUpsert) {
  694. s.SetStatus(v)
  695. })
  696. }
  697. // AddStatus adds v to the "status" field.
  698. func (u *UsageStatisticHourUpsertOne) AddStatus(v uint8) *UsageStatisticHourUpsertOne {
  699. return u.Update(func(s *UsageStatisticHourUpsert) {
  700. s.AddStatus(v)
  701. })
  702. }
  703. // UpdateStatus sets the "status" field to the value that was provided on create.
  704. func (u *UsageStatisticHourUpsertOne) UpdateStatus() *UsageStatisticHourUpsertOne {
  705. return u.Update(func(s *UsageStatisticHourUpsert) {
  706. s.UpdateStatus()
  707. })
  708. }
  709. // ClearStatus clears the value of the "status" field.
  710. func (u *UsageStatisticHourUpsertOne) ClearStatus() *UsageStatisticHourUpsertOne {
  711. return u.Update(func(s *UsageStatisticHourUpsert) {
  712. s.ClearStatus()
  713. })
  714. }
  715. // SetDeletedAt sets the "deleted_at" field.
  716. func (u *UsageStatisticHourUpsertOne) SetDeletedAt(v time.Time) *UsageStatisticHourUpsertOne {
  717. return u.Update(func(s *UsageStatisticHourUpsert) {
  718. s.SetDeletedAt(v)
  719. })
  720. }
  721. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  722. func (u *UsageStatisticHourUpsertOne) UpdateDeletedAt() *UsageStatisticHourUpsertOne {
  723. return u.Update(func(s *UsageStatisticHourUpsert) {
  724. s.UpdateDeletedAt()
  725. })
  726. }
  727. // ClearDeletedAt clears the value of the "deleted_at" field.
  728. func (u *UsageStatisticHourUpsertOne) ClearDeletedAt() *UsageStatisticHourUpsertOne {
  729. return u.Update(func(s *UsageStatisticHourUpsert) {
  730. s.ClearDeletedAt()
  731. })
  732. }
  733. // SetAddtime sets the "addtime" field.
  734. func (u *UsageStatisticHourUpsertOne) SetAddtime(v uint64) *UsageStatisticHourUpsertOne {
  735. return u.Update(func(s *UsageStatisticHourUpsert) {
  736. s.SetAddtime(v)
  737. })
  738. }
  739. // AddAddtime adds v to the "addtime" field.
  740. func (u *UsageStatisticHourUpsertOne) AddAddtime(v uint64) *UsageStatisticHourUpsertOne {
  741. return u.Update(func(s *UsageStatisticHourUpsert) {
  742. s.AddAddtime(v)
  743. })
  744. }
  745. // UpdateAddtime sets the "addtime" field to the value that was provided on create.
  746. func (u *UsageStatisticHourUpsertOne) UpdateAddtime() *UsageStatisticHourUpsertOne {
  747. return u.Update(func(s *UsageStatisticHourUpsert) {
  748. s.UpdateAddtime()
  749. })
  750. }
  751. // SetType sets the "type" field.
  752. func (u *UsageStatisticHourUpsertOne) SetType(v int) *UsageStatisticHourUpsertOne {
  753. return u.Update(func(s *UsageStatisticHourUpsert) {
  754. s.SetType(v)
  755. })
  756. }
  757. // AddType adds v to the "type" field.
  758. func (u *UsageStatisticHourUpsertOne) AddType(v int) *UsageStatisticHourUpsertOne {
  759. return u.Update(func(s *UsageStatisticHourUpsert) {
  760. s.AddType(v)
  761. })
  762. }
  763. // UpdateType sets the "type" field to the value that was provided on create.
  764. func (u *UsageStatisticHourUpsertOne) UpdateType() *UsageStatisticHourUpsertOne {
  765. return u.Update(func(s *UsageStatisticHourUpsert) {
  766. s.UpdateType()
  767. })
  768. }
  769. // SetBotID sets the "bot_id" field.
  770. func (u *UsageStatisticHourUpsertOne) SetBotID(v string) *UsageStatisticHourUpsertOne {
  771. return u.Update(func(s *UsageStatisticHourUpsert) {
  772. s.SetBotID(v)
  773. })
  774. }
  775. // UpdateBotID sets the "bot_id" field to the value that was provided on create.
  776. func (u *UsageStatisticHourUpsertOne) UpdateBotID() *UsageStatisticHourUpsertOne {
  777. return u.Update(func(s *UsageStatisticHourUpsert) {
  778. s.UpdateBotID()
  779. })
  780. }
  781. // ClearBotID clears the value of the "bot_id" field.
  782. func (u *UsageStatisticHourUpsertOne) ClearBotID() *UsageStatisticHourUpsertOne {
  783. return u.Update(func(s *UsageStatisticHourUpsert) {
  784. s.ClearBotID()
  785. })
  786. }
  787. // SetOrganizationID sets the "organization_id" field.
  788. func (u *UsageStatisticHourUpsertOne) SetOrganizationID(v uint64) *UsageStatisticHourUpsertOne {
  789. return u.Update(func(s *UsageStatisticHourUpsert) {
  790. s.SetOrganizationID(v)
  791. })
  792. }
  793. // AddOrganizationID adds v to the "organization_id" field.
  794. func (u *UsageStatisticHourUpsertOne) AddOrganizationID(v uint64) *UsageStatisticHourUpsertOne {
  795. return u.Update(func(s *UsageStatisticHourUpsert) {
  796. s.AddOrganizationID(v)
  797. })
  798. }
  799. // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
  800. func (u *UsageStatisticHourUpsertOne) UpdateOrganizationID() *UsageStatisticHourUpsertOne {
  801. return u.Update(func(s *UsageStatisticHourUpsert) {
  802. s.UpdateOrganizationID()
  803. })
  804. }
  805. // ClearOrganizationID clears the value of the "organization_id" field.
  806. func (u *UsageStatisticHourUpsertOne) ClearOrganizationID() *UsageStatisticHourUpsertOne {
  807. return u.Update(func(s *UsageStatisticHourUpsert) {
  808. s.ClearOrganizationID()
  809. })
  810. }
  811. // SetAiResponse sets the "ai_response" field.
  812. func (u *UsageStatisticHourUpsertOne) SetAiResponse(v uint64) *UsageStatisticHourUpsertOne {
  813. return u.Update(func(s *UsageStatisticHourUpsert) {
  814. s.SetAiResponse(v)
  815. })
  816. }
  817. // AddAiResponse adds v to the "ai_response" field.
  818. func (u *UsageStatisticHourUpsertOne) AddAiResponse(v uint64) *UsageStatisticHourUpsertOne {
  819. return u.Update(func(s *UsageStatisticHourUpsert) {
  820. s.AddAiResponse(v)
  821. })
  822. }
  823. // UpdateAiResponse sets the "ai_response" field to the value that was provided on create.
  824. func (u *UsageStatisticHourUpsertOne) UpdateAiResponse() *UsageStatisticHourUpsertOne {
  825. return u.Update(func(s *UsageStatisticHourUpsert) {
  826. s.UpdateAiResponse()
  827. })
  828. }
  829. // SetSopRun sets the "sop_run" field.
  830. func (u *UsageStatisticHourUpsertOne) SetSopRun(v uint64) *UsageStatisticHourUpsertOne {
  831. return u.Update(func(s *UsageStatisticHourUpsert) {
  832. s.SetSopRun(v)
  833. })
  834. }
  835. // AddSopRun adds v to the "sop_run" field.
  836. func (u *UsageStatisticHourUpsertOne) AddSopRun(v uint64) *UsageStatisticHourUpsertOne {
  837. return u.Update(func(s *UsageStatisticHourUpsert) {
  838. s.AddSopRun(v)
  839. })
  840. }
  841. // UpdateSopRun sets the "sop_run" field to the value that was provided on create.
  842. func (u *UsageStatisticHourUpsertOne) UpdateSopRun() *UsageStatisticHourUpsertOne {
  843. return u.Update(func(s *UsageStatisticHourUpsert) {
  844. s.UpdateSopRun()
  845. })
  846. }
  847. // SetTotalFriend sets the "total_friend" field.
  848. func (u *UsageStatisticHourUpsertOne) SetTotalFriend(v uint64) *UsageStatisticHourUpsertOne {
  849. return u.Update(func(s *UsageStatisticHourUpsert) {
  850. s.SetTotalFriend(v)
  851. })
  852. }
  853. // AddTotalFriend adds v to the "total_friend" field.
  854. func (u *UsageStatisticHourUpsertOne) AddTotalFriend(v uint64) *UsageStatisticHourUpsertOne {
  855. return u.Update(func(s *UsageStatisticHourUpsert) {
  856. s.AddTotalFriend(v)
  857. })
  858. }
  859. // UpdateTotalFriend sets the "total_friend" field to the value that was provided on create.
  860. func (u *UsageStatisticHourUpsertOne) UpdateTotalFriend() *UsageStatisticHourUpsertOne {
  861. return u.Update(func(s *UsageStatisticHourUpsert) {
  862. s.UpdateTotalFriend()
  863. })
  864. }
  865. // SetTotalGroup sets the "total_group" field.
  866. func (u *UsageStatisticHourUpsertOne) SetTotalGroup(v uint64) *UsageStatisticHourUpsertOne {
  867. return u.Update(func(s *UsageStatisticHourUpsert) {
  868. s.SetTotalGroup(v)
  869. })
  870. }
  871. // AddTotalGroup adds v to the "total_group" field.
  872. func (u *UsageStatisticHourUpsertOne) AddTotalGroup(v uint64) *UsageStatisticHourUpsertOne {
  873. return u.Update(func(s *UsageStatisticHourUpsert) {
  874. s.AddTotalGroup(v)
  875. })
  876. }
  877. // UpdateTotalGroup sets the "total_group" field to the value that was provided on create.
  878. func (u *UsageStatisticHourUpsertOne) UpdateTotalGroup() *UsageStatisticHourUpsertOne {
  879. return u.Update(func(s *UsageStatisticHourUpsert) {
  880. s.UpdateTotalGroup()
  881. })
  882. }
  883. // SetAccountBalance sets the "account_balance" field.
  884. func (u *UsageStatisticHourUpsertOne) SetAccountBalance(v uint64) *UsageStatisticHourUpsertOne {
  885. return u.Update(func(s *UsageStatisticHourUpsert) {
  886. s.SetAccountBalance(v)
  887. })
  888. }
  889. // AddAccountBalance adds v to the "account_balance" field.
  890. func (u *UsageStatisticHourUpsertOne) AddAccountBalance(v uint64) *UsageStatisticHourUpsertOne {
  891. return u.Update(func(s *UsageStatisticHourUpsert) {
  892. s.AddAccountBalance(v)
  893. })
  894. }
  895. // UpdateAccountBalance sets the "account_balance" field to the value that was provided on create.
  896. func (u *UsageStatisticHourUpsertOne) UpdateAccountBalance() *UsageStatisticHourUpsertOne {
  897. return u.Update(func(s *UsageStatisticHourUpsert) {
  898. s.UpdateAccountBalance()
  899. })
  900. }
  901. // SetConsumeToken sets the "consume_token" field.
  902. func (u *UsageStatisticHourUpsertOne) SetConsumeToken(v uint64) *UsageStatisticHourUpsertOne {
  903. return u.Update(func(s *UsageStatisticHourUpsert) {
  904. s.SetConsumeToken(v)
  905. })
  906. }
  907. // AddConsumeToken adds v to the "consume_token" field.
  908. func (u *UsageStatisticHourUpsertOne) AddConsumeToken(v uint64) *UsageStatisticHourUpsertOne {
  909. return u.Update(func(s *UsageStatisticHourUpsert) {
  910. s.AddConsumeToken(v)
  911. })
  912. }
  913. // UpdateConsumeToken sets the "consume_token" field to the value that was provided on create.
  914. func (u *UsageStatisticHourUpsertOne) UpdateConsumeToken() *UsageStatisticHourUpsertOne {
  915. return u.Update(func(s *UsageStatisticHourUpsert) {
  916. s.UpdateConsumeToken()
  917. })
  918. }
  919. // SetActiveUser sets the "active_user" field.
  920. func (u *UsageStatisticHourUpsertOne) SetActiveUser(v uint64) *UsageStatisticHourUpsertOne {
  921. return u.Update(func(s *UsageStatisticHourUpsert) {
  922. s.SetActiveUser(v)
  923. })
  924. }
  925. // AddActiveUser adds v to the "active_user" field.
  926. func (u *UsageStatisticHourUpsertOne) AddActiveUser(v uint64) *UsageStatisticHourUpsertOne {
  927. return u.Update(func(s *UsageStatisticHourUpsert) {
  928. s.AddActiveUser(v)
  929. })
  930. }
  931. // UpdateActiveUser sets the "active_user" field to the value that was provided on create.
  932. func (u *UsageStatisticHourUpsertOne) UpdateActiveUser() *UsageStatisticHourUpsertOne {
  933. return u.Update(func(s *UsageStatisticHourUpsert) {
  934. s.UpdateActiveUser()
  935. })
  936. }
  937. // SetNewUser sets the "new_user" field.
  938. func (u *UsageStatisticHourUpsertOne) SetNewUser(v int64) *UsageStatisticHourUpsertOne {
  939. return u.Update(func(s *UsageStatisticHourUpsert) {
  940. s.SetNewUser(v)
  941. })
  942. }
  943. // AddNewUser adds v to the "new_user" field.
  944. func (u *UsageStatisticHourUpsertOne) AddNewUser(v int64) *UsageStatisticHourUpsertOne {
  945. return u.Update(func(s *UsageStatisticHourUpsert) {
  946. s.AddNewUser(v)
  947. })
  948. }
  949. // UpdateNewUser sets the "new_user" field to the value that was provided on create.
  950. func (u *UsageStatisticHourUpsertOne) UpdateNewUser() *UsageStatisticHourUpsertOne {
  951. return u.Update(func(s *UsageStatisticHourUpsert) {
  952. s.UpdateNewUser()
  953. })
  954. }
  955. // SetLabelDist sets the "label_dist" field.
  956. func (u *UsageStatisticHourUpsertOne) SetLabelDist(v []custom_types.LabelDist) *UsageStatisticHourUpsertOne {
  957. return u.Update(func(s *UsageStatisticHourUpsert) {
  958. s.SetLabelDist(v)
  959. })
  960. }
  961. // UpdateLabelDist sets the "label_dist" field to the value that was provided on create.
  962. func (u *UsageStatisticHourUpsertOne) UpdateLabelDist() *UsageStatisticHourUpsertOne {
  963. return u.Update(func(s *UsageStatisticHourUpsert) {
  964. s.UpdateLabelDist()
  965. })
  966. }
  967. // Exec executes the query.
  968. func (u *UsageStatisticHourUpsertOne) Exec(ctx context.Context) error {
  969. if len(u.create.conflict) == 0 {
  970. return errors.New("ent: missing options for UsageStatisticHourCreate.OnConflict")
  971. }
  972. return u.create.Exec(ctx)
  973. }
  974. // ExecX is like Exec, but panics if an error occurs.
  975. func (u *UsageStatisticHourUpsertOne) ExecX(ctx context.Context) {
  976. if err := u.create.Exec(ctx); err != nil {
  977. panic(err)
  978. }
  979. }
  980. // Exec executes the UPSERT query and returns the inserted/updated ID.
  981. func (u *UsageStatisticHourUpsertOne) ID(ctx context.Context) (id uint64, err error) {
  982. node, err := u.create.Save(ctx)
  983. if err != nil {
  984. return id, err
  985. }
  986. return node.ID, nil
  987. }
  988. // IDX is like ID, but panics if an error occurs.
  989. func (u *UsageStatisticHourUpsertOne) IDX(ctx context.Context) uint64 {
  990. id, err := u.ID(ctx)
  991. if err != nil {
  992. panic(err)
  993. }
  994. return id
  995. }
  996. // UsageStatisticHourCreateBulk is the builder for creating many UsageStatisticHour entities in bulk.
  997. type UsageStatisticHourCreateBulk struct {
  998. config
  999. err error
  1000. builders []*UsageStatisticHourCreate
  1001. conflict []sql.ConflictOption
  1002. }
  1003. // Save creates the UsageStatisticHour entities in the database.
  1004. func (ushcb *UsageStatisticHourCreateBulk) Save(ctx context.Context) ([]*UsageStatisticHour, error) {
  1005. if ushcb.err != nil {
  1006. return nil, ushcb.err
  1007. }
  1008. specs := make([]*sqlgraph.CreateSpec, len(ushcb.builders))
  1009. nodes := make([]*UsageStatisticHour, len(ushcb.builders))
  1010. mutators := make([]Mutator, len(ushcb.builders))
  1011. for i := range ushcb.builders {
  1012. func(i int, root context.Context) {
  1013. builder := ushcb.builders[i]
  1014. builder.defaults()
  1015. var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
  1016. mutation, ok := m.(*UsageStatisticHourMutation)
  1017. if !ok {
  1018. return nil, fmt.Errorf("unexpected mutation type %T", m)
  1019. }
  1020. if err := builder.check(); err != nil {
  1021. return nil, err
  1022. }
  1023. builder.mutation = mutation
  1024. var err error
  1025. nodes[i], specs[i] = builder.createSpec()
  1026. if i < len(mutators)-1 {
  1027. _, err = mutators[i+1].Mutate(root, ushcb.builders[i+1].mutation)
  1028. } else {
  1029. spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
  1030. spec.OnConflict = ushcb.conflict
  1031. // Invoke the actual operation on the latest mutation in the chain.
  1032. if err = sqlgraph.BatchCreate(ctx, ushcb.driver, spec); err != nil {
  1033. if sqlgraph.IsConstraintError(err) {
  1034. err = &ConstraintError{msg: err.Error(), wrap: err}
  1035. }
  1036. }
  1037. }
  1038. if err != nil {
  1039. return nil, err
  1040. }
  1041. mutation.id = &nodes[i].ID
  1042. if specs[i].ID.Value != nil && nodes[i].ID == 0 {
  1043. id := specs[i].ID.Value.(int64)
  1044. nodes[i].ID = uint64(id)
  1045. }
  1046. mutation.done = true
  1047. return nodes[i], nil
  1048. })
  1049. for i := len(builder.hooks) - 1; i >= 0; i-- {
  1050. mut = builder.hooks[i](mut)
  1051. }
  1052. mutators[i] = mut
  1053. }(i, ctx)
  1054. }
  1055. if len(mutators) > 0 {
  1056. if _, err := mutators[0].Mutate(ctx, ushcb.builders[0].mutation); err != nil {
  1057. return nil, err
  1058. }
  1059. }
  1060. return nodes, nil
  1061. }
  1062. // SaveX is like Save, but panics if an error occurs.
  1063. func (ushcb *UsageStatisticHourCreateBulk) SaveX(ctx context.Context) []*UsageStatisticHour {
  1064. v, err := ushcb.Save(ctx)
  1065. if err != nil {
  1066. panic(err)
  1067. }
  1068. return v
  1069. }
  1070. // Exec executes the query.
  1071. func (ushcb *UsageStatisticHourCreateBulk) Exec(ctx context.Context) error {
  1072. _, err := ushcb.Save(ctx)
  1073. return err
  1074. }
  1075. // ExecX is like Exec, but panics if an error occurs.
  1076. func (ushcb *UsageStatisticHourCreateBulk) ExecX(ctx context.Context) {
  1077. if err := ushcb.Exec(ctx); err != nil {
  1078. panic(err)
  1079. }
  1080. }
  1081. // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
  1082. // of the `INSERT` statement. For example:
  1083. //
  1084. // client.UsageStatisticHour.CreateBulk(builders...).
  1085. // OnConflict(
  1086. // // Update the row with the new values
  1087. // // the was proposed for insertion.
  1088. // sql.ResolveWithNewValues(),
  1089. // ).
  1090. // // Override some of the fields with custom
  1091. // // update values.
  1092. // Update(func(u *ent.UsageStatisticHourUpsert) {
  1093. // SetCreatedAt(v+v).
  1094. // }).
  1095. // Exec(ctx)
  1096. func (ushcb *UsageStatisticHourCreateBulk) OnConflict(opts ...sql.ConflictOption) *UsageStatisticHourUpsertBulk {
  1097. ushcb.conflict = opts
  1098. return &UsageStatisticHourUpsertBulk{
  1099. create: ushcb,
  1100. }
  1101. }
  1102. // OnConflictColumns calls `OnConflict` and configures the columns
  1103. // as conflict target. Using this option is equivalent to using:
  1104. //
  1105. // client.UsageStatisticHour.Create().
  1106. // OnConflict(sql.ConflictColumns(columns...)).
  1107. // Exec(ctx)
  1108. func (ushcb *UsageStatisticHourCreateBulk) OnConflictColumns(columns ...string) *UsageStatisticHourUpsertBulk {
  1109. ushcb.conflict = append(ushcb.conflict, sql.ConflictColumns(columns...))
  1110. return &UsageStatisticHourUpsertBulk{
  1111. create: ushcb,
  1112. }
  1113. }
  1114. // UsageStatisticHourUpsertBulk is the builder for "upsert"-ing
  1115. // a bulk of UsageStatisticHour nodes.
  1116. type UsageStatisticHourUpsertBulk struct {
  1117. create *UsageStatisticHourCreateBulk
  1118. }
  1119. // UpdateNewValues updates the mutable fields using the new values that
  1120. // were set on create. Using this option is equivalent to using:
  1121. //
  1122. // client.UsageStatisticHour.Create().
  1123. // OnConflict(
  1124. // sql.ResolveWithNewValues(),
  1125. // sql.ResolveWith(func(u *sql.UpdateSet) {
  1126. // u.SetIgnore(usagestatistichour.FieldID)
  1127. // }),
  1128. // ).
  1129. // Exec(ctx)
  1130. func (u *UsageStatisticHourUpsertBulk) UpdateNewValues() *UsageStatisticHourUpsertBulk {
  1131. u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
  1132. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
  1133. for _, b := range u.create.builders {
  1134. if _, exists := b.mutation.ID(); exists {
  1135. s.SetIgnore(usagestatistichour.FieldID)
  1136. }
  1137. if _, exists := b.mutation.CreatedAt(); exists {
  1138. s.SetIgnore(usagestatistichour.FieldCreatedAt)
  1139. }
  1140. }
  1141. }))
  1142. return u
  1143. }
  1144. // Ignore sets each column to itself in case of conflict.
  1145. // Using this option is equivalent to using:
  1146. //
  1147. // client.UsageStatisticHour.Create().
  1148. // OnConflict(sql.ResolveWithIgnore()).
  1149. // Exec(ctx)
  1150. func (u *UsageStatisticHourUpsertBulk) Ignore() *UsageStatisticHourUpsertBulk {
  1151. u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
  1152. return u
  1153. }
  1154. // DoNothing configures the conflict_action to `DO NOTHING`.
  1155. // Supported only by SQLite and PostgreSQL.
  1156. func (u *UsageStatisticHourUpsertBulk) DoNothing() *UsageStatisticHourUpsertBulk {
  1157. u.create.conflict = append(u.create.conflict, sql.DoNothing())
  1158. return u
  1159. }
  1160. // Update allows overriding fields `UPDATE` values. See the UsageStatisticHourCreateBulk.OnConflict
  1161. // documentation for more info.
  1162. func (u *UsageStatisticHourUpsertBulk) Update(set func(*UsageStatisticHourUpsert)) *UsageStatisticHourUpsertBulk {
  1163. u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
  1164. set(&UsageStatisticHourUpsert{UpdateSet: update})
  1165. }))
  1166. return u
  1167. }
  1168. // SetUpdatedAt sets the "updated_at" field.
  1169. func (u *UsageStatisticHourUpsertBulk) SetUpdatedAt(v time.Time) *UsageStatisticHourUpsertBulk {
  1170. return u.Update(func(s *UsageStatisticHourUpsert) {
  1171. s.SetUpdatedAt(v)
  1172. })
  1173. }
  1174. // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
  1175. func (u *UsageStatisticHourUpsertBulk) UpdateUpdatedAt() *UsageStatisticHourUpsertBulk {
  1176. return u.Update(func(s *UsageStatisticHourUpsert) {
  1177. s.UpdateUpdatedAt()
  1178. })
  1179. }
  1180. // SetStatus sets the "status" field.
  1181. func (u *UsageStatisticHourUpsertBulk) SetStatus(v uint8) *UsageStatisticHourUpsertBulk {
  1182. return u.Update(func(s *UsageStatisticHourUpsert) {
  1183. s.SetStatus(v)
  1184. })
  1185. }
  1186. // AddStatus adds v to the "status" field.
  1187. func (u *UsageStatisticHourUpsertBulk) AddStatus(v uint8) *UsageStatisticHourUpsertBulk {
  1188. return u.Update(func(s *UsageStatisticHourUpsert) {
  1189. s.AddStatus(v)
  1190. })
  1191. }
  1192. // UpdateStatus sets the "status" field to the value that was provided on create.
  1193. func (u *UsageStatisticHourUpsertBulk) UpdateStatus() *UsageStatisticHourUpsertBulk {
  1194. return u.Update(func(s *UsageStatisticHourUpsert) {
  1195. s.UpdateStatus()
  1196. })
  1197. }
  1198. // ClearStatus clears the value of the "status" field.
  1199. func (u *UsageStatisticHourUpsertBulk) ClearStatus() *UsageStatisticHourUpsertBulk {
  1200. return u.Update(func(s *UsageStatisticHourUpsert) {
  1201. s.ClearStatus()
  1202. })
  1203. }
  1204. // SetDeletedAt sets the "deleted_at" field.
  1205. func (u *UsageStatisticHourUpsertBulk) SetDeletedAt(v time.Time) *UsageStatisticHourUpsertBulk {
  1206. return u.Update(func(s *UsageStatisticHourUpsert) {
  1207. s.SetDeletedAt(v)
  1208. })
  1209. }
  1210. // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
  1211. func (u *UsageStatisticHourUpsertBulk) UpdateDeletedAt() *UsageStatisticHourUpsertBulk {
  1212. return u.Update(func(s *UsageStatisticHourUpsert) {
  1213. s.UpdateDeletedAt()
  1214. })
  1215. }
  1216. // ClearDeletedAt clears the value of the "deleted_at" field.
  1217. func (u *UsageStatisticHourUpsertBulk) ClearDeletedAt() *UsageStatisticHourUpsertBulk {
  1218. return u.Update(func(s *UsageStatisticHourUpsert) {
  1219. s.ClearDeletedAt()
  1220. })
  1221. }
  1222. // SetAddtime sets the "addtime" field.
  1223. func (u *UsageStatisticHourUpsertBulk) SetAddtime(v uint64) *UsageStatisticHourUpsertBulk {
  1224. return u.Update(func(s *UsageStatisticHourUpsert) {
  1225. s.SetAddtime(v)
  1226. })
  1227. }
  1228. // AddAddtime adds v to the "addtime" field.
  1229. func (u *UsageStatisticHourUpsertBulk) AddAddtime(v uint64) *UsageStatisticHourUpsertBulk {
  1230. return u.Update(func(s *UsageStatisticHourUpsert) {
  1231. s.AddAddtime(v)
  1232. })
  1233. }
  1234. // UpdateAddtime sets the "addtime" field to the value that was provided on create.
  1235. func (u *UsageStatisticHourUpsertBulk) UpdateAddtime() *UsageStatisticHourUpsertBulk {
  1236. return u.Update(func(s *UsageStatisticHourUpsert) {
  1237. s.UpdateAddtime()
  1238. })
  1239. }
  1240. // SetType sets the "type" field.
  1241. func (u *UsageStatisticHourUpsertBulk) SetType(v int) *UsageStatisticHourUpsertBulk {
  1242. return u.Update(func(s *UsageStatisticHourUpsert) {
  1243. s.SetType(v)
  1244. })
  1245. }
  1246. // AddType adds v to the "type" field.
  1247. func (u *UsageStatisticHourUpsertBulk) AddType(v int) *UsageStatisticHourUpsertBulk {
  1248. return u.Update(func(s *UsageStatisticHourUpsert) {
  1249. s.AddType(v)
  1250. })
  1251. }
  1252. // UpdateType sets the "type" field to the value that was provided on create.
  1253. func (u *UsageStatisticHourUpsertBulk) UpdateType() *UsageStatisticHourUpsertBulk {
  1254. return u.Update(func(s *UsageStatisticHourUpsert) {
  1255. s.UpdateType()
  1256. })
  1257. }
  1258. // SetBotID sets the "bot_id" field.
  1259. func (u *UsageStatisticHourUpsertBulk) SetBotID(v string) *UsageStatisticHourUpsertBulk {
  1260. return u.Update(func(s *UsageStatisticHourUpsert) {
  1261. s.SetBotID(v)
  1262. })
  1263. }
  1264. // UpdateBotID sets the "bot_id" field to the value that was provided on create.
  1265. func (u *UsageStatisticHourUpsertBulk) UpdateBotID() *UsageStatisticHourUpsertBulk {
  1266. return u.Update(func(s *UsageStatisticHourUpsert) {
  1267. s.UpdateBotID()
  1268. })
  1269. }
  1270. // ClearBotID clears the value of the "bot_id" field.
  1271. func (u *UsageStatisticHourUpsertBulk) ClearBotID() *UsageStatisticHourUpsertBulk {
  1272. return u.Update(func(s *UsageStatisticHourUpsert) {
  1273. s.ClearBotID()
  1274. })
  1275. }
  1276. // SetOrganizationID sets the "organization_id" field.
  1277. func (u *UsageStatisticHourUpsertBulk) SetOrganizationID(v uint64) *UsageStatisticHourUpsertBulk {
  1278. return u.Update(func(s *UsageStatisticHourUpsert) {
  1279. s.SetOrganizationID(v)
  1280. })
  1281. }
  1282. // AddOrganizationID adds v to the "organization_id" field.
  1283. func (u *UsageStatisticHourUpsertBulk) AddOrganizationID(v uint64) *UsageStatisticHourUpsertBulk {
  1284. return u.Update(func(s *UsageStatisticHourUpsert) {
  1285. s.AddOrganizationID(v)
  1286. })
  1287. }
  1288. // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
  1289. func (u *UsageStatisticHourUpsertBulk) UpdateOrganizationID() *UsageStatisticHourUpsertBulk {
  1290. return u.Update(func(s *UsageStatisticHourUpsert) {
  1291. s.UpdateOrganizationID()
  1292. })
  1293. }
  1294. // ClearOrganizationID clears the value of the "organization_id" field.
  1295. func (u *UsageStatisticHourUpsertBulk) ClearOrganizationID() *UsageStatisticHourUpsertBulk {
  1296. return u.Update(func(s *UsageStatisticHourUpsert) {
  1297. s.ClearOrganizationID()
  1298. })
  1299. }
  1300. // SetAiResponse sets the "ai_response" field.
  1301. func (u *UsageStatisticHourUpsertBulk) SetAiResponse(v uint64) *UsageStatisticHourUpsertBulk {
  1302. return u.Update(func(s *UsageStatisticHourUpsert) {
  1303. s.SetAiResponse(v)
  1304. })
  1305. }
  1306. // AddAiResponse adds v to the "ai_response" field.
  1307. func (u *UsageStatisticHourUpsertBulk) AddAiResponse(v uint64) *UsageStatisticHourUpsertBulk {
  1308. return u.Update(func(s *UsageStatisticHourUpsert) {
  1309. s.AddAiResponse(v)
  1310. })
  1311. }
  1312. // UpdateAiResponse sets the "ai_response" field to the value that was provided on create.
  1313. func (u *UsageStatisticHourUpsertBulk) UpdateAiResponse() *UsageStatisticHourUpsertBulk {
  1314. return u.Update(func(s *UsageStatisticHourUpsert) {
  1315. s.UpdateAiResponse()
  1316. })
  1317. }
  1318. // SetSopRun sets the "sop_run" field.
  1319. func (u *UsageStatisticHourUpsertBulk) SetSopRun(v uint64) *UsageStatisticHourUpsertBulk {
  1320. return u.Update(func(s *UsageStatisticHourUpsert) {
  1321. s.SetSopRun(v)
  1322. })
  1323. }
  1324. // AddSopRun adds v to the "sop_run" field.
  1325. func (u *UsageStatisticHourUpsertBulk) AddSopRun(v uint64) *UsageStatisticHourUpsertBulk {
  1326. return u.Update(func(s *UsageStatisticHourUpsert) {
  1327. s.AddSopRun(v)
  1328. })
  1329. }
  1330. // UpdateSopRun sets the "sop_run" field to the value that was provided on create.
  1331. func (u *UsageStatisticHourUpsertBulk) UpdateSopRun() *UsageStatisticHourUpsertBulk {
  1332. return u.Update(func(s *UsageStatisticHourUpsert) {
  1333. s.UpdateSopRun()
  1334. })
  1335. }
  1336. // SetTotalFriend sets the "total_friend" field.
  1337. func (u *UsageStatisticHourUpsertBulk) SetTotalFriend(v uint64) *UsageStatisticHourUpsertBulk {
  1338. return u.Update(func(s *UsageStatisticHourUpsert) {
  1339. s.SetTotalFriend(v)
  1340. })
  1341. }
  1342. // AddTotalFriend adds v to the "total_friend" field.
  1343. func (u *UsageStatisticHourUpsertBulk) AddTotalFriend(v uint64) *UsageStatisticHourUpsertBulk {
  1344. return u.Update(func(s *UsageStatisticHourUpsert) {
  1345. s.AddTotalFriend(v)
  1346. })
  1347. }
  1348. // UpdateTotalFriend sets the "total_friend" field to the value that was provided on create.
  1349. func (u *UsageStatisticHourUpsertBulk) UpdateTotalFriend() *UsageStatisticHourUpsertBulk {
  1350. return u.Update(func(s *UsageStatisticHourUpsert) {
  1351. s.UpdateTotalFriend()
  1352. })
  1353. }
  1354. // SetTotalGroup sets the "total_group" field.
  1355. func (u *UsageStatisticHourUpsertBulk) SetTotalGroup(v uint64) *UsageStatisticHourUpsertBulk {
  1356. return u.Update(func(s *UsageStatisticHourUpsert) {
  1357. s.SetTotalGroup(v)
  1358. })
  1359. }
  1360. // AddTotalGroup adds v to the "total_group" field.
  1361. func (u *UsageStatisticHourUpsertBulk) AddTotalGroup(v uint64) *UsageStatisticHourUpsertBulk {
  1362. return u.Update(func(s *UsageStatisticHourUpsert) {
  1363. s.AddTotalGroup(v)
  1364. })
  1365. }
  1366. // UpdateTotalGroup sets the "total_group" field to the value that was provided on create.
  1367. func (u *UsageStatisticHourUpsertBulk) UpdateTotalGroup() *UsageStatisticHourUpsertBulk {
  1368. return u.Update(func(s *UsageStatisticHourUpsert) {
  1369. s.UpdateTotalGroup()
  1370. })
  1371. }
  1372. // SetAccountBalance sets the "account_balance" field.
  1373. func (u *UsageStatisticHourUpsertBulk) SetAccountBalance(v uint64) *UsageStatisticHourUpsertBulk {
  1374. return u.Update(func(s *UsageStatisticHourUpsert) {
  1375. s.SetAccountBalance(v)
  1376. })
  1377. }
  1378. // AddAccountBalance adds v to the "account_balance" field.
  1379. func (u *UsageStatisticHourUpsertBulk) AddAccountBalance(v uint64) *UsageStatisticHourUpsertBulk {
  1380. return u.Update(func(s *UsageStatisticHourUpsert) {
  1381. s.AddAccountBalance(v)
  1382. })
  1383. }
  1384. // UpdateAccountBalance sets the "account_balance" field to the value that was provided on create.
  1385. func (u *UsageStatisticHourUpsertBulk) UpdateAccountBalance() *UsageStatisticHourUpsertBulk {
  1386. return u.Update(func(s *UsageStatisticHourUpsert) {
  1387. s.UpdateAccountBalance()
  1388. })
  1389. }
  1390. // SetConsumeToken sets the "consume_token" field.
  1391. func (u *UsageStatisticHourUpsertBulk) SetConsumeToken(v uint64) *UsageStatisticHourUpsertBulk {
  1392. return u.Update(func(s *UsageStatisticHourUpsert) {
  1393. s.SetConsumeToken(v)
  1394. })
  1395. }
  1396. // AddConsumeToken adds v to the "consume_token" field.
  1397. func (u *UsageStatisticHourUpsertBulk) AddConsumeToken(v uint64) *UsageStatisticHourUpsertBulk {
  1398. return u.Update(func(s *UsageStatisticHourUpsert) {
  1399. s.AddConsumeToken(v)
  1400. })
  1401. }
  1402. // UpdateConsumeToken sets the "consume_token" field to the value that was provided on create.
  1403. func (u *UsageStatisticHourUpsertBulk) UpdateConsumeToken() *UsageStatisticHourUpsertBulk {
  1404. return u.Update(func(s *UsageStatisticHourUpsert) {
  1405. s.UpdateConsumeToken()
  1406. })
  1407. }
  1408. // SetActiveUser sets the "active_user" field.
  1409. func (u *UsageStatisticHourUpsertBulk) SetActiveUser(v uint64) *UsageStatisticHourUpsertBulk {
  1410. return u.Update(func(s *UsageStatisticHourUpsert) {
  1411. s.SetActiveUser(v)
  1412. })
  1413. }
  1414. // AddActiveUser adds v to the "active_user" field.
  1415. func (u *UsageStatisticHourUpsertBulk) AddActiveUser(v uint64) *UsageStatisticHourUpsertBulk {
  1416. return u.Update(func(s *UsageStatisticHourUpsert) {
  1417. s.AddActiveUser(v)
  1418. })
  1419. }
  1420. // UpdateActiveUser sets the "active_user" field to the value that was provided on create.
  1421. func (u *UsageStatisticHourUpsertBulk) UpdateActiveUser() *UsageStatisticHourUpsertBulk {
  1422. return u.Update(func(s *UsageStatisticHourUpsert) {
  1423. s.UpdateActiveUser()
  1424. })
  1425. }
  1426. // SetNewUser sets the "new_user" field.
  1427. func (u *UsageStatisticHourUpsertBulk) SetNewUser(v int64) *UsageStatisticHourUpsertBulk {
  1428. return u.Update(func(s *UsageStatisticHourUpsert) {
  1429. s.SetNewUser(v)
  1430. })
  1431. }
  1432. // AddNewUser adds v to the "new_user" field.
  1433. func (u *UsageStatisticHourUpsertBulk) AddNewUser(v int64) *UsageStatisticHourUpsertBulk {
  1434. return u.Update(func(s *UsageStatisticHourUpsert) {
  1435. s.AddNewUser(v)
  1436. })
  1437. }
  1438. // UpdateNewUser sets the "new_user" field to the value that was provided on create.
  1439. func (u *UsageStatisticHourUpsertBulk) UpdateNewUser() *UsageStatisticHourUpsertBulk {
  1440. return u.Update(func(s *UsageStatisticHourUpsert) {
  1441. s.UpdateNewUser()
  1442. })
  1443. }
  1444. // SetLabelDist sets the "label_dist" field.
  1445. func (u *UsageStatisticHourUpsertBulk) SetLabelDist(v []custom_types.LabelDist) *UsageStatisticHourUpsertBulk {
  1446. return u.Update(func(s *UsageStatisticHourUpsert) {
  1447. s.SetLabelDist(v)
  1448. })
  1449. }
  1450. // UpdateLabelDist sets the "label_dist" field to the value that was provided on create.
  1451. func (u *UsageStatisticHourUpsertBulk) UpdateLabelDist() *UsageStatisticHourUpsertBulk {
  1452. return u.Update(func(s *UsageStatisticHourUpsert) {
  1453. s.UpdateLabelDist()
  1454. })
  1455. }
  1456. // Exec executes the query.
  1457. func (u *UsageStatisticHourUpsertBulk) Exec(ctx context.Context) error {
  1458. if u.create.err != nil {
  1459. return u.create.err
  1460. }
  1461. for i, b := range u.create.builders {
  1462. if len(b.conflict) != 0 {
  1463. return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the UsageStatisticHourCreateBulk instead", i)
  1464. }
  1465. }
  1466. if len(u.create.conflict) == 0 {
  1467. return errors.New("ent: missing options for UsageStatisticHourCreateBulk.OnConflict")
  1468. }
  1469. return u.create.Exec(ctx)
  1470. }
  1471. // ExecX is like Exec, but panics if an error occurs.
  1472. func (u *UsageStatisticHourUpsertBulk) ExecX(ctx context.Context) {
  1473. if err := u.create.Exec(ctx); err != nil {
  1474. panic(err)
  1475. }
  1476. }