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