12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "context"
- "errors"
- "fmt"
- "time"
- "wechat-api/ent/agent"
- "wechat-api/ent/predicate"
- "wechat-api/ent/whatsapp"
- "entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
- "entgo.io/ent/dialect/sql/sqljson"
- "entgo.io/ent/schema/field"
- )
- // WhatsappUpdate is the builder for updating Whatsapp entities.
- type WhatsappUpdate struct {
- config
- hooks []Hook
- mutation *WhatsappMutation
- }
- // Where appends a list predicates to the WhatsappUpdate builder.
- func (wu *WhatsappUpdate) Where(ps ...predicate.Whatsapp) *WhatsappUpdate {
- wu.mutation.Where(ps...)
- return wu
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (wu *WhatsappUpdate) SetUpdatedAt(t time.Time) *WhatsappUpdate {
- wu.mutation.SetUpdatedAt(t)
- return wu
- }
- // SetStatus sets the "status" field.
- func (wu *WhatsappUpdate) SetStatus(u uint8) *WhatsappUpdate {
- wu.mutation.ResetStatus()
- wu.mutation.SetStatus(u)
- return wu
- }
- // SetNillableStatus sets the "status" field if the given value is not nil.
- func (wu *WhatsappUpdate) SetNillableStatus(u *uint8) *WhatsappUpdate {
- if u != nil {
- wu.SetStatus(*u)
- }
- return wu
- }
- // AddStatus adds u to the "status" field.
- func (wu *WhatsappUpdate) AddStatus(u int8) *WhatsappUpdate {
- wu.mutation.AddStatus(u)
- return wu
- }
- // ClearStatus clears the value of the "status" field.
- func (wu *WhatsappUpdate) ClearStatus() *WhatsappUpdate {
- wu.mutation.ClearStatus()
- return wu
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (wu *WhatsappUpdate) SetDeletedAt(t time.Time) *WhatsappUpdate {
- wu.mutation.SetDeletedAt(t)
- return wu
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (wu *WhatsappUpdate) SetNillableDeletedAt(t *time.Time) *WhatsappUpdate {
- if t != nil {
- wu.SetDeletedAt(*t)
- }
- return wu
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (wu *WhatsappUpdate) ClearDeletedAt() *WhatsappUpdate {
- wu.mutation.ClearDeletedAt()
- return wu
- }
- // SetWaID sets the "wa_id" field.
- func (wu *WhatsappUpdate) SetWaID(s string) *WhatsappUpdate {
- wu.mutation.SetWaID(s)
- return wu
- }
- // SetNillableWaID sets the "wa_id" field if the given value is not nil.
- func (wu *WhatsappUpdate) SetNillableWaID(s *string) *WhatsappUpdate {
- if s != nil {
- wu.SetWaID(*s)
- }
- return wu
- }
- // ClearWaID clears the value of the "wa_id" field.
- func (wu *WhatsappUpdate) ClearWaID() *WhatsappUpdate {
- wu.mutation.ClearWaID()
- return wu
- }
- // SetWaName sets the "wa_name" field.
- func (wu *WhatsappUpdate) SetWaName(s string) *WhatsappUpdate {
- wu.mutation.SetWaName(s)
- return wu
- }
- // SetNillableWaName sets the "wa_name" field if the given value is not nil.
- func (wu *WhatsappUpdate) SetNillableWaName(s *string) *WhatsappUpdate {
- if s != nil {
- wu.SetWaName(*s)
- }
- return wu
- }
- // ClearWaName clears the value of the "wa_name" field.
- func (wu *WhatsappUpdate) ClearWaName() *WhatsappUpdate {
- wu.mutation.ClearWaName()
- return wu
- }
- // SetCallback sets the "callback" field.
- func (wu *WhatsappUpdate) SetCallback(s string) *WhatsappUpdate {
- wu.mutation.SetCallback(s)
- return wu
- }
- // SetNillableCallback sets the "callback" field if the given value is not nil.
- func (wu *WhatsappUpdate) SetNillableCallback(s *string) *WhatsappUpdate {
- if s != nil {
- wu.SetCallback(*s)
- }
- return wu
- }
- // ClearCallback clears the value of the "callback" field.
- func (wu *WhatsappUpdate) ClearCallback() *WhatsappUpdate {
- wu.mutation.ClearCallback()
- return wu
- }
- // SetAgentID sets the "agent_id" field.
- func (wu *WhatsappUpdate) SetAgentID(u uint64) *WhatsappUpdate {
- wu.mutation.SetAgentID(u)
- return wu
- }
- // SetNillableAgentID sets the "agent_id" field if the given value is not nil.
- func (wu *WhatsappUpdate) SetNillableAgentID(u *uint64) *WhatsappUpdate {
- if u != nil {
- wu.SetAgentID(*u)
- }
- return wu
- }
- // SetAccount sets the "account" field.
- func (wu *WhatsappUpdate) SetAccount(s string) *WhatsappUpdate {
- wu.mutation.SetAccount(s)
- return wu
- }
- // SetNillableAccount sets the "account" field if the given value is not nil.
- func (wu *WhatsappUpdate) SetNillableAccount(s *string) *WhatsappUpdate {
- if s != nil {
- wu.SetAccount(*s)
- }
- return wu
- }
- // ClearAccount clears the value of the "account" field.
- func (wu *WhatsappUpdate) ClearAccount() *WhatsappUpdate {
- wu.mutation.ClearAccount()
- return wu
- }
- // SetCc sets the "cc" field.
- func (wu *WhatsappUpdate) SetCc(s string) *WhatsappUpdate {
- wu.mutation.SetCc(s)
- return wu
- }
- // SetNillableCc sets the "cc" field if the given value is not nil.
- func (wu *WhatsappUpdate) SetNillableCc(s *string) *WhatsappUpdate {
- if s != nil {
- wu.SetCc(*s)
- }
- return wu
- }
- // SetPhone sets the "phone" field.
- func (wu *WhatsappUpdate) SetPhone(s string) *WhatsappUpdate {
- wu.mutation.SetPhone(s)
- return wu
- }
- // SetNillablePhone sets the "phone" field if the given value is not nil.
- func (wu *WhatsappUpdate) SetNillablePhone(s *string) *WhatsappUpdate {
- if s != nil {
- wu.SetPhone(*s)
- }
- return wu
- }
- // SetCcPhone sets the "cc_phone" field.
- func (wu *WhatsappUpdate) SetCcPhone(s string) *WhatsappUpdate {
- wu.mutation.SetCcPhone(s)
- return wu
- }
- // SetNillableCcPhone sets the "cc_phone" field if the given value is not nil.
- func (wu *WhatsappUpdate) SetNillableCcPhone(s *string) *WhatsappUpdate {
- if s != nil {
- wu.SetCcPhone(*s)
- }
- return wu
- }
- // SetPhoneName sets the "phone_name" field.
- func (wu *WhatsappUpdate) SetPhoneName(s string) *WhatsappUpdate {
- wu.mutation.SetPhoneName(s)
- return wu
- }
- // SetNillablePhoneName sets the "phone_name" field if the given value is not nil.
- func (wu *WhatsappUpdate) SetNillablePhoneName(s *string) *WhatsappUpdate {
- if s != nil {
- wu.SetPhoneName(*s)
- }
- return wu
- }
- // SetPhoneStatus sets the "phone_status" field.
- func (wu *WhatsappUpdate) SetPhoneStatus(i int8) *WhatsappUpdate {
- wu.mutation.ResetPhoneStatus()
- wu.mutation.SetPhoneStatus(i)
- return wu
- }
- // SetNillablePhoneStatus sets the "phone_status" field if the given value is not nil.
- func (wu *WhatsappUpdate) SetNillablePhoneStatus(i *int8) *WhatsappUpdate {
- if i != nil {
- wu.SetPhoneStatus(*i)
- }
- return wu
- }
- // AddPhoneStatus adds i to the "phone_status" field.
- func (wu *WhatsappUpdate) AddPhoneStatus(i int8) *WhatsappUpdate {
- wu.mutation.AddPhoneStatus(i)
- return wu
- }
- // SetOrganizationID sets the "organization_id" field.
- func (wu *WhatsappUpdate) SetOrganizationID(u uint64) *WhatsappUpdate {
- wu.mutation.ResetOrganizationID()
- wu.mutation.SetOrganizationID(u)
- return wu
- }
- // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
- func (wu *WhatsappUpdate) SetNillableOrganizationID(u *uint64) *WhatsappUpdate {
- if u != nil {
- wu.SetOrganizationID(*u)
- }
- return wu
- }
- // AddOrganizationID adds u to the "organization_id" field.
- func (wu *WhatsappUpdate) AddOrganizationID(u int64) *WhatsappUpdate {
- wu.mutation.AddOrganizationID(u)
- return wu
- }
- // ClearOrganizationID clears the value of the "organization_id" field.
- func (wu *WhatsappUpdate) ClearOrganizationID() *WhatsappUpdate {
- wu.mutation.ClearOrganizationID()
- return wu
- }
- // SetAPIBase sets the "api_base" field.
- func (wu *WhatsappUpdate) SetAPIBase(s string) *WhatsappUpdate {
- wu.mutation.SetAPIBase(s)
- return wu
- }
- // SetNillableAPIBase sets the "api_base" field if the given value is not nil.
- func (wu *WhatsappUpdate) SetNillableAPIBase(s *string) *WhatsappUpdate {
- if s != nil {
- wu.SetAPIBase(*s)
- }
- return wu
- }
- // ClearAPIBase clears the value of the "api_base" field.
- func (wu *WhatsappUpdate) ClearAPIBase() *WhatsappUpdate {
- wu.mutation.ClearAPIBase()
- return wu
- }
- // SetAPIKey sets the "api_key" field.
- func (wu *WhatsappUpdate) SetAPIKey(s string) *WhatsappUpdate {
- wu.mutation.SetAPIKey(s)
- return wu
- }
- // SetNillableAPIKey sets the "api_key" field if the given value is not nil.
- func (wu *WhatsappUpdate) SetNillableAPIKey(s *string) *WhatsappUpdate {
- if s != nil {
- wu.SetAPIKey(*s)
- }
- return wu
- }
- // ClearAPIKey clears the value of the "api_key" field.
- func (wu *WhatsappUpdate) ClearAPIKey() *WhatsappUpdate {
- wu.mutation.ClearAPIKey()
- return wu
- }
- // SetAllowList sets the "allow_list" field.
- func (wu *WhatsappUpdate) SetAllowList(s []string) *WhatsappUpdate {
- wu.mutation.SetAllowList(s)
- return wu
- }
- // AppendAllowList appends s to the "allow_list" field.
- func (wu *WhatsappUpdate) AppendAllowList(s []string) *WhatsappUpdate {
- wu.mutation.AppendAllowList(s)
- return wu
- }
- // ClearAllowList clears the value of the "allow_list" field.
- func (wu *WhatsappUpdate) ClearAllowList() *WhatsappUpdate {
- wu.mutation.ClearAllowList()
- return wu
- }
- // SetGroupAllowList sets the "group_allow_list" field.
- func (wu *WhatsappUpdate) SetGroupAllowList(s []string) *WhatsappUpdate {
- wu.mutation.SetGroupAllowList(s)
- return wu
- }
- // AppendGroupAllowList appends s to the "group_allow_list" field.
- func (wu *WhatsappUpdate) AppendGroupAllowList(s []string) *WhatsappUpdate {
- wu.mutation.AppendGroupAllowList(s)
- return wu
- }
- // ClearGroupAllowList clears the value of the "group_allow_list" field.
- func (wu *WhatsappUpdate) ClearGroupAllowList() *WhatsappUpdate {
- wu.mutation.ClearGroupAllowList()
- return wu
- }
- // SetBlockList sets the "block_list" field.
- func (wu *WhatsappUpdate) SetBlockList(s []string) *WhatsappUpdate {
- wu.mutation.SetBlockList(s)
- return wu
- }
- // AppendBlockList appends s to the "block_list" field.
- func (wu *WhatsappUpdate) AppendBlockList(s []string) *WhatsappUpdate {
- wu.mutation.AppendBlockList(s)
- return wu
- }
- // ClearBlockList clears the value of the "block_list" field.
- func (wu *WhatsappUpdate) ClearBlockList() *WhatsappUpdate {
- wu.mutation.ClearBlockList()
- return wu
- }
- // SetGroupBlockList sets the "group_block_list" field.
- func (wu *WhatsappUpdate) SetGroupBlockList(s []string) *WhatsappUpdate {
- wu.mutation.SetGroupBlockList(s)
- return wu
- }
- // AppendGroupBlockList appends s to the "group_block_list" field.
- func (wu *WhatsappUpdate) AppendGroupBlockList(s []string) *WhatsappUpdate {
- wu.mutation.AppendGroupBlockList(s)
- return wu
- }
- // ClearGroupBlockList clears the value of the "group_block_list" field.
- func (wu *WhatsappUpdate) ClearGroupBlockList() *WhatsappUpdate {
- wu.mutation.ClearGroupBlockList()
- return wu
- }
- // SetAgent sets the "agent" edge to the Agent entity.
- func (wu *WhatsappUpdate) SetAgent(a *Agent) *WhatsappUpdate {
- return wu.SetAgentID(a.ID)
- }
- // Mutation returns the WhatsappMutation object of the builder.
- func (wu *WhatsappUpdate) Mutation() *WhatsappMutation {
- return wu.mutation
- }
- // ClearAgent clears the "agent" edge to the Agent entity.
- func (wu *WhatsappUpdate) ClearAgent() *WhatsappUpdate {
- wu.mutation.ClearAgent()
- return wu
- }
- // Save executes the query and returns the number of nodes affected by the update operation.
- func (wu *WhatsappUpdate) Save(ctx context.Context) (int, error) {
- if err := wu.defaults(); err != nil {
- return 0, err
- }
- return withHooks(ctx, wu.sqlSave, wu.mutation, wu.hooks)
- }
- // SaveX is like Save, but panics if an error occurs.
- func (wu *WhatsappUpdate) SaveX(ctx context.Context) int {
- affected, err := wu.Save(ctx)
- if err != nil {
- panic(err)
- }
- return affected
- }
- // Exec executes the query.
- func (wu *WhatsappUpdate) Exec(ctx context.Context) error {
- _, err := wu.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (wu *WhatsappUpdate) ExecX(ctx context.Context) {
- if err := wu.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (wu *WhatsappUpdate) defaults() error {
- if _, ok := wu.mutation.UpdatedAt(); !ok {
- if whatsapp.UpdateDefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized whatsapp.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := whatsapp.UpdateDefaultUpdatedAt()
- wu.mutation.SetUpdatedAt(v)
- }
- return nil
- }
- // check runs all checks and user-defined validators on the builder.
- func (wu *WhatsappUpdate) check() error {
- if _, ok := wu.mutation.AgentID(); wu.mutation.AgentCleared() && !ok {
- return errors.New(`ent: clearing a required unique edge "Whatsapp.agent"`)
- }
- return nil
- }
- func (wu *WhatsappUpdate) sqlSave(ctx context.Context) (n int, err error) {
- if err := wu.check(); err != nil {
- return n, err
- }
- _spec := sqlgraph.NewUpdateSpec(whatsapp.Table, whatsapp.Columns, sqlgraph.NewFieldSpec(whatsapp.FieldID, field.TypeUint64))
- if ps := wu.mutation.predicates; len(ps) > 0 {
- _spec.Predicate = func(selector *sql.Selector) {
- for i := range ps {
- ps[i](selector)
- }
- }
- }
- if value, ok := wu.mutation.UpdatedAt(); ok {
- _spec.SetField(whatsapp.FieldUpdatedAt, field.TypeTime, value)
- }
- if value, ok := wu.mutation.Status(); ok {
- _spec.SetField(whatsapp.FieldStatus, field.TypeUint8, value)
- }
- if value, ok := wu.mutation.AddedStatus(); ok {
- _spec.AddField(whatsapp.FieldStatus, field.TypeUint8, value)
- }
- if wu.mutation.StatusCleared() {
- _spec.ClearField(whatsapp.FieldStatus, field.TypeUint8)
- }
- if value, ok := wu.mutation.DeletedAt(); ok {
- _spec.SetField(whatsapp.FieldDeletedAt, field.TypeTime, value)
- }
- if wu.mutation.DeletedAtCleared() {
- _spec.ClearField(whatsapp.FieldDeletedAt, field.TypeTime)
- }
- if value, ok := wu.mutation.WaID(); ok {
- _spec.SetField(whatsapp.FieldWaID, field.TypeString, value)
- }
- if wu.mutation.WaIDCleared() {
- _spec.ClearField(whatsapp.FieldWaID, field.TypeString)
- }
- if value, ok := wu.mutation.WaName(); ok {
- _spec.SetField(whatsapp.FieldWaName, field.TypeString, value)
- }
- if wu.mutation.WaNameCleared() {
- _spec.ClearField(whatsapp.FieldWaName, field.TypeString)
- }
- if value, ok := wu.mutation.Callback(); ok {
- _spec.SetField(whatsapp.FieldCallback, field.TypeString, value)
- }
- if wu.mutation.CallbackCleared() {
- _spec.ClearField(whatsapp.FieldCallback, field.TypeString)
- }
- if value, ok := wu.mutation.Account(); ok {
- _spec.SetField(whatsapp.FieldAccount, field.TypeString, value)
- }
- if wu.mutation.AccountCleared() {
- _spec.ClearField(whatsapp.FieldAccount, field.TypeString)
- }
- if value, ok := wu.mutation.Cc(); ok {
- _spec.SetField(whatsapp.FieldCc, field.TypeString, value)
- }
- if value, ok := wu.mutation.Phone(); ok {
- _spec.SetField(whatsapp.FieldPhone, field.TypeString, value)
- }
- if value, ok := wu.mutation.CcPhone(); ok {
- _spec.SetField(whatsapp.FieldCcPhone, field.TypeString, value)
- }
- if value, ok := wu.mutation.PhoneName(); ok {
- _spec.SetField(whatsapp.FieldPhoneName, field.TypeString, value)
- }
- if value, ok := wu.mutation.PhoneStatus(); ok {
- _spec.SetField(whatsapp.FieldPhoneStatus, field.TypeInt8, value)
- }
- if value, ok := wu.mutation.AddedPhoneStatus(); ok {
- _spec.AddField(whatsapp.FieldPhoneStatus, field.TypeInt8, value)
- }
- if value, ok := wu.mutation.OrganizationID(); ok {
- _spec.SetField(whatsapp.FieldOrganizationID, field.TypeUint64, value)
- }
- if value, ok := wu.mutation.AddedOrganizationID(); ok {
- _spec.AddField(whatsapp.FieldOrganizationID, field.TypeUint64, value)
- }
- if wu.mutation.OrganizationIDCleared() {
- _spec.ClearField(whatsapp.FieldOrganizationID, field.TypeUint64)
- }
- if value, ok := wu.mutation.APIBase(); ok {
- _spec.SetField(whatsapp.FieldAPIBase, field.TypeString, value)
- }
- if wu.mutation.APIBaseCleared() {
- _spec.ClearField(whatsapp.FieldAPIBase, field.TypeString)
- }
- if value, ok := wu.mutation.APIKey(); ok {
- _spec.SetField(whatsapp.FieldAPIKey, field.TypeString, value)
- }
- if wu.mutation.APIKeyCleared() {
- _spec.ClearField(whatsapp.FieldAPIKey, field.TypeString)
- }
- if value, ok := wu.mutation.AllowList(); ok {
- _spec.SetField(whatsapp.FieldAllowList, field.TypeJSON, value)
- }
- if value, ok := wu.mutation.AppendedAllowList(); ok {
- _spec.AddModifier(func(u *sql.UpdateBuilder) {
- sqljson.Append(u, whatsapp.FieldAllowList, value)
- })
- }
- if wu.mutation.AllowListCleared() {
- _spec.ClearField(whatsapp.FieldAllowList, field.TypeJSON)
- }
- if value, ok := wu.mutation.GroupAllowList(); ok {
- _spec.SetField(whatsapp.FieldGroupAllowList, field.TypeJSON, value)
- }
- if value, ok := wu.mutation.AppendedGroupAllowList(); ok {
- _spec.AddModifier(func(u *sql.UpdateBuilder) {
- sqljson.Append(u, whatsapp.FieldGroupAllowList, value)
- })
- }
- if wu.mutation.GroupAllowListCleared() {
- _spec.ClearField(whatsapp.FieldGroupAllowList, field.TypeJSON)
- }
- if value, ok := wu.mutation.BlockList(); ok {
- _spec.SetField(whatsapp.FieldBlockList, field.TypeJSON, value)
- }
- if value, ok := wu.mutation.AppendedBlockList(); ok {
- _spec.AddModifier(func(u *sql.UpdateBuilder) {
- sqljson.Append(u, whatsapp.FieldBlockList, value)
- })
- }
- if wu.mutation.BlockListCleared() {
- _spec.ClearField(whatsapp.FieldBlockList, field.TypeJSON)
- }
- if value, ok := wu.mutation.GroupBlockList(); ok {
- _spec.SetField(whatsapp.FieldGroupBlockList, field.TypeJSON, value)
- }
- if value, ok := wu.mutation.AppendedGroupBlockList(); ok {
- _spec.AddModifier(func(u *sql.UpdateBuilder) {
- sqljson.Append(u, whatsapp.FieldGroupBlockList, value)
- })
- }
- if wu.mutation.GroupBlockListCleared() {
- _spec.ClearField(whatsapp.FieldGroupBlockList, field.TypeJSON)
- }
- if wu.mutation.AgentCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: whatsapp.AgentTable,
- Columns: []string{whatsapp.AgentColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(agent.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := wu.mutation.AgentIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: whatsapp.AgentTable,
- Columns: []string{whatsapp.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)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if n, err = sqlgraph.UpdateNodes(ctx, wu.driver, _spec); err != nil {
- if _, ok := err.(*sqlgraph.NotFoundError); ok {
- err = &NotFoundError{whatsapp.Label}
- } else if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return 0, err
- }
- wu.mutation.done = true
- return n, nil
- }
- // WhatsappUpdateOne is the builder for updating a single Whatsapp entity.
- type WhatsappUpdateOne struct {
- config
- fields []string
- hooks []Hook
- mutation *WhatsappMutation
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (wuo *WhatsappUpdateOne) SetUpdatedAt(t time.Time) *WhatsappUpdateOne {
- wuo.mutation.SetUpdatedAt(t)
- return wuo
- }
- // SetStatus sets the "status" field.
- func (wuo *WhatsappUpdateOne) SetStatus(u uint8) *WhatsappUpdateOne {
- wuo.mutation.ResetStatus()
- wuo.mutation.SetStatus(u)
- return wuo
- }
- // SetNillableStatus sets the "status" field if the given value is not nil.
- func (wuo *WhatsappUpdateOne) SetNillableStatus(u *uint8) *WhatsappUpdateOne {
- if u != nil {
- wuo.SetStatus(*u)
- }
- return wuo
- }
- // AddStatus adds u to the "status" field.
- func (wuo *WhatsappUpdateOne) AddStatus(u int8) *WhatsappUpdateOne {
- wuo.mutation.AddStatus(u)
- return wuo
- }
- // ClearStatus clears the value of the "status" field.
- func (wuo *WhatsappUpdateOne) ClearStatus() *WhatsappUpdateOne {
- wuo.mutation.ClearStatus()
- return wuo
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (wuo *WhatsappUpdateOne) SetDeletedAt(t time.Time) *WhatsappUpdateOne {
- wuo.mutation.SetDeletedAt(t)
- return wuo
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (wuo *WhatsappUpdateOne) SetNillableDeletedAt(t *time.Time) *WhatsappUpdateOne {
- if t != nil {
- wuo.SetDeletedAt(*t)
- }
- return wuo
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (wuo *WhatsappUpdateOne) ClearDeletedAt() *WhatsappUpdateOne {
- wuo.mutation.ClearDeletedAt()
- return wuo
- }
- // SetWaID sets the "wa_id" field.
- func (wuo *WhatsappUpdateOne) SetWaID(s string) *WhatsappUpdateOne {
- wuo.mutation.SetWaID(s)
- return wuo
- }
- // SetNillableWaID sets the "wa_id" field if the given value is not nil.
- func (wuo *WhatsappUpdateOne) SetNillableWaID(s *string) *WhatsappUpdateOne {
- if s != nil {
- wuo.SetWaID(*s)
- }
- return wuo
- }
- // ClearWaID clears the value of the "wa_id" field.
- func (wuo *WhatsappUpdateOne) ClearWaID() *WhatsappUpdateOne {
- wuo.mutation.ClearWaID()
- return wuo
- }
- // SetWaName sets the "wa_name" field.
- func (wuo *WhatsappUpdateOne) SetWaName(s string) *WhatsappUpdateOne {
- wuo.mutation.SetWaName(s)
- return wuo
- }
- // SetNillableWaName sets the "wa_name" field if the given value is not nil.
- func (wuo *WhatsappUpdateOne) SetNillableWaName(s *string) *WhatsappUpdateOne {
- if s != nil {
- wuo.SetWaName(*s)
- }
- return wuo
- }
- // ClearWaName clears the value of the "wa_name" field.
- func (wuo *WhatsappUpdateOne) ClearWaName() *WhatsappUpdateOne {
- wuo.mutation.ClearWaName()
- return wuo
- }
- // SetCallback sets the "callback" field.
- func (wuo *WhatsappUpdateOne) SetCallback(s string) *WhatsappUpdateOne {
- wuo.mutation.SetCallback(s)
- return wuo
- }
- // SetNillableCallback sets the "callback" field if the given value is not nil.
- func (wuo *WhatsappUpdateOne) SetNillableCallback(s *string) *WhatsappUpdateOne {
- if s != nil {
- wuo.SetCallback(*s)
- }
- return wuo
- }
- // ClearCallback clears the value of the "callback" field.
- func (wuo *WhatsappUpdateOne) ClearCallback() *WhatsappUpdateOne {
- wuo.mutation.ClearCallback()
- return wuo
- }
- // SetAgentID sets the "agent_id" field.
- func (wuo *WhatsappUpdateOne) SetAgentID(u uint64) *WhatsappUpdateOne {
- wuo.mutation.SetAgentID(u)
- return wuo
- }
- // SetNillableAgentID sets the "agent_id" field if the given value is not nil.
- func (wuo *WhatsappUpdateOne) SetNillableAgentID(u *uint64) *WhatsappUpdateOne {
- if u != nil {
- wuo.SetAgentID(*u)
- }
- return wuo
- }
- // SetAccount sets the "account" field.
- func (wuo *WhatsappUpdateOne) SetAccount(s string) *WhatsappUpdateOne {
- wuo.mutation.SetAccount(s)
- return wuo
- }
- // SetNillableAccount sets the "account" field if the given value is not nil.
- func (wuo *WhatsappUpdateOne) SetNillableAccount(s *string) *WhatsappUpdateOne {
- if s != nil {
- wuo.SetAccount(*s)
- }
- return wuo
- }
- // ClearAccount clears the value of the "account" field.
- func (wuo *WhatsappUpdateOne) ClearAccount() *WhatsappUpdateOne {
- wuo.mutation.ClearAccount()
- return wuo
- }
- // SetCc sets the "cc" field.
- func (wuo *WhatsappUpdateOne) SetCc(s string) *WhatsappUpdateOne {
- wuo.mutation.SetCc(s)
- return wuo
- }
- // SetNillableCc sets the "cc" field if the given value is not nil.
- func (wuo *WhatsappUpdateOne) SetNillableCc(s *string) *WhatsappUpdateOne {
- if s != nil {
- wuo.SetCc(*s)
- }
- return wuo
- }
- // SetPhone sets the "phone" field.
- func (wuo *WhatsappUpdateOne) SetPhone(s string) *WhatsappUpdateOne {
- wuo.mutation.SetPhone(s)
- return wuo
- }
- // SetNillablePhone sets the "phone" field if the given value is not nil.
- func (wuo *WhatsappUpdateOne) SetNillablePhone(s *string) *WhatsappUpdateOne {
- if s != nil {
- wuo.SetPhone(*s)
- }
- return wuo
- }
- // SetCcPhone sets the "cc_phone" field.
- func (wuo *WhatsappUpdateOne) SetCcPhone(s string) *WhatsappUpdateOne {
- wuo.mutation.SetCcPhone(s)
- return wuo
- }
- // SetNillableCcPhone sets the "cc_phone" field if the given value is not nil.
- func (wuo *WhatsappUpdateOne) SetNillableCcPhone(s *string) *WhatsappUpdateOne {
- if s != nil {
- wuo.SetCcPhone(*s)
- }
- return wuo
- }
- // SetPhoneName sets the "phone_name" field.
- func (wuo *WhatsappUpdateOne) SetPhoneName(s string) *WhatsappUpdateOne {
- wuo.mutation.SetPhoneName(s)
- return wuo
- }
- // SetNillablePhoneName sets the "phone_name" field if the given value is not nil.
- func (wuo *WhatsappUpdateOne) SetNillablePhoneName(s *string) *WhatsappUpdateOne {
- if s != nil {
- wuo.SetPhoneName(*s)
- }
- return wuo
- }
- // SetPhoneStatus sets the "phone_status" field.
- func (wuo *WhatsappUpdateOne) SetPhoneStatus(i int8) *WhatsappUpdateOne {
- wuo.mutation.ResetPhoneStatus()
- wuo.mutation.SetPhoneStatus(i)
- return wuo
- }
- // SetNillablePhoneStatus sets the "phone_status" field if the given value is not nil.
- func (wuo *WhatsappUpdateOne) SetNillablePhoneStatus(i *int8) *WhatsappUpdateOne {
- if i != nil {
- wuo.SetPhoneStatus(*i)
- }
- return wuo
- }
- // AddPhoneStatus adds i to the "phone_status" field.
- func (wuo *WhatsappUpdateOne) AddPhoneStatus(i int8) *WhatsappUpdateOne {
- wuo.mutation.AddPhoneStatus(i)
- return wuo
- }
- // SetOrganizationID sets the "organization_id" field.
- func (wuo *WhatsappUpdateOne) SetOrganizationID(u uint64) *WhatsappUpdateOne {
- wuo.mutation.ResetOrganizationID()
- wuo.mutation.SetOrganizationID(u)
- return wuo
- }
- // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
- func (wuo *WhatsappUpdateOne) SetNillableOrganizationID(u *uint64) *WhatsappUpdateOne {
- if u != nil {
- wuo.SetOrganizationID(*u)
- }
- return wuo
- }
- // AddOrganizationID adds u to the "organization_id" field.
- func (wuo *WhatsappUpdateOne) AddOrganizationID(u int64) *WhatsappUpdateOne {
- wuo.mutation.AddOrganizationID(u)
- return wuo
- }
- // ClearOrganizationID clears the value of the "organization_id" field.
- func (wuo *WhatsappUpdateOne) ClearOrganizationID() *WhatsappUpdateOne {
- wuo.mutation.ClearOrganizationID()
- return wuo
- }
- // SetAPIBase sets the "api_base" field.
- func (wuo *WhatsappUpdateOne) SetAPIBase(s string) *WhatsappUpdateOne {
- wuo.mutation.SetAPIBase(s)
- return wuo
- }
- // SetNillableAPIBase sets the "api_base" field if the given value is not nil.
- func (wuo *WhatsappUpdateOne) SetNillableAPIBase(s *string) *WhatsappUpdateOne {
- if s != nil {
- wuo.SetAPIBase(*s)
- }
- return wuo
- }
- // ClearAPIBase clears the value of the "api_base" field.
- func (wuo *WhatsappUpdateOne) ClearAPIBase() *WhatsappUpdateOne {
- wuo.mutation.ClearAPIBase()
- return wuo
- }
- // SetAPIKey sets the "api_key" field.
- func (wuo *WhatsappUpdateOne) SetAPIKey(s string) *WhatsappUpdateOne {
- wuo.mutation.SetAPIKey(s)
- return wuo
- }
- // SetNillableAPIKey sets the "api_key" field if the given value is not nil.
- func (wuo *WhatsappUpdateOne) SetNillableAPIKey(s *string) *WhatsappUpdateOne {
- if s != nil {
- wuo.SetAPIKey(*s)
- }
- return wuo
- }
- // ClearAPIKey clears the value of the "api_key" field.
- func (wuo *WhatsappUpdateOne) ClearAPIKey() *WhatsappUpdateOne {
- wuo.mutation.ClearAPIKey()
- return wuo
- }
- // SetAllowList sets the "allow_list" field.
- func (wuo *WhatsappUpdateOne) SetAllowList(s []string) *WhatsappUpdateOne {
- wuo.mutation.SetAllowList(s)
- return wuo
- }
- // AppendAllowList appends s to the "allow_list" field.
- func (wuo *WhatsappUpdateOne) AppendAllowList(s []string) *WhatsappUpdateOne {
- wuo.mutation.AppendAllowList(s)
- return wuo
- }
- // ClearAllowList clears the value of the "allow_list" field.
- func (wuo *WhatsappUpdateOne) ClearAllowList() *WhatsappUpdateOne {
- wuo.mutation.ClearAllowList()
- return wuo
- }
- // SetGroupAllowList sets the "group_allow_list" field.
- func (wuo *WhatsappUpdateOne) SetGroupAllowList(s []string) *WhatsappUpdateOne {
- wuo.mutation.SetGroupAllowList(s)
- return wuo
- }
- // AppendGroupAllowList appends s to the "group_allow_list" field.
- func (wuo *WhatsappUpdateOne) AppendGroupAllowList(s []string) *WhatsappUpdateOne {
- wuo.mutation.AppendGroupAllowList(s)
- return wuo
- }
- // ClearGroupAllowList clears the value of the "group_allow_list" field.
- func (wuo *WhatsappUpdateOne) ClearGroupAllowList() *WhatsappUpdateOne {
- wuo.mutation.ClearGroupAllowList()
- return wuo
- }
- // SetBlockList sets the "block_list" field.
- func (wuo *WhatsappUpdateOne) SetBlockList(s []string) *WhatsappUpdateOne {
- wuo.mutation.SetBlockList(s)
- return wuo
- }
- // AppendBlockList appends s to the "block_list" field.
- func (wuo *WhatsappUpdateOne) AppendBlockList(s []string) *WhatsappUpdateOne {
- wuo.mutation.AppendBlockList(s)
- return wuo
- }
- // ClearBlockList clears the value of the "block_list" field.
- func (wuo *WhatsappUpdateOne) ClearBlockList() *WhatsappUpdateOne {
- wuo.mutation.ClearBlockList()
- return wuo
- }
- // SetGroupBlockList sets the "group_block_list" field.
- func (wuo *WhatsappUpdateOne) SetGroupBlockList(s []string) *WhatsappUpdateOne {
- wuo.mutation.SetGroupBlockList(s)
- return wuo
- }
- // AppendGroupBlockList appends s to the "group_block_list" field.
- func (wuo *WhatsappUpdateOne) AppendGroupBlockList(s []string) *WhatsappUpdateOne {
- wuo.mutation.AppendGroupBlockList(s)
- return wuo
- }
- // ClearGroupBlockList clears the value of the "group_block_list" field.
- func (wuo *WhatsappUpdateOne) ClearGroupBlockList() *WhatsappUpdateOne {
- wuo.mutation.ClearGroupBlockList()
- return wuo
- }
- // SetAgent sets the "agent" edge to the Agent entity.
- func (wuo *WhatsappUpdateOne) SetAgent(a *Agent) *WhatsappUpdateOne {
- return wuo.SetAgentID(a.ID)
- }
- // Mutation returns the WhatsappMutation object of the builder.
- func (wuo *WhatsappUpdateOne) Mutation() *WhatsappMutation {
- return wuo.mutation
- }
- // ClearAgent clears the "agent" edge to the Agent entity.
- func (wuo *WhatsappUpdateOne) ClearAgent() *WhatsappUpdateOne {
- wuo.mutation.ClearAgent()
- return wuo
- }
- // Where appends a list predicates to the WhatsappUpdate builder.
- func (wuo *WhatsappUpdateOne) Where(ps ...predicate.Whatsapp) *WhatsappUpdateOne {
- wuo.mutation.Where(ps...)
- return wuo
- }
- // Select allows selecting one or more fields (columns) of the returned entity.
- // The default is selecting all fields defined in the entity schema.
- func (wuo *WhatsappUpdateOne) Select(field string, fields ...string) *WhatsappUpdateOne {
- wuo.fields = append([]string{field}, fields...)
- return wuo
- }
- // Save executes the query and returns the updated Whatsapp entity.
- func (wuo *WhatsappUpdateOne) Save(ctx context.Context) (*Whatsapp, error) {
- if err := wuo.defaults(); err != nil {
- return nil, err
- }
- return withHooks(ctx, wuo.sqlSave, wuo.mutation, wuo.hooks)
- }
- // SaveX is like Save, but panics if an error occurs.
- func (wuo *WhatsappUpdateOne) SaveX(ctx context.Context) *Whatsapp {
- node, err := wuo.Save(ctx)
- if err != nil {
- panic(err)
- }
- return node
- }
- // Exec executes the query on the entity.
- func (wuo *WhatsappUpdateOne) Exec(ctx context.Context) error {
- _, err := wuo.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (wuo *WhatsappUpdateOne) ExecX(ctx context.Context) {
- if err := wuo.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (wuo *WhatsappUpdateOne) defaults() error {
- if _, ok := wuo.mutation.UpdatedAt(); !ok {
- if whatsapp.UpdateDefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized whatsapp.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := whatsapp.UpdateDefaultUpdatedAt()
- wuo.mutation.SetUpdatedAt(v)
- }
- return nil
- }
- // check runs all checks and user-defined validators on the builder.
- func (wuo *WhatsappUpdateOne) check() error {
- if _, ok := wuo.mutation.AgentID(); wuo.mutation.AgentCleared() && !ok {
- return errors.New(`ent: clearing a required unique edge "Whatsapp.agent"`)
- }
- return nil
- }
- func (wuo *WhatsappUpdateOne) sqlSave(ctx context.Context) (_node *Whatsapp, err error) {
- if err := wuo.check(); err != nil {
- return _node, err
- }
- _spec := sqlgraph.NewUpdateSpec(whatsapp.Table, whatsapp.Columns, sqlgraph.NewFieldSpec(whatsapp.FieldID, field.TypeUint64))
- id, ok := wuo.mutation.ID()
- if !ok {
- return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Whatsapp.id" for update`)}
- }
- _spec.Node.ID.Value = id
- if fields := wuo.fields; len(fields) > 0 {
- _spec.Node.Columns = make([]string, 0, len(fields))
- _spec.Node.Columns = append(_spec.Node.Columns, whatsapp.FieldID)
- for _, f := range fields {
- if !whatsapp.ValidColumn(f) {
- return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
- }
- if f != whatsapp.FieldID {
- _spec.Node.Columns = append(_spec.Node.Columns, f)
- }
- }
- }
- if ps := wuo.mutation.predicates; len(ps) > 0 {
- _spec.Predicate = func(selector *sql.Selector) {
- for i := range ps {
- ps[i](selector)
- }
- }
- }
- if value, ok := wuo.mutation.UpdatedAt(); ok {
- _spec.SetField(whatsapp.FieldUpdatedAt, field.TypeTime, value)
- }
- if value, ok := wuo.mutation.Status(); ok {
- _spec.SetField(whatsapp.FieldStatus, field.TypeUint8, value)
- }
- if value, ok := wuo.mutation.AddedStatus(); ok {
- _spec.AddField(whatsapp.FieldStatus, field.TypeUint8, value)
- }
- if wuo.mutation.StatusCleared() {
- _spec.ClearField(whatsapp.FieldStatus, field.TypeUint8)
- }
- if value, ok := wuo.mutation.DeletedAt(); ok {
- _spec.SetField(whatsapp.FieldDeletedAt, field.TypeTime, value)
- }
- if wuo.mutation.DeletedAtCleared() {
- _spec.ClearField(whatsapp.FieldDeletedAt, field.TypeTime)
- }
- if value, ok := wuo.mutation.WaID(); ok {
- _spec.SetField(whatsapp.FieldWaID, field.TypeString, value)
- }
- if wuo.mutation.WaIDCleared() {
- _spec.ClearField(whatsapp.FieldWaID, field.TypeString)
- }
- if value, ok := wuo.mutation.WaName(); ok {
- _spec.SetField(whatsapp.FieldWaName, field.TypeString, value)
- }
- if wuo.mutation.WaNameCleared() {
- _spec.ClearField(whatsapp.FieldWaName, field.TypeString)
- }
- if value, ok := wuo.mutation.Callback(); ok {
- _spec.SetField(whatsapp.FieldCallback, field.TypeString, value)
- }
- if wuo.mutation.CallbackCleared() {
- _spec.ClearField(whatsapp.FieldCallback, field.TypeString)
- }
- if value, ok := wuo.mutation.Account(); ok {
- _spec.SetField(whatsapp.FieldAccount, field.TypeString, value)
- }
- if wuo.mutation.AccountCleared() {
- _spec.ClearField(whatsapp.FieldAccount, field.TypeString)
- }
- if value, ok := wuo.mutation.Cc(); ok {
- _spec.SetField(whatsapp.FieldCc, field.TypeString, value)
- }
- if value, ok := wuo.mutation.Phone(); ok {
- _spec.SetField(whatsapp.FieldPhone, field.TypeString, value)
- }
- if value, ok := wuo.mutation.CcPhone(); ok {
- _spec.SetField(whatsapp.FieldCcPhone, field.TypeString, value)
- }
- if value, ok := wuo.mutation.PhoneName(); ok {
- _spec.SetField(whatsapp.FieldPhoneName, field.TypeString, value)
- }
- if value, ok := wuo.mutation.PhoneStatus(); ok {
- _spec.SetField(whatsapp.FieldPhoneStatus, field.TypeInt8, value)
- }
- if value, ok := wuo.mutation.AddedPhoneStatus(); ok {
- _spec.AddField(whatsapp.FieldPhoneStatus, field.TypeInt8, value)
- }
- if value, ok := wuo.mutation.OrganizationID(); ok {
- _spec.SetField(whatsapp.FieldOrganizationID, field.TypeUint64, value)
- }
- if value, ok := wuo.mutation.AddedOrganizationID(); ok {
- _spec.AddField(whatsapp.FieldOrganizationID, field.TypeUint64, value)
- }
- if wuo.mutation.OrganizationIDCleared() {
- _spec.ClearField(whatsapp.FieldOrganizationID, field.TypeUint64)
- }
- if value, ok := wuo.mutation.APIBase(); ok {
- _spec.SetField(whatsapp.FieldAPIBase, field.TypeString, value)
- }
- if wuo.mutation.APIBaseCleared() {
- _spec.ClearField(whatsapp.FieldAPIBase, field.TypeString)
- }
- if value, ok := wuo.mutation.APIKey(); ok {
- _spec.SetField(whatsapp.FieldAPIKey, field.TypeString, value)
- }
- if wuo.mutation.APIKeyCleared() {
- _spec.ClearField(whatsapp.FieldAPIKey, field.TypeString)
- }
- if value, ok := wuo.mutation.AllowList(); ok {
- _spec.SetField(whatsapp.FieldAllowList, field.TypeJSON, value)
- }
- if value, ok := wuo.mutation.AppendedAllowList(); ok {
- _spec.AddModifier(func(u *sql.UpdateBuilder) {
- sqljson.Append(u, whatsapp.FieldAllowList, value)
- })
- }
- if wuo.mutation.AllowListCleared() {
- _spec.ClearField(whatsapp.FieldAllowList, field.TypeJSON)
- }
- if value, ok := wuo.mutation.GroupAllowList(); ok {
- _spec.SetField(whatsapp.FieldGroupAllowList, field.TypeJSON, value)
- }
- if value, ok := wuo.mutation.AppendedGroupAllowList(); ok {
- _spec.AddModifier(func(u *sql.UpdateBuilder) {
- sqljson.Append(u, whatsapp.FieldGroupAllowList, value)
- })
- }
- if wuo.mutation.GroupAllowListCleared() {
- _spec.ClearField(whatsapp.FieldGroupAllowList, field.TypeJSON)
- }
- if value, ok := wuo.mutation.BlockList(); ok {
- _spec.SetField(whatsapp.FieldBlockList, field.TypeJSON, value)
- }
- if value, ok := wuo.mutation.AppendedBlockList(); ok {
- _spec.AddModifier(func(u *sql.UpdateBuilder) {
- sqljson.Append(u, whatsapp.FieldBlockList, value)
- })
- }
- if wuo.mutation.BlockListCleared() {
- _spec.ClearField(whatsapp.FieldBlockList, field.TypeJSON)
- }
- if value, ok := wuo.mutation.GroupBlockList(); ok {
- _spec.SetField(whatsapp.FieldGroupBlockList, field.TypeJSON, value)
- }
- if value, ok := wuo.mutation.AppendedGroupBlockList(); ok {
- _spec.AddModifier(func(u *sql.UpdateBuilder) {
- sqljson.Append(u, whatsapp.FieldGroupBlockList, value)
- })
- }
- if wuo.mutation.GroupBlockListCleared() {
- _spec.ClearField(whatsapp.FieldGroupBlockList, field.TypeJSON)
- }
- if wuo.mutation.AgentCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: whatsapp.AgentTable,
- Columns: []string{whatsapp.AgentColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(agent.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := wuo.mutation.AgentIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.M2O,
- Inverse: true,
- Table: whatsapp.AgentTable,
- Columns: []string{whatsapp.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)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- _node = &Whatsapp{config: wuo.config}
- _spec.Assign = _node.assignValues
- _spec.ScanValues = _node.scanValues
- if err = sqlgraph.UpdateNode(ctx, wuo.driver, _spec); err != nil {
- if _, ok := err.(*sqlgraph.NotFoundError); ok {
- err = &NotFoundError{whatsapp.Label}
- } else if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return nil, err
- }
- wuo.mutation.done = true
- return _node, nil
- }
|