// Code generated by ent, DO NOT EDIT. package ent import ( "context" "errors" "fmt" "time" "wechat-api/ent/custom_types" "wechat-api/ent/usagestatistichour" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" ) // UsageStatisticHourCreate is the builder for creating a UsageStatisticHour entity. type UsageStatisticHourCreate struct { config mutation *UsageStatisticHourMutation hooks []Hook conflict []sql.ConflictOption } // SetCreatedAt sets the "created_at" field. func (ushc *UsageStatisticHourCreate) SetCreatedAt(t time.Time) *UsageStatisticHourCreate { ushc.mutation.SetCreatedAt(t) return ushc } // SetNillableCreatedAt sets the "created_at" field if the given value is not nil. func (ushc *UsageStatisticHourCreate) SetNillableCreatedAt(t *time.Time) *UsageStatisticHourCreate { if t != nil { ushc.SetCreatedAt(*t) } return ushc } // SetUpdatedAt sets the "updated_at" field. func (ushc *UsageStatisticHourCreate) SetUpdatedAt(t time.Time) *UsageStatisticHourCreate { ushc.mutation.SetUpdatedAt(t) return ushc } // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. func (ushc *UsageStatisticHourCreate) SetNillableUpdatedAt(t *time.Time) *UsageStatisticHourCreate { if t != nil { ushc.SetUpdatedAt(*t) } return ushc } // SetStatus sets the "status" field. func (ushc *UsageStatisticHourCreate) SetStatus(u uint8) *UsageStatisticHourCreate { ushc.mutation.SetStatus(u) return ushc } // SetNillableStatus sets the "status" field if the given value is not nil. func (ushc *UsageStatisticHourCreate) SetNillableStatus(u *uint8) *UsageStatisticHourCreate { if u != nil { ushc.SetStatus(*u) } return ushc } // SetDeletedAt sets the "deleted_at" field. func (ushc *UsageStatisticHourCreate) SetDeletedAt(t time.Time) *UsageStatisticHourCreate { ushc.mutation.SetDeletedAt(t) return ushc } // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. func (ushc *UsageStatisticHourCreate) SetNillableDeletedAt(t *time.Time) *UsageStatisticHourCreate { if t != nil { ushc.SetDeletedAt(*t) } return ushc } // SetAddtime sets the "addtime" field. func (ushc *UsageStatisticHourCreate) SetAddtime(u uint64) *UsageStatisticHourCreate { ushc.mutation.SetAddtime(u) return ushc } // SetType sets the "type" field. func (ushc *UsageStatisticHourCreate) SetType(i int) *UsageStatisticHourCreate { ushc.mutation.SetType(i) return ushc } // SetBotID sets the "bot_id" field. func (ushc *UsageStatisticHourCreate) SetBotID(s string) *UsageStatisticHourCreate { ushc.mutation.SetBotID(s) return ushc } // SetNillableBotID sets the "bot_id" field if the given value is not nil. func (ushc *UsageStatisticHourCreate) SetNillableBotID(s *string) *UsageStatisticHourCreate { if s != nil { ushc.SetBotID(*s) } return ushc } // SetOrganizationID sets the "organization_id" field. func (ushc *UsageStatisticHourCreate) SetOrganizationID(u uint64) *UsageStatisticHourCreate { ushc.mutation.SetOrganizationID(u) return ushc } // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil. func (ushc *UsageStatisticHourCreate) SetNillableOrganizationID(u *uint64) *UsageStatisticHourCreate { if u != nil { ushc.SetOrganizationID(*u) } return ushc } // SetAiResponse sets the "ai_response" field. func (ushc *UsageStatisticHourCreate) SetAiResponse(u uint64) *UsageStatisticHourCreate { ushc.mutation.SetAiResponse(u) return ushc } // SetSopRun sets the "sop_run" field. func (ushc *UsageStatisticHourCreate) SetSopRun(u uint64) *UsageStatisticHourCreate { ushc.mutation.SetSopRun(u) return ushc } // SetTotalFriend sets the "total_friend" field. func (ushc *UsageStatisticHourCreate) SetTotalFriend(u uint64) *UsageStatisticHourCreate { ushc.mutation.SetTotalFriend(u) return ushc } // SetTotalGroup sets the "total_group" field. func (ushc *UsageStatisticHourCreate) SetTotalGroup(u uint64) *UsageStatisticHourCreate { ushc.mutation.SetTotalGroup(u) return ushc } // SetAccountBalance sets the "account_balance" field. func (ushc *UsageStatisticHourCreate) SetAccountBalance(u uint64) *UsageStatisticHourCreate { ushc.mutation.SetAccountBalance(u) return ushc } // SetConsumeToken sets the "consume_token" field. func (ushc *UsageStatisticHourCreate) SetConsumeToken(u uint64) *UsageStatisticHourCreate { ushc.mutation.SetConsumeToken(u) return ushc } // SetActiveUser sets the "active_user" field. func (ushc *UsageStatisticHourCreate) SetActiveUser(u uint64) *UsageStatisticHourCreate { ushc.mutation.SetActiveUser(u) return ushc } // SetNewUser sets the "new_user" field. func (ushc *UsageStatisticHourCreate) SetNewUser(i int64) *UsageStatisticHourCreate { ushc.mutation.SetNewUser(i) return ushc } // SetLabelDist sets the "label_dist" field. func (ushc *UsageStatisticHourCreate) SetLabelDist(ctd []custom_types.LabelDist) *UsageStatisticHourCreate { ushc.mutation.SetLabelDist(ctd) return ushc } // SetID sets the "id" field. func (ushc *UsageStatisticHourCreate) SetID(u uint64) *UsageStatisticHourCreate { ushc.mutation.SetID(u) return ushc } // Mutation returns the UsageStatisticHourMutation object of the builder. func (ushc *UsageStatisticHourCreate) Mutation() *UsageStatisticHourMutation { return ushc.mutation } // Save creates the UsageStatisticHour in the database. func (ushc *UsageStatisticHourCreate) Save(ctx context.Context) (*UsageStatisticHour, error) { if err := ushc.defaults(); err != nil { return nil, err } return withHooks(ctx, ushc.sqlSave, ushc.mutation, ushc.hooks) } // SaveX calls Save and panics if Save returns an error. func (ushc *UsageStatisticHourCreate) SaveX(ctx context.Context) *UsageStatisticHour { v, err := ushc.Save(ctx) if err != nil { panic(err) } return v } // Exec executes the query. func (ushc *UsageStatisticHourCreate) Exec(ctx context.Context) error { _, err := ushc.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (ushc *UsageStatisticHourCreate) ExecX(ctx context.Context) { if err := ushc.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. func (ushc *UsageStatisticHourCreate) defaults() error { if _, ok := ushc.mutation.CreatedAt(); !ok { if usagestatistichour.DefaultCreatedAt == nil { return fmt.Errorf("ent: uninitialized usagestatistichour.DefaultCreatedAt (forgotten import ent/runtime?)") } v := usagestatistichour.DefaultCreatedAt() ushc.mutation.SetCreatedAt(v) } if _, ok := ushc.mutation.UpdatedAt(); !ok { if usagestatistichour.DefaultUpdatedAt == nil { return fmt.Errorf("ent: uninitialized usagestatistichour.DefaultUpdatedAt (forgotten import ent/runtime?)") } v := usagestatistichour.DefaultUpdatedAt() ushc.mutation.SetUpdatedAt(v) } if _, ok := ushc.mutation.Status(); !ok { v := usagestatistichour.DefaultStatus ushc.mutation.SetStatus(v) } return nil } // check runs all checks and user-defined validators on the builder. func (ushc *UsageStatisticHourCreate) check() error { if _, ok := ushc.mutation.CreatedAt(); !ok { return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "UsageStatisticHour.created_at"`)} } if _, ok := ushc.mutation.UpdatedAt(); !ok { return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "UsageStatisticHour.updated_at"`)} } if _, ok := ushc.mutation.Addtime(); !ok { return &ValidationError{Name: "addtime", err: errors.New(`ent: missing required field "UsageStatisticHour.addtime"`)} } if _, ok := ushc.mutation.GetType(); !ok { return &ValidationError{Name: "type", err: errors.New(`ent: missing required field "UsageStatisticHour.type"`)} } if _, ok := ushc.mutation.AiResponse(); !ok { return &ValidationError{Name: "ai_response", err: errors.New(`ent: missing required field "UsageStatisticHour.ai_response"`)} } if _, ok := ushc.mutation.SopRun(); !ok { return &ValidationError{Name: "sop_run", err: errors.New(`ent: missing required field "UsageStatisticHour.sop_run"`)} } if _, ok := ushc.mutation.TotalFriend(); !ok { return &ValidationError{Name: "total_friend", err: errors.New(`ent: missing required field "UsageStatisticHour.total_friend"`)} } if _, ok := ushc.mutation.TotalGroup(); !ok { return &ValidationError{Name: "total_group", err: errors.New(`ent: missing required field "UsageStatisticHour.total_group"`)} } if _, ok := ushc.mutation.AccountBalance(); !ok { return &ValidationError{Name: "account_balance", err: errors.New(`ent: missing required field "UsageStatisticHour.account_balance"`)} } if _, ok := ushc.mutation.ConsumeToken(); !ok { return &ValidationError{Name: "consume_token", err: errors.New(`ent: missing required field "UsageStatisticHour.consume_token"`)} } if _, ok := ushc.mutation.ActiveUser(); !ok { return &ValidationError{Name: "active_user", err: errors.New(`ent: missing required field "UsageStatisticHour.active_user"`)} } if _, ok := ushc.mutation.NewUser(); !ok { return &ValidationError{Name: "new_user", err: errors.New(`ent: missing required field "UsageStatisticHour.new_user"`)} } if _, ok := ushc.mutation.LabelDist(); !ok { return &ValidationError{Name: "label_dist", err: errors.New(`ent: missing required field "UsageStatisticHour.label_dist"`)} } return nil } func (ushc *UsageStatisticHourCreate) sqlSave(ctx context.Context) (*UsageStatisticHour, error) { if err := ushc.check(); err != nil { return nil, err } _node, _spec := ushc.createSpec() if err := sqlgraph.CreateNode(ctx, ushc.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } return nil, err } if _spec.ID.Value != _node.ID { id := _spec.ID.Value.(int64) _node.ID = uint64(id) } ushc.mutation.id = &_node.ID ushc.mutation.done = true return _node, nil } func (ushc *UsageStatisticHourCreate) createSpec() (*UsageStatisticHour, *sqlgraph.CreateSpec) { var ( _node = &UsageStatisticHour{config: ushc.config} _spec = sqlgraph.NewCreateSpec(usagestatistichour.Table, sqlgraph.NewFieldSpec(usagestatistichour.FieldID, field.TypeUint64)) ) _spec.OnConflict = ushc.conflict if id, ok := ushc.mutation.ID(); ok { _node.ID = id _spec.ID.Value = id } if value, ok := ushc.mutation.CreatedAt(); ok { _spec.SetField(usagestatistichour.FieldCreatedAt, field.TypeTime, value) _node.CreatedAt = value } if value, ok := ushc.mutation.UpdatedAt(); ok { _spec.SetField(usagestatistichour.FieldUpdatedAt, field.TypeTime, value) _node.UpdatedAt = value } if value, ok := ushc.mutation.Status(); ok { _spec.SetField(usagestatistichour.FieldStatus, field.TypeUint8, value) _node.Status = value } if value, ok := ushc.mutation.DeletedAt(); ok { _spec.SetField(usagestatistichour.FieldDeletedAt, field.TypeTime, value) _node.DeletedAt = value } if value, ok := ushc.mutation.Addtime(); ok { _spec.SetField(usagestatistichour.FieldAddtime, field.TypeUint64, value) _node.Addtime = value } if value, ok := ushc.mutation.GetType(); ok { _spec.SetField(usagestatistichour.FieldType, field.TypeInt, value) _node.Type = value } if value, ok := ushc.mutation.BotID(); ok { _spec.SetField(usagestatistichour.FieldBotID, field.TypeString, value) _node.BotID = value } if value, ok := ushc.mutation.OrganizationID(); ok { _spec.SetField(usagestatistichour.FieldOrganizationID, field.TypeUint64, value) _node.OrganizationID = value } if value, ok := ushc.mutation.AiResponse(); ok { _spec.SetField(usagestatistichour.FieldAiResponse, field.TypeUint64, value) _node.AiResponse = value } if value, ok := ushc.mutation.SopRun(); ok { _spec.SetField(usagestatistichour.FieldSopRun, field.TypeUint64, value) _node.SopRun = value } if value, ok := ushc.mutation.TotalFriend(); ok { _spec.SetField(usagestatistichour.FieldTotalFriend, field.TypeUint64, value) _node.TotalFriend = value } if value, ok := ushc.mutation.TotalGroup(); ok { _spec.SetField(usagestatistichour.FieldTotalGroup, field.TypeUint64, value) _node.TotalGroup = value } if value, ok := ushc.mutation.AccountBalance(); ok { _spec.SetField(usagestatistichour.FieldAccountBalance, field.TypeUint64, value) _node.AccountBalance = value } if value, ok := ushc.mutation.ConsumeToken(); ok { _spec.SetField(usagestatistichour.FieldConsumeToken, field.TypeUint64, value) _node.ConsumeToken = value } if value, ok := ushc.mutation.ActiveUser(); ok { _spec.SetField(usagestatistichour.FieldActiveUser, field.TypeUint64, value) _node.ActiveUser = value } if value, ok := ushc.mutation.NewUser(); ok { _spec.SetField(usagestatistichour.FieldNewUser, field.TypeInt64, value) _node.NewUser = value } if value, ok := ushc.mutation.LabelDist(); ok { _spec.SetField(usagestatistichour.FieldLabelDist, field.TypeJSON, value) _node.LabelDist = value } return _node, _spec } // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause // of the `INSERT` statement. For example: // // client.UsageStatisticHour.Create(). // SetCreatedAt(v). // OnConflict( // // Update the row with the new values // // the was proposed for insertion. // sql.ResolveWithNewValues(), // ). // // Override some of the fields with custom // // update values. // Update(func(u *ent.UsageStatisticHourUpsert) { // SetCreatedAt(v+v). // }). // Exec(ctx) func (ushc *UsageStatisticHourCreate) OnConflict(opts ...sql.ConflictOption) *UsageStatisticHourUpsertOne { ushc.conflict = opts return &UsageStatisticHourUpsertOne{ create: ushc, } } // OnConflictColumns calls `OnConflict` and configures the columns // as conflict target. Using this option is equivalent to using: // // client.UsageStatisticHour.Create(). // OnConflict(sql.ConflictColumns(columns...)). // Exec(ctx) func (ushc *UsageStatisticHourCreate) OnConflictColumns(columns ...string) *UsageStatisticHourUpsertOne { ushc.conflict = append(ushc.conflict, sql.ConflictColumns(columns...)) return &UsageStatisticHourUpsertOne{ create: ushc, } } type ( // UsageStatisticHourUpsertOne is the builder for "upsert"-ing // one UsageStatisticHour node. UsageStatisticHourUpsertOne struct { create *UsageStatisticHourCreate } // UsageStatisticHourUpsert is the "OnConflict" setter. UsageStatisticHourUpsert struct { *sql.UpdateSet } ) // SetUpdatedAt sets the "updated_at" field. func (u *UsageStatisticHourUpsert) SetUpdatedAt(v time.Time) *UsageStatisticHourUpsert { u.Set(usagestatistichour.FieldUpdatedAt, v) return u } // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. func (u *UsageStatisticHourUpsert) UpdateUpdatedAt() *UsageStatisticHourUpsert { u.SetExcluded(usagestatistichour.FieldUpdatedAt) return u } // SetStatus sets the "status" field. func (u *UsageStatisticHourUpsert) SetStatus(v uint8) *UsageStatisticHourUpsert { u.Set(usagestatistichour.FieldStatus, v) return u } // UpdateStatus sets the "status" field to the value that was provided on create. func (u *UsageStatisticHourUpsert) UpdateStatus() *UsageStatisticHourUpsert { u.SetExcluded(usagestatistichour.FieldStatus) return u } // AddStatus adds v to the "status" field. func (u *UsageStatisticHourUpsert) AddStatus(v uint8) *UsageStatisticHourUpsert { u.Add(usagestatistichour.FieldStatus, v) return u } // ClearStatus clears the value of the "status" field. func (u *UsageStatisticHourUpsert) ClearStatus() *UsageStatisticHourUpsert { u.SetNull(usagestatistichour.FieldStatus) return u } // SetDeletedAt sets the "deleted_at" field. func (u *UsageStatisticHourUpsert) SetDeletedAt(v time.Time) *UsageStatisticHourUpsert { u.Set(usagestatistichour.FieldDeletedAt, v) return u } // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. func (u *UsageStatisticHourUpsert) UpdateDeletedAt() *UsageStatisticHourUpsert { u.SetExcluded(usagestatistichour.FieldDeletedAt) return u } // ClearDeletedAt clears the value of the "deleted_at" field. func (u *UsageStatisticHourUpsert) ClearDeletedAt() *UsageStatisticHourUpsert { u.SetNull(usagestatistichour.FieldDeletedAt) return u } // SetAddtime sets the "addtime" field. func (u *UsageStatisticHourUpsert) SetAddtime(v uint64) *UsageStatisticHourUpsert { u.Set(usagestatistichour.FieldAddtime, v) return u } // UpdateAddtime sets the "addtime" field to the value that was provided on create. func (u *UsageStatisticHourUpsert) UpdateAddtime() *UsageStatisticHourUpsert { u.SetExcluded(usagestatistichour.FieldAddtime) return u } // AddAddtime adds v to the "addtime" field. func (u *UsageStatisticHourUpsert) AddAddtime(v uint64) *UsageStatisticHourUpsert { u.Add(usagestatistichour.FieldAddtime, v) return u } // SetType sets the "type" field. func (u *UsageStatisticHourUpsert) SetType(v int) *UsageStatisticHourUpsert { u.Set(usagestatistichour.FieldType, v) return u } // UpdateType sets the "type" field to the value that was provided on create. func (u *UsageStatisticHourUpsert) UpdateType() *UsageStatisticHourUpsert { u.SetExcluded(usagestatistichour.FieldType) return u } // AddType adds v to the "type" field. func (u *UsageStatisticHourUpsert) AddType(v int) *UsageStatisticHourUpsert { u.Add(usagestatistichour.FieldType, v) return u } // SetBotID sets the "bot_id" field. func (u *UsageStatisticHourUpsert) SetBotID(v string) *UsageStatisticHourUpsert { u.Set(usagestatistichour.FieldBotID, v) return u } // UpdateBotID sets the "bot_id" field to the value that was provided on create. func (u *UsageStatisticHourUpsert) UpdateBotID() *UsageStatisticHourUpsert { u.SetExcluded(usagestatistichour.FieldBotID) return u } // ClearBotID clears the value of the "bot_id" field. func (u *UsageStatisticHourUpsert) ClearBotID() *UsageStatisticHourUpsert { u.SetNull(usagestatistichour.FieldBotID) return u } // SetOrganizationID sets the "organization_id" field. func (u *UsageStatisticHourUpsert) SetOrganizationID(v uint64) *UsageStatisticHourUpsert { u.Set(usagestatistichour.FieldOrganizationID, v) return u } // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create. func (u *UsageStatisticHourUpsert) UpdateOrganizationID() *UsageStatisticHourUpsert { u.SetExcluded(usagestatistichour.FieldOrganizationID) return u } // AddOrganizationID adds v to the "organization_id" field. func (u *UsageStatisticHourUpsert) AddOrganizationID(v uint64) *UsageStatisticHourUpsert { u.Add(usagestatistichour.FieldOrganizationID, v) return u } // ClearOrganizationID clears the value of the "organization_id" field. func (u *UsageStatisticHourUpsert) ClearOrganizationID() *UsageStatisticHourUpsert { u.SetNull(usagestatistichour.FieldOrganizationID) return u } // SetAiResponse sets the "ai_response" field. func (u *UsageStatisticHourUpsert) SetAiResponse(v uint64) *UsageStatisticHourUpsert { u.Set(usagestatistichour.FieldAiResponse, v) return u } // UpdateAiResponse sets the "ai_response" field to the value that was provided on create. func (u *UsageStatisticHourUpsert) UpdateAiResponse() *UsageStatisticHourUpsert { u.SetExcluded(usagestatistichour.FieldAiResponse) return u } // AddAiResponse adds v to the "ai_response" field. func (u *UsageStatisticHourUpsert) AddAiResponse(v uint64) *UsageStatisticHourUpsert { u.Add(usagestatistichour.FieldAiResponse, v) return u } // SetSopRun sets the "sop_run" field. func (u *UsageStatisticHourUpsert) SetSopRun(v uint64) *UsageStatisticHourUpsert { u.Set(usagestatistichour.FieldSopRun, v) return u } // UpdateSopRun sets the "sop_run" field to the value that was provided on create. func (u *UsageStatisticHourUpsert) UpdateSopRun() *UsageStatisticHourUpsert { u.SetExcluded(usagestatistichour.FieldSopRun) return u } // AddSopRun adds v to the "sop_run" field. func (u *UsageStatisticHourUpsert) AddSopRun(v uint64) *UsageStatisticHourUpsert { u.Add(usagestatistichour.FieldSopRun, v) return u } // SetTotalFriend sets the "total_friend" field. func (u *UsageStatisticHourUpsert) SetTotalFriend(v uint64) *UsageStatisticHourUpsert { u.Set(usagestatistichour.FieldTotalFriend, v) return u } // UpdateTotalFriend sets the "total_friend" field to the value that was provided on create. func (u *UsageStatisticHourUpsert) UpdateTotalFriend() *UsageStatisticHourUpsert { u.SetExcluded(usagestatistichour.FieldTotalFriend) return u } // AddTotalFriend adds v to the "total_friend" field. func (u *UsageStatisticHourUpsert) AddTotalFriend(v uint64) *UsageStatisticHourUpsert { u.Add(usagestatistichour.FieldTotalFriend, v) return u } // SetTotalGroup sets the "total_group" field. func (u *UsageStatisticHourUpsert) SetTotalGroup(v uint64) *UsageStatisticHourUpsert { u.Set(usagestatistichour.FieldTotalGroup, v) return u } // UpdateTotalGroup sets the "total_group" field to the value that was provided on create. func (u *UsageStatisticHourUpsert) UpdateTotalGroup() *UsageStatisticHourUpsert { u.SetExcluded(usagestatistichour.FieldTotalGroup) return u } // AddTotalGroup adds v to the "total_group" field. func (u *UsageStatisticHourUpsert) AddTotalGroup(v uint64) *UsageStatisticHourUpsert { u.Add(usagestatistichour.FieldTotalGroup, v) return u } // SetAccountBalance sets the "account_balance" field. func (u *UsageStatisticHourUpsert) SetAccountBalance(v uint64) *UsageStatisticHourUpsert { u.Set(usagestatistichour.FieldAccountBalance, v) return u } // UpdateAccountBalance sets the "account_balance" field to the value that was provided on create. func (u *UsageStatisticHourUpsert) UpdateAccountBalance() *UsageStatisticHourUpsert { u.SetExcluded(usagestatistichour.FieldAccountBalance) return u } // AddAccountBalance adds v to the "account_balance" field. func (u *UsageStatisticHourUpsert) AddAccountBalance(v uint64) *UsageStatisticHourUpsert { u.Add(usagestatistichour.FieldAccountBalance, v) return u } // SetConsumeToken sets the "consume_token" field. func (u *UsageStatisticHourUpsert) SetConsumeToken(v uint64) *UsageStatisticHourUpsert { u.Set(usagestatistichour.FieldConsumeToken, v) return u } // UpdateConsumeToken sets the "consume_token" field to the value that was provided on create. func (u *UsageStatisticHourUpsert) UpdateConsumeToken() *UsageStatisticHourUpsert { u.SetExcluded(usagestatistichour.FieldConsumeToken) return u } // AddConsumeToken adds v to the "consume_token" field. func (u *UsageStatisticHourUpsert) AddConsumeToken(v uint64) *UsageStatisticHourUpsert { u.Add(usagestatistichour.FieldConsumeToken, v) return u } // SetActiveUser sets the "active_user" field. func (u *UsageStatisticHourUpsert) SetActiveUser(v uint64) *UsageStatisticHourUpsert { u.Set(usagestatistichour.FieldActiveUser, v) return u } // UpdateActiveUser sets the "active_user" field to the value that was provided on create. func (u *UsageStatisticHourUpsert) UpdateActiveUser() *UsageStatisticHourUpsert { u.SetExcluded(usagestatistichour.FieldActiveUser) return u } // AddActiveUser adds v to the "active_user" field. func (u *UsageStatisticHourUpsert) AddActiveUser(v uint64) *UsageStatisticHourUpsert { u.Add(usagestatistichour.FieldActiveUser, v) return u } // SetNewUser sets the "new_user" field. func (u *UsageStatisticHourUpsert) SetNewUser(v int64) *UsageStatisticHourUpsert { u.Set(usagestatistichour.FieldNewUser, v) return u } // UpdateNewUser sets the "new_user" field to the value that was provided on create. func (u *UsageStatisticHourUpsert) UpdateNewUser() *UsageStatisticHourUpsert { u.SetExcluded(usagestatistichour.FieldNewUser) return u } // AddNewUser adds v to the "new_user" field. func (u *UsageStatisticHourUpsert) AddNewUser(v int64) *UsageStatisticHourUpsert { u.Add(usagestatistichour.FieldNewUser, v) return u } // SetLabelDist sets the "label_dist" field. func (u *UsageStatisticHourUpsert) SetLabelDist(v []custom_types.LabelDist) *UsageStatisticHourUpsert { u.Set(usagestatistichour.FieldLabelDist, v) return u } // UpdateLabelDist sets the "label_dist" field to the value that was provided on create. func (u *UsageStatisticHourUpsert) UpdateLabelDist() *UsageStatisticHourUpsert { u.SetExcluded(usagestatistichour.FieldLabelDist) return u } // UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field. // Using this option is equivalent to using: // // client.UsageStatisticHour.Create(). // OnConflict( // sql.ResolveWithNewValues(), // sql.ResolveWith(func(u *sql.UpdateSet) { // u.SetIgnore(usagestatistichour.FieldID) // }), // ). // Exec(ctx) func (u *UsageStatisticHourUpsertOne) UpdateNewValues() *UsageStatisticHourUpsertOne { u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { if _, exists := u.create.mutation.ID(); exists { s.SetIgnore(usagestatistichour.FieldID) } if _, exists := u.create.mutation.CreatedAt(); exists { s.SetIgnore(usagestatistichour.FieldCreatedAt) } })) return u } // Ignore sets each column to itself in case of conflict. // Using this option is equivalent to using: // // client.UsageStatisticHour.Create(). // OnConflict(sql.ResolveWithIgnore()). // Exec(ctx) func (u *UsageStatisticHourUpsertOne) Ignore() *UsageStatisticHourUpsertOne { u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) return u } // DoNothing configures the conflict_action to `DO NOTHING`. // Supported only by SQLite and PostgreSQL. func (u *UsageStatisticHourUpsertOne) DoNothing() *UsageStatisticHourUpsertOne { u.create.conflict = append(u.create.conflict, sql.DoNothing()) return u } // Update allows overriding fields `UPDATE` values. See the UsageStatisticHourCreate.OnConflict // documentation for more info. func (u *UsageStatisticHourUpsertOne) Update(set func(*UsageStatisticHourUpsert)) *UsageStatisticHourUpsertOne { u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { set(&UsageStatisticHourUpsert{UpdateSet: update}) })) return u } // SetUpdatedAt sets the "updated_at" field. func (u *UsageStatisticHourUpsertOne) SetUpdatedAt(v time.Time) *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetUpdatedAt(v) }) } // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. func (u *UsageStatisticHourUpsertOne) UpdateUpdatedAt() *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateUpdatedAt() }) } // SetStatus sets the "status" field. func (u *UsageStatisticHourUpsertOne) SetStatus(v uint8) *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetStatus(v) }) } // AddStatus adds v to the "status" field. func (u *UsageStatisticHourUpsertOne) AddStatus(v uint8) *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.AddStatus(v) }) } // UpdateStatus sets the "status" field to the value that was provided on create. func (u *UsageStatisticHourUpsertOne) UpdateStatus() *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateStatus() }) } // ClearStatus clears the value of the "status" field. func (u *UsageStatisticHourUpsertOne) ClearStatus() *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.ClearStatus() }) } // SetDeletedAt sets the "deleted_at" field. func (u *UsageStatisticHourUpsertOne) SetDeletedAt(v time.Time) *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetDeletedAt(v) }) } // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. func (u *UsageStatisticHourUpsertOne) UpdateDeletedAt() *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateDeletedAt() }) } // ClearDeletedAt clears the value of the "deleted_at" field. func (u *UsageStatisticHourUpsertOne) ClearDeletedAt() *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.ClearDeletedAt() }) } // SetAddtime sets the "addtime" field. func (u *UsageStatisticHourUpsertOne) SetAddtime(v uint64) *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetAddtime(v) }) } // AddAddtime adds v to the "addtime" field. func (u *UsageStatisticHourUpsertOne) AddAddtime(v uint64) *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.AddAddtime(v) }) } // UpdateAddtime sets the "addtime" field to the value that was provided on create. func (u *UsageStatisticHourUpsertOne) UpdateAddtime() *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateAddtime() }) } // SetType sets the "type" field. func (u *UsageStatisticHourUpsertOne) SetType(v int) *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetType(v) }) } // AddType adds v to the "type" field. func (u *UsageStatisticHourUpsertOne) AddType(v int) *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.AddType(v) }) } // UpdateType sets the "type" field to the value that was provided on create. func (u *UsageStatisticHourUpsertOne) UpdateType() *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateType() }) } // SetBotID sets the "bot_id" field. func (u *UsageStatisticHourUpsertOne) SetBotID(v string) *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetBotID(v) }) } // UpdateBotID sets the "bot_id" field to the value that was provided on create. func (u *UsageStatisticHourUpsertOne) UpdateBotID() *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateBotID() }) } // ClearBotID clears the value of the "bot_id" field. func (u *UsageStatisticHourUpsertOne) ClearBotID() *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.ClearBotID() }) } // SetOrganizationID sets the "organization_id" field. func (u *UsageStatisticHourUpsertOne) SetOrganizationID(v uint64) *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetOrganizationID(v) }) } // AddOrganizationID adds v to the "organization_id" field. func (u *UsageStatisticHourUpsertOne) AddOrganizationID(v uint64) *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.AddOrganizationID(v) }) } // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create. func (u *UsageStatisticHourUpsertOne) UpdateOrganizationID() *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateOrganizationID() }) } // ClearOrganizationID clears the value of the "organization_id" field. func (u *UsageStatisticHourUpsertOne) ClearOrganizationID() *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.ClearOrganizationID() }) } // SetAiResponse sets the "ai_response" field. func (u *UsageStatisticHourUpsertOne) SetAiResponse(v uint64) *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetAiResponse(v) }) } // AddAiResponse adds v to the "ai_response" field. func (u *UsageStatisticHourUpsertOne) AddAiResponse(v uint64) *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.AddAiResponse(v) }) } // UpdateAiResponse sets the "ai_response" field to the value that was provided on create. func (u *UsageStatisticHourUpsertOne) UpdateAiResponse() *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateAiResponse() }) } // SetSopRun sets the "sop_run" field. func (u *UsageStatisticHourUpsertOne) SetSopRun(v uint64) *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetSopRun(v) }) } // AddSopRun adds v to the "sop_run" field. func (u *UsageStatisticHourUpsertOne) AddSopRun(v uint64) *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.AddSopRun(v) }) } // UpdateSopRun sets the "sop_run" field to the value that was provided on create. func (u *UsageStatisticHourUpsertOne) UpdateSopRun() *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateSopRun() }) } // SetTotalFriend sets the "total_friend" field. func (u *UsageStatisticHourUpsertOne) SetTotalFriend(v uint64) *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetTotalFriend(v) }) } // AddTotalFriend adds v to the "total_friend" field. func (u *UsageStatisticHourUpsertOne) AddTotalFriend(v uint64) *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.AddTotalFriend(v) }) } // UpdateTotalFriend sets the "total_friend" field to the value that was provided on create. func (u *UsageStatisticHourUpsertOne) UpdateTotalFriend() *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateTotalFriend() }) } // SetTotalGroup sets the "total_group" field. func (u *UsageStatisticHourUpsertOne) SetTotalGroup(v uint64) *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetTotalGroup(v) }) } // AddTotalGroup adds v to the "total_group" field. func (u *UsageStatisticHourUpsertOne) AddTotalGroup(v uint64) *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.AddTotalGroup(v) }) } // UpdateTotalGroup sets the "total_group" field to the value that was provided on create. func (u *UsageStatisticHourUpsertOne) UpdateTotalGroup() *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateTotalGroup() }) } // SetAccountBalance sets the "account_balance" field. func (u *UsageStatisticHourUpsertOne) SetAccountBalance(v uint64) *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetAccountBalance(v) }) } // AddAccountBalance adds v to the "account_balance" field. func (u *UsageStatisticHourUpsertOne) AddAccountBalance(v uint64) *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.AddAccountBalance(v) }) } // UpdateAccountBalance sets the "account_balance" field to the value that was provided on create. func (u *UsageStatisticHourUpsertOne) UpdateAccountBalance() *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateAccountBalance() }) } // SetConsumeToken sets the "consume_token" field. func (u *UsageStatisticHourUpsertOne) SetConsumeToken(v uint64) *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetConsumeToken(v) }) } // AddConsumeToken adds v to the "consume_token" field. func (u *UsageStatisticHourUpsertOne) AddConsumeToken(v uint64) *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.AddConsumeToken(v) }) } // UpdateConsumeToken sets the "consume_token" field to the value that was provided on create. func (u *UsageStatisticHourUpsertOne) UpdateConsumeToken() *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateConsumeToken() }) } // SetActiveUser sets the "active_user" field. func (u *UsageStatisticHourUpsertOne) SetActiveUser(v uint64) *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetActiveUser(v) }) } // AddActiveUser adds v to the "active_user" field. func (u *UsageStatisticHourUpsertOne) AddActiveUser(v uint64) *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.AddActiveUser(v) }) } // UpdateActiveUser sets the "active_user" field to the value that was provided on create. func (u *UsageStatisticHourUpsertOne) UpdateActiveUser() *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateActiveUser() }) } // SetNewUser sets the "new_user" field. func (u *UsageStatisticHourUpsertOne) SetNewUser(v int64) *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetNewUser(v) }) } // AddNewUser adds v to the "new_user" field. func (u *UsageStatisticHourUpsertOne) AddNewUser(v int64) *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.AddNewUser(v) }) } // UpdateNewUser sets the "new_user" field to the value that was provided on create. func (u *UsageStatisticHourUpsertOne) UpdateNewUser() *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateNewUser() }) } // SetLabelDist sets the "label_dist" field. func (u *UsageStatisticHourUpsertOne) SetLabelDist(v []custom_types.LabelDist) *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetLabelDist(v) }) } // UpdateLabelDist sets the "label_dist" field to the value that was provided on create. func (u *UsageStatisticHourUpsertOne) UpdateLabelDist() *UsageStatisticHourUpsertOne { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateLabelDist() }) } // Exec executes the query. func (u *UsageStatisticHourUpsertOne) Exec(ctx context.Context) error { if len(u.create.conflict) == 0 { return errors.New("ent: missing options for UsageStatisticHourCreate.OnConflict") } return u.create.Exec(ctx) } // ExecX is like Exec, but panics if an error occurs. func (u *UsageStatisticHourUpsertOne) ExecX(ctx context.Context) { if err := u.create.Exec(ctx); err != nil { panic(err) } } // Exec executes the UPSERT query and returns the inserted/updated ID. func (u *UsageStatisticHourUpsertOne) ID(ctx context.Context) (id uint64, err error) { node, err := u.create.Save(ctx) if err != nil { return id, err } return node.ID, nil } // IDX is like ID, but panics if an error occurs. func (u *UsageStatisticHourUpsertOne) IDX(ctx context.Context) uint64 { id, err := u.ID(ctx) if err != nil { panic(err) } return id } // UsageStatisticHourCreateBulk is the builder for creating many UsageStatisticHour entities in bulk. type UsageStatisticHourCreateBulk struct { config err error builders []*UsageStatisticHourCreate conflict []sql.ConflictOption } // Save creates the UsageStatisticHour entities in the database. func (ushcb *UsageStatisticHourCreateBulk) Save(ctx context.Context) ([]*UsageStatisticHour, error) { if ushcb.err != nil { return nil, ushcb.err } specs := make([]*sqlgraph.CreateSpec, len(ushcb.builders)) nodes := make([]*UsageStatisticHour, len(ushcb.builders)) mutators := make([]Mutator, len(ushcb.builders)) for i := range ushcb.builders { func(i int, root context.Context) { builder := ushcb.builders[i] builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*UsageStatisticHourMutation) if !ok { return nil, fmt.Errorf("unexpected mutation type %T", m) } if err := builder.check(); err != nil { return nil, err } builder.mutation = mutation var err error nodes[i], specs[i] = builder.createSpec() if i < len(mutators)-1 { _, err = mutators[i+1].Mutate(root, ushcb.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} spec.OnConflict = ushcb.conflict // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, ushcb.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } } } if err != nil { return nil, err } mutation.id = &nodes[i].ID if specs[i].ID.Value != nil && nodes[i].ID == 0 { id := specs[i].ID.Value.(int64) nodes[i].ID = uint64(id) } mutation.done = true return nodes[i], nil }) for i := len(builder.hooks) - 1; i >= 0; i-- { mut = builder.hooks[i](mut) } mutators[i] = mut }(i, ctx) } if len(mutators) > 0 { if _, err := mutators[0].Mutate(ctx, ushcb.builders[0].mutation); err != nil { return nil, err } } return nodes, nil } // SaveX is like Save, but panics if an error occurs. func (ushcb *UsageStatisticHourCreateBulk) SaveX(ctx context.Context) []*UsageStatisticHour { v, err := ushcb.Save(ctx) if err != nil { panic(err) } return v } // Exec executes the query. func (ushcb *UsageStatisticHourCreateBulk) Exec(ctx context.Context) error { _, err := ushcb.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (ushcb *UsageStatisticHourCreateBulk) ExecX(ctx context.Context) { if err := ushcb.Exec(ctx); err != nil { panic(err) } } // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause // of the `INSERT` statement. For example: // // client.UsageStatisticHour.CreateBulk(builders...). // OnConflict( // // Update the row with the new values // // the was proposed for insertion. // sql.ResolveWithNewValues(), // ). // // Override some of the fields with custom // // update values. // Update(func(u *ent.UsageStatisticHourUpsert) { // SetCreatedAt(v+v). // }). // Exec(ctx) func (ushcb *UsageStatisticHourCreateBulk) OnConflict(opts ...sql.ConflictOption) *UsageStatisticHourUpsertBulk { ushcb.conflict = opts return &UsageStatisticHourUpsertBulk{ create: ushcb, } } // OnConflictColumns calls `OnConflict` and configures the columns // as conflict target. Using this option is equivalent to using: // // client.UsageStatisticHour.Create(). // OnConflict(sql.ConflictColumns(columns...)). // Exec(ctx) func (ushcb *UsageStatisticHourCreateBulk) OnConflictColumns(columns ...string) *UsageStatisticHourUpsertBulk { ushcb.conflict = append(ushcb.conflict, sql.ConflictColumns(columns...)) return &UsageStatisticHourUpsertBulk{ create: ushcb, } } // UsageStatisticHourUpsertBulk is the builder for "upsert"-ing // a bulk of UsageStatisticHour nodes. type UsageStatisticHourUpsertBulk struct { create *UsageStatisticHourCreateBulk } // UpdateNewValues updates the mutable fields using the new values that // were set on create. Using this option is equivalent to using: // // client.UsageStatisticHour.Create(). // OnConflict( // sql.ResolveWithNewValues(), // sql.ResolveWith(func(u *sql.UpdateSet) { // u.SetIgnore(usagestatistichour.FieldID) // }), // ). // Exec(ctx) func (u *UsageStatisticHourUpsertBulk) UpdateNewValues() *UsageStatisticHourUpsertBulk { u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues()) u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) { for _, b := range u.create.builders { if _, exists := b.mutation.ID(); exists { s.SetIgnore(usagestatistichour.FieldID) } if _, exists := b.mutation.CreatedAt(); exists { s.SetIgnore(usagestatistichour.FieldCreatedAt) } } })) return u } // Ignore sets each column to itself in case of conflict. // Using this option is equivalent to using: // // client.UsageStatisticHour.Create(). // OnConflict(sql.ResolveWithIgnore()). // Exec(ctx) func (u *UsageStatisticHourUpsertBulk) Ignore() *UsageStatisticHourUpsertBulk { u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore()) return u } // DoNothing configures the conflict_action to `DO NOTHING`. // Supported only by SQLite and PostgreSQL. func (u *UsageStatisticHourUpsertBulk) DoNothing() *UsageStatisticHourUpsertBulk { u.create.conflict = append(u.create.conflict, sql.DoNothing()) return u } // Update allows overriding fields `UPDATE` values. See the UsageStatisticHourCreateBulk.OnConflict // documentation for more info. func (u *UsageStatisticHourUpsertBulk) Update(set func(*UsageStatisticHourUpsert)) *UsageStatisticHourUpsertBulk { u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { set(&UsageStatisticHourUpsert{UpdateSet: update}) })) return u } // SetUpdatedAt sets the "updated_at" field. func (u *UsageStatisticHourUpsertBulk) SetUpdatedAt(v time.Time) *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetUpdatedAt(v) }) } // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. func (u *UsageStatisticHourUpsertBulk) UpdateUpdatedAt() *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateUpdatedAt() }) } // SetStatus sets the "status" field. func (u *UsageStatisticHourUpsertBulk) SetStatus(v uint8) *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetStatus(v) }) } // AddStatus adds v to the "status" field. func (u *UsageStatisticHourUpsertBulk) AddStatus(v uint8) *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.AddStatus(v) }) } // UpdateStatus sets the "status" field to the value that was provided on create. func (u *UsageStatisticHourUpsertBulk) UpdateStatus() *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateStatus() }) } // ClearStatus clears the value of the "status" field. func (u *UsageStatisticHourUpsertBulk) ClearStatus() *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.ClearStatus() }) } // SetDeletedAt sets the "deleted_at" field. func (u *UsageStatisticHourUpsertBulk) SetDeletedAt(v time.Time) *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetDeletedAt(v) }) } // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. func (u *UsageStatisticHourUpsertBulk) UpdateDeletedAt() *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateDeletedAt() }) } // ClearDeletedAt clears the value of the "deleted_at" field. func (u *UsageStatisticHourUpsertBulk) ClearDeletedAt() *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.ClearDeletedAt() }) } // SetAddtime sets the "addtime" field. func (u *UsageStatisticHourUpsertBulk) SetAddtime(v uint64) *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetAddtime(v) }) } // AddAddtime adds v to the "addtime" field. func (u *UsageStatisticHourUpsertBulk) AddAddtime(v uint64) *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.AddAddtime(v) }) } // UpdateAddtime sets the "addtime" field to the value that was provided on create. func (u *UsageStatisticHourUpsertBulk) UpdateAddtime() *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateAddtime() }) } // SetType sets the "type" field. func (u *UsageStatisticHourUpsertBulk) SetType(v int) *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetType(v) }) } // AddType adds v to the "type" field. func (u *UsageStatisticHourUpsertBulk) AddType(v int) *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.AddType(v) }) } // UpdateType sets the "type" field to the value that was provided on create. func (u *UsageStatisticHourUpsertBulk) UpdateType() *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateType() }) } // SetBotID sets the "bot_id" field. func (u *UsageStatisticHourUpsertBulk) SetBotID(v string) *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetBotID(v) }) } // UpdateBotID sets the "bot_id" field to the value that was provided on create. func (u *UsageStatisticHourUpsertBulk) UpdateBotID() *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateBotID() }) } // ClearBotID clears the value of the "bot_id" field. func (u *UsageStatisticHourUpsertBulk) ClearBotID() *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.ClearBotID() }) } // SetOrganizationID sets the "organization_id" field. func (u *UsageStatisticHourUpsertBulk) SetOrganizationID(v uint64) *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetOrganizationID(v) }) } // AddOrganizationID adds v to the "organization_id" field. func (u *UsageStatisticHourUpsertBulk) AddOrganizationID(v uint64) *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.AddOrganizationID(v) }) } // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create. func (u *UsageStatisticHourUpsertBulk) UpdateOrganizationID() *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateOrganizationID() }) } // ClearOrganizationID clears the value of the "organization_id" field. func (u *UsageStatisticHourUpsertBulk) ClearOrganizationID() *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.ClearOrganizationID() }) } // SetAiResponse sets the "ai_response" field. func (u *UsageStatisticHourUpsertBulk) SetAiResponse(v uint64) *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetAiResponse(v) }) } // AddAiResponse adds v to the "ai_response" field. func (u *UsageStatisticHourUpsertBulk) AddAiResponse(v uint64) *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.AddAiResponse(v) }) } // UpdateAiResponse sets the "ai_response" field to the value that was provided on create. func (u *UsageStatisticHourUpsertBulk) UpdateAiResponse() *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateAiResponse() }) } // SetSopRun sets the "sop_run" field. func (u *UsageStatisticHourUpsertBulk) SetSopRun(v uint64) *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetSopRun(v) }) } // AddSopRun adds v to the "sop_run" field. func (u *UsageStatisticHourUpsertBulk) AddSopRun(v uint64) *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.AddSopRun(v) }) } // UpdateSopRun sets the "sop_run" field to the value that was provided on create. func (u *UsageStatisticHourUpsertBulk) UpdateSopRun() *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateSopRun() }) } // SetTotalFriend sets the "total_friend" field. func (u *UsageStatisticHourUpsertBulk) SetTotalFriend(v uint64) *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetTotalFriend(v) }) } // AddTotalFriend adds v to the "total_friend" field. func (u *UsageStatisticHourUpsertBulk) AddTotalFriend(v uint64) *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.AddTotalFriend(v) }) } // UpdateTotalFriend sets the "total_friend" field to the value that was provided on create. func (u *UsageStatisticHourUpsertBulk) UpdateTotalFriend() *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateTotalFriend() }) } // SetTotalGroup sets the "total_group" field. func (u *UsageStatisticHourUpsertBulk) SetTotalGroup(v uint64) *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetTotalGroup(v) }) } // AddTotalGroup adds v to the "total_group" field. func (u *UsageStatisticHourUpsertBulk) AddTotalGroup(v uint64) *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.AddTotalGroup(v) }) } // UpdateTotalGroup sets the "total_group" field to the value that was provided on create. func (u *UsageStatisticHourUpsertBulk) UpdateTotalGroup() *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateTotalGroup() }) } // SetAccountBalance sets the "account_balance" field. func (u *UsageStatisticHourUpsertBulk) SetAccountBalance(v uint64) *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetAccountBalance(v) }) } // AddAccountBalance adds v to the "account_balance" field. func (u *UsageStatisticHourUpsertBulk) AddAccountBalance(v uint64) *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.AddAccountBalance(v) }) } // UpdateAccountBalance sets the "account_balance" field to the value that was provided on create. func (u *UsageStatisticHourUpsertBulk) UpdateAccountBalance() *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateAccountBalance() }) } // SetConsumeToken sets the "consume_token" field. func (u *UsageStatisticHourUpsertBulk) SetConsumeToken(v uint64) *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetConsumeToken(v) }) } // AddConsumeToken adds v to the "consume_token" field. func (u *UsageStatisticHourUpsertBulk) AddConsumeToken(v uint64) *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.AddConsumeToken(v) }) } // UpdateConsumeToken sets the "consume_token" field to the value that was provided on create. func (u *UsageStatisticHourUpsertBulk) UpdateConsumeToken() *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateConsumeToken() }) } // SetActiveUser sets the "active_user" field. func (u *UsageStatisticHourUpsertBulk) SetActiveUser(v uint64) *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetActiveUser(v) }) } // AddActiveUser adds v to the "active_user" field. func (u *UsageStatisticHourUpsertBulk) AddActiveUser(v uint64) *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.AddActiveUser(v) }) } // UpdateActiveUser sets the "active_user" field to the value that was provided on create. func (u *UsageStatisticHourUpsertBulk) UpdateActiveUser() *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateActiveUser() }) } // SetNewUser sets the "new_user" field. func (u *UsageStatisticHourUpsertBulk) SetNewUser(v int64) *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetNewUser(v) }) } // AddNewUser adds v to the "new_user" field. func (u *UsageStatisticHourUpsertBulk) AddNewUser(v int64) *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.AddNewUser(v) }) } // UpdateNewUser sets the "new_user" field to the value that was provided on create. func (u *UsageStatisticHourUpsertBulk) UpdateNewUser() *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateNewUser() }) } // SetLabelDist sets the "label_dist" field. func (u *UsageStatisticHourUpsertBulk) SetLabelDist(v []custom_types.LabelDist) *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.SetLabelDist(v) }) } // UpdateLabelDist sets the "label_dist" field to the value that was provided on create. func (u *UsageStatisticHourUpsertBulk) UpdateLabelDist() *UsageStatisticHourUpsertBulk { return u.Update(func(s *UsageStatisticHourUpsert) { s.UpdateLabelDist() }) } // Exec executes the query. func (u *UsageStatisticHourUpsertBulk) Exec(ctx context.Context) error { if u.create.err != nil { return u.create.err } for i, b := range u.create.builders { if len(b.conflict) != 0 { return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the UsageStatisticHourCreateBulk instead", i) } } if len(u.create.conflict) == 0 { return errors.New("ent: missing options for UsageStatisticHourCreateBulk.OnConflict") } return u.create.Exec(ctx) } // ExecX is like Exec, but panics if an error occurs. func (u *UsageStatisticHourUpsertBulk) ExecX(ctx context.Context) { if err := u.create.Exec(ctx); err != nil { panic(err) } }