usagestatisticmonth_create.go 59 KB

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