1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "context"
- "errors"
- "fmt"
- "time"
- "wechat-api/ent/custom_types"
- "wechat-api/ent/predicate"
- "wechat-api/ent/usagestatisticmonth"
- "entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
- "entgo.io/ent/dialect/sql/sqljson"
- "entgo.io/ent/schema/field"
- )
- // UsageStatisticMonthUpdate is the builder for updating UsageStatisticMonth entities.
- type UsageStatisticMonthUpdate struct {
- config
- hooks []Hook
- mutation *UsageStatisticMonthMutation
- }
- // Where appends a list predicates to the UsageStatisticMonthUpdate builder.
- func (usmu *UsageStatisticMonthUpdate) Where(ps ...predicate.UsageStatisticMonth) *UsageStatisticMonthUpdate {
- usmu.mutation.Where(ps...)
- return usmu
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (usmu *UsageStatisticMonthUpdate) SetUpdatedAt(t time.Time) *UsageStatisticMonthUpdate {
- usmu.mutation.SetUpdatedAt(t)
- return usmu
- }
- // SetStatus sets the "status" field.
- func (usmu *UsageStatisticMonthUpdate) SetStatus(u uint8) *UsageStatisticMonthUpdate {
- usmu.mutation.ResetStatus()
- usmu.mutation.SetStatus(u)
- return usmu
- }
- // SetNillableStatus sets the "status" field if the given value is not nil.
- func (usmu *UsageStatisticMonthUpdate) SetNillableStatus(u *uint8) *UsageStatisticMonthUpdate {
- if u != nil {
- usmu.SetStatus(*u)
- }
- return usmu
- }
- // AddStatus adds u to the "status" field.
- func (usmu *UsageStatisticMonthUpdate) AddStatus(u int8) *UsageStatisticMonthUpdate {
- usmu.mutation.AddStatus(u)
- return usmu
- }
- // ClearStatus clears the value of the "status" field.
- func (usmu *UsageStatisticMonthUpdate) ClearStatus() *UsageStatisticMonthUpdate {
- usmu.mutation.ClearStatus()
- return usmu
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (usmu *UsageStatisticMonthUpdate) SetDeletedAt(t time.Time) *UsageStatisticMonthUpdate {
- usmu.mutation.SetDeletedAt(t)
- return usmu
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (usmu *UsageStatisticMonthUpdate) SetNillableDeletedAt(t *time.Time) *UsageStatisticMonthUpdate {
- if t != nil {
- usmu.SetDeletedAt(*t)
- }
- return usmu
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (usmu *UsageStatisticMonthUpdate) ClearDeletedAt() *UsageStatisticMonthUpdate {
- usmu.mutation.ClearDeletedAt()
- return usmu
- }
- // SetAddtime sets the "addtime" field.
- func (usmu *UsageStatisticMonthUpdate) SetAddtime(u uint64) *UsageStatisticMonthUpdate {
- usmu.mutation.ResetAddtime()
- usmu.mutation.SetAddtime(u)
- return usmu
- }
- // SetNillableAddtime sets the "addtime" field if the given value is not nil.
- func (usmu *UsageStatisticMonthUpdate) SetNillableAddtime(u *uint64) *UsageStatisticMonthUpdate {
- if u != nil {
- usmu.SetAddtime(*u)
- }
- return usmu
- }
- // AddAddtime adds u to the "addtime" field.
- func (usmu *UsageStatisticMonthUpdate) AddAddtime(u int64) *UsageStatisticMonthUpdate {
- usmu.mutation.AddAddtime(u)
- return usmu
- }
- // SetType sets the "type" field.
- func (usmu *UsageStatisticMonthUpdate) SetType(i int) *UsageStatisticMonthUpdate {
- usmu.mutation.ResetType()
- usmu.mutation.SetType(i)
- return usmu
- }
- // SetNillableType sets the "type" field if the given value is not nil.
- func (usmu *UsageStatisticMonthUpdate) SetNillableType(i *int) *UsageStatisticMonthUpdate {
- if i != nil {
- usmu.SetType(*i)
- }
- return usmu
- }
- // AddType adds i to the "type" field.
- func (usmu *UsageStatisticMonthUpdate) AddType(i int) *UsageStatisticMonthUpdate {
- usmu.mutation.AddType(i)
- return usmu
- }
- // SetBotID sets the "bot_id" field.
- func (usmu *UsageStatisticMonthUpdate) SetBotID(s string) *UsageStatisticMonthUpdate {
- usmu.mutation.SetBotID(s)
- return usmu
- }
- // SetNillableBotID sets the "bot_id" field if the given value is not nil.
- func (usmu *UsageStatisticMonthUpdate) SetNillableBotID(s *string) *UsageStatisticMonthUpdate {
- if s != nil {
- usmu.SetBotID(*s)
- }
- return usmu
- }
- // ClearBotID clears the value of the "bot_id" field.
- func (usmu *UsageStatisticMonthUpdate) ClearBotID() *UsageStatisticMonthUpdate {
- usmu.mutation.ClearBotID()
- return usmu
- }
- // SetOrganizationID sets the "organization_id" field.
- func (usmu *UsageStatisticMonthUpdate) SetOrganizationID(u uint64) *UsageStatisticMonthUpdate {
- usmu.mutation.ResetOrganizationID()
- usmu.mutation.SetOrganizationID(u)
- return usmu
- }
- // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
- func (usmu *UsageStatisticMonthUpdate) SetNillableOrganizationID(u *uint64) *UsageStatisticMonthUpdate {
- if u != nil {
- usmu.SetOrganizationID(*u)
- }
- return usmu
- }
- // AddOrganizationID adds u to the "organization_id" field.
- func (usmu *UsageStatisticMonthUpdate) AddOrganizationID(u int64) *UsageStatisticMonthUpdate {
- usmu.mutation.AddOrganizationID(u)
- return usmu
- }
- // ClearOrganizationID clears the value of the "organization_id" field.
- func (usmu *UsageStatisticMonthUpdate) ClearOrganizationID() *UsageStatisticMonthUpdate {
- usmu.mutation.ClearOrganizationID()
- return usmu
- }
- // SetAiResponse sets the "ai_response" field.
- func (usmu *UsageStatisticMonthUpdate) SetAiResponse(u uint64) *UsageStatisticMonthUpdate {
- usmu.mutation.ResetAiResponse()
- usmu.mutation.SetAiResponse(u)
- return usmu
- }
- // SetNillableAiResponse sets the "ai_response" field if the given value is not nil.
- func (usmu *UsageStatisticMonthUpdate) SetNillableAiResponse(u *uint64) *UsageStatisticMonthUpdate {
- if u != nil {
- usmu.SetAiResponse(*u)
- }
- return usmu
- }
- // AddAiResponse adds u to the "ai_response" field.
- func (usmu *UsageStatisticMonthUpdate) AddAiResponse(u int64) *UsageStatisticMonthUpdate {
- usmu.mutation.AddAiResponse(u)
- return usmu
- }
- // SetSopRun sets the "sop_run" field.
- func (usmu *UsageStatisticMonthUpdate) SetSopRun(u uint64) *UsageStatisticMonthUpdate {
- usmu.mutation.ResetSopRun()
- usmu.mutation.SetSopRun(u)
- return usmu
- }
- // SetNillableSopRun sets the "sop_run" field if the given value is not nil.
- func (usmu *UsageStatisticMonthUpdate) SetNillableSopRun(u *uint64) *UsageStatisticMonthUpdate {
- if u != nil {
- usmu.SetSopRun(*u)
- }
- return usmu
- }
- // AddSopRun adds u to the "sop_run" field.
- func (usmu *UsageStatisticMonthUpdate) AddSopRun(u int64) *UsageStatisticMonthUpdate {
- usmu.mutation.AddSopRun(u)
- return usmu
- }
- // SetTotalFriend sets the "total_friend" field.
- func (usmu *UsageStatisticMonthUpdate) SetTotalFriend(u uint64) *UsageStatisticMonthUpdate {
- usmu.mutation.ResetTotalFriend()
- usmu.mutation.SetTotalFriend(u)
- return usmu
- }
- // SetNillableTotalFriend sets the "total_friend" field if the given value is not nil.
- func (usmu *UsageStatisticMonthUpdate) SetNillableTotalFriend(u *uint64) *UsageStatisticMonthUpdate {
- if u != nil {
- usmu.SetTotalFriend(*u)
- }
- return usmu
- }
- // AddTotalFriend adds u to the "total_friend" field.
- func (usmu *UsageStatisticMonthUpdate) AddTotalFriend(u int64) *UsageStatisticMonthUpdate {
- usmu.mutation.AddTotalFriend(u)
- return usmu
- }
- // SetTotalGroup sets the "total_group" field.
- func (usmu *UsageStatisticMonthUpdate) SetTotalGroup(u uint64) *UsageStatisticMonthUpdate {
- usmu.mutation.ResetTotalGroup()
- usmu.mutation.SetTotalGroup(u)
- return usmu
- }
- // SetNillableTotalGroup sets the "total_group" field if the given value is not nil.
- func (usmu *UsageStatisticMonthUpdate) SetNillableTotalGroup(u *uint64) *UsageStatisticMonthUpdate {
- if u != nil {
- usmu.SetTotalGroup(*u)
- }
- return usmu
- }
- // AddTotalGroup adds u to the "total_group" field.
- func (usmu *UsageStatisticMonthUpdate) AddTotalGroup(u int64) *UsageStatisticMonthUpdate {
- usmu.mutation.AddTotalGroup(u)
- return usmu
- }
- // SetAccountBalance sets the "account_balance" field.
- func (usmu *UsageStatisticMonthUpdate) SetAccountBalance(u uint64) *UsageStatisticMonthUpdate {
- usmu.mutation.ResetAccountBalance()
- usmu.mutation.SetAccountBalance(u)
- return usmu
- }
- // SetNillableAccountBalance sets the "account_balance" field if the given value is not nil.
- func (usmu *UsageStatisticMonthUpdate) SetNillableAccountBalance(u *uint64) *UsageStatisticMonthUpdate {
- if u != nil {
- usmu.SetAccountBalance(*u)
- }
- return usmu
- }
- // AddAccountBalance adds u to the "account_balance" field.
- func (usmu *UsageStatisticMonthUpdate) AddAccountBalance(u int64) *UsageStatisticMonthUpdate {
- usmu.mutation.AddAccountBalance(u)
- return usmu
- }
- // SetConsumeToken sets the "consume_token" field.
- func (usmu *UsageStatisticMonthUpdate) SetConsumeToken(u uint64) *UsageStatisticMonthUpdate {
- usmu.mutation.ResetConsumeToken()
- usmu.mutation.SetConsumeToken(u)
- return usmu
- }
- // SetNillableConsumeToken sets the "consume_token" field if the given value is not nil.
- func (usmu *UsageStatisticMonthUpdate) SetNillableConsumeToken(u *uint64) *UsageStatisticMonthUpdate {
- if u != nil {
- usmu.SetConsumeToken(*u)
- }
- return usmu
- }
- // AddConsumeToken adds u to the "consume_token" field.
- func (usmu *UsageStatisticMonthUpdate) AddConsumeToken(u int64) *UsageStatisticMonthUpdate {
- usmu.mutation.AddConsumeToken(u)
- return usmu
- }
- // SetActiveUser sets the "active_user" field.
- func (usmu *UsageStatisticMonthUpdate) SetActiveUser(u uint64) *UsageStatisticMonthUpdate {
- usmu.mutation.ResetActiveUser()
- usmu.mutation.SetActiveUser(u)
- return usmu
- }
- // SetNillableActiveUser sets the "active_user" field if the given value is not nil.
- func (usmu *UsageStatisticMonthUpdate) SetNillableActiveUser(u *uint64) *UsageStatisticMonthUpdate {
- if u != nil {
- usmu.SetActiveUser(*u)
- }
- return usmu
- }
- // AddActiveUser adds u to the "active_user" field.
- func (usmu *UsageStatisticMonthUpdate) AddActiveUser(u int64) *UsageStatisticMonthUpdate {
- usmu.mutation.AddActiveUser(u)
- return usmu
- }
- // SetNewUser sets the "new_user" field.
- func (usmu *UsageStatisticMonthUpdate) SetNewUser(i int64) *UsageStatisticMonthUpdate {
- usmu.mutation.ResetNewUser()
- usmu.mutation.SetNewUser(i)
- return usmu
- }
- // SetNillableNewUser sets the "new_user" field if the given value is not nil.
- func (usmu *UsageStatisticMonthUpdate) SetNillableNewUser(i *int64) *UsageStatisticMonthUpdate {
- if i != nil {
- usmu.SetNewUser(*i)
- }
- return usmu
- }
- // AddNewUser adds i to the "new_user" field.
- func (usmu *UsageStatisticMonthUpdate) AddNewUser(i int64) *UsageStatisticMonthUpdate {
- usmu.mutation.AddNewUser(i)
- return usmu
- }
- // SetLabelDist sets the "label_dist" field.
- func (usmu *UsageStatisticMonthUpdate) SetLabelDist(ctd []custom_types.LabelDist) *UsageStatisticMonthUpdate {
- usmu.mutation.SetLabelDist(ctd)
- return usmu
- }
- // AppendLabelDist appends ctd to the "label_dist" field.
- func (usmu *UsageStatisticMonthUpdate) AppendLabelDist(ctd []custom_types.LabelDist) *UsageStatisticMonthUpdate {
- usmu.mutation.AppendLabelDist(ctd)
- return usmu
- }
- // Mutation returns the UsageStatisticMonthMutation object of the builder.
- func (usmu *UsageStatisticMonthUpdate) Mutation() *UsageStatisticMonthMutation {
- return usmu.mutation
- }
- // Save executes the query and returns the number of nodes affected by the update operation.
- func (usmu *UsageStatisticMonthUpdate) Save(ctx context.Context) (int, error) {
- if err := usmu.defaults(); err != nil {
- return 0, err
- }
- return withHooks(ctx, usmu.sqlSave, usmu.mutation, usmu.hooks)
- }
- // SaveX is like Save, but panics if an error occurs.
- func (usmu *UsageStatisticMonthUpdate) SaveX(ctx context.Context) int {
- affected, err := usmu.Save(ctx)
- if err != nil {
- panic(err)
- }
- return affected
- }
- // Exec executes the query.
- func (usmu *UsageStatisticMonthUpdate) Exec(ctx context.Context) error {
- _, err := usmu.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (usmu *UsageStatisticMonthUpdate) ExecX(ctx context.Context) {
- if err := usmu.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (usmu *UsageStatisticMonthUpdate) defaults() error {
- if _, ok := usmu.mutation.UpdatedAt(); !ok {
- if usagestatisticmonth.UpdateDefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized usagestatisticmonth.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := usagestatisticmonth.UpdateDefaultUpdatedAt()
- usmu.mutation.SetUpdatedAt(v)
- }
- return nil
- }
- func (usmu *UsageStatisticMonthUpdate) sqlSave(ctx context.Context) (n int, err error) {
- _spec := sqlgraph.NewUpdateSpec(usagestatisticmonth.Table, usagestatisticmonth.Columns, sqlgraph.NewFieldSpec(usagestatisticmonth.FieldID, field.TypeUint64))
- if ps := usmu.mutation.predicates; len(ps) > 0 {
- _spec.Predicate = func(selector *sql.Selector) {
- for i := range ps {
- ps[i](selector)
- }
- }
- }
- if value, ok := usmu.mutation.UpdatedAt(); ok {
- _spec.SetField(usagestatisticmonth.FieldUpdatedAt, field.TypeTime, value)
- }
- if value, ok := usmu.mutation.Status(); ok {
- _spec.SetField(usagestatisticmonth.FieldStatus, field.TypeUint8, value)
- }
- if value, ok := usmu.mutation.AddedStatus(); ok {
- _spec.AddField(usagestatisticmonth.FieldStatus, field.TypeUint8, value)
- }
- if usmu.mutation.StatusCleared() {
- _spec.ClearField(usagestatisticmonth.FieldStatus, field.TypeUint8)
- }
- if value, ok := usmu.mutation.DeletedAt(); ok {
- _spec.SetField(usagestatisticmonth.FieldDeletedAt, field.TypeTime, value)
- }
- if usmu.mutation.DeletedAtCleared() {
- _spec.ClearField(usagestatisticmonth.FieldDeletedAt, field.TypeTime)
- }
- if value, ok := usmu.mutation.Addtime(); ok {
- _spec.SetField(usagestatisticmonth.FieldAddtime, field.TypeUint64, value)
- }
- if value, ok := usmu.mutation.AddedAddtime(); ok {
- _spec.AddField(usagestatisticmonth.FieldAddtime, field.TypeUint64, value)
- }
- if value, ok := usmu.mutation.GetType(); ok {
- _spec.SetField(usagestatisticmonth.FieldType, field.TypeInt, value)
- }
- if value, ok := usmu.mutation.AddedType(); ok {
- _spec.AddField(usagestatisticmonth.FieldType, field.TypeInt, value)
- }
- if value, ok := usmu.mutation.BotID(); ok {
- _spec.SetField(usagestatisticmonth.FieldBotID, field.TypeString, value)
- }
- if usmu.mutation.BotIDCleared() {
- _spec.ClearField(usagestatisticmonth.FieldBotID, field.TypeString)
- }
- if value, ok := usmu.mutation.OrganizationID(); ok {
- _spec.SetField(usagestatisticmonth.FieldOrganizationID, field.TypeUint64, value)
- }
- if value, ok := usmu.mutation.AddedOrganizationID(); ok {
- _spec.AddField(usagestatisticmonth.FieldOrganizationID, field.TypeUint64, value)
- }
- if usmu.mutation.OrganizationIDCleared() {
- _spec.ClearField(usagestatisticmonth.FieldOrganizationID, field.TypeUint64)
- }
- if value, ok := usmu.mutation.AiResponse(); ok {
- _spec.SetField(usagestatisticmonth.FieldAiResponse, field.TypeUint64, value)
- }
- if value, ok := usmu.mutation.AddedAiResponse(); ok {
- _spec.AddField(usagestatisticmonth.FieldAiResponse, field.TypeUint64, value)
- }
- if value, ok := usmu.mutation.SopRun(); ok {
- _spec.SetField(usagestatisticmonth.FieldSopRun, field.TypeUint64, value)
- }
- if value, ok := usmu.mutation.AddedSopRun(); ok {
- _spec.AddField(usagestatisticmonth.FieldSopRun, field.TypeUint64, value)
- }
- if value, ok := usmu.mutation.TotalFriend(); ok {
- _spec.SetField(usagestatisticmonth.FieldTotalFriend, field.TypeUint64, value)
- }
- if value, ok := usmu.mutation.AddedTotalFriend(); ok {
- _spec.AddField(usagestatisticmonth.FieldTotalFriend, field.TypeUint64, value)
- }
- if value, ok := usmu.mutation.TotalGroup(); ok {
- _spec.SetField(usagestatisticmonth.FieldTotalGroup, field.TypeUint64, value)
- }
- if value, ok := usmu.mutation.AddedTotalGroup(); ok {
- _spec.AddField(usagestatisticmonth.FieldTotalGroup, field.TypeUint64, value)
- }
- if value, ok := usmu.mutation.AccountBalance(); ok {
- _spec.SetField(usagestatisticmonth.FieldAccountBalance, field.TypeUint64, value)
- }
- if value, ok := usmu.mutation.AddedAccountBalance(); ok {
- _spec.AddField(usagestatisticmonth.FieldAccountBalance, field.TypeUint64, value)
- }
- if value, ok := usmu.mutation.ConsumeToken(); ok {
- _spec.SetField(usagestatisticmonth.FieldConsumeToken, field.TypeUint64, value)
- }
- if value, ok := usmu.mutation.AddedConsumeToken(); ok {
- _spec.AddField(usagestatisticmonth.FieldConsumeToken, field.TypeUint64, value)
- }
- if value, ok := usmu.mutation.ActiveUser(); ok {
- _spec.SetField(usagestatisticmonth.FieldActiveUser, field.TypeUint64, value)
- }
- if value, ok := usmu.mutation.AddedActiveUser(); ok {
- _spec.AddField(usagestatisticmonth.FieldActiveUser, field.TypeUint64, value)
- }
- if value, ok := usmu.mutation.NewUser(); ok {
- _spec.SetField(usagestatisticmonth.FieldNewUser, field.TypeInt64, value)
- }
- if value, ok := usmu.mutation.AddedNewUser(); ok {
- _spec.AddField(usagestatisticmonth.FieldNewUser, field.TypeInt64, value)
- }
- if value, ok := usmu.mutation.LabelDist(); ok {
- _spec.SetField(usagestatisticmonth.FieldLabelDist, field.TypeJSON, value)
- }
- if value, ok := usmu.mutation.AppendedLabelDist(); ok {
- _spec.AddModifier(func(u *sql.UpdateBuilder) {
- sqljson.Append(u, usagestatisticmonth.FieldLabelDist, value)
- })
- }
- if n, err = sqlgraph.UpdateNodes(ctx, usmu.driver, _spec); err != nil {
- if _, ok := err.(*sqlgraph.NotFoundError); ok {
- err = &NotFoundError{usagestatisticmonth.Label}
- } else if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return 0, err
- }
- usmu.mutation.done = true
- return n, nil
- }
- // UsageStatisticMonthUpdateOne is the builder for updating a single UsageStatisticMonth entity.
- type UsageStatisticMonthUpdateOne struct {
- config
- fields []string
- hooks []Hook
- mutation *UsageStatisticMonthMutation
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (usmuo *UsageStatisticMonthUpdateOne) SetUpdatedAt(t time.Time) *UsageStatisticMonthUpdateOne {
- usmuo.mutation.SetUpdatedAt(t)
- return usmuo
- }
- // SetStatus sets the "status" field.
- func (usmuo *UsageStatisticMonthUpdateOne) SetStatus(u uint8) *UsageStatisticMonthUpdateOne {
- usmuo.mutation.ResetStatus()
- usmuo.mutation.SetStatus(u)
- return usmuo
- }
- // SetNillableStatus sets the "status" field if the given value is not nil.
- func (usmuo *UsageStatisticMonthUpdateOne) SetNillableStatus(u *uint8) *UsageStatisticMonthUpdateOne {
- if u != nil {
- usmuo.SetStatus(*u)
- }
- return usmuo
- }
- // AddStatus adds u to the "status" field.
- func (usmuo *UsageStatisticMonthUpdateOne) AddStatus(u int8) *UsageStatisticMonthUpdateOne {
- usmuo.mutation.AddStatus(u)
- return usmuo
- }
- // ClearStatus clears the value of the "status" field.
- func (usmuo *UsageStatisticMonthUpdateOne) ClearStatus() *UsageStatisticMonthUpdateOne {
- usmuo.mutation.ClearStatus()
- return usmuo
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (usmuo *UsageStatisticMonthUpdateOne) SetDeletedAt(t time.Time) *UsageStatisticMonthUpdateOne {
- usmuo.mutation.SetDeletedAt(t)
- return usmuo
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (usmuo *UsageStatisticMonthUpdateOne) SetNillableDeletedAt(t *time.Time) *UsageStatisticMonthUpdateOne {
- if t != nil {
- usmuo.SetDeletedAt(*t)
- }
- return usmuo
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (usmuo *UsageStatisticMonthUpdateOne) ClearDeletedAt() *UsageStatisticMonthUpdateOne {
- usmuo.mutation.ClearDeletedAt()
- return usmuo
- }
- // SetAddtime sets the "addtime" field.
- func (usmuo *UsageStatisticMonthUpdateOne) SetAddtime(u uint64) *UsageStatisticMonthUpdateOne {
- usmuo.mutation.ResetAddtime()
- usmuo.mutation.SetAddtime(u)
- return usmuo
- }
- // SetNillableAddtime sets the "addtime" field if the given value is not nil.
- func (usmuo *UsageStatisticMonthUpdateOne) SetNillableAddtime(u *uint64) *UsageStatisticMonthUpdateOne {
- if u != nil {
- usmuo.SetAddtime(*u)
- }
- return usmuo
- }
- // AddAddtime adds u to the "addtime" field.
- func (usmuo *UsageStatisticMonthUpdateOne) AddAddtime(u int64) *UsageStatisticMonthUpdateOne {
- usmuo.mutation.AddAddtime(u)
- return usmuo
- }
- // SetType sets the "type" field.
- func (usmuo *UsageStatisticMonthUpdateOne) SetType(i int) *UsageStatisticMonthUpdateOne {
- usmuo.mutation.ResetType()
- usmuo.mutation.SetType(i)
- return usmuo
- }
- // SetNillableType sets the "type" field if the given value is not nil.
- func (usmuo *UsageStatisticMonthUpdateOne) SetNillableType(i *int) *UsageStatisticMonthUpdateOne {
- if i != nil {
- usmuo.SetType(*i)
- }
- return usmuo
- }
- // AddType adds i to the "type" field.
- func (usmuo *UsageStatisticMonthUpdateOne) AddType(i int) *UsageStatisticMonthUpdateOne {
- usmuo.mutation.AddType(i)
- return usmuo
- }
- // SetBotID sets the "bot_id" field.
- func (usmuo *UsageStatisticMonthUpdateOne) SetBotID(s string) *UsageStatisticMonthUpdateOne {
- usmuo.mutation.SetBotID(s)
- return usmuo
- }
- // SetNillableBotID sets the "bot_id" field if the given value is not nil.
- func (usmuo *UsageStatisticMonthUpdateOne) SetNillableBotID(s *string) *UsageStatisticMonthUpdateOne {
- if s != nil {
- usmuo.SetBotID(*s)
- }
- return usmuo
- }
- // ClearBotID clears the value of the "bot_id" field.
- func (usmuo *UsageStatisticMonthUpdateOne) ClearBotID() *UsageStatisticMonthUpdateOne {
- usmuo.mutation.ClearBotID()
- return usmuo
- }
- // SetOrganizationID sets the "organization_id" field.
- func (usmuo *UsageStatisticMonthUpdateOne) SetOrganizationID(u uint64) *UsageStatisticMonthUpdateOne {
- usmuo.mutation.ResetOrganizationID()
- usmuo.mutation.SetOrganizationID(u)
- return usmuo
- }
- // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
- func (usmuo *UsageStatisticMonthUpdateOne) SetNillableOrganizationID(u *uint64) *UsageStatisticMonthUpdateOne {
- if u != nil {
- usmuo.SetOrganizationID(*u)
- }
- return usmuo
- }
- // AddOrganizationID adds u to the "organization_id" field.
- func (usmuo *UsageStatisticMonthUpdateOne) AddOrganizationID(u int64) *UsageStatisticMonthUpdateOne {
- usmuo.mutation.AddOrganizationID(u)
- return usmuo
- }
- // ClearOrganizationID clears the value of the "organization_id" field.
- func (usmuo *UsageStatisticMonthUpdateOne) ClearOrganizationID() *UsageStatisticMonthUpdateOne {
- usmuo.mutation.ClearOrganizationID()
- return usmuo
- }
- // SetAiResponse sets the "ai_response" field.
- func (usmuo *UsageStatisticMonthUpdateOne) SetAiResponse(u uint64) *UsageStatisticMonthUpdateOne {
- usmuo.mutation.ResetAiResponse()
- usmuo.mutation.SetAiResponse(u)
- return usmuo
- }
- // SetNillableAiResponse sets the "ai_response" field if the given value is not nil.
- func (usmuo *UsageStatisticMonthUpdateOne) SetNillableAiResponse(u *uint64) *UsageStatisticMonthUpdateOne {
- if u != nil {
- usmuo.SetAiResponse(*u)
- }
- return usmuo
- }
- // AddAiResponse adds u to the "ai_response" field.
- func (usmuo *UsageStatisticMonthUpdateOne) AddAiResponse(u int64) *UsageStatisticMonthUpdateOne {
- usmuo.mutation.AddAiResponse(u)
- return usmuo
- }
- // SetSopRun sets the "sop_run" field.
- func (usmuo *UsageStatisticMonthUpdateOne) SetSopRun(u uint64) *UsageStatisticMonthUpdateOne {
- usmuo.mutation.ResetSopRun()
- usmuo.mutation.SetSopRun(u)
- return usmuo
- }
- // SetNillableSopRun sets the "sop_run" field if the given value is not nil.
- func (usmuo *UsageStatisticMonthUpdateOne) SetNillableSopRun(u *uint64) *UsageStatisticMonthUpdateOne {
- if u != nil {
- usmuo.SetSopRun(*u)
- }
- return usmuo
- }
- // AddSopRun adds u to the "sop_run" field.
- func (usmuo *UsageStatisticMonthUpdateOne) AddSopRun(u int64) *UsageStatisticMonthUpdateOne {
- usmuo.mutation.AddSopRun(u)
- return usmuo
- }
- // SetTotalFriend sets the "total_friend" field.
- func (usmuo *UsageStatisticMonthUpdateOne) SetTotalFriend(u uint64) *UsageStatisticMonthUpdateOne {
- usmuo.mutation.ResetTotalFriend()
- usmuo.mutation.SetTotalFriend(u)
- return usmuo
- }
- // SetNillableTotalFriend sets the "total_friend" field if the given value is not nil.
- func (usmuo *UsageStatisticMonthUpdateOne) SetNillableTotalFriend(u *uint64) *UsageStatisticMonthUpdateOne {
- if u != nil {
- usmuo.SetTotalFriend(*u)
- }
- return usmuo
- }
- // AddTotalFriend adds u to the "total_friend" field.
- func (usmuo *UsageStatisticMonthUpdateOne) AddTotalFriend(u int64) *UsageStatisticMonthUpdateOne {
- usmuo.mutation.AddTotalFriend(u)
- return usmuo
- }
- // SetTotalGroup sets the "total_group" field.
- func (usmuo *UsageStatisticMonthUpdateOne) SetTotalGroup(u uint64) *UsageStatisticMonthUpdateOne {
- usmuo.mutation.ResetTotalGroup()
- usmuo.mutation.SetTotalGroup(u)
- return usmuo
- }
- // SetNillableTotalGroup sets the "total_group" field if the given value is not nil.
- func (usmuo *UsageStatisticMonthUpdateOne) SetNillableTotalGroup(u *uint64) *UsageStatisticMonthUpdateOne {
- if u != nil {
- usmuo.SetTotalGroup(*u)
- }
- return usmuo
- }
- // AddTotalGroup adds u to the "total_group" field.
- func (usmuo *UsageStatisticMonthUpdateOne) AddTotalGroup(u int64) *UsageStatisticMonthUpdateOne {
- usmuo.mutation.AddTotalGroup(u)
- return usmuo
- }
- // SetAccountBalance sets the "account_balance" field.
- func (usmuo *UsageStatisticMonthUpdateOne) SetAccountBalance(u uint64) *UsageStatisticMonthUpdateOne {
- usmuo.mutation.ResetAccountBalance()
- usmuo.mutation.SetAccountBalance(u)
- return usmuo
- }
- // SetNillableAccountBalance sets the "account_balance" field if the given value is not nil.
- func (usmuo *UsageStatisticMonthUpdateOne) SetNillableAccountBalance(u *uint64) *UsageStatisticMonthUpdateOne {
- if u != nil {
- usmuo.SetAccountBalance(*u)
- }
- return usmuo
- }
- // AddAccountBalance adds u to the "account_balance" field.
- func (usmuo *UsageStatisticMonthUpdateOne) AddAccountBalance(u int64) *UsageStatisticMonthUpdateOne {
- usmuo.mutation.AddAccountBalance(u)
- return usmuo
- }
- // SetConsumeToken sets the "consume_token" field.
- func (usmuo *UsageStatisticMonthUpdateOne) SetConsumeToken(u uint64) *UsageStatisticMonthUpdateOne {
- usmuo.mutation.ResetConsumeToken()
- usmuo.mutation.SetConsumeToken(u)
- return usmuo
- }
- // SetNillableConsumeToken sets the "consume_token" field if the given value is not nil.
- func (usmuo *UsageStatisticMonthUpdateOne) SetNillableConsumeToken(u *uint64) *UsageStatisticMonthUpdateOne {
- if u != nil {
- usmuo.SetConsumeToken(*u)
- }
- return usmuo
- }
- // AddConsumeToken adds u to the "consume_token" field.
- func (usmuo *UsageStatisticMonthUpdateOne) AddConsumeToken(u int64) *UsageStatisticMonthUpdateOne {
- usmuo.mutation.AddConsumeToken(u)
- return usmuo
- }
- // SetActiveUser sets the "active_user" field.
- func (usmuo *UsageStatisticMonthUpdateOne) SetActiveUser(u uint64) *UsageStatisticMonthUpdateOne {
- usmuo.mutation.ResetActiveUser()
- usmuo.mutation.SetActiveUser(u)
- return usmuo
- }
- // SetNillableActiveUser sets the "active_user" field if the given value is not nil.
- func (usmuo *UsageStatisticMonthUpdateOne) SetNillableActiveUser(u *uint64) *UsageStatisticMonthUpdateOne {
- if u != nil {
- usmuo.SetActiveUser(*u)
- }
- return usmuo
- }
- // AddActiveUser adds u to the "active_user" field.
- func (usmuo *UsageStatisticMonthUpdateOne) AddActiveUser(u int64) *UsageStatisticMonthUpdateOne {
- usmuo.mutation.AddActiveUser(u)
- return usmuo
- }
- // SetNewUser sets the "new_user" field.
- func (usmuo *UsageStatisticMonthUpdateOne) SetNewUser(i int64) *UsageStatisticMonthUpdateOne {
- usmuo.mutation.ResetNewUser()
- usmuo.mutation.SetNewUser(i)
- return usmuo
- }
- // SetNillableNewUser sets the "new_user" field if the given value is not nil.
- func (usmuo *UsageStatisticMonthUpdateOne) SetNillableNewUser(i *int64) *UsageStatisticMonthUpdateOne {
- if i != nil {
- usmuo.SetNewUser(*i)
- }
- return usmuo
- }
- // AddNewUser adds i to the "new_user" field.
- func (usmuo *UsageStatisticMonthUpdateOne) AddNewUser(i int64) *UsageStatisticMonthUpdateOne {
- usmuo.mutation.AddNewUser(i)
- return usmuo
- }
- // SetLabelDist sets the "label_dist" field.
- func (usmuo *UsageStatisticMonthUpdateOne) SetLabelDist(ctd []custom_types.LabelDist) *UsageStatisticMonthUpdateOne {
- usmuo.mutation.SetLabelDist(ctd)
- return usmuo
- }
- // AppendLabelDist appends ctd to the "label_dist" field.
- func (usmuo *UsageStatisticMonthUpdateOne) AppendLabelDist(ctd []custom_types.LabelDist) *UsageStatisticMonthUpdateOne {
- usmuo.mutation.AppendLabelDist(ctd)
- return usmuo
- }
- // Mutation returns the UsageStatisticMonthMutation object of the builder.
- func (usmuo *UsageStatisticMonthUpdateOne) Mutation() *UsageStatisticMonthMutation {
- return usmuo.mutation
- }
- // Where appends a list predicates to the UsageStatisticMonthUpdate builder.
- func (usmuo *UsageStatisticMonthUpdateOne) Where(ps ...predicate.UsageStatisticMonth) *UsageStatisticMonthUpdateOne {
- usmuo.mutation.Where(ps...)
- return usmuo
- }
- // Select allows selecting one or more fields (columns) of the returned entity.
- // The default is selecting all fields defined in the entity schema.
- func (usmuo *UsageStatisticMonthUpdateOne) Select(field string, fields ...string) *UsageStatisticMonthUpdateOne {
- usmuo.fields = append([]string{field}, fields...)
- return usmuo
- }
- // Save executes the query and returns the updated UsageStatisticMonth entity.
- func (usmuo *UsageStatisticMonthUpdateOne) Save(ctx context.Context) (*UsageStatisticMonth, error) {
- if err := usmuo.defaults(); err != nil {
- return nil, err
- }
- return withHooks(ctx, usmuo.sqlSave, usmuo.mutation, usmuo.hooks)
- }
- // SaveX is like Save, but panics if an error occurs.
- func (usmuo *UsageStatisticMonthUpdateOne) SaveX(ctx context.Context) *UsageStatisticMonth {
- node, err := usmuo.Save(ctx)
- if err != nil {
- panic(err)
- }
- return node
- }
- // Exec executes the query on the entity.
- func (usmuo *UsageStatisticMonthUpdateOne) Exec(ctx context.Context) error {
- _, err := usmuo.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (usmuo *UsageStatisticMonthUpdateOne) ExecX(ctx context.Context) {
- if err := usmuo.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (usmuo *UsageStatisticMonthUpdateOne) defaults() error {
- if _, ok := usmuo.mutation.UpdatedAt(); !ok {
- if usagestatisticmonth.UpdateDefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized usagestatisticmonth.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := usagestatisticmonth.UpdateDefaultUpdatedAt()
- usmuo.mutation.SetUpdatedAt(v)
- }
- return nil
- }
- func (usmuo *UsageStatisticMonthUpdateOne) sqlSave(ctx context.Context) (_node *UsageStatisticMonth, err error) {
- _spec := sqlgraph.NewUpdateSpec(usagestatisticmonth.Table, usagestatisticmonth.Columns, sqlgraph.NewFieldSpec(usagestatisticmonth.FieldID, field.TypeUint64))
- id, ok := usmuo.mutation.ID()
- if !ok {
- return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "UsageStatisticMonth.id" for update`)}
- }
- _spec.Node.ID.Value = id
- if fields := usmuo.fields; len(fields) > 0 {
- _spec.Node.Columns = make([]string, 0, len(fields))
- _spec.Node.Columns = append(_spec.Node.Columns, usagestatisticmonth.FieldID)
- for _, f := range fields {
- if !usagestatisticmonth.ValidColumn(f) {
- return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
- }
- if f != usagestatisticmonth.FieldID {
- _spec.Node.Columns = append(_spec.Node.Columns, f)
- }
- }
- }
- if ps := usmuo.mutation.predicates; len(ps) > 0 {
- _spec.Predicate = func(selector *sql.Selector) {
- for i := range ps {
- ps[i](selector)
- }
- }
- }
- if value, ok := usmuo.mutation.UpdatedAt(); ok {
- _spec.SetField(usagestatisticmonth.FieldUpdatedAt, field.TypeTime, value)
- }
- if value, ok := usmuo.mutation.Status(); ok {
- _spec.SetField(usagestatisticmonth.FieldStatus, field.TypeUint8, value)
- }
- if value, ok := usmuo.mutation.AddedStatus(); ok {
- _spec.AddField(usagestatisticmonth.FieldStatus, field.TypeUint8, value)
- }
- if usmuo.mutation.StatusCleared() {
- _spec.ClearField(usagestatisticmonth.FieldStatus, field.TypeUint8)
- }
- if value, ok := usmuo.mutation.DeletedAt(); ok {
- _spec.SetField(usagestatisticmonth.FieldDeletedAt, field.TypeTime, value)
- }
- if usmuo.mutation.DeletedAtCleared() {
- _spec.ClearField(usagestatisticmonth.FieldDeletedAt, field.TypeTime)
- }
- if value, ok := usmuo.mutation.Addtime(); ok {
- _spec.SetField(usagestatisticmonth.FieldAddtime, field.TypeUint64, value)
- }
- if value, ok := usmuo.mutation.AddedAddtime(); ok {
- _spec.AddField(usagestatisticmonth.FieldAddtime, field.TypeUint64, value)
- }
- if value, ok := usmuo.mutation.GetType(); ok {
- _spec.SetField(usagestatisticmonth.FieldType, field.TypeInt, value)
- }
- if value, ok := usmuo.mutation.AddedType(); ok {
- _spec.AddField(usagestatisticmonth.FieldType, field.TypeInt, value)
- }
- if value, ok := usmuo.mutation.BotID(); ok {
- _spec.SetField(usagestatisticmonth.FieldBotID, field.TypeString, value)
- }
- if usmuo.mutation.BotIDCleared() {
- _spec.ClearField(usagestatisticmonth.FieldBotID, field.TypeString)
- }
- if value, ok := usmuo.mutation.OrganizationID(); ok {
- _spec.SetField(usagestatisticmonth.FieldOrganizationID, field.TypeUint64, value)
- }
- if value, ok := usmuo.mutation.AddedOrganizationID(); ok {
- _spec.AddField(usagestatisticmonth.FieldOrganizationID, field.TypeUint64, value)
- }
- if usmuo.mutation.OrganizationIDCleared() {
- _spec.ClearField(usagestatisticmonth.FieldOrganizationID, field.TypeUint64)
- }
- if value, ok := usmuo.mutation.AiResponse(); ok {
- _spec.SetField(usagestatisticmonth.FieldAiResponse, field.TypeUint64, value)
- }
- if value, ok := usmuo.mutation.AddedAiResponse(); ok {
- _spec.AddField(usagestatisticmonth.FieldAiResponse, field.TypeUint64, value)
- }
- if value, ok := usmuo.mutation.SopRun(); ok {
- _spec.SetField(usagestatisticmonth.FieldSopRun, field.TypeUint64, value)
- }
- if value, ok := usmuo.mutation.AddedSopRun(); ok {
- _spec.AddField(usagestatisticmonth.FieldSopRun, field.TypeUint64, value)
- }
- if value, ok := usmuo.mutation.TotalFriend(); ok {
- _spec.SetField(usagestatisticmonth.FieldTotalFriend, field.TypeUint64, value)
- }
- if value, ok := usmuo.mutation.AddedTotalFriend(); ok {
- _spec.AddField(usagestatisticmonth.FieldTotalFriend, field.TypeUint64, value)
- }
- if value, ok := usmuo.mutation.TotalGroup(); ok {
- _spec.SetField(usagestatisticmonth.FieldTotalGroup, field.TypeUint64, value)
- }
- if value, ok := usmuo.mutation.AddedTotalGroup(); ok {
- _spec.AddField(usagestatisticmonth.FieldTotalGroup, field.TypeUint64, value)
- }
- if value, ok := usmuo.mutation.AccountBalance(); ok {
- _spec.SetField(usagestatisticmonth.FieldAccountBalance, field.TypeUint64, value)
- }
- if value, ok := usmuo.mutation.AddedAccountBalance(); ok {
- _spec.AddField(usagestatisticmonth.FieldAccountBalance, field.TypeUint64, value)
- }
- if value, ok := usmuo.mutation.ConsumeToken(); ok {
- _spec.SetField(usagestatisticmonth.FieldConsumeToken, field.TypeUint64, value)
- }
- if value, ok := usmuo.mutation.AddedConsumeToken(); ok {
- _spec.AddField(usagestatisticmonth.FieldConsumeToken, field.TypeUint64, value)
- }
- if value, ok := usmuo.mutation.ActiveUser(); ok {
- _spec.SetField(usagestatisticmonth.FieldActiveUser, field.TypeUint64, value)
- }
- if value, ok := usmuo.mutation.AddedActiveUser(); ok {
- _spec.AddField(usagestatisticmonth.FieldActiveUser, field.TypeUint64, value)
- }
- if value, ok := usmuo.mutation.NewUser(); ok {
- _spec.SetField(usagestatisticmonth.FieldNewUser, field.TypeInt64, value)
- }
- if value, ok := usmuo.mutation.AddedNewUser(); ok {
- _spec.AddField(usagestatisticmonth.FieldNewUser, field.TypeInt64, value)
- }
- if value, ok := usmuo.mutation.LabelDist(); ok {
- _spec.SetField(usagestatisticmonth.FieldLabelDist, field.TypeJSON, value)
- }
- if value, ok := usmuo.mutation.AppendedLabelDist(); ok {
- _spec.AddModifier(func(u *sql.UpdateBuilder) {
- sqljson.Append(u, usagestatisticmonth.FieldLabelDist, value)
- })
- }
- _node = &UsageStatisticMonth{config: usmuo.config}
- _spec.Assign = _node.assignValues
- _spec.ScanValues = _node.scanValues
- if err = sqlgraph.UpdateNode(ctx, usmuo.driver, _spec); err != nil {
- if _, ok := err.(*sqlgraph.NotFoundError); ok {
- err = &NotFoundError{usagestatisticmonth.Label}
- } else if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return nil, err
- }
- usmuo.mutation.done = true
- return _node, nil
- }
|