// Code generated by ent, DO NOT EDIT. package ent import ( "context" "errors" "fmt" "time" "wechat-api/ent/agent" "wechat-api/ent/server" "wechat-api/ent/wx" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" ) // WxCreate is the builder for creating a Wx entity. type WxCreate struct { config mutation *WxMutation hooks []Hook conflict []sql.ConflictOption } // SetCreatedAt sets the "created_at" field. func (wc *WxCreate) SetCreatedAt(t time.Time) *WxCreate { wc.mutation.SetCreatedAt(t) return wc } // SetNillableCreatedAt sets the "created_at" field if the given value is not nil. func (wc *WxCreate) SetNillableCreatedAt(t *time.Time) *WxCreate { if t != nil { wc.SetCreatedAt(*t) } return wc } // SetUpdatedAt sets the "updated_at" field. func (wc *WxCreate) SetUpdatedAt(t time.Time) *WxCreate { wc.mutation.SetUpdatedAt(t) return wc } // SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil. func (wc *WxCreate) SetNillableUpdatedAt(t *time.Time) *WxCreate { if t != nil { wc.SetUpdatedAt(*t) } return wc } // SetStatus sets the "status" field. func (wc *WxCreate) SetStatus(u uint8) *WxCreate { wc.mutation.SetStatus(u) return wc } // SetNillableStatus sets the "status" field if the given value is not nil. func (wc *WxCreate) SetNillableStatus(u *uint8) *WxCreate { if u != nil { wc.SetStatus(*u) } return wc } // SetDeletedAt sets the "deleted_at" field. func (wc *WxCreate) SetDeletedAt(t time.Time) *WxCreate { wc.mutation.SetDeletedAt(t) return wc } // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil. func (wc *WxCreate) SetNillableDeletedAt(t *time.Time) *WxCreate { if t != nil { wc.SetDeletedAt(*t) } return wc } // SetServerID sets the "server_id" field. func (wc *WxCreate) SetServerID(u uint64) *WxCreate { wc.mutation.SetServerID(u) return wc } // SetNillableServerID sets the "server_id" field if the given value is not nil. func (wc *WxCreate) SetNillableServerID(u *uint64) *WxCreate { if u != nil { wc.SetServerID(*u) } return wc } // SetPort sets the "port" field. func (wc *WxCreate) SetPort(s string) *WxCreate { wc.mutation.SetPort(s) return wc } // SetNillablePort sets the "port" field if the given value is not nil. func (wc *WxCreate) SetNillablePort(s *string) *WxCreate { if s != nil { wc.SetPort(*s) } return wc } // SetProcessID sets the "process_id" field. func (wc *WxCreate) SetProcessID(s string) *WxCreate { wc.mutation.SetProcessID(s) return wc } // SetNillableProcessID sets the "process_id" field if the given value is not nil. func (wc *WxCreate) SetNillableProcessID(s *string) *WxCreate { if s != nil { wc.SetProcessID(*s) } return wc } // SetCallback sets the "callback" field. func (wc *WxCreate) SetCallback(s string) *WxCreate { wc.mutation.SetCallback(s) return wc } // SetNillableCallback sets the "callback" field if the given value is not nil. func (wc *WxCreate) SetNillableCallback(s *string) *WxCreate { if s != nil { wc.SetCallback(*s) } return wc } // SetWxid sets the "wxid" field. func (wc *WxCreate) SetWxid(s string) *WxCreate { wc.mutation.SetWxid(s) return wc } // SetNillableWxid sets the "wxid" field if the given value is not nil. func (wc *WxCreate) SetNillableWxid(s *string) *WxCreate { if s != nil { wc.SetWxid(*s) } return wc } // SetAccount sets the "account" field. func (wc *WxCreate) SetAccount(s string) *WxCreate { wc.mutation.SetAccount(s) return wc } // SetNillableAccount sets the "account" field if the given value is not nil. func (wc *WxCreate) SetNillableAccount(s *string) *WxCreate { if s != nil { wc.SetAccount(*s) } return wc } // SetNickname sets the "nickname" field. func (wc *WxCreate) SetNickname(s string) *WxCreate { wc.mutation.SetNickname(s) return wc } // SetNillableNickname sets the "nickname" field if the given value is not nil. func (wc *WxCreate) SetNillableNickname(s *string) *WxCreate { if s != nil { wc.SetNickname(*s) } return wc } // SetTel sets the "tel" field. func (wc *WxCreate) SetTel(s string) *WxCreate { wc.mutation.SetTel(s) return wc } // SetNillableTel sets the "tel" field if the given value is not nil. func (wc *WxCreate) SetNillableTel(s *string) *WxCreate { if s != nil { wc.SetTel(*s) } return wc } // SetHeadBig sets the "head_big" field. func (wc *WxCreate) SetHeadBig(s string) *WxCreate { wc.mutation.SetHeadBig(s) return wc } // SetNillableHeadBig sets the "head_big" field if the given value is not nil. func (wc *WxCreate) SetNillableHeadBig(s *string) *WxCreate { if s != nil { wc.SetHeadBig(*s) } return wc } // SetOrganizationID sets the "organization_id" field. func (wc *WxCreate) SetOrganizationID(u uint64) *WxCreate { wc.mutation.SetOrganizationID(u) return wc } // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil. func (wc *WxCreate) SetNillableOrganizationID(u *uint64) *WxCreate { if u != nil { wc.SetOrganizationID(*u) } return wc } // SetAgentID sets the "agent_id" field. func (wc *WxCreate) SetAgentID(u uint64) *WxCreate { wc.mutation.SetAgentID(u) return wc } // SetNillableAgentID sets the "agent_id" field if the given value is not nil. func (wc *WxCreate) SetNillableAgentID(u *uint64) *WxCreate { if u != nil { wc.SetAgentID(*u) } return wc } // SetAPIBase sets the "api_base" field. func (wc *WxCreate) SetAPIBase(s string) *WxCreate { wc.mutation.SetAPIBase(s) return wc } // SetNillableAPIBase sets the "api_base" field if the given value is not nil. func (wc *WxCreate) SetNillableAPIBase(s *string) *WxCreate { if s != nil { wc.SetAPIBase(*s) } return wc } // SetAPIKey sets the "api_key" field. func (wc *WxCreate) SetAPIKey(s string) *WxCreate { wc.mutation.SetAPIKey(s) return wc } // SetNillableAPIKey sets the "api_key" field if the given value is not nil. func (wc *WxCreate) SetNillableAPIKey(s *string) *WxCreate { if s != nil { wc.SetAPIKey(*s) } return wc } // SetAllowList sets the "allow_list" field. func (wc *WxCreate) SetAllowList(s []string) *WxCreate { wc.mutation.SetAllowList(s) return wc } // SetGroupAllowList sets the "group_allow_list" field. func (wc *WxCreate) SetGroupAllowList(s []string) *WxCreate { wc.mutation.SetGroupAllowList(s) return wc } // SetBlockList sets the "block_list" field. func (wc *WxCreate) SetBlockList(s []string) *WxCreate { wc.mutation.SetBlockList(s) return wc } // SetGroupBlockList sets the "group_block_list" field. func (wc *WxCreate) SetGroupBlockList(s []string) *WxCreate { wc.mutation.SetGroupBlockList(s) return wc } // SetID sets the "id" field. func (wc *WxCreate) SetID(u uint64) *WxCreate { wc.mutation.SetID(u) return wc } // SetServer sets the "server" edge to the Server entity. func (wc *WxCreate) SetServer(s *Server) *WxCreate { return wc.SetServerID(s.ID) } // SetAgent sets the "agent" edge to the Agent entity. func (wc *WxCreate) SetAgent(a *Agent) *WxCreate { return wc.SetAgentID(a.ID) } // Mutation returns the WxMutation object of the builder. func (wc *WxCreate) Mutation() *WxMutation { return wc.mutation } // Save creates the Wx in the database. func (wc *WxCreate) Save(ctx context.Context) (*Wx, error) { if err := wc.defaults(); err != nil { return nil, err } return withHooks(ctx, wc.sqlSave, wc.mutation, wc.hooks) } // SaveX calls Save and panics if Save returns an error. func (wc *WxCreate) SaveX(ctx context.Context) *Wx { v, err := wc.Save(ctx) if err != nil { panic(err) } return v } // Exec executes the query. func (wc *WxCreate) Exec(ctx context.Context) error { _, err := wc.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (wc *WxCreate) ExecX(ctx context.Context) { if err := wc.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. func (wc *WxCreate) defaults() error { if _, ok := wc.mutation.CreatedAt(); !ok { if wx.DefaultCreatedAt == nil { return fmt.Errorf("ent: uninitialized wx.DefaultCreatedAt (forgotten import ent/runtime?)") } v := wx.DefaultCreatedAt() wc.mutation.SetCreatedAt(v) } if _, ok := wc.mutation.UpdatedAt(); !ok { if wx.DefaultUpdatedAt == nil { return fmt.Errorf("ent: uninitialized wx.DefaultUpdatedAt (forgotten import ent/runtime?)") } v := wx.DefaultUpdatedAt() wc.mutation.SetUpdatedAt(v) } if _, ok := wc.mutation.Status(); !ok { v := wx.DefaultStatus wc.mutation.SetStatus(v) } if _, ok := wc.mutation.ServerID(); !ok { v := wx.DefaultServerID wc.mutation.SetServerID(v) } if _, ok := wc.mutation.Port(); !ok { v := wx.DefaultPort wc.mutation.SetPort(v) } if _, ok := wc.mutation.ProcessID(); !ok { v := wx.DefaultProcessID wc.mutation.SetProcessID(v) } if _, ok := wc.mutation.Callback(); !ok { v := wx.DefaultCallback wc.mutation.SetCallback(v) } if _, ok := wc.mutation.Wxid(); !ok { v := wx.DefaultWxid wc.mutation.SetWxid(v) } if _, ok := wc.mutation.Account(); !ok { v := wx.DefaultAccount wc.mutation.SetAccount(v) } if _, ok := wc.mutation.Nickname(); !ok { v := wx.DefaultNickname wc.mutation.SetNickname(v) } if _, ok := wc.mutation.Tel(); !ok { v := wx.DefaultTel wc.mutation.SetTel(v) } if _, ok := wc.mutation.HeadBig(); !ok { v := wx.DefaultHeadBig wc.mutation.SetHeadBig(v) } if _, ok := wc.mutation.OrganizationID(); !ok { v := wx.DefaultOrganizationID wc.mutation.SetOrganizationID(v) } if _, ok := wc.mutation.AgentID(); !ok { v := wx.DefaultAgentID wc.mutation.SetAgentID(v) } if _, ok := wc.mutation.APIBase(); !ok { v := wx.DefaultAPIBase wc.mutation.SetAPIBase(v) } if _, ok := wc.mutation.APIKey(); !ok { v := wx.DefaultAPIKey wc.mutation.SetAPIKey(v) } return nil } // check runs all checks and user-defined validators on the builder. func (wc *WxCreate) check() error { if _, ok := wc.mutation.CreatedAt(); !ok { return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Wx.created_at"`)} } if _, ok := wc.mutation.UpdatedAt(); !ok { return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Wx.updated_at"`)} } if _, ok := wc.mutation.Port(); !ok { return &ValidationError{Name: "port", err: errors.New(`ent: missing required field "Wx.port"`)} } if _, ok := wc.mutation.ProcessID(); !ok { return &ValidationError{Name: "process_id", err: errors.New(`ent: missing required field "Wx.process_id"`)} } if _, ok := wc.mutation.Callback(); !ok { return &ValidationError{Name: "callback", err: errors.New(`ent: missing required field "Wx.callback"`)} } if _, ok := wc.mutation.Wxid(); !ok { return &ValidationError{Name: "wxid", err: errors.New(`ent: missing required field "Wx.wxid"`)} } if _, ok := wc.mutation.Account(); !ok { return &ValidationError{Name: "account", err: errors.New(`ent: missing required field "Wx.account"`)} } if _, ok := wc.mutation.Nickname(); !ok { return &ValidationError{Name: "nickname", err: errors.New(`ent: missing required field "Wx.nickname"`)} } if _, ok := wc.mutation.Tel(); !ok { return &ValidationError{Name: "tel", err: errors.New(`ent: missing required field "Wx.tel"`)} } if _, ok := wc.mutation.HeadBig(); !ok { return &ValidationError{Name: "head_big", err: errors.New(`ent: missing required field "Wx.head_big"`)} } if _, ok := wc.mutation.AgentID(); !ok { return &ValidationError{Name: "agent_id", err: errors.New(`ent: missing required field "Wx.agent_id"`)} } if _, ok := wc.mutation.AllowList(); !ok { return &ValidationError{Name: "allow_list", err: errors.New(`ent: missing required field "Wx.allow_list"`)} } if _, ok := wc.mutation.GroupAllowList(); !ok { return &ValidationError{Name: "group_allow_list", err: errors.New(`ent: missing required field "Wx.group_allow_list"`)} } if _, ok := wc.mutation.BlockList(); !ok { return &ValidationError{Name: "block_list", err: errors.New(`ent: missing required field "Wx.block_list"`)} } if _, ok := wc.mutation.GroupBlockList(); !ok { return &ValidationError{Name: "group_block_list", err: errors.New(`ent: missing required field "Wx.group_block_list"`)} } if _, ok := wc.mutation.AgentID(); !ok { return &ValidationError{Name: "agent", err: errors.New(`ent: missing required edge "Wx.agent"`)} } return nil } func (wc *WxCreate) sqlSave(ctx context.Context) (*Wx, error) { if err := wc.check(); err != nil { return nil, err } _node, _spec := wc.createSpec() if err := sqlgraph.CreateNode(ctx, wc.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) } wc.mutation.id = &_node.ID wc.mutation.done = true return _node, nil } func (wc *WxCreate) createSpec() (*Wx, *sqlgraph.CreateSpec) { var ( _node = &Wx{config: wc.config} _spec = sqlgraph.NewCreateSpec(wx.Table, sqlgraph.NewFieldSpec(wx.FieldID, field.TypeUint64)) ) _spec.OnConflict = wc.conflict if id, ok := wc.mutation.ID(); ok { _node.ID = id _spec.ID.Value = id } if value, ok := wc.mutation.CreatedAt(); ok { _spec.SetField(wx.FieldCreatedAt, field.TypeTime, value) _node.CreatedAt = value } if value, ok := wc.mutation.UpdatedAt(); ok { _spec.SetField(wx.FieldUpdatedAt, field.TypeTime, value) _node.UpdatedAt = value } if value, ok := wc.mutation.Status(); ok { _spec.SetField(wx.FieldStatus, field.TypeUint8, value) _node.Status = value } if value, ok := wc.mutation.DeletedAt(); ok { _spec.SetField(wx.FieldDeletedAt, field.TypeTime, value) _node.DeletedAt = value } if value, ok := wc.mutation.Port(); ok { _spec.SetField(wx.FieldPort, field.TypeString, value) _node.Port = value } if value, ok := wc.mutation.ProcessID(); ok { _spec.SetField(wx.FieldProcessID, field.TypeString, value) _node.ProcessID = value } if value, ok := wc.mutation.Callback(); ok { _spec.SetField(wx.FieldCallback, field.TypeString, value) _node.Callback = value } if value, ok := wc.mutation.Wxid(); ok { _spec.SetField(wx.FieldWxid, field.TypeString, value) _node.Wxid = value } if value, ok := wc.mutation.Account(); ok { _spec.SetField(wx.FieldAccount, field.TypeString, value) _node.Account = value } if value, ok := wc.mutation.Nickname(); ok { _spec.SetField(wx.FieldNickname, field.TypeString, value) _node.Nickname = value } if value, ok := wc.mutation.Tel(); ok { _spec.SetField(wx.FieldTel, field.TypeString, value) _node.Tel = value } if value, ok := wc.mutation.HeadBig(); ok { _spec.SetField(wx.FieldHeadBig, field.TypeString, value) _node.HeadBig = value } if value, ok := wc.mutation.OrganizationID(); ok { _spec.SetField(wx.FieldOrganizationID, field.TypeUint64, value) _node.OrganizationID = value } if value, ok := wc.mutation.APIBase(); ok { _spec.SetField(wx.FieldAPIBase, field.TypeString, value) _node.APIBase = value } if value, ok := wc.mutation.APIKey(); ok { _spec.SetField(wx.FieldAPIKey, field.TypeString, value) _node.APIKey = value } if value, ok := wc.mutation.AllowList(); ok { _spec.SetField(wx.FieldAllowList, field.TypeJSON, value) _node.AllowList = value } if value, ok := wc.mutation.GroupAllowList(); ok { _spec.SetField(wx.FieldGroupAllowList, field.TypeJSON, value) _node.GroupAllowList = value } if value, ok := wc.mutation.BlockList(); ok { _spec.SetField(wx.FieldBlockList, field.TypeJSON, value) _node.BlockList = value } if value, ok := wc.mutation.GroupBlockList(); ok { _spec.SetField(wx.FieldGroupBlockList, field.TypeJSON, value) _node.GroupBlockList = value } if nodes := wc.mutation.ServerIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: wx.ServerTable, Columns: []string{wx.ServerColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(server.FieldID, field.TypeUint64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _node.ServerID = nodes[0] _spec.Edges = append(_spec.Edges, edge) } if nodes := wc.mutation.AgentIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, Table: wx.AgentTable, Columns: []string{wx.AgentColumn}, Bidi: false, Target: &sqlgraph.EdgeTarget{ IDSpec: sqlgraph.NewFieldSpec(agent.FieldID, field.TypeUint64), }, } for _, k := range nodes { edge.Target.Nodes = append(edge.Target.Nodes, k) } _node.AgentID = nodes[0] _spec.Edges = append(_spec.Edges, edge) } return _node, _spec } // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause // of the `INSERT` statement. For example: // // client.Wx.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.WxUpsert) { // SetCreatedAt(v+v). // }). // Exec(ctx) func (wc *WxCreate) OnConflict(opts ...sql.ConflictOption) *WxUpsertOne { wc.conflict = opts return &WxUpsertOne{ create: wc, } } // OnConflictColumns calls `OnConflict` and configures the columns // as conflict target. Using this option is equivalent to using: // // client.Wx.Create(). // OnConflict(sql.ConflictColumns(columns...)). // Exec(ctx) func (wc *WxCreate) OnConflictColumns(columns ...string) *WxUpsertOne { wc.conflict = append(wc.conflict, sql.ConflictColumns(columns...)) return &WxUpsertOne{ create: wc, } } type ( // WxUpsertOne is the builder for "upsert"-ing // one Wx node. WxUpsertOne struct { create *WxCreate } // WxUpsert is the "OnConflict" setter. WxUpsert struct { *sql.UpdateSet } ) // SetUpdatedAt sets the "updated_at" field. func (u *WxUpsert) SetUpdatedAt(v time.Time) *WxUpsert { u.Set(wx.FieldUpdatedAt, v) return u } // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. func (u *WxUpsert) UpdateUpdatedAt() *WxUpsert { u.SetExcluded(wx.FieldUpdatedAt) return u } // SetStatus sets the "status" field. func (u *WxUpsert) SetStatus(v uint8) *WxUpsert { u.Set(wx.FieldStatus, v) return u } // UpdateStatus sets the "status" field to the value that was provided on create. func (u *WxUpsert) UpdateStatus() *WxUpsert { u.SetExcluded(wx.FieldStatus) return u } // AddStatus adds v to the "status" field. func (u *WxUpsert) AddStatus(v uint8) *WxUpsert { u.Add(wx.FieldStatus, v) return u } // ClearStatus clears the value of the "status" field. func (u *WxUpsert) ClearStatus() *WxUpsert { u.SetNull(wx.FieldStatus) return u } // SetDeletedAt sets the "deleted_at" field. func (u *WxUpsert) SetDeletedAt(v time.Time) *WxUpsert { u.Set(wx.FieldDeletedAt, v) return u } // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. func (u *WxUpsert) UpdateDeletedAt() *WxUpsert { u.SetExcluded(wx.FieldDeletedAt) return u } // ClearDeletedAt clears the value of the "deleted_at" field. func (u *WxUpsert) ClearDeletedAt() *WxUpsert { u.SetNull(wx.FieldDeletedAt) return u } // SetServerID sets the "server_id" field. func (u *WxUpsert) SetServerID(v uint64) *WxUpsert { u.Set(wx.FieldServerID, v) return u } // UpdateServerID sets the "server_id" field to the value that was provided on create. func (u *WxUpsert) UpdateServerID() *WxUpsert { u.SetExcluded(wx.FieldServerID) return u } // ClearServerID clears the value of the "server_id" field. func (u *WxUpsert) ClearServerID() *WxUpsert { u.SetNull(wx.FieldServerID) return u } // SetPort sets the "port" field. func (u *WxUpsert) SetPort(v string) *WxUpsert { u.Set(wx.FieldPort, v) return u } // UpdatePort sets the "port" field to the value that was provided on create. func (u *WxUpsert) UpdatePort() *WxUpsert { u.SetExcluded(wx.FieldPort) return u } // SetProcessID sets the "process_id" field. func (u *WxUpsert) SetProcessID(v string) *WxUpsert { u.Set(wx.FieldProcessID, v) return u } // UpdateProcessID sets the "process_id" field to the value that was provided on create. func (u *WxUpsert) UpdateProcessID() *WxUpsert { u.SetExcluded(wx.FieldProcessID) return u } // SetCallback sets the "callback" field. func (u *WxUpsert) SetCallback(v string) *WxUpsert { u.Set(wx.FieldCallback, v) return u } // UpdateCallback sets the "callback" field to the value that was provided on create. func (u *WxUpsert) UpdateCallback() *WxUpsert { u.SetExcluded(wx.FieldCallback) return u } // SetWxid sets the "wxid" field. func (u *WxUpsert) SetWxid(v string) *WxUpsert { u.Set(wx.FieldWxid, v) return u } // UpdateWxid sets the "wxid" field to the value that was provided on create. func (u *WxUpsert) UpdateWxid() *WxUpsert { u.SetExcluded(wx.FieldWxid) return u } // SetAccount sets the "account" field. func (u *WxUpsert) SetAccount(v string) *WxUpsert { u.Set(wx.FieldAccount, v) return u } // UpdateAccount sets the "account" field to the value that was provided on create. func (u *WxUpsert) UpdateAccount() *WxUpsert { u.SetExcluded(wx.FieldAccount) return u } // SetNickname sets the "nickname" field. func (u *WxUpsert) SetNickname(v string) *WxUpsert { u.Set(wx.FieldNickname, v) return u } // UpdateNickname sets the "nickname" field to the value that was provided on create. func (u *WxUpsert) UpdateNickname() *WxUpsert { u.SetExcluded(wx.FieldNickname) return u } // SetTel sets the "tel" field. func (u *WxUpsert) SetTel(v string) *WxUpsert { u.Set(wx.FieldTel, v) return u } // UpdateTel sets the "tel" field to the value that was provided on create. func (u *WxUpsert) UpdateTel() *WxUpsert { u.SetExcluded(wx.FieldTel) return u } // SetHeadBig sets the "head_big" field. func (u *WxUpsert) SetHeadBig(v string) *WxUpsert { u.Set(wx.FieldHeadBig, v) return u } // UpdateHeadBig sets the "head_big" field to the value that was provided on create. func (u *WxUpsert) UpdateHeadBig() *WxUpsert { u.SetExcluded(wx.FieldHeadBig) return u } // SetOrganizationID sets the "organization_id" field. func (u *WxUpsert) SetOrganizationID(v uint64) *WxUpsert { u.Set(wx.FieldOrganizationID, v) return u } // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create. func (u *WxUpsert) UpdateOrganizationID() *WxUpsert { u.SetExcluded(wx.FieldOrganizationID) return u } // AddOrganizationID adds v to the "organization_id" field. func (u *WxUpsert) AddOrganizationID(v uint64) *WxUpsert { u.Add(wx.FieldOrganizationID, v) return u } // ClearOrganizationID clears the value of the "organization_id" field. func (u *WxUpsert) ClearOrganizationID() *WxUpsert { u.SetNull(wx.FieldOrganizationID) return u } // SetAgentID sets the "agent_id" field. func (u *WxUpsert) SetAgentID(v uint64) *WxUpsert { u.Set(wx.FieldAgentID, v) return u } // UpdateAgentID sets the "agent_id" field to the value that was provided on create. func (u *WxUpsert) UpdateAgentID() *WxUpsert { u.SetExcluded(wx.FieldAgentID) return u } // SetAPIBase sets the "api_base" field. func (u *WxUpsert) SetAPIBase(v string) *WxUpsert { u.Set(wx.FieldAPIBase, v) return u } // UpdateAPIBase sets the "api_base" field to the value that was provided on create. func (u *WxUpsert) UpdateAPIBase() *WxUpsert { u.SetExcluded(wx.FieldAPIBase) return u } // ClearAPIBase clears the value of the "api_base" field. func (u *WxUpsert) ClearAPIBase() *WxUpsert { u.SetNull(wx.FieldAPIBase) return u } // SetAPIKey sets the "api_key" field. func (u *WxUpsert) SetAPIKey(v string) *WxUpsert { u.Set(wx.FieldAPIKey, v) return u } // UpdateAPIKey sets the "api_key" field to the value that was provided on create. func (u *WxUpsert) UpdateAPIKey() *WxUpsert { u.SetExcluded(wx.FieldAPIKey) return u } // ClearAPIKey clears the value of the "api_key" field. func (u *WxUpsert) ClearAPIKey() *WxUpsert { u.SetNull(wx.FieldAPIKey) return u } // SetAllowList sets the "allow_list" field. func (u *WxUpsert) SetAllowList(v []string) *WxUpsert { u.Set(wx.FieldAllowList, v) return u } // UpdateAllowList sets the "allow_list" field to the value that was provided on create. func (u *WxUpsert) UpdateAllowList() *WxUpsert { u.SetExcluded(wx.FieldAllowList) return u } // SetGroupAllowList sets the "group_allow_list" field. func (u *WxUpsert) SetGroupAllowList(v []string) *WxUpsert { u.Set(wx.FieldGroupAllowList, v) return u } // UpdateGroupAllowList sets the "group_allow_list" field to the value that was provided on create. func (u *WxUpsert) UpdateGroupAllowList() *WxUpsert { u.SetExcluded(wx.FieldGroupAllowList) return u } // SetBlockList sets the "block_list" field. func (u *WxUpsert) SetBlockList(v []string) *WxUpsert { u.Set(wx.FieldBlockList, v) return u } // UpdateBlockList sets the "block_list" field to the value that was provided on create. func (u *WxUpsert) UpdateBlockList() *WxUpsert { u.SetExcluded(wx.FieldBlockList) return u } // SetGroupBlockList sets the "group_block_list" field. func (u *WxUpsert) SetGroupBlockList(v []string) *WxUpsert { u.Set(wx.FieldGroupBlockList, v) return u } // UpdateGroupBlockList sets the "group_block_list" field to the value that was provided on create. func (u *WxUpsert) UpdateGroupBlockList() *WxUpsert { u.SetExcluded(wx.FieldGroupBlockList) 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.Wx.Create(). // OnConflict( // sql.ResolveWithNewValues(), // sql.ResolveWith(func(u *sql.UpdateSet) { // u.SetIgnore(wx.FieldID) // }), // ). // Exec(ctx) func (u *WxUpsertOne) UpdateNewValues() *WxUpsertOne { 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(wx.FieldID) } if _, exists := u.create.mutation.CreatedAt(); exists { s.SetIgnore(wx.FieldCreatedAt) } })) return u } // Ignore sets each column to itself in case of conflict. // Using this option is equivalent to using: // // client.Wx.Create(). // OnConflict(sql.ResolveWithIgnore()). // Exec(ctx) func (u *WxUpsertOne) Ignore() *WxUpsertOne { 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 *WxUpsertOne) DoNothing() *WxUpsertOne { u.create.conflict = append(u.create.conflict, sql.DoNothing()) return u } // Update allows overriding fields `UPDATE` values. See the WxCreate.OnConflict // documentation for more info. func (u *WxUpsertOne) Update(set func(*WxUpsert)) *WxUpsertOne { u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { set(&WxUpsert{UpdateSet: update}) })) return u } // SetUpdatedAt sets the "updated_at" field. func (u *WxUpsertOne) SetUpdatedAt(v time.Time) *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.SetUpdatedAt(v) }) } // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. func (u *WxUpsertOne) UpdateUpdatedAt() *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.UpdateUpdatedAt() }) } // SetStatus sets the "status" field. func (u *WxUpsertOne) SetStatus(v uint8) *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.SetStatus(v) }) } // AddStatus adds v to the "status" field. func (u *WxUpsertOne) AddStatus(v uint8) *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.AddStatus(v) }) } // UpdateStatus sets the "status" field to the value that was provided on create. func (u *WxUpsertOne) UpdateStatus() *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.UpdateStatus() }) } // ClearStatus clears the value of the "status" field. func (u *WxUpsertOne) ClearStatus() *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.ClearStatus() }) } // SetDeletedAt sets the "deleted_at" field. func (u *WxUpsertOne) SetDeletedAt(v time.Time) *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.SetDeletedAt(v) }) } // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. func (u *WxUpsertOne) UpdateDeletedAt() *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.UpdateDeletedAt() }) } // ClearDeletedAt clears the value of the "deleted_at" field. func (u *WxUpsertOne) ClearDeletedAt() *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.ClearDeletedAt() }) } // SetServerID sets the "server_id" field. func (u *WxUpsertOne) SetServerID(v uint64) *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.SetServerID(v) }) } // UpdateServerID sets the "server_id" field to the value that was provided on create. func (u *WxUpsertOne) UpdateServerID() *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.UpdateServerID() }) } // ClearServerID clears the value of the "server_id" field. func (u *WxUpsertOne) ClearServerID() *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.ClearServerID() }) } // SetPort sets the "port" field. func (u *WxUpsertOne) SetPort(v string) *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.SetPort(v) }) } // UpdatePort sets the "port" field to the value that was provided on create. func (u *WxUpsertOne) UpdatePort() *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.UpdatePort() }) } // SetProcessID sets the "process_id" field. func (u *WxUpsertOne) SetProcessID(v string) *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.SetProcessID(v) }) } // UpdateProcessID sets the "process_id" field to the value that was provided on create. func (u *WxUpsertOne) UpdateProcessID() *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.UpdateProcessID() }) } // SetCallback sets the "callback" field. func (u *WxUpsertOne) SetCallback(v string) *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.SetCallback(v) }) } // UpdateCallback sets the "callback" field to the value that was provided on create. func (u *WxUpsertOne) UpdateCallback() *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.UpdateCallback() }) } // SetWxid sets the "wxid" field. func (u *WxUpsertOne) SetWxid(v string) *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.SetWxid(v) }) } // UpdateWxid sets the "wxid" field to the value that was provided on create. func (u *WxUpsertOne) UpdateWxid() *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.UpdateWxid() }) } // SetAccount sets the "account" field. func (u *WxUpsertOne) SetAccount(v string) *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.SetAccount(v) }) } // UpdateAccount sets the "account" field to the value that was provided on create. func (u *WxUpsertOne) UpdateAccount() *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.UpdateAccount() }) } // SetNickname sets the "nickname" field. func (u *WxUpsertOne) SetNickname(v string) *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.SetNickname(v) }) } // UpdateNickname sets the "nickname" field to the value that was provided on create. func (u *WxUpsertOne) UpdateNickname() *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.UpdateNickname() }) } // SetTel sets the "tel" field. func (u *WxUpsertOne) SetTel(v string) *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.SetTel(v) }) } // UpdateTel sets the "tel" field to the value that was provided on create. func (u *WxUpsertOne) UpdateTel() *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.UpdateTel() }) } // SetHeadBig sets the "head_big" field. func (u *WxUpsertOne) SetHeadBig(v string) *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.SetHeadBig(v) }) } // UpdateHeadBig sets the "head_big" field to the value that was provided on create. func (u *WxUpsertOne) UpdateHeadBig() *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.UpdateHeadBig() }) } // SetOrganizationID sets the "organization_id" field. func (u *WxUpsertOne) SetOrganizationID(v uint64) *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.SetOrganizationID(v) }) } // AddOrganizationID adds v to the "organization_id" field. func (u *WxUpsertOne) AddOrganizationID(v uint64) *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.AddOrganizationID(v) }) } // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create. func (u *WxUpsertOne) UpdateOrganizationID() *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.UpdateOrganizationID() }) } // ClearOrganizationID clears the value of the "organization_id" field. func (u *WxUpsertOne) ClearOrganizationID() *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.ClearOrganizationID() }) } // SetAgentID sets the "agent_id" field. func (u *WxUpsertOne) SetAgentID(v uint64) *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.SetAgentID(v) }) } // UpdateAgentID sets the "agent_id" field to the value that was provided on create. func (u *WxUpsertOne) UpdateAgentID() *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.UpdateAgentID() }) } // SetAPIBase sets the "api_base" field. func (u *WxUpsertOne) SetAPIBase(v string) *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.SetAPIBase(v) }) } // UpdateAPIBase sets the "api_base" field to the value that was provided on create. func (u *WxUpsertOne) UpdateAPIBase() *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.UpdateAPIBase() }) } // ClearAPIBase clears the value of the "api_base" field. func (u *WxUpsertOne) ClearAPIBase() *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.ClearAPIBase() }) } // SetAPIKey sets the "api_key" field. func (u *WxUpsertOne) SetAPIKey(v string) *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.SetAPIKey(v) }) } // UpdateAPIKey sets the "api_key" field to the value that was provided on create. func (u *WxUpsertOne) UpdateAPIKey() *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.UpdateAPIKey() }) } // ClearAPIKey clears the value of the "api_key" field. func (u *WxUpsertOne) ClearAPIKey() *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.ClearAPIKey() }) } // SetAllowList sets the "allow_list" field. func (u *WxUpsertOne) SetAllowList(v []string) *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.SetAllowList(v) }) } // UpdateAllowList sets the "allow_list" field to the value that was provided on create. func (u *WxUpsertOne) UpdateAllowList() *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.UpdateAllowList() }) } // SetGroupAllowList sets the "group_allow_list" field. func (u *WxUpsertOne) SetGroupAllowList(v []string) *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.SetGroupAllowList(v) }) } // UpdateGroupAllowList sets the "group_allow_list" field to the value that was provided on create. func (u *WxUpsertOne) UpdateGroupAllowList() *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.UpdateGroupAllowList() }) } // SetBlockList sets the "block_list" field. func (u *WxUpsertOne) SetBlockList(v []string) *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.SetBlockList(v) }) } // UpdateBlockList sets the "block_list" field to the value that was provided on create. func (u *WxUpsertOne) UpdateBlockList() *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.UpdateBlockList() }) } // SetGroupBlockList sets the "group_block_list" field. func (u *WxUpsertOne) SetGroupBlockList(v []string) *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.SetGroupBlockList(v) }) } // UpdateGroupBlockList sets the "group_block_list" field to the value that was provided on create. func (u *WxUpsertOne) UpdateGroupBlockList() *WxUpsertOne { return u.Update(func(s *WxUpsert) { s.UpdateGroupBlockList() }) } // Exec executes the query. func (u *WxUpsertOne) Exec(ctx context.Context) error { if len(u.create.conflict) == 0 { return errors.New("ent: missing options for WxCreate.OnConflict") } return u.create.Exec(ctx) } // ExecX is like Exec, but panics if an error occurs. func (u *WxUpsertOne) 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 *WxUpsertOne) 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 *WxUpsertOne) IDX(ctx context.Context) uint64 { id, err := u.ID(ctx) if err != nil { panic(err) } return id } // WxCreateBulk is the builder for creating many Wx entities in bulk. type WxCreateBulk struct { config err error builders []*WxCreate conflict []sql.ConflictOption } // Save creates the Wx entities in the database. func (wcb *WxCreateBulk) Save(ctx context.Context) ([]*Wx, error) { if wcb.err != nil { return nil, wcb.err } specs := make([]*sqlgraph.CreateSpec, len(wcb.builders)) nodes := make([]*Wx, len(wcb.builders)) mutators := make([]Mutator, len(wcb.builders)) for i := range wcb.builders { func(i int, root context.Context) { builder := wcb.builders[i] builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*WxMutation) 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, wcb.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} spec.OnConflict = wcb.conflict // Invoke the actual operation on the latest mutation in the chain. if err = sqlgraph.BatchCreate(ctx, wcb.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, wcb.builders[0].mutation); err != nil { return nil, err } } return nodes, nil } // SaveX is like Save, but panics if an error occurs. func (wcb *WxCreateBulk) SaveX(ctx context.Context) []*Wx { v, err := wcb.Save(ctx) if err != nil { panic(err) } return v } // Exec executes the query. func (wcb *WxCreateBulk) Exec(ctx context.Context) error { _, err := wcb.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. func (wcb *WxCreateBulk) ExecX(ctx context.Context) { if err := wcb.Exec(ctx); err != nil { panic(err) } } // OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause // of the `INSERT` statement. For example: // // client.Wx.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.WxUpsert) { // SetCreatedAt(v+v). // }). // Exec(ctx) func (wcb *WxCreateBulk) OnConflict(opts ...sql.ConflictOption) *WxUpsertBulk { wcb.conflict = opts return &WxUpsertBulk{ create: wcb, } } // OnConflictColumns calls `OnConflict` and configures the columns // as conflict target. Using this option is equivalent to using: // // client.Wx.Create(). // OnConflict(sql.ConflictColumns(columns...)). // Exec(ctx) func (wcb *WxCreateBulk) OnConflictColumns(columns ...string) *WxUpsertBulk { wcb.conflict = append(wcb.conflict, sql.ConflictColumns(columns...)) return &WxUpsertBulk{ create: wcb, } } // WxUpsertBulk is the builder for "upsert"-ing // a bulk of Wx nodes. type WxUpsertBulk struct { create *WxCreateBulk } // UpdateNewValues updates the mutable fields using the new values that // were set on create. Using this option is equivalent to using: // // client.Wx.Create(). // OnConflict( // sql.ResolveWithNewValues(), // sql.ResolveWith(func(u *sql.UpdateSet) { // u.SetIgnore(wx.FieldID) // }), // ). // Exec(ctx) func (u *WxUpsertBulk) UpdateNewValues() *WxUpsertBulk { 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(wx.FieldID) } if _, exists := b.mutation.CreatedAt(); exists { s.SetIgnore(wx.FieldCreatedAt) } } })) return u } // Ignore sets each column to itself in case of conflict. // Using this option is equivalent to using: // // client.Wx.Create(). // OnConflict(sql.ResolveWithIgnore()). // Exec(ctx) func (u *WxUpsertBulk) Ignore() *WxUpsertBulk { 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 *WxUpsertBulk) DoNothing() *WxUpsertBulk { u.create.conflict = append(u.create.conflict, sql.DoNothing()) return u } // Update allows overriding fields `UPDATE` values. See the WxCreateBulk.OnConflict // documentation for more info. func (u *WxUpsertBulk) Update(set func(*WxUpsert)) *WxUpsertBulk { u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) { set(&WxUpsert{UpdateSet: update}) })) return u } // SetUpdatedAt sets the "updated_at" field. func (u *WxUpsertBulk) SetUpdatedAt(v time.Time) *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.SetUpdatedAt(v) }) } // UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create. func (u *WxUpsertBulk) UpdateUpdatedAt() *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.UpdateUpdatedAt() }) } // SetStatus sets the "status" field. func (u *WxUpsertBulk) SetStatus(v uint8) *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.SetStatus(v) }) } // AddStatus adds v to the "status" field. func (u *WxUpsertBulk) AddStatus(v uint8) *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.AddStatus(v) }) } // UpdateStatus sets the "status" field to the value that was provided on create. func (u *WxUpsertBulk) UpdateStatus() *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.UpdateStatus() }) } // ClearStatus clears the value of the "status" field. func (u *WxUpsertBulk) ClearStatus() *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.ClearStatus() }) } // SetDeletedAt sets the "deleted_at" field. func (u *WxUpsertBulk) SetDeletedAt(v time.Time) *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.SetDeletedAt(v) }) } // UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create. func (u *WxUpsertBulk) UpdateDeletedAt() *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.UpdateDeletedAt() }) } // ClearDeletedAt clears the value of the "deleted_at" field. func (u *WxUpsertBulk) ClearDeletedAt() *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.ClearDeletedAt() }) } // SetServerID sets the "server_id" field. func (u *WxUpsertBulk) SetServerID(v uint64) *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.SetServerID(v) }) } // UpdateServerID sets the "server_id" field to the value that was provided on create. func (u *WxUpsertBulk) UpdateServerID() *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.UpdateServerID() }) } // ClearServerID clears the value of the "server_id" field. func (u *WxUpsertBulk) ClearServerID() *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.ClearServerID() }) } // SetPort sets the "port" field. func (u *WxUpsertBulk) SetPort(v string) *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.SetPort(v) }) } // UpdatePort sets the "port" field to the value that was provided on create. func (u *WxUpsertBulk) UpdatePort() *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.UpdatePort() }) } // SetProcessID sets the "process_id" field. func (u *WxUpsertBulk) SetProcessID(v string) *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.SetProcessID(v) }) } // UpdateProcessID sets the "process_id" field to the value that was provided on create. func (u *WxUpsertBulk) UpdateProcessID() *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.UpdateProcessID() }) } // SetCallback sets the "callback" field. func (u *WxUpsertBulk) SetCallback(v string) *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.SetCallback(v) }) } // UpdateCallback sets the "callback" field to the value that was provided on create. func (u *WxUpsertBulk) UpdateCallback() *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.UpdateCallback() }) } // SetWxid sets the "wxid" field. func (u *WxUpsertBulk) SetWxid(v string) *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.SetWxid(v) }) } // UpdateWxid sets the "wxid" field to the value that was provided on create. func (u *WxUpsertBulk) UpdateWxid() *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.UpdateWxid() }) } // SetAccount sets the "account" field. func (u *WxUpsertBulk) SetAccount(v string) *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.SetAccount(v) }) } // UpdateAccount sets the "account" field to the value that was provided on create. func (u *WxUpsertBulk) UpdateAccount() *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.UpdateAccount() }) } // SetNickname sets the "nickname" field. func (u *WxUpsertBulk) SetNickname(v string) *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.SetNickname(v) }) } // UpdateNickname sets the "nickname" field to the value that was provided on create. func (u *WxUpsertBulk) UpdateNickname() *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.UpdateNickname() }) } // SetTel sets the "tel" field. func (u *WxUpsertBulk) SetTel(v string) *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.SetTel(v) }) } // UpdateTel sets the "tel" field to the value that was provided on create. func (u *WxUpsertBulk) UpdateTel() *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.UpdateTel() }) } // SetHeadBig sets the "head_big" field. func (u *WxUpsertBulk) SetHeadBig(v string) *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.SetHeadBig(v) }) } // UpdateHeadBig sets the "head_big" field to the value that was provided on create. func (u *WxUpsertBulk) UpdateHeadBig() *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.UpdateHeadBig() }) } // SetOrganizationID sets the "organization_id" field. func (u *WxUpsertBulk) SetOrganizationID(v uint64) *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.SetOrganizationID(v) }) } // AddOrganizationID adds v to the "organization_id" field. func (u *WxUpsertBulk) AddOrganizationID(v uint64) *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.AddOrganizationID(v) }) } // UpdateOrganizationID sets the "organization_id" field to the value that was provided on create. func (u *WxUpsertBulk) UpdateOrganizationID() *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.UpdateOrganizationID() }) } // ClearOrganizationID clears the value of the "organization_id" field. func (u *WxUpsertBulk) ClearOrganizationID() *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.ClearOrganizationID() }) } // SetAgentID sets the "agent_id" field. func (u *WxUpsertBulk) SetAgentID(v uint64) *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.SetAgentID(v) }) } // UpdateAgentID sets the "agent_id" field to the value that was provided on create. func (u *WxUpsertBulk) UpdateAgentID() *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.UpdateAgentID() }) } // SetAPIBase sets the "api_base" field. func (u *WxUpsertBulk) SetAPIBase(v string) *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.SetAPIBase(v) }) } // UpdateAPIBase sets the "api_base" field to the value that was provided on create. func (u *WxUpsertBulk) UpdateAPIBase() *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.UpdateAPIBase() }) } // ClearAPIBase clears the value of the "api_base" field. func (u *WxUpsertBulk) ClearAPIBase() *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.ClearAPIBase() }) } // SetAPIKey sets the "api_key" field. func (u *WxUpsertBulk) SetAPIKey(v string) *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.SetAPIKey(v) }) } // UpdateAPIKey sets the "api_key" field to the value that was provided on create. func (u *WxUpsertBulk) UpdateAPIKey() *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.UpdateAPIKey() }) } // ClearAPIKey clears the value of the "api_key" field. func (u *WxUpsertBulk) ClearAPIKey() *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.ClearAPIKey() }) } // SetAllowList sets the "allow_list" field. func (u *WxUpsertBulk) SetAllowList(v []string) *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.SetAllowList(v) }) } // UpdateAllowList sets the "allow_list" field to the value that was provided on create. func (u *WxUpsertBulk) UpdateAllowList() *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.UpdateAllowList() }) } // SetGroupAllowList sets the "group_allow_list" field. func (u *WxUpsertBulk) SetGroupAllowList(v []string) *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.SetGroupAllowList(v) }) } // UpdateGroupAllowList sets the "group_allow_list" field to the value that was provided on create. func (u *WxUpsertBulk) UpdateGroupAllowList() *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.UpdateGroupAllowList() }) } // SetBlockList sets the "block_list" field. func (u *WxUpsertBulk) SetBlockList(v []string) *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.SetBlockList(v) }) } // UpdateBlockList sets the "block_list" field to the value that was provided on create. func (u *WxUpsertBulk) UpdateBlockList() *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.UpdateBlockList() }) } // SetGroupBlockList sets the "group_block_list" field. func (u *WxUpsertBulk) SetGroupBlockList(v []string) *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.SetGroupBlockList(v) }) } // UpdateGroupBlockList sets the "group_block_list" field to the value that was provided on create. func (u *WxUpsertBulk) UpdateGroupBlockList() *WxUpsertBulk { return u.Update(func(s *WxUpsert) { s.UpdateGroupBlockList() }) } // Exec executes the query. func (u *WxUpsertBulk) 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 WxCreateBulk instead", i) } } if len(u.create.conflict) == 0 { return errors.New("ent: missing options for WxCreateBulk.OnConflict") } return u.create.Exec(ctx) } // ExecX is like Exec, but panics if an error occurs. func (u *WxUpsertBulk) ExecX(ctx context.Context) { if err := u.create.Exec(ctx); err != nil { panic(err) } }