123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "context"
- "errors"
- "fmt"
- "time"
- "wechat-api/ent/contact"
- "wechat-api/ent/labelrelationship"
- "wechat-api/ent/messagerecords"
- "wechat-api/ent/predicate"
- "entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
- "entgo.io/ent/schema/field"
- )
- // ContactUpdate is the builder for updating Contact entities.
- type ContactUpdate struct {
- config
- hooks []Hook
- mutation *ContactMutation
- }
- // Where appends a list predicates to the ContactUpdate builder.
- func (cu *ContactUpdate) Where(ps ...predicate.Contact) *ContactUpdate {
- cu.mutation.Where(ps...)
- return cu
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (cu *ContactUpdate) SetUpdatedAt(t time.Time) *ContactUpdate {
- cu.mutation.SetUpdatedAt(t)
- return cu
- }
- // SetStatus sets the "status" field.
- func (cu *ContactUpdate) SetStatus(u uint8) *ContactUpdate {
- cu.mutation.ResetStatus()
- cu.mutation.SetStatus(u)
- return cu
- }
- // SetNillableStatus sets the "status" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableStatus(u *uint8) *ContactUpdate {
- if u != nil {
- cu.SetStatus(*u)
- }
- return cu
- }
- // AddStatus adds u to the "status" field.
- func (cu *ContactUpdate) AddStatus(u int8) *ContactUpdate {
- cu.mutation.AddStatus(u)
- return cu
- }
- // ClearStatus clears the value of the "status" field.
- func (cu *ContactUpdate) ClearStatus() *ContactUpdate {
- cu.mutation.ClearStatus()
- return cu
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (cu *ContactUpdate) SetDeletedAt(t time.Time) *ContactUpdate {
- cu.mutation.SetDeletedAt(t)
- return cu
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableDeletedAt(t *time.Time) *ContactUpdate {
- if t != nil {
- cu.SetDeletedAt(*t)
- }
- return cu
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (cu *ContactUpdate) ClearDeletedAt() *ContactUpdate {
- cu.mutation.ClearDeletedAt()
- return cu
- }
- // SetWxWxid sets the "wx_wxid" field.
- func (cu *ContactUpdate) SetWxWxid(s string) *ContactUpdate {
- cu.mutation.SetWxWxid(s)
- return cu
- }
- // SetNillableWxWxid sets the "wx_wxid" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableWxWxid(s *string) *ContactUpdate {
- if s != nil {
- cu.SetWxWxid(*s)
- }
- return cu
- }
- // SetType sets the "type" field.
- func (cu *ContactUpdate) SetType(i int) *ContactUpdate {
- cu.mutation.ResetType()
- cu.mutation.SetType(i)
- return cu
- }
- // SetNillableType sets the "type" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableType(i *int) *ContactUpdate {
- if i != nil {
- cu.SetType(*i)
- }
- return cu
- }
- // AddType adds i to the "type" field.
- func (cu *ContactUpdate) AddType(i int) *ContactUpdate {
- cu.mutation.AddType(i)
- return cu
- }
- // ClearType clears the value of the "type" field.
- func (cu *ContactUpdate) ClearType() *ContactUpdate {
- cu.mutation.ClearType()
- return cu
- }
- // SetWxid sets the "wxid" field.
- func (cu *ContactUpdate) SetWxid(s string) *ContactUpdate {
- cu.mutation.SetWxid(s)
- return cu
- }
- // SetNillableWxid sets the "wxid" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableWxid(s *string) *ContactUpdate {
- if s != nil {
- cu.SetWxid(*s)
- }
- return cu
- }
- // SetAccount sets the "account" field.
- func (cu *ContactUpdate) SetAccount(s string) *ContactUpdate {
- cu.mutation.SetAccount(s)
- return cu
- }
- // SetNillableAccount sets the "account" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableAccount(s *string) *ContactUpdate {
- if s != nil {
- cu.SetAccount(*s)
- }
- return cu
- }
- // SetNickname sets the "nickname" field.
- func (cu *ContactUpdate) SetNickname(s string) *ContactUpdate {
- cu.mutation.SetNickname(s)
- return cu
- }
- // SetNillableNickname sets the "nickname" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableNickname(s *string) *ContactUpdate {
- if s != nil {
- cu.SetNickname(*s)
- }
- return cu
- }
- // SetMarkname sets the "markname" field.
- func (cu *ContactUpdate) SetMarkname(s string) *ContactUpdate {
- cu.mutation.SetMarkname(s)
- return cu
- }
- // SetNillableMarkname sets the "markname" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableMarkname(s *string) *ContactUpdate {
- if s != nil {
- cu.SetMarkname(*s)
- }
- return cu
- }
- // SetHeadimg sets the "headimg" field.
- func (cu *ContactUpdate) SetHeadimg(s string) *ContactUpdate {
- cu.mutation.SetHeadimg(s)
- return cu
- }
- // SetNillableHeadimg sets the "headimg" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableHeadimg(s *string) *ContactUpdate {
- if s != nil {
- cu.SetHeadimg(*s)
- }
- return cu
- }
- // SetSex sets the "sex" field.
- func (cu *ContactUpdate) SetSex(i int) *ContactUpdate {
- cu.mutation.ResetSex()
- cu.mutation.SetSex(i)
- return cu
- }
- // SetNillableSex sets the "sex" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableSex(i *int) *ContactUpdate {
- if i != nil {
- cu.SetSex(*i)
- }
- return cu
- }
- // AddSex adds i to the "sex" field.
- func (cu *ContactUpdate) AddSex(i int) *ContactUpdate {
- cu.mutation.AddSex(i)
- return cu
- }
- // SetStarrole sets the "starrole" field.
- func (cu *ContactUpdate) SetStarrole(s string) *ContactUpdate {
- cu.mutation.SetStarrole(s)
- return cu
- }
- // SetNillableStarrole sets the "starrole" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableStarrole(s *string) *ContactUpdate {
- if s != nil {
- cu.SetStarrole(*s)
- }
- return cu
- }
- // SetDontseeit sets the "dontseeit" field.
- func (cu *ContactUpdate) SetDontseeit(i int) *ContactUpdate {
- cu.mutation.ResetDontseeit()
- cu.mutation.SetDontseeit(i)
- return cu
- }
- // SetNillableDontseeit sets the "dontseeit" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableDontseeit(i *int) *ContactUpdate {
- if i != nil {
- cu.SetDontseeit(*i)
- }
- return cu
- }
- // AddDontseeit adds i to the "dontseeit" field.
- func (cu *ContactUpdate) AddDontseeit(i int) *ContactUpdate {
- cu.mutation.AddDontseeit(i)
- return cu
- }
- // SetDontseeme sets the "dontseeme" field.
- func (cu *ContactUpdate) SetDontseeme(i int) *ContactUpdate {
- cu.mutation.ResetDontseeme()
- cu.mutation.SetDontseeme(i)
- return cu
- }
- // SetNillableDontseeme sets the "dontseeme" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableDontseeme(i *int) *ContactUpdate {
- if i != nil {
- cu.SetDontseeme(*i)
- }
- return cu
- }
- // AddDontseeme adds i to the "dontseeme" field.
- func (cu *ContactUpdate) AddDontseeme(i int) *ContactUpdate {
- cu.mutation.AddDontseeme(i)
- return cu
- }
- // SetLag sets the "lag" field.
- func (cu *ContactUpdate) SetLag(s string) *ContactUpdate {
- cu.mutation.SetLag(s)
- return cu
- }
- // SetNillableLag sets the "lag" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableLag(s *string) *ContactUpdate {
- if s != nil {
- cu.SetLag(*s)
- }
- return cu
- }
- // SetGid sets the "gid" field.
- func (cu *ContactUpdate) SetGid(s string) *ContactUpdate {
- cu.mutation.SetGid(s)
- return cu
- }
- // SetNillableGid sets the "gid" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableGid(s *string) *ContactUpdate {
- if s != nil {
- cu.SetGid(*s)
- }
- return cu
- }
- // SetGname sets the "gname" field.
- func (cu *ContactUpdate) SetGname(s string) *ContactUpdate {
- cu.mutation.SetGname(s)
- return cu
- }
- // SetNillableGname sets the "gname" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableGname(s *string) *ContactUpdate {
- if s != nil {
- cu.SetGname(*s)
- }
- return cu
- }
- // SetV3 sets the "v3" field.
- func (cu *ContactUpdate) SetV3(s string) *ContactUpdate {
- cu.mutation.SetV3(s)
- return cu
- }
- // SetNillableV3 sets the "v3" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableV3(s *string) *ContactUpdate {
- if s != nil {
- cu.SetV3(*s)
- }
- return cu
- }
- // SetOrganizationID sets the "organization_id" field.
- func (cu *ContactUpdate) SetOrganizationID(u uint64) *ContactUpdate {
- cu.mutation.ResetOrganizationID()
- cu.mutation.SetOrganizationID(u)
- return cu
- }
- // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableOrganizationID(u *uint64) *ContactUpdate {
- if u != nil {
- cu.SetOrganizationID(*u)
- }
- return cu
- }
- // AddOrganizationID adds u to the "organization_id" field.
- func (cu *ContactUpdate) AddOrganizationID(u int64) *ContactUpdate {
- cu.mutation.AddOrganizationID(u)
- return cu
- }
- // ClearOrganizationID clears the value of the "organization_id" field.
- func (cu *ContactUpdate) ClearOrganizationID() *ContactUpdate {
- cu.mutation.ClearOrganizationID()
- return cu
- }
- // SetCtype sets the "ctype" field.
- func (cu *ContactUpdate) SetCtype(u uint64) *ContactUpdate {
- cu.mutation.ResetCtype()
- cu.mutation.SetCtype(u)
- return cu
- }
- // SetNillableCtype sets the "ctype" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableCtype(u *uint64) *ContactUpdate {
- if u != nil {
- cu.SetCtype(*u)
- }
- return cu
- }
- // AddCtype adds u to the "ctype" field.
- func (cu *ContactUpdate) AddCtype(u int64) *ContactUpdate {
- cu.mutation.AddCtype(u)
- return cu
- }
- // SetCage sets the "cage" field.
- func (cu *ContactUpdate) SetCage(i int) *ContactUpdate {
- cu.mutation.ResetCage()
- cu.mutation.SetCage(i)
- return cu
- }
- // SetNillableCage sets the "cage" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableCage(i *int) *ContactUpdate {
- if i != nil {
- cu.SetCage(*i)
- }
- return cu
- }
- // AddCage adds i to the "cage" field.
- func (cu *ContactUpdate) AddCage(i int) *ContactUpdate {
- cu.mutation.AddCage(i)
- return cu
- }
- // SetCname sets the "cname" field.
- func (cu *ContactUpdate) SetCname(s string) *ContactUpdate {
- cu.mutation.SetCname(s)
- return cu
- }
- // SetNillableCname sets the "cname" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableCname(s *string) *ContactUpdate {
- if s != nil {
- cu.SetCname(*s)
- }
- return cu
- }
- // SetCarea sets the "carea" field.
- func (cu *ContactUpdate) SetCarea(s string) *ContactUpdate {
- cu.mutation.SetCarea(s)
- return cu
- }
- // SetNillableCarea sets the "carea" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableCarea(s *string) *ContactUpdate {
- if s != nil {
- cu.SetCarea(*s)
- }
- return cu
- }
- // SetCbirthday sets the "cbirthday" field.
- func (cu *ContactUpdate) SetCbirthday(s string) *ContactUpdate {
- cu.mutation.SetCbirthday(s)
- return cu
- }
- // SetNillableCbirthday sets the "cbirthday" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableCbirthday(s *string) *ContactUpdate {
- if s != nil {
- cu.SetCbirthday(*s)
- }
- return cu
- }
- // SetCbirtharea sets the "cbirtharea" field.
- func (cu *ContactUpdate) SetCbirtharea(s string) *ContactUpdate {
- cu.mutation.SetCbirtharea(s)
- return cu
- }
- // SetNillableCbirtharea sets the "cbirtharea" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableCbirtharea(s *string) *ContactUpdate {
- if s != nil {
- cu.SetCbirtharea(*s)
- }
- return cu
- }
- // SetCidcardNo sets the "cidcard_no" field.
- func (cu *ContactUpdate) SetCidcardNo(s string) *ContactUpdate {
- cu.mutation.SetCidcardNo(s)
- return cu
- }
- // SetNillableCidcardNo sets the "cidcard_no" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableCidcardNo(s *string) *ContactUpdate {
- if s != nil {
- cu.SetCidcardNo(*s)
- }
- return cu
- }
- // SetCtitle sets the "ctitle" field.
- func (cu *ContactUpdate) SetCtitle(s string) *ContactUpdate {
- cu.mutation.SetCtitle(s)
- return cu
- }
- // SetNillableCtitle sets the "ctitle" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableCtitle(s *string) *ContactUpdate {
- if s != nil {
- cu.SetCtitle(*s)
- }
- return cu
- }
- // SetCc sets the "cc" field.
- func (cu *ContactUpdate) SetCc(s string) *ContactUpdate {
- cu.mutation.SetCc(s)
- return cu
- }
- // SetNillableCc sets the "cc" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillableCc(s *string) *ContactUpdate {
- if s != nil {
- cu.SetCc(*s)
- }
- return cu
- }
- // SetPhone sets the "phone" field.
- func (cu *ContactUpdate) SetPhone(s string) *ContactUpdate {
- cu.mutation.SetPhone(s)
- return cu
- }
- // SetNillablePhone sets the "phone" field if the given value is not nil.
- func (cu *ContactUpdate) SetNillablePhone(s *string) *ContactUpdate {
- if s != nil {
- cu.SetPhone(*s)
- }
- return cu
- }
- // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by IDs.
- func (cu *ContactUpdate) AddContactRelationshipIDs(ids ...uint64) *ContactUpdate {
- cu.mutation.AddContactRelationshipIDs(ids...)
- return cu
- }
- // AddContactRelationships adds the "contact_relationships" edges to the LabelRelationship entity.
- func (cu *ContactUpdate) AddContactRelationships(l ...*LabelRelationship) *ContactUpdate {
- ids := make([]uint64, len(l))
- for i := range l {
- ids[i] = l[i].ID
- }
- return cu.AddContactRelationshipIDs(ids...)
- }
- // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by IDs.
- func (cu *ContactUpdate) AddContactMessageIDs(ids ...uint64) *ContactUpdate {
- cu.mutation.AddContactMessageIDs(ids...)
- return cu
- }
- // AddContactMessages adds the "contact_messages" edges to the MessageRecords entity.
- func (cu *ContactUpdate) AddContactMessages(m ...*MessageRecords) *ContactUpdate {
- ids := make([]uint64, len(m))
- for i := range m {
- ids[i] = m[i].ID
- }
- return cu.AddContactMessageIDs(ids...)
- }
- // Mutation returns the ContactMutation object of the builder.
- func (cu *ContactUpdate) Mutation() *ContactMutation {
- return cu.mutation
- }
- // ClearContactRelationships clears all "contact_relationships" edges to the LabelRelationship entity.
- func (cu *ContactUpdate) ClearContactRelationships() *ContactUpdate {
- cu.mutation.ClearContactRelationships()
- return cu
- }
- // RemoveContactRelationshipIDs removes the "contact_relationships" edge to LabelRelationship entities by IDs.
- func (cu *ContactUpdate) RemoveContactRelationshipIDs(ids ...uint64) *ContactUpdate {
- cu.mutation.RemoveContactRelationshipIDs(ids...)
- return cu
- }
- // RemoveContactRelationships removes "contact_relationships" edges to LabelRelationship entities.
- func (cu *ContactUpdate) RemoveContactRelationships(l ...*LabelRelationship) *ContactUpdate {
- ids := make([]uint64, len(l))
- for i := range l {
- ids[i] = l[i].ID
- }
- return cu.RemoveContactRelationshipIDs(ids...)
- }
- // ClearContactMessages clears all "contact_messages" edges to the MessageRecords entity.
- func (cu *ContactUpdate) ClearContactMessages() *ContactUpdate {
- cu.mutation.ClearContactMessages()
- return cu
- }
- // RemoveContactMessageIDs removes the "contact_messages" edge to MessageRecords entities by IDs.
- func (cu *ContactUpdate) RemoveContactMessageIDs(ids ...uint64) *ContactUpdate {
- cu.mutation.RemoveContactMessageIDs(ids...)
- return cu
- }
- // RemoveContactMessages removes "contact_messages" edges to MessageRecords entities.
- func (cu *ContactUpdate) RemoveContactMessages(m ...*MessageRecords) *ContactUpdate {
- ids := make([]uint64, len(m))
- for i := range m {
- ids[i] = m[i].ID
- }
- return cu.RemoveContactMessageIDs(ids...)
- }
- // Save executes the query and returns the number of nodes affected by the update operation.
- func (cu *ContactUpdate) Save(ctx context.Context) (int, error) {
- if err := cu.defaults(); err != nil {
- return 0, err
- }
- return withHooks(ctx, cu.sqlSave, cu.mutation, cu.hooks)
- }
- // SaveX is like Save, but panics if an error occurs.
- func (cu *ContactUpdate) SaveX(ctx context.Context) int {
- affected, err := cu.Save(ctx)
- if err != nil {
- panic(err)
- }
- return affected
- }
- // Exec executes the query.
- func (cu *ContactUpdate) Exec(ctx context.Context) error {
- _, err := cu.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (cu *ContactUpdate) ExecX(ctx context.Context) {
- if err := cu.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (cu *ContactUpdate) defaults() error {
- if _, ok := cu.mutation.UpdatedAt(); !ok {
- if contact.UpdateDefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized contact.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := contact.UpdateDefaultUpdatedAt()
- cu.mutation.SetUpdatedAt(v)
- }
- return nil
- }
- func (cu *ContactUpdate) sqlSave(ctx context.Context) (n int, err error) {
- _spec := sqlgraph.NewUpdateSpec(contact.Table, contact.Columns, sqlgraph.NewFieldSpec(contact.FieldID, field.TypeUint64))
- if ps := cu.mutation.predicates; len(ps) > 0 {
- _spec.Predicate = func(selector *sql.Selector) {
- for i := range ps {
- ps[i](selector)
- }
- }
- }
- if value, ok := cu.mutation.UpdatedAt(); ok {
- _spec.SetField(contact.FieldUpdatedAt, field.TypeTime, value)
- }
- if value, ok := cu.mutation.Status(); ok {
- _spec.SetField(contact.FieldStatus, field.TypeUint8, value)
- }
- if value, ok := cu.mutation.AddedStatus(); ok {
- _spec.AddField(contact.FieldStatus, field.TypeUint8, value)
- }
- if cu.mutation.StatusCleared() {
- _spec.ClearField(contact.FieldStatus, field.TypeUint8)
- }
- if value, ok := cu.mutation.DeletedAt(); ok {
- _spec.SetField(contact.FieldDeletedAt, field.TypeTime, value)
- }
- if cu.mutation.DeletedAtCleared() {
- _spec.ClearField(contact.FieldDeletedAt, field.TypeTime)
- }
- if value, ok := cu.mutation.WxWxid(); ok {
- _spec.SetField(contact.FieldWxWxid, field.TypeString, value)
- }
- if value, ok := cu.mutation.GetType(); ok {
- _spec.SetField(contact.FieldType, field.TypeInt, value)
- }
- if value, ok := cu.mutation.AddedType(); ok {
- _spec.AddField(contact.FieldType, field.TypeInt, value)
- }
- if cu.mutation.TypeCleared() {
- _spec.ClearField(contact.FieldType, field.TypeInt)
- }
- if value, ok := cu.mutation.Wxid(); ok {
- _spec.SetField(contact.FieldWxid, field.TypeString, value)
- }
- if value, ok := cu.mutation.Account(); ok {
- _spec.SetField(contact.FieldAccount, field.TypeString, value)
- }
- if value, ok := cu.mutation.Nickname(); ok {
- _spec.SetField(contact.FieldNickname, field.TypeString, value)
- }
- if value, ok := cu.mutation.Markname(); ok {
- _spec.SetField(contact.FieldMarkname, field.TypeString, value)
- }
- if value, ok := cu.mutation.Headimg(); ok {
- _spec.SetField(contact.FieldHeadimg, field.TypeString, value)
- }
- if value, ok := cu.mutation.Sex(); ok {
- _spec.SetField(contact.FieldSex, field.TypeInt, value)
- }
- if value, ok := cu.mutation.AddedSex(); ok {
- _spec.AddField(contact.FieldSex, field.TypeInt, value)
- }
- if value, ok := cu.mutation.Starrole(); ok {
- _spec.SetField(contact.FieldStarrole, field.TypeString, value)
- }
- if value, ok := cu.mutation.Dontseeit(); ok {
- _spec.SetField(contact.FieldDontseeit, field.TypeInt, value)
- }
- if value, ok := cu.mutation.AddedDontseeit(); ok {
- _spec.AddField(contact.FieldDontseeit, field.TypeInt, value)
- }
- if value, ok := cu.mutation.Dontseeme(); ok {
- _spec.SetField(contact.FieldDontseeme, field.TypeInt, value)
- }
- if value, ok := cu.mutation.AddedDontseeme(); ok {
- _spec.AddField(contact.FieldDontseeme, field.TypeInt, value)
- }
- if value, ok := cu.mutation.Lag(); ok {
- _spec.SetField(contact.FieldLag, field.TypeString, value)
- }
- if value, ok := cu.mutation.Gid(); ok {
- _spec.SetField(contact.FieldGid, field.TypeString, value)
- }
- if value, ok := cu.mutation.Gname(); ok {
- _spec.SetField(contact.FieldGname, field.TypeString, value)
- }
- if value, ok := cu.mutation.V3(); ok {
- _spec.SetField(contact.FieldV3, field.TypeString, value)
- }
- if value, ok := cu.mutation.OrganizationID(); ok {
- _spec.SetField(contact.FieldOrganizationID, field.TypeUint64, value)
- }
- if value, ok := cu.mutation.AddedOrganizationID(); ok {
- _spec.AddField(contact.FieldOrganizationID, field.TypeUint64, value)
- }
- if cu.mutation.OrganizationIDCleared() {
- _spec.ClearField(contact.FieldOrganizationID, field.TypeUint64)
- }
- if value, ok := cu.mutation.Ctype(); ok {
- _spec.SetField(contact.FieldCtype, field.TypeUint64, value)
- }
- if value, ok := cu.mutation.AddedCtype(); ok {
- _spec.AddField(contact.FieldCtype, field.TypeUint64, value)
- }
- if value, ok := cu.mutation.Cage(); ok {
- _spec.SetField(contact.FieldCage, field.TypeInt, value)
- }
- if value, ok := cu.mutation.AddedCage(); ok {
- _spec.AddField(contact.FieldCage, field.TypeInt, value)
- }
- if value, ok := cu.mutation.Cname(); ok {
- _spec.SetField(contact.FieldCname, field.TypeString, value)
- }
- if value, ok := cu.mutation.Carea(); ok {
- _spec.SetField(contact.FieldCarea, field.TypeString, value)
- }
- if value, ok := cu.mutation.Cbirthday(); ok {
- _spec.SetField(contact.FieldCbirthday, field.TypeString, value)
- }
- if value, ok := cu.mutation.Cbirtharea(); ok {
- _spec.SetField(contact.FieldCbirtharea, field.TypeString, value)
- }
- if value, ok := cu.mutation.CidcardNo(); ok {
- _spec.SetField(contact.FieldCidcardNo, field.TypeString, value)
- }
- if value, ok := cu.mutation.Ctitle(); ok {
- _spec.SetField(contact.FieldCtitle, field.TypeString, value)
- }
- if value, ok := cu.mutation.Cc(); ok {
- _spec.SetField(contact.FieldCc, field.TypeString, value)
- }
- if value, ok := cu.mutation.Phone(); ok {
- _spec.SetField(contact.FieldPhone, field.TypeString, value)
- }
- if cu.mutation.ContactRelationshipsCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: contact.ContactRelationshipsTable,
- Columns: []string{contact.ContactRelationshipsColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(labelrelationship.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := cu.mutation.RemovedContactRelationshipsIDs(); len(nodes) > 0 && !cu.mutation.ContactRelationshipsCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: contact.ContactRelationshipsTable,
- Columns: []string{contact.ContactRelationshipsColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(labelrelationship.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := cu.mutation.ContactRelationshipsIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: contact.ContactRelationshipsTable,
- Columns: []string{contact.ContactRelationshipsColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(labelrelationship.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if cu.mutation.ContactMessagesCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: contact.ContactMessagesTable,
- Columns: []string{contact.ContactMessagesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := cu.mutation.RemovedContactMessagesIDs(); len(nodes) > 0 && !cu.mutation.ContactMessagesCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: contact.ContactMessagesTable,
- Columns: []string{contact.ContactMessagesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := cu.mutation.ContactMessagesIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: contact.ContactMessagesTable,
- Columns: []string{contact.ContactMessagesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(messagerecords.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, cu.driver, _spec); err != nil {
- if _, ok := err.(*sqlgraph.NotFoundError); ok {
- err = &NotFoundError{contact.Label}
- } else if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return 0, err
- }
- cu.mutation.done = true
- return n, nil
- }
- // ContactUpdateOne is the builder for updating a single Contact entity.
- type ContactUpdateOne struct {
- config
- fields []string
- hooks []Hook
- mutation *ContactMutation
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (cuo *ContactUpdateOne) SetUpdatedAt(t time.Time) *ContactUpdateOne {
- cuo.mutation.SetUpdatedAt(t)
- return cuo
- }
- // SetStatus sets the "status" field.
- func (cuo *ContactUpdateOne) SetStatus(u uint8) *ContactUpdateOne {
- cuo.mutation.ResetStatus()
- cuo.mutation.SetStatus(u)
- return cuo
- }
- // SetNillableStatus sets the "status" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableStatus(u *uint8) *ContactUpdateOne {
- if u != nil {
- cuo.SetStatus(*u)
- }
- return cuo
- }
- // AddStatus adds u to the "status" field.
- func (cuo *ContactUpdateOne) AddStatus(u int8) *ContactUpdateOne {
- cuo.mutation.AddStatus(u)
- return cuo
- }
- // ClearStatus clears the value of the "status" field.
- func (cuo *ContactUpdateOne) ClearStatus() *ContactUpdateOne {
- cuo.mutation.ClearStatus()
- return cuo
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (cuo *ContactUpdateOne) SetDeletedAt(t time.Time) *ContactUpdateOne {
- cuo.mutation.SetDeletedAt(t)
- return cuo
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableDeletedAt(t *time.Time) *ContactUpdateOne {
- if t != nil {
- cuo.SetDeletedAt(*t)
- }
- return cuo
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (cuo *ContactUpdateOne) ClearDeletedAt() *ContactUpdateOne {
- cuo.mutation.ClearDeletedAt()
- return cuo
- }
- // SetWxWxid sets the "wx_wxid" field.
- func (cuo *ContactUpdateOne) SetWxWxid(s string) *ContactUpdateOne {
- cuo.mutation.SetWxWxid(s)
- return cuo
- }
- // SetNillableWxWxid sets the "wx_wxid" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableWxWxid(s *string) *ContactUpdateOne {
- if s != nil {
- cuo.SetWxWxid(*s)
- }
- return cuo
- }
- // SetType sets the "type" field.
- func (cuo *ContactUpdateOne) SetType(i int) *ContactUpdateOne {
- cuo.mutation.ResetType()
- cuo.mutation.SetType(i)
- return cuo
- }
- // SetNillableType sets the "type" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableType(i *int) *ContactUpdateOne {
- if i != nil {
- cuo.SetType(*i)
- }
- return cuo
- }
- // AddType adds i to the "type" field.
- func (cuo *ContactUpdateOne) AddType(i int) *ContactUpdateOne {
- cuo.mutation.AddType(i)
- return cuo
- }
- // ClearType clears the value of the "type" field.
- func (cuo *ContactUpdateOne) ClearType() *ContactUpdateOne {
- cuo.mutation.ClearType()
- return cuo
- }
- // SetWxid sets the "wxid" field.
- func (cuo *ContactUpdateOne) SetWxid(s string) *ContactUpdateOne {
- cuo.mutation.SetWxid(s)
- return cuo
- }
- // SetNillableWxid sets the "wxid" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableWxid(s *string) *ContactUpdateOne {
- if s != nil {
- cuo.SetWxid(*s)
- }
- return cuo
- }
- // SetAccount sets the "account" field.
- func (cuo *ContactUpdateOne) SetAccount(s string) *ContactUpdateOne {
- cuo.mutation.SetAccount(s)
- return cuo
- }
- // SetNillableAccount sets the "account" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableAccount(s *string) *ContactUpdateOne {
- if s != nil {
- cuo.SetAccount(*s)
- }
- return cuo
- }
- // SetNickname sets the "nickname" field.
- func (cuo *ContactUpdateOne) SetNickname(s string) *ContactUpdateOne {
- cuo.mutation.SetNickname(s)
- return cuo
- }
- // SetNillableNickname sets the "nickname" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableNickname(s *string) *ContactUpdateOne {
- if s != nil {
- cuo.SetNickname(*s)
- }
- return cuo
- }
- // SetMarkname sets the "markname" field.
- func (cuo *ContactUpdateOne) SetMarkname(s string) *ContactUpdateOne {
- cuo.mutation.SetMarkname(s)
- return cuo
- }
- // SetNillableMarkname sets the "markname" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableMarkname(s *string) *ContactUpdateOne {
- if s != nil {
- cuo.SetMarkname(*s)
- }
- return cuo
- }
- // SetHeadimg sets the "headimg" field.
- func (cuo *ContactUpdateOne) SetHeadimg(s string) *ContactUpdateOne {
- cuo.mutation.SetHeadimg(s)
- return cuo
- }
- // SetNillableHeadimg sets the "headimg" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableHeadimg(s *string) *ContactUpdateOne {
- if s != nil {
- cuo.SetHeadimg(*s)
- }
- return cuo
- }
- // SetSex sets the "sex" field.
- func (cuo *ContactUpdateOne) SetSex(i int) *ContactUpdateOne {
- cuo.mutation.ResetSex()
- cuo.mutation.SetSex(i)
- return cuo
- }
- // SetNillableSex sets the "sex" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableSex(i *int) *ContactUpdateOne {
- if i != nil {
- cuo.SetSex(*i)
- }
- return cuo
- }
- // AddSex adds i to the "sex" field.
- func (cuo *ContactUpdateOne) AddSex(i int) *ContactUpdateOne {
- cuo.mutation.AddSex(i)
- return cuo
- }
- // SetStarrole sets the "starrole" field.
- func (cuo *ContactUpdateOne) SetStarrole(s string) *ContactUpdateOne {
- cuo.mutation.SetStarrole(s)
- return cuo
- }
- // SetNillableStarrole sets the "starrole" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableStarrole(s *string) *ContactUpdateOne {
- if s != nil {
- cuo.SetStarrole(*s)
- }
- return cuo
- }
- // SetDontseeit sets the "dontseeit" field.
- func (cuo *ContactUpdateOne) SetDontseeit(i int) *ContactUpdateOne {
- cuo.mutation.ResetDontseeit()
- cuo.mutation.SetDontseeit(i)
- return cuo
- }
- // SetNillableDontseeit sets the "dontseeit" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableDontseeit(i *int) *ContactUpdateOne {
- if i != nil {
- cuo.SetDontseeit(*i)
- }
- return cuo
- }
- // AddDontseeit adds i to the "dontseeit" field.
- func (cuo *ContactUpdateOne) AddDontseeit(i int) *ContactUpdateOne {
- cuo.mutation.AddDontseeit(i)
- return cuo
- }
- // SetDontseeme sets the "dontseeme" field.
- func (cuo *ContactUpdateOne) SetDontseeme(i int) *ContactUpdateOne {
- cuo.mutation.ResetDontseeme()
- cuo.mutation.SetDontseeme(i)
- return cuo
- }
- // SetNillableDontseeme sets the "dontseeme" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableDontseeme(i *int) *ContactUpdateOne {
- if i != nil {
- cuo.SetDontseeme(*i)
- }
- return cuo
- }
- // AddDontseeme adds i to the "dontseeme" field.
- func (cuo *ContactUpdateOne) AddDontseeme(i int) *ContactUpdateOne {
- cuo.mutation.AddDontseeme(i)
- return cuo
- }
- // SetLag sets the "lag" field.
- func (cuo *ContactUpdateOne) SetLag(s string) *ContactUpdateOne {
- cuo.mutation.SetLag(s)
- return cuo
- }
- // SetNillableLag sets the "lag" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableLag(s *string) *ContactUpdateOne {
- if s != nil {
- cuo.SetLag(*s)
- }
- return cuo
- }
- // SetGid sets the "gid" field.
- func (cuo *ContactUpdateOne) SetGid(s string) *ContactUpdateOne {
- cuo.mutation.SetGid(s)
- return cuo
- }
- // SetNillableGid sets the "gid" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableGid(s *string) *ContactUpdateOne {
- if s != nil {
- cuo.SetGid(*s)
- }
- return cuo
- }
- // SetGname sets the "gname" field.
- func (cuo *ContactUpdateOne) SetGname(s string) *ContactUpdateOne {
- cuo.mutation.SetGname(s)
- return cuo
- }
- // SetNillableGname sets the "gname" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableGname(s *string) *ContactUpdateOne {
- if s != nil {
- cuo.SetGname(*s)
- }
- return cuo
- }
- // SetV3 sets the "v3" field.
- func (cuo *ContactUpdateOne) SetV3(s string) *ContactUpdateOne {
- cuo.mutation.SetV3(s)
- return cuo
- }
- // SetNillableV3 sets the "v3" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableV3(s *string) *ContactUpdateOne {
- if s != nil {
- cuo.SetV3(*s)
- }
- return cuo
- }
- // SetOrganizationID sets the "organization_id" field.
- func (cuo *ContactUpdateOne) SetOrganizationID(u uint64) *ContactUpdateOne {
- cuo.mutation.ResetOrganizationID()
- cuo.mutation.SetOrganizationID(u)
- return cuo
- }
- // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableOrganizationID(u *uint64) *ContactUpdateOne {
- if u != nil {
- cuo.SetOrganizationID(*u)
- }
- return cuo
- }
- // AddOrganizationID adds u to the "organization_id" field.
- func (cuo *ContactUpdateOne) AddOrganizationID(u int64) *ContactUpdateOne {
- cuo.mutation.AddOrganizationID(u)
- return cuo
- }
- // ClearOrganizationID clears the value of the "organization_id" field.
- func (cuo *ContactUpdateOne) ClearOrganizationID() *ContactUpdateOne {
- cuo.mutation.ClearOrganizationID()
- return cuo
- }
- // SetCtype sets the "ctype" field.
- func (cuo *ContactUpdateOne) SetCtype(u uint64) *ContactUpdateOne {
- cuo.mutation.ResetCtype()
- cuo.mutation.SetCtype(u)
- return cuo
- }
- // SetNillableCtype sets the "ctype" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableCtype(u *uint64) *ContactUpdateOne {
- if u != nil {
- cuo.SetCtype(*u)
- }
- return cuo
- }
- // AddCtype adds u to the "ctype" field.
- func (cuo *ContactUpdateOne) AddCtype(u int64) *ContactUpdateOne {
- cuo.mutation.AddCtype(u)
- return cuo
- }
- // SetCage sets the "cage" field.
- func (cuo *ContactUpdateOne) SetCage(i int) *ContactUpdateOne {
- cuo.mutation.ResetCage()
- cuo.mutation.SetCage(i)
- return cuo
- }
- // SetNillableCage sets the "cage" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableCage(i *int) *ContactUpdateOne {
- if i != nil {
- cuo.SetCage(*i)
- }
- return cuo
- }
- // AddCage adds i to the "cage" field.
- func (cuo *ContactUpdateOne) AddCage(i int) *ContactUpdateOne {
- cuo.mutation.AddCage(i)
- return cuo
- }
- // SetCname sets the "cname" field.
- func (cuo *ContactUpdateOne) SetCname(s string) *ContactUpdateOne {
- cuo.mutation.SetCname(s)
- return cuo
- }
- // SetNillableCname sets the "cname" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableCname(s *string) *ContactUpdateOne {
- if s != nil {
- cuo.SetCname(*s)
- }
- return cuo
- }
- // SetCarea sets the "carea" field.
- func (cuo *ContactUpdateOne) SetCarea(s string) *ContactUpdateOne {
- cuo.mutation.SetCarea(s)
- return cuo
- }
- // SetNillableCarea sets the "carea" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableCarea(s *string) *ContactUpdateOne {
- if s != nil {
- cuo.SetCarea(*s)
- }
- return cuo
- }
- // SetCbirthday sets the "cbirthday" field.
- func (cuo *ContactUpdateOne) SetCbirthday(s string) *ContactUpdateOne {
- cuo.mutation.SetCbirthday(s)
- return cuo
- }
- // SetNillableCbirthday sets the "cbirthday" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableCbirthday(s *string) *ContactUpdateOne {
- if s != nil {
- cuo.SetCbirthday(*s)
- }
- return cuo
- }
- // SetCbirtharea sets the "cbirtharea" field.
- func (cuo *ContactUpdateOne) SetCbirtharea(s string) *ContactUpdateOne {
- cuo.mutation.SetCbirtharea(s)
- return cuo
- }
- // SetNillableCbirtharea sets the "cbirtharea" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableCbirtharea(s *string) *ContactUpdateOne {
- if s != nil {
- cuo.SetCbirtharea(*s)
- }
- return cuo
- }
- // SetCidcardNo sets the "cidcard_no" field.
- func (cuo *ContactUpdateOne) SetCidcardNo(s string) *ContactUpdateOne {
- cuo.mutation.SetCidcardNo(s)
- return cuo
- }
- // SetNillableCidcardNo sets the "cidcard_no" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableCidcardNo(s *string) *ContactUpdateOne {
- if s != nil {
- cuo.SetCidcardNo(*s)
- }
- return cuo
- }
- // SetCtitle sets the "ctitle" field.
- func (cuo *ContactUpdateOne) SetCtitle(s string) *ContactUpdateOne {
- cuo.mutation.SetCtitle(s)
- return cuo
- }
- // SetNillableCtitle sets the "ctitle" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableCtitle(s *string) *ContactUpdateOne {
- if s != nil {
- cuo.SetCtitle(*s)
- }
- return cuo
- }
- // SetCc sets the "cc" field.
- func (cuo *ContactUpdateOne) SetCc(s string) *ContactUpdateOne {
- cuo.mutation.SetCc(s)
- return cuo
- }
- // SetNillableCc sets the "cc" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillableCc(s *string) *ContactUpdateOne {
- if s != nil {
- cuo.SetCc(*s)
- }
- return cuo
- }
- // SetPhone sets the "phone" field.
- func (cuo *ContactUpdateOne) SetPhone(s string) *ContactUpdateOne {
- cuo.mutation.SetPhone(s)
- return cuo
- }
- // SetNillablePhone sets the "phone" field if the given value is not nil.
- func (cuo *ContactUpdateOne) SetNillablePhone(s *string) *ContactUpdateOne {
- if s != nil {
- cuo.SetPhone(*s)
- }
- return cuo
- }
- // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by IDs.
- func (cuo *ContactUpdateOne) AddContactRelationshipIDs(ids ...uint64) *ContactUpdateOne {
- cuo.mutation.AddContactRelationshipIDs(ids...)
- return cuo
- }
- // AddContactRelationships adds the "contact_relationships" edges to the LabelRelationship entity.
- func (cuo *ContactUpdateOne) AddContactRelationships(l ...*LabelRelationship) *ContactUpdateOne {
- ids := make([]uint64, len(l))
- for i := range l {
- ids[i] = l[i].ID
- }
- return cuo.AddContactRelationshipIDs(ids...)
- }
- // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by IDs.
- func (cuo *ContactUpdateOne) AddContactMessageIDs(ids ...uint64) *ContactUpdateOne {
- cuo.mutation.AddContactMessageIDs(ids...)
- return cuo
- }
- // AddContactMessages adds the "contact_messages" edges to the MessageRecords entity.
- func (cuo *ContactUpdateOne) AddContactMessages(m ...*MessageRecords) *ContactUpdateOne {
- ids := make([]uint64, len(m))
- for i := range m {
- ids[i] = m[i].ID
- }
- return cuo.AddContactMessageIDs(ids...)
- }
- // Mutation returns the ContactMutation object of the builder.
- func (cuo *ContactUpdateOne) Mutation() *ContactMutation {
- return cuo.mutation
- }
- // ClearContactRelationships clears all "contact_relationships" edges to the LabelRelationship entity.
- func (cuo *ContactUpdateOne) ClearContactRelationships() *ContactUpdateOne {
- cuo.mutation.ClearContactRelationships()
- return cuo
- }
- // RemoveContactRelationshipIDs removes the "contact_relationships" edge to LabelRelationship entities by IDs.
- func (cuo *ContactUpdateOne) RemoveContactRelationshipIDs(ids ...uint64) *ContactUpdateOne {
- cuo.mutation.RemoveContactRelationshipIDs(ids...)
- return cuo
- }
- // RemoveContactRelationships removes "contact_relationships" edges to LabelRelationship entities.
- func (cuo *ContactUpdateOne) RemoveContactRelationships(l ...*LabelRelationship) *ContactUpdateOne {
- ids := make([]uint64, len(l))
- for i := range l {
- ids[i] = l[i].ID
- }
- return cuo.RemoveContactRelationshipIDs(ids...)
- }
- // ClearContactMessages clears all "contact_messages" edges to the MessageRecords entity.
- func (cuo *ContactUpdateOne) ClearContactMessages() *ContactUpdateOne {
- cuo.mutation.ClearContactMessages()
- return cuo
- }
- // RemoveContactMessageIDs removes the "contact_messages" edge to MessageRecords entities by IDs.
- func (cuo *ContactUpdateOne) RemoveContactMessageIDs(ids ...uint64) *ContactUpdateOne {
- cuo.mutation.RemoveContactMessageIDs(ids...)
- return cuo
- }
- // RemoveContactMessages removes "contact_messages" edges to MessageRecords entities.
- func (cuo *ContactUpdateOne) RemoveContactMessages(m ...*MessageRecords) *ContactUpdateOne {
- ids := make([]uint64, len(m))
- for i := range m {
- ids[i] = m[i].ID
- }
- return cuo.RemoveContactMessageIDs(ids...)
- }
- // Where appends a list predicates to the ContactUpdate builder.
- func (cuo *ContactUpdateOne) Where(ps ...predicate.Contact) *ContactUpdateOne {
- cuo.mutation.Where(ps...)
- return cuo
- }
- // Select allows selecting one or more fields (columns) of the returned entity.
- // The default is selecting all fields defined in the entity schema.
- func (cuo *ContactUpdateOne) Select(field string, fields ...string) *ContactUpdateOne {
- cuo.fields = append([]string{field}, fields...)
- return cuo
- }
- // Save executes the query and returns the updated Contact entity.
- func (cuo *ContactUpdateOne) Save(ctx context.Context) (*Contact, error) {
- if err := cuo.defaults(); err != nil {
- return nil, err
- }
- return withHooks(ctx, cuo.sqlSave, cuo.mutation, cuo.hooks)
- }
- // SaveX is like Save, but panics if an error occurs.
- func (cuo *ContactUpdateOne) SaveX(ctx context.Context) *Contact {
- node, err := cuo.Save(ctx)
- if err != nil {
- panic(err)
- }
- return node
- }
- // Exec executes the query on the entity.
- func (cuo *ContactUpdateOne) Exec(ctx context.Context) error {
- _, err := cuo.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (cuo *ContactUpdateOne) ExecX(ctx context.Context) {
- if err := cuo.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (cuo *ContactUpdateOne) defaults() error {
- if _, ok := cuo.mutation.UpdatedAt(); !ok {
- if contact.UpdateDefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized contact.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := contact.UpdateDefaultUpdatedAt()
- cuo.mutation.SetUpdatedAt(v)
- }
- return nil
- }
- func (cuo *ContactUpdateOne) sqlSave(ctx context.Context) (_node *Contact, err error) {
- _spec := sqlgraph.NewUpdateSpec(contact.Table, contact.Columns, sqlgraph.NewFieldSpec(contact.FieldID, field.TypeUint64))
- id, ok := cuo.mutation.ID()
- if !ok {
- return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Contact.id" for update`)}
- }
- _spec.Node.ID.Value = id
- if fields := cuo.fields; len(fields) > 0 {
- _spec.Node.Columns = make([]string, 0, len(fields))
- _spec.Node.Columns = append(_spec.Node.Columns, contact.FieldID)
- for _, f := range fields {
- if !contact.ValidColumn(f) {
- return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
- }
- if f != contact.FieldID {
- _spec.Node.Columns = append(_spec.Node.Columns, f)
- }
- }
- }
- if ps := cuo.mutation.predicates; len(ps) > 0 {
- _spec.Predicate = func(selector *sql.Selector) {
- for i := range ps {
- ps[i](selector)
- }
- }
- }
- if value, ok := cuo.mutation.UpdatedAt(); ok {
- _spec.SetField(contact.FieldUpdatedAt, field.TypeTime, value)
- }
- if value, ok := cuo.mutation.Status(); ok {
- _spec.SetField(contact.FieldStatus, field.TypeUint8, value)
- }
- if value, ok := cuo.mutation.AddedStatus(); ok {
- _spec.AddField(contact.FieldStatus, field.TypeUint8, value)
- }
- if cuo.mutation.StatusCleared() {
- _spec.ClearField(contact.FieldStatus, field.TypeUint8)
- }
- if value, ok := cuo.mutation.DeletedAt(); ok {
- _spec.SetField(contact.FieldDeletedAt, field.TypeTime, value)
- }
- if cuo.mutation.DeletedAtCleared() {
- _spec.ClearField(contact.FieldDeletedAt, field.TypeTime)
- }
- if value, ok := cuo.mutation.WxWxid(); ok {
- _spec.SetField(contact.FieldWxWxid, field.TypeString, value)
- }
- if value, ok := cuo.mutation.GetType(); ok {
- _spec.SetField(contact.FieldType, field.TypeInt, value)
- }
- if value, ok := cuo.mutation.AddedType(); ok {
- _spec.AddField(contact.FieldType, field.TypeInt, value)
- }
- if cuo.mutation.TypeCleared() {
- _spec.ClearField(contact.FieldType, field.TypeInt)
- }
- if value, ok := cuo.mutation.Wxid(); ok {
- _spec.SetField(contact.FieldWxid, field.TypeString, value)
- }
- if value, ok := cuo.mutation.Account(); ok {
- _spec.SetField(contact.FieldAccount, field.TypeString, value)
- }
- if value, ok := cuo.mutation.Nickname(); ok {
- _spec.SetField(contact.FieldNickname, field.TypeString, value)
- }
- if value, ok := cuo.mutation.Markname(); ok {
- _spec.SetField(contact.FieldMarkname, field.TypeString, value)
- }
- if value, ok := cuo.mutation.Headimg(); ok {
- _spec.SetField(contact.FieldHeadimg, field.TypeString, value)
- }
- if value, ok := cuo.mutation.Sex(); ok {
- _spec.SetField(contact.FieldSex, field.TypeInt, value)
- }
- if value, ok := cuo.mutation.AddedSex(); ok {
- _spec.AddField(contact.FieldSex, field.TypeInt, value)
- }
- if value, ok := cuo.mutation.Starrole(); ok {
- _spec.SetField(contact.FieldStarrole, field.TypeString, value)
- }
- if value, ok := cuo.mutation.Dontseeit(); ok {
- _spec.SetField(contact.FieldDontseeit, field.TypeInt, value)
- }
- if value, ok := cuo.mutation.AddedDontseeit(); ok {
- _spec.AddField(contact.FieldDontseeit, field.TypeInt, value)
- }
- if value, ok := cuo.mutation.Dontseeme(); ok {
- _spec.SetField(contact.FieldDontseeme, field.TypeInt, value)
- }
- if value, ok := cuo.mutation.AddedDontseeme(); ok {
- _spec.AddField(contact.FieldDontseeme, field.TypeInt, value)
- }
- if value, ok := cuo.mutation.Lag(); ok {
- _spec.SetField(contact.FieldLag, field.TypeString, value)
- }
- if value, ok := cuo.mutation.Gid(); ok {
- _spec.SetField(contact.FieldGid, field.TypeString, value)
- }
- if value, ok := cuo.mutation.Gname(); ok {
- _spec.SetField(contact.FieldGname, field.TypeString, value)
- }
- if value, ok := cuo.mutation.V3(); ok {
- _spec.SetField(contact.FieldV3, field.TypeString, value)
- }
- if value, ok := cuo.mutation.OrganizationID(); ok {
- _spec.SetField(contact.FieldOrganizationID, field.TypeUint64, value)
- }
- if value, ok := cuo.mutation.AddedOrganizationID(); ok {
- _spec.AddField(contact.FieldOrganizationID, field.TypeUint64, value)
- }
- if cuo.mutation.OrganizationIDCleared() {
- _spec.ClearField(contact.FieldOrganizationID, field.TypeUint64)
- }
- if value, ok := cuo.mutation.Ctype(); ok {
- _spec.SetField(contact.FieldCtype, field.TypeUint64, value)
- }
- if value, ok := cuo.mutation.AddedCtype(); ok {
- _spec.AddField(contact.FieldCtype, field.TypeUint64, value)
- }
- if value, ok := cuo.mutation.Cage(); ok {
- _spec.SetField(contact.FieldCage, field.TypeInt, value)
- }
- if value, ok := cuo.mutation.AddedCage(); ok {
- _spec.AddField(contact.FieldCage, field.TypeInt, value)
- }
- if value, ok := cuo.mutation.Cname(); ok {
- _spec.SetField(contact.FieldCname, field.TypeString, value)
- }
- if value, ok := cuo.mutation.Carea(); ok {
- _spec.SetField(contact.FieldCarea, field.TypeString, value)
- }
- if value, ok := cuo.mutation.Cbirthday(); ok {
- _spec.SetField(contact.FieldCbirthday, field.TypeString, value)
- }
- if value, ok := cuo.mutation.Cbirtharea(); ok {
- _spec.SetField(contact.FieldCbirtharea, field.TypeString, value)
- }
- if value, ok := cuo.mutation.CidcardNo(); ok {
- _spec.SetField(contact.FieldCidcardNo, field.TypeString, value)
- }
- if value, ok := cuo.mutation.Ctitle(); ok {
- _spec.SetField(contact.FieldCtitle, field.TypeString, value)
- }
- if value, ok := cuo.mutation.Cc(); ok {
- _spec.SetField(contact.FieldCc, field.TypeString, value)
- }
- if value, ok := cuo.mutation.Phone(); ok {
- _spec.SetField(contact.FieldPhone, field.TypeString, value)
- }
- if cuo.mutation.ContactRelationshipsCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: contact.ContactRelationshipsTable,
- Columns: []string{contact.ContactRelationshipsColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(labelrelationship.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := cuo.mutation.RemovedContactRelationshipsIDs(); len(nodes) > 0 && !cuo.mutation.ContactRelationshipsCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: contact.ContactRelationshipsTable,
- Columns: []string{contact.ContactRelationshipsColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(labelrelationship.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := cuo.mutation.ContactRelationshipsIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: contact.ContactRelationshipsTable,
- Columns: []string{contact.ContactRelationshipsColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(labelrelationship.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- if cuo.mutation.ContactMessagesCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: contact.ContactMessagesTable,
- Columns: []string{contact.ContactMessagesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
- },
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := cuo.mutation.RemovedContactMessagesIDs(); len(nodes) > 0 && !cuo.mutation.ContactMessagesCleared() {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: contact.ContactMessagesTable,
- Columns: []string{contact.ContactMessagesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
- }
- if nodes := cuo.mutation.ContactMessagesIDs(); len(nodes) > 0 {
- edge := &sqlgraph.EdgeSpec{
- Rel: sqlgraph.O2M,
- Inverse: false,
- Table: contact.ContactMessagesTable,
- Columns: []string{contact.ContactMessagesColumn},
- Bidi: false,
- Target: &sqlgraph.EdgeTarget{
- IDSpec: sqlgraph.NewFieldSpec(messagerecords.FieldID, field.TypeUint64),
- },
- }
- for _, k := range nodes {
- edge.Target.Nodes = append(edge.Target.Nodes, k)
- }
- _spec.Edges.Add = append(_spec.Edges.Add, edge)
- }
- _node = &Contact{config: cuo.config}
- _spec.Assign = _node.assignValues
- _spec.ScanValues = _node.scanValues
- if err = sqlgraph.UpdateNode(ctx, cuo.driver, _spec); err != nil {
- if _, ok := err.(*sqlgraph.NotFoundError); ok {
- err = &NotFoundError{contact.Label}
- } else if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return nil, err
- }
- cuo.mutation.done = true
- return _node, nil
- }
|