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