1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909 |
- // 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)
- }
- }
|