1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "context"
- "errors"
- "fmt"
- "time"
- "wechat-api/ent/batchmsg"
- "wechat-api/ent/predicate"
- "entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
- "entgo.io/ent/schema/field"
- )
- // BatchMsgUpdate is the builder for updating BatchMsg entities.
- type BatchMsgUpdate struct {
- config
- hooks []Hook
- mutation *BatchMsgMutation
- }
- // Where appends a list predicates to the BatchMsgUpdate builder.
- func (bmu *BatchMsgUpdate) Where(ps ...predicate.BatchMsg) *BatchMsgUpdate {
- bmu.mutation.Where(ps...)
- return bmu
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (bmu *BatchMsgUpdate) SetUpdatedAt(t time.Time) *BatchMsgUpdate {
- bmu.mutation.SetUpdatedAt(t)
- return bmu
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (bmu *BatchMsgUpdate) SetDeletedAt(t time.Time) *BatchMsgUpdate {
- bmu.mutation.SetDeletedAt(t)
- return bmu
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (bmu *BatchMsgUpdate) SetNillableDeletedAt(t *time.Time) *BatchMsgUpdate {
- if t != nil {
- bmu.SetDeletedAt(*t)
- }
- return bmu
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (bmu *BatchMsgUpdate) ClearDeletedAt() *BatchMsgUpdate {
- bmu.mutation.ClearDeletedAt()
- return bmu
- }
- // SetStatus sets the "status" field.
- func (bmu *BatchMsgUpdate) SetStatus(u uint8) *BatchMsgUpdate {
- bmu.mutation.ResetStatus()
- bmu.mutation.SetStatus(u)
- return bmu
- }
- // SetNillableStatus sets the "status" field if the given value is not nil.
- func (bmu *BatchMsgUpdate) SetNillableStatus(u *uint8) *BatchMsgUpdate {
- if u != nil {
- bmu.SetStatus(*u)
- }
- return bmu
- }
- // AddStatus adds u to the "status" field.
- func (bmu *BatchMsgUpdate) AddStatus(u int8) *BatchMsgUpdate {
- bmu.mutation.AddStatus(u)
- return bmu
- }
- // ClearStatus clears the value of the "status" field.
- func (bmu *BatchMsgUpdate) ClearStatus() *BatchMsgUpdate {
- bmu.mutation.ClearStatus()
- return bmu
- }
- // SetBatchNo sets the "batch_no" field.
- func (bmu *BatchMsgUpdate) SetBatchNo(s string) *BatchMsgUpdate {
- bmu.mutation.SetBatchNo(s)
- return bmu
- }
- // SetNillableBatchNo sets the "batch_no" field if the given value is not nil.
- func (bmu *BatchMsgUpdate) SetNillableBatchNo(s *string) *BatchMsgUpdate {
- if s != nil {
- bmu.SetBatchNo(*s)
- }
- return bmu
- }
- // ClearBatchNo clears the value of the "batch_no" field.
- func (bmu *BatchMsgUpdate) ClearBatchNo() *BatchMsgUpdate {
- bmu.mutation.ClearBatchNo()
- return bmu
- }
- // SetTaskName sets the "task_name" field.
- func (bmu *BatchMsgUpdate) SetTaskName(s string) *BatchMsgUpdate {
- bmu.mutation.SetTaskName(s)
- return bmu
- }
- // SetNillableTaskName sets the "task_name" field if the given value is not nil.
- func (bmu *BatchMsgUpdate) SetNillableTaskName(s *string) *BatchMsgUpdate {
- if s != nil {
- bmu.SetTaskName(*s)
- }
- return bmu
- }
- // ClearTaskName clears the value of the "task_name" field.
- func (bmu *BatchMsgUpdate) ClearTaskName() *BatchMsgUpdate {
- bmu.mutation.ClearTaskName()
- return bmu
- }
- // SetFromwxid sets the "fromwxid" field.
- func (bmu *BatchMsgUpdate) SetFromwxid(s string) *BatchMsgUpdate {
- bmu.mutation.SetFromwxid(s)
- return bmu
- }
- // SetNillableFromwxid sets the "fromwxid" field if the given value is not nil.
- func (bmu *BatchMsgUpdate) SetNillableFromwxid(s *string) *BatchMsgUpdate {
- if s != nil {
- bmu.SetFromwxid(*s)
- }
- return bmu
- }
- // ClearFromwxid clears the value of the "fromwxid" field.
- func (bmu *BatchMsgUpdate) ClearFromwxid() *BatchMsgUpdate {
- bmu.mutation.ClearFromwxid()
- return bmu
- }
- // SetMsg sets the "msg" field.
- func (bmu *BatchMsgUpdate) SetMsg(s string) *BatchMsgUpdate {
- bmu.mutation.SetMsg(s)
- return bmu
- }
- // SetNillableMsg sets the "msg" field if the given value is not nil.
- func (bmu *BatchMsgUpdate) SetNillableMsg(s *string) *BatchMsgUpdate {
- if s != nil {
- bmu.SetMsg(*s)
- }
- return bmu
- }
- // ClearMsg clears the value of the "msg" field.
- func (bmu *BatchMsgUpdate) ClearMsg() *BatchMsgUpdate {
- bmu.mutation.ClearMsg()
- return bmu
- }
- // SetTag sets the "tag" field.
- func (bmu *BatchMsgUpdate) SetTag(s string) *BatchMsgUpdate {
- bmu.mutation.SetTag(s)
- return bmu
- }
- // SetNillableTag sets the "tag" field if the given value is not nil.
- func (bmu *BatchMsgUpdate) SetNillableTag(s *string) *BatchMsgUpdate {
- if s != nil {
- bmu.SetTag(*s)
- }
- return bmu
- }
- // ClearTag clears the value of the "tag" field.
- func (bmu *BatchMsgUpdate) ClearTag() *BatchMsgUpdate {
- bmu.mutation.ClearTag()
- return bmu
- }
- // SetTagids sets the "tagids" field.
- func (bmu *BatchMsgUpdate) SetTagids(s string) *BatchMsgUpdate {
- bmu.mutation.SetTagids(s)
- return bmu
- }
- // SetNillableTagids sets the "tagids" field if the given value is not nil.
- func (bmu *BatchMsgUpdate) SetNillableTagids(s *string) *BatchMsgUpdate {
- if s != nil {
- bmu.SetTagids(*s)
- }
- return bmu
- }
- // ClearTagids clears the value of the "tagids" field.
- func (bmu *BatchMsgUpdate) ClearTagids() *BatchMsgUpdate {
- bmu.mutation.ClearTagids()
- return bmu
- }
- // SetTotal sets the "total" field.
- func (bmu *BatchMsgUpdate) SetTotal(i int32) *BatchMsgUpdate {
- bmu.mutation.ResetTotal()
- bmu.mutation.SetTotal(i)
- return bmu
- }
- // SetNillableTotal sets the "total" field if the given value is not nil.
- func (bmu *BatchMsgUpdate) SetNillableTotal(i *int32) *BatchMsgUpdate {
- if i != nil {
- bmu.SetTotal(*i)
- }
- return bmu
- }
- // AddTotal adds i to the "total" field.
- func (bmu *BatchMsgUpdate) AddTotal(i int32) *BatchMsgUpdate {
- bmu.mutation.AddTotal(i)
- return bmu
- }
- // ClearTotal clears the value of the "total" field.
- func (bmu *BatchMsgUpdate) ClearTotal() *BatchMsgUpdate {
- bmu.mutation.ClearTotal()
- return bmu
- }
- // SetSuccess sets the "success" field.
- func (bmu *BatchMsgUpdate) SetSuccess(i int32) *BatchMsgUpdate {
- bmu.mutation.ResetSuccess()
- bmu.mutation.SetSuccess(i)
- return bmu
- }
- // SetNillableSuccess sets the "success" field if the given value is not nil.
- func (bmu *BatchMsgUpdate) SetNillableSuccess(i *int32) *BatchMsgUpdate {
- if i != nil {
- bmu.SetSuccess(*i)
- }
- return bmu
- }
- // AddSuccess adds i to the "success" field.
- func (bmu *BatchMsgUpdate) AddSuccess(i int32) *BatchMsgUpdate {
- bmu.mutation.AddSuccess(i)
- return bmu
- }
- // ClearSuccess clears the value of the "success" field.
- func (bmu *BatchMsgUpdate) ClearSuccess() *BatchMsgUpdate {
- bmu.mutation.ClearSuccess()
- return bmu
- }
- // SetFail sets the "fail" field.
- func (bmu *BatchMsgUpdate) SetFail(i int32) *BatchMsgUpdate {
- bmu.mutation.ResetFail()
- bmu.mutation.SetFail(i)
- return bmu
- }
- // SetNillableFail sets the "fail" field if the given value is not nil.
- func (bmu *BatchMsgUpdate) SetNillableFail(i *int32) *BatchMsgUpdate {
- if i != nil {
- bmu.SetFail(*i)
- }
- return bmu
- }
- // AddFail adds i to the "fail" field.
- func (bmu *BatchMsgUpdate) AddFail(i int32) *BatchMsgUpdate {
- bmu.mutation.AddFail(i)
- return bmu
- }
- // ClearFail clears the value of the "fail" field.
- func (bmu *BatchMsgUpdate) ClearFail() *BatchMsgUpdate {
- bmu.mutation.ClearFail()
- return bmu
- }
- // SetStartTime sets the "start_time" field.
- func (bmu *BatchMsgUpdate) SetStartTime(t time.Time) *BatchMsgUpdate {
- bmu.mutation.SetStartTime(t)
- return bmu
- }
- // SetNillableStartTime sets the "start_time" field if the given value is not nil.
- func (bmu *BatchMsgUpdate) SetNillableStartTime(t *time.Time) *BatchMsgUpdate {
- if t != nil {
- bmu.SetStartTime(*t)
- }
- return bmu
- }
- // ClearStartTime clears the value of the "start_time" field.
- func (bmu *BatchMsgUpdate) ClearStartTime() *BatchMsgUpdate {
- bmu.mutation.ClearStartTime()
- return bmu
- }
- // SetStopTime sets the "stop_time" field.
- func (bmu *BatchMsgUpdate) SetStopTime(t time.Time) *BatchMsgUpdate {
- bmu.mutation.SetStopTime(t)
- return bmu
- }
- // SetNillableStopTime sets the "stop_time" field if the given value is not nil.
- func (bmu *BatchMsgUpdate) SetNillableStopTime(t *time.Time) *BatchMsgUpdate {
- if t != nil {
- bmu.SetStopTime(*t)
- }
- return bmu
- }
- // ClearStopTime clears the value of the "stop_time" field.
- func (bmu *BatchMsgUpdate) ClearStopTime() *BatchMsgUpdate {
- bmu.mutation.ClearStopTime()
- return bmu
- }
- // SetSendTime sets the "send_time" field.
- func (bmu *BatchMsgUpdate) SetSendTime(t time.Time) *BatchMsgUpdate {
- bmu.mutation.SetSendTime(t)
- return bmu
- }
- // SetNillableSendTime sets the "send_time" field if the given value is not nil.
- func (bmu *BatchMsgUpdate) SetNillableSendTime(t *time.Time) *BatchMsgUpdate {
- if t != nil {
- bmu.SetSendTime(*t)
- }
- return bmu
- }
- // ClearSendTime clears the value of the "send_time" field.
- func (bmu *BatchMsgUpdate) ClearSendTime() *BatchMsgUpdate {
- bmu.mutation.ClearSendTime()
- return bmu
- }
- // SetType sets the "type" field.
- func (bmu *BatchMsgUpdate) SetType(i int32) *BatchMsgUpdate {
- bmu.mutation.ResetType()
- bmu.mutation.SetType(i)
- return bmu
- }
- // SetNillableType sets the "type" field if the given value is not nil.
- func (bmu *BatchMsgUpdate) SetNillableType(i *int32) *BatchMsgUpdate {
- if i != nil {
- bmu.SetType(*i)
- }
- return bmu
- }
- // AddType adds i to the "type" field.
- func (bmu *BatchMsgUpdate) AddType(i int32) *BatchMsgUpdate {
- bmu.mutation.AddType(i)
- return bmu
- }
- // ClearType clears the value of the "type" field.
- func (bmu *BatchMsgUpdate) ClearType() *BatchMsgUpdate {
- bmu.mutation.ClearType()
- return bmu
- }
- // SetOrganizationID sets the "organization_id" field.
- func (bmu *BatchMsgUpdate) SetOrganizationID(u uint64) *BatchMsgUpdate {
- bmu.mutation.ResetOrganizationID()
- bmu.mutation.SetOrganizationID(u)
- return bmu
- }
- // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
- func (bmu *BatchMsgUpdate) SetNillableOrganizationID(u *uint64) *BatchMsgUpdate {
- if u != nil {
- bmu.SetOrganizationID(*u)
- }
- return bmu
- }
- // AddOrganizationID adds u to the "organization_id" field.
- func (bmu *BatchMsgUpdate) AddOrganizationID(u int64) *BatchMsgUpdate {
- bmu.mutation.AddOrganizationID(u)
- return bmu
- }
- // SetCtype sets the "ctype" field.
- func (bmu *BatchMsgUpdate) SetCtype(u uint64) *BatchMsgUpdate {
- bmu.mutation.ResetCtype()
- bmu.mutation.SetCtype(u)
- return bmu
- }
- // SetNillableCtype sets the "ctype" field if the given value is not nil.
- func (bmu *BatchMsgUpdate) SetNillableCtype(u *uint64) *BatchMsgUpdate {
- if u != nil {
- bmu.SetCtype(*u)
- }
- return bmu
- }
- // AddCtype adds u to the "ctype" field.
- func (bmu *BatchMsgUpdate) AddCtype(u int64) *BatchMsgUpdate {
- bmu.mutation.AddCtype(u)
- return bmu
- }
- // SetCc sets the "cc" field.
- func (bmu *BatchMsgUpdate) SetCc(s string) *BatchMsgUpdate {
- bmu.mutation.SetCc(s)
- return bmu
- }
- // SetNillableCc sets the "cc" field if the given value is not nil.
- func (bmu *BatchMsgUpdate) SetNillableCc(s *string) *BatchMsgUpdate {
- if s != nil {
- bmu.SetCc(*s)
- }
- return bmu
- }
- // ClearCc clears the value of the "cc" field.
- func (bmu *BatchMsgUpdate) ClearCc() *BatchMsgUpdate {
- bmu.mutation.ClearCc()
- return bmu
- }
- // SetPhone sets the "phone" field.
- func (bmu *BatchMsgUpdate) SetPhone(s string) *BatchMsgUpdate {
- bmu.mutation.SetPhone(s)
- return bmu
- }
- // SetNillablePhone sets the "phone" field if the given value is not nil.
- func (bmu *BatchMsgUpdate) SetNillablePhone(s *string) *BatchMsgUpdate {
- if s != nil {
- bmu.SetPhone(*s)
- }
- return bmu
- }
- // ClearPhone clears the value of the "phone" field.
- func (bmu *BatchMsgUpdate) ClearPhone() *BatchMsgUpdate {
- bmu.mutation.ClearPhone()
- return bmu
- }
- // SetTemplateName sets the "template_name" field.
- func (bmu *BatchMsgUpdate) SetTemplateName(s string) *BatchMsgUpdate {
- bmu.mutation.SetTemplateName(s)
- return bmu
- }
- // SetNillableTemplateName sets the "template_name" field if the given value is not nil.
- func (bmu *BatchMsgUpdate) SetNillableTemplateName(s *string) *BatchMsgUpdate {
- if s != nil {
- bmu.SetTemplateName(*s)
- }
- return bmu
- }
- // ClearTemplateName clears the value of the "template_name" field.
- func (bmu *BatchMsgUpdate) ClearTemplateName() *BatchMsgUpdate {
- bmu.mutation.ClearTemplateName()
- return bmu
- }
- // SetTemplateCode sets the "template_code" field.
- func (bmu *BatchMsgUpdate) SetTemplateCode(s string) *BatchMsgUpdate {
- bmu.mutation.SetTemplateCode(s)
- return bmu
- }
- // SetNillableTemplateCode sets the "template_code" field if the given value is not nil.
- func (bmu *BatchMsgUpdate) SetNillableTemplateCode(s *string) *BatchMsgUpdate {
- if s != nil {
- bmu.SetTemplateCode(*s)
- }
- return bmu
- }
- // ClearTemplateCode clears the value of the "template_code" field.
- func (bmu *BatchMsgUpdate) ClearTemplateCode() *BatchMsgUpdate {
- bmu.mutation.ClearTemplateCode()
- return bmu
- }
- // SetLang sets the "lang" field.
- func (bmu *BatchMsgUpdate) SetLang(s string) *BatchMsgUpdate {
- bmu.mutation.SetLang(s)
- return bmu
- }
- // SetNillableLang sets the "lang" field if the given value is not nil.
- func (bmu *BatchMsgUpdate) SetNillableLang(s *string) *BatchMsgUpdate {
- if s != nil {
- bmu.SetLang(*s)
- }
- return bmu
- }
- // ClearLang clears the value of the "lang" field.
- func (bmu *BatchMsgUpdate) ClearLang() *BatchMsgUpdate {
- bmu.mutation.ClearLang()
- return bmu
- }
- // Mutation returns the BatchMsgMutation object of the builder.
- func (bmu *BatchMsgUpdate) Mutation() *BatchMsgMutation {
- return bmu.mutation
- }
- // Save executes the query and returns the number of nodes affected by the update operation.
- func (bmu *BatchMsgUpdate) Save(ctx context.Context) (int, error) {
- if err := bmu.defaults(); err != nil {
- return 0, err
- }
- return withHooks(ctx, bmu.sqlSave, bmu.mutation, bmu.hooks)
- }
- // SaveX is like Save, but panics if an error occurs.
- func (bmu *BatchMsgUpdate) SaveX(ctx context.Context) int {
- affected, err := bmu.Save(ctx)
- if err != nil {
- panic(err)
- }
- return affected
- }
- // Exec executes the query.
- func (bmu *BatchMsgUpdate) Exec(ctx context.Context) error {
- _, err := bmu.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (bmu *BatchMsgUpdate) ExecX(ctx context.Context) {
- if err := bmu.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (bmu *BatchMsgUpdate) defaults() error {
- if _, ok := bmu.mutation.UpdatedAt(); !ok {
- if batchmsg.UpdateDefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized batchmsg.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := batchmsg.UpdateDefaultUpdatedAt()
- bmu.mutation.SetUpdatedAt(v)
- }
- return nil
- }
- // check runs all checks and user-defined validators on the builder.
- func (bmu *BatchMsgUpdate) check() error {
- if v, ok := bmu.mutation.OrganizationID(); ok {
- if err := batchmsg.OrganizationIDValidator(v); err != nil {
- return &ValidationError{Name: "organization_id", err: fmt.Errorf(`ent: validator failed for field "BatchMsg.organization_id": %w`, err)}
- }
- }
- return nil
- }
- func (bmu *BatchMsgUpdate) sqlSave(ctx context.Context) (n int, err error) {
- if err := bmu.check(); err != nil {
- return n, err
- }
- _spec := sqlgraph.NewUpdateSpec(batchmsg.Table, batchmsg.Columns, sqlgraph.NewFieldSpec(batchmsg.FieldID, field.TypeUint64))
- if ps := bmu.mutation.predicates; len(ps) > 0 {
- _spec.Predicate = func(selector *sql.Selector) {
- for i := range ps {
- ps[i](selector)
- }
- }
- }
- if value, ok := bmu.mutation.UpdatedAt(); ok {
- _spec.SetField(batchmsg.FieldUpdatedAt, field.TypeTime, value)
- }
- if value, ok := bmu.mutation.DeletedAt(); ok {
- _spec.SetField(batchmsg.FieldDeletedAt, field.TypeTime, value)
- }
- if bmu.mutation.DeletedAtCleared() {
- _spec.ClearField(batchmsg.FieldDeletedAt, field.TypeTime)
- }
- if value, ok := bmu.mutation.Status(); ok {
- _spec.SetField(batchmsg.FieldStatus, field.TypeUint8, value)
- }
- if value, ok := bmu.mutation.AddedStatus(); ok {
- _spec.AddField(batchmsg.FieldStatus, field.TypeUint8, value)
- }
- if bmu.mutation.StatusCleared() {
- _spec.ClearField(batchmsg.FieldStatus, field.TypeUint8)
- }
- if value, ok := bmu.mutation.BatchNo(); ok {
- _spec.SetField(batchmsg.FieldBatchNo, field.TypeString, value)
- }
- if bmu.mutation.BatchNoCleared() {
- _spec.ClearField(batchmsg.FieldBatchNo, field.TypeString)
- }
- if value, ok := bmu.mutation.TaskName(); ok {
- _spec.SetField(batchmsg.FieldTaskName, field.TypeString, value)
- }
- if bmu.mutation.TaskNameCleared() {
- _spec.ClearField(batchmsg.FieldTaskName, field.TypeString)
- }
- if value, ok := bmu.mutation.Fromwxid(); ok {
- _spec.SetField(batchmsg.FieldFromwxid, field.TypeString, value)
- }
- if bmu.mutation.FromwxidCleared() {
- _spec.ClearField(batchmsg.FieldFromwxid, field.TypeString)
- }
- if value, ok := bmu.mutation.Msg(); ok {
- _spec.SetField(batchmsg.FieldMsg, field.TypeString, value)
- }
- if bmu.mutation.MsgCleared() {
- _spec.ClearField(batchmsg.FieldMsg, field.TypeString)
- }
- if value, ok := bmu.mutation.Tag(); ok {
- _spec.SetField(batchmsg.FieldTag, field.TypeString, value)
- }
- if bmu.mutation.TagCleared() {
- _spec.ClearField(batchmsg.FieldTag, field.TypeString)
- }
- if value, ok := bmu.mutation.Tagids(); ok {
- _spec.SetField(batchmsg.FieldTagids, field.TypeString, value)
- }
- if bmu.mutation.TagidsCleared() {
- _spec.ClearField(batchmsg.FieldTagids, field.TypeString)
- }
- if value, ok := bmu.mutation.Total(); ok {
- _spec.SetField(batchmsg.FieldTotal, field.TypeInt32, value)
- }
- if value, ok := bmu.mutation.AddedTotal(); ok {
- _spec.AddField(batchmsg.FieldTotal, field.TypeInt32, value)
- }
- if bmu.mutation.TotalCleared() {
- _spec.ClearField(batchmsg.FieldTotal, field.TypeInt32)
- }
- if value, ok := bmu.mutation.Success(); ok {
- _spec.SetField(batchmsg.FieldSuccess, field.TypeInt32, value)
- }
- if value, ok := bmu.mutation.AddedSuccess(); ok {
- _spec.AddField(batchmsg.FieldSuccess, field.TypeInt32, value)
- }
- if bmu.mutation.SuccessCleared() {
- _spec.ClearField(batchmsg.FieldSuccess, field.TypeInt32)
- }
- if value, ok := bmu.mutation.Fail(); ok {
- _spec.SetField(batchmsg.FieldFail, field.TypeInt32, value)
- }
- if value, ok := bmu.mutation.AddedFail(); ok {
- _spec.AddField(batchmsg.FieldFail, field.TypeInt32, value)
- }
- if bmu.mutation.FailCleared() {
- _spec.ClearField(batchmsg.FieldFail, field.TypeInt32)
- }
- if value, ok := bmu.mutation.StartTime(); ok {
- _spec.SetField(batchmsg.FieldStartTime, field.TypeTime, value)
- }
- if bmu.mutation.StartTimeCleared() {
- _spec.ClearField(batchmsg.FieldStartTime, field.TypeTime)
- }
- if value, ok := bmu.mutation.StopTime(); ok {
- _spec.SetField(batchmsg.FieldStopTime, field.TypeTime, value)
- }
- if bmu.mutation.StopTimeCleared() {
- _spec.ClearField(batchmsg.FieldStopTime, field.TypeTime)
- }
- if value, ok := bmu.mutation.SendTime(); ok {
- _spec.SetField(batchmsg.FieldSendTime, field.TypeTime, value)
- }
- if bmu.mutation.SendTimeCleared() {
- _spec.ClearField(batchmsg.FieldSendTime, field.TypeTime)
- }
- if value, ok := bmu.mutation.GetType(); ok {
- _spec.SetField(batchmsg.FieldType, field.TypeInt32, value)
- }
- if value, ok := bmu.mutation.AddedType(); ok {
- _spec.AddField(batchmsg.FieldType, field.TypeInt32, value)
- }
- if bmu.mutation.TypeCleared() {
- _spec.ClearField(batchmsg.FieldType, field.TypeInt32)
- }
- if value, ok := bmu.mutation.OrganizationID(); ok {
- _spec.SetField(batchmsg.FieldOrganizationID, field.TypeUint64, value)
- }
- if value, ok := bmu.mutation.AddedOrganizationID(); ok {
- _spec.AddField(batchmsg.FieldOrganizationID, field.TypeUint64, value)
- }
- if value, ok := bmu.mutation.Ctype(); ok {
- _spec.SetField(batchmsg.FieldCtype, field.TypeUint64, value)
- }
- if value, ok := bmu.mutation.AddedCtype(); ok {
- _spec.AddField(batchmsg.FieldCtype, field.TypeUint64, value)
- }
- if value, ok := bmu.mutation.Cc(); ok {
- _spec.SetField(batchmsg.FieldCc, field.TypeString, value)
- }
- if bmu.mutation.CcCleared() {
- _spec.ClearField(batchmsg.FieldCc, field.TypeString)
- }
- if value, ok := bmu.mutation.Phone(); ok {
- _spec.SetField(batchmsg.FieldPhone, field.TypeString, value)
- }
- if bmu.mutation.PhoneCleared() {
- _spec.ClearField(batchmsg.FieldPhone, field.TypeString)
- }
- if value, ok := bmu.mutation.TemplateName(); ok {
- _spec.SetField(batchmsg.FieldTemplateName, field.TypeString, value)
- }
- if bmu.mutation.TemplateNameCleared() {
- _spec.ClearField(batchmsg.FieldTemplateName, field.TypeString)
- }
- if value, ok := bmu.mutation.TemplateCode(); ok {
- _spec.SetField(batchmsg.FieldTemplateCode, field.TypeString, value)
- }
- if bmu.mutation.TemplateCodeCleared() {
- _spec.ClearField(batchmsg.FieldTemplateCode, field.TypeString)
- }
- if value, ok := bmu.mutation.Lang(); ok {
- _spec.SetField(batchmsg.FieldLang, field.TypeString, value)
- }
- if bmu.mutation.LangCleared() {
- _spec.ClearField(batchmsg.FieldLang, field.TypeString)
- }
- if n, err = sqlgraph.UpdateNodes(ctx, bmu.driver, _spec); err != nil {
- if _, ok := err.(*sqlgraph.NotFoundError); ok {
- err = &NotFoundError{batchmsg.Label}
- } else if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return 0, err
- }
- bmu.mutation.done = true
- return n, nil
- }
- // BatchMsgUpdateOne is the builder for updating a single BatchMsg entity.
- type BatchMsgUpdateOne struct {
- config
- fields []string
- hooks []Hook
- mutation *BatchMsgMutation
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (bmuo *BatchMsgUpdateOne) SetUpdatedAt(t time.Time) *BatchMsgUpdateOne {
- bmuo.mutation.SetUpdatedAt(t)
- return bmuo
- }
- // SetDeletedAt sets the "deleted_at" field.
- func (bmuo *BatchMsgUpdateOne) SetDeletedAt(t time.Time) *BatchMsgUpdateOne {
- bmuo.mutation.SetDeletedAt(t)
- return bmuo
- }
- // SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
- func (bmuo *BatchMsgUpdateOne) SetNillableDeletedAt(t *time.Time) *BatchMsgUpdateOne {
- if t != nil {
- bmuo.SetDeletedAt(*t)
- }
- return bmuo
- }
- // ClearDeletedAt clears the value of the "deleted_at" field.
- func (bmuo *BatchMsgUpdateOne) ClearDeletedAt() *BatchMsgUpdateOne {
- bmuo.mutation.ClearDeletedAt()
- return bmuo
- }
- // SetStatus sets the "status" field.
- func (bmuo *BatchMsgUpdateOne) SetStatus(u uint8) *BatchMsgUpdateOne {
- bmuo.mutation.ResetStatus()
- bmuo.mutation.SetStatus(u)
- return bmuo
- }
- // SetNillableStatus sets the "status" field if the given value is not nil.
- func (bmuo *BatchMsgUpdateOne) SetNillableStatus(u *uint8) *BatchMsgUpdateOne {
- if u != nil {
- bmuo.SetStatus(*u)
- }
- return bmuo
- }
- // AddStatus adds u to the "status" field.
- func (bmuo *BatchMsgUpdateOne) AddStatus(u int8) *BatchMsgUpdateOne {
- bmuo.mutation.AddStatus(u)
- return bmuo
- }
- // ClearStatus clears the value of the "status" field.
- func (bmuo *BatchMsgUpdateOne) ClearStatus() *BatchMsgUpdateOne {
- bmuo.mutation.ClearStatus()
- return bmuo
- }
- // SetBatchNo sets the "batch_no" field.
- func (bmuo *BatchMsgUpdateOne) SetBatchNo(s string) *BatchMsgUpdateOne {
- bmuo.mutation.SetBatchNo(s)
- return bmuo
- }
- // SetNillableBatchNo sets the "batch_no" field if the given value is not nil.
- func (bmuo *BatchMsgUpdateOne) SetNillableBatchNo(s *string) *BatchMsgUpdateOne {
- if s != nil {
- bmuo.SetBatchNo(*s)
- }
- return bmuo
- }
- // ClearBatchNo clears the value of the "batch_no" field.
- func (bmuo *BatchMsgUpdateOne) ClearBatchNo() *BatchMsgUpdateOne {
- bmuo.mutation.ClearBatchNo()
- return bmuo
- }
- // SetTaskName sets the "task_name" field.
- func (bmuo *BatchMsgUpdateOne) SetTaskName(s string) *BatchMsgUpdateOne {
- bmuo.mutation.SetTaskName(s)
- return bmuo
- }
- // SetNillableTaskName sets the "task_name" field if the given value is not nil.
- func (bmuo *BatchMsgUpdateOne) SetNillableTaskName(s *string) *BatchMsgUpdateOne {
- if s != nil {
- bmuo.SetTaskName(*s)
- }
- return bmuo
- }
- // ClearTaskName clears the value of the "task_name" field.
- func (bmuo *BatchMsgUpdateOne) ClearTaskName() *BatchMsgUpdateOne {
- bmuo.mutation.ClearTaskName()
- return bmuo
- }
- // SetFromwxid sets the "fromwxid" field.
- func (bmuo *BatchMsgUpdateOne) SetFromwxid(s string) *BatchMsgUpdateOne {
- bmuo.mutation.SetFromwxid(s)
- return bmuo
- }
- // SetNillableFromwxid sets the "fromwxid" field if the given value is not nil.
- func (bmuo *BatchMsgUpdateOne) SetNillableFromwxid(s *string) *BatchMsgUpdateOne {
- if s != nil {
- bmuo.SetFromwxid(*s)
- }
- return bmuo
- }
- // ClearFromwxid clears the value of the "fromwxid" field.
- func (bmuo *BatchMsgUpdateOne) ClearFromwxid() *BatchMsgUpdateOne {
- bmuo.mutation.ClearFromwxid()
- return bmuo
- }
- // SetMsg sets the "msg" field.
- func (bmuo *BatchMsgUpdateOne) SetMsg(s string) *BatchMsgUpdateOne {
- bmuo.mutation.SetMsg(s)
- return bmuo
- }
- // SetNillableMsg sets the "msg" field if the given value is not nil.
- func (bmuo *BatchMsgUpdateOne) SetNillableMsg(s *string) *BatchMsgUpdateOne {
- if s != nil {
- bmuo.SetMsg(*s)
- }
- return bmuo
- }
- // ClearMsg clears the value of the "msg" field.
- func (bmuo *BatchMsgUpdateOne) ClearMsg() *BatchMsgUpdateOne {
- bmuo.mutation.ClearMsg()
- return bmuo
- }
- // SetTag sets the "tag" field.
- func (bmuo *BatchMsgUpdateOne) SetTag(s string) *BatchMsgUpdateOne {
- bmuo.mutation.SetTag(s)
- return bmuo
- }
- // SetNillableTag sets the "tag" field if the given value is not nil.
- func (bmuo *BatchMsgUpdateOne) SetNillableTag(s *string) *BatchMsgUpdateOne {
- if s != nil {
- bmuo.SetTag(*s)
- }
- return bmuo
- }
- // ClearTag clears the value of the "tag" field.
- func (bmuo *BatchMsgUpdateOne) ClearTag() *BatchMsgUpdateOne {
- bmuo.mutation.ClearTag()
- return bmuo
- }
- // SetTagids sets the "tagids" field.
- func (bmuo *BatchMsgUpdateOne) SetTagids(s string) *BatchMsgUpdateOne {
- bmuo.mutation.SetTagids(s)
- return bmuo
- }
- // SetNillableTagids sets the "tagids" field if the given value is not nil.
- func (bmuo *BatchMsgUpdateOne) SetNillableTagids(s *string) *BatchMsgUpdateOne {
- if s != nil {
- bmuo.SetTagids(*s)
- }
- return bmuo
- }
- // ClearTagids clears the value of the "tagids" field.
- func (bmuo *BatchMsgUpdateOne) ClearTagids() *BatchMsgUpdateOne {
- bmuo.mutation.ClearTagids()
- return bmuo
- }
- // SetTotal sets the "total" field.
- func (bmuo *BatchMsgUpdateOne) SetTotal(i int32) *BatchMsgUpdateOne {
- bmuo.mutation.ResetTotal()
- bmuo.mutation.SetTotal(i)
- return bmuo
- }
- // SetNillableTotal sets the "total" field if the given value is not nil.
- func (bmuo *BatchMsgUpdateOne) SetNillableTotal(i *int32) *BatchMsgUpdateOne {
- if i != nil {
- bmuo.SetTotal(*i)
- }
- return bmuo
- }
- // AddTotal adds i to the "total" field.
- func (bmuo *BatchMsgUpdateOne) AddTotal(i int32) *BatchMsgUpdateOne {
- bmuo.mutation.AddTotal(i)
- return bmuo
- }
- // ClearTotal clears the value of the "total" field.
- func (bmuo *BatchMsgUpdateOne) ClearTotal() *BatchMsgUpdateOne {
- bmuo.mutation.ClearTotal()
- return bmuo
- }
- // SetSuccess sets the "success" field.
- func (bmuo *BatchMsgUpdateOne) SetSuccess(i int32) *BatchMsgUpdateOne {
- bmuo.mutation.ResetSuccess()
- bmuo.mutation.SetSuccess(i)
- return bmuo
- }
- // SetNillableSuccess sets the "success" field if the given value is not nil.
- func (bmuo *BatchMsgUpdateOne) SetNillableSuccess(i *int32) *BatchMsgUpdateOne {
- if i != nil {
- bmuo.SetSuccess(*i)
- }
- return bmuo
- }
- // AddSuccess adds i to the "success" field.
- func (bmuo *BatchMsgUpdateOne) AddSuccess(i int32) *BatchMsgUpdateOne {
- bmuo.mutation.AddSuccess(i)
- return bmuo
- }
- // ClearSuccess clears the value of the "success" field.
- func (bmuo *BatchMsgUpdateOne) ClearSuccess() *BatchMsgUpdateOne {
- bmuo.mutation.ClearSuccess()
- return bmuo
- }
- // SetFail sets the "fail" field.
- func (bmuo *BatchMsgUpdateOne) SetFail(i int32) *BatchMsgUpdateOne {
- bmuo.mutation.ResetFail()
- bmuo.mutation.SetFail(i)
- return bmuo
- }
- // SetNillableFail sets the "fail" field if the given value is not nil.
- func (bmuo *BatchMsgUpdateOne) SetNillableFail(i *int32) *BatchMsgUpdateOne {
- if i != nil {
- bmuo.SetFail(*i)
- }
- return bmuo
- }
- // AddFail adds i to the "fail" field.
- func (bmuo *BatchMsgUpdateOne) AddFail(i int32) *BatchMsgUpdateOne {
- bmuo.mutation.AddFail(i)
- return bmuo
- }
- // ClearFail clears the value of the "fail" field.
- func (bmuo *BatchMsgUpdateOne) ClearFail() *BatchMsgUpdateOne {
- bmuo.mutation.ClearFail()
- return bmuo
- }
- // SetStartTime sets the "start_time" field.
- func (bmuo *BatchMsgUpdateOne) SetStartTime(t time.Time) *BatchMsgUpdateOne {
- bmuo.mutation.SetStartTime(t)
- return bmuo
- }
- // SetNillableStartTime sets the "start_time" field if the given value is not nil.
- func (bmuo *BatchMsgUpdateOne) SetNillableStartTime(t *time.Time) *BatchMsgUpdateOne {
- if t != nil {
- bmuo.SetStartTime(*t)
- }
- return bmuo
- }
- // ClearStartTime clears the value of the "start_time" field.
- func (bmuo *BatchMsgUpdateOne) ClearStartTime() *BatchMsgUpdateOne {
- bmuo.mutation.ClearStartTime()
- return bmuo
- }
- // SetStopTime sets the "stop_time" field.
- func (bmuo *BatchMsgUpdateOne) SetStopTime(t time.Time) *BatchMsgUpdateOne {
- bmuo.mutation.SetStopTime(t)
- return bmuo
- }
- // SetNillableStopTime sets the "stop_time" field if the given value is not nil.
- func (bmuo *BatchMsgUpdateOne) SetNillableStopTime(t *time.Time) *BatchMsgUpdateOne {
- if t != nil {
- bmuo.SetStopTime(*t)
- }
- return bmuo
- }
- // ClearStopTime clears the value of the "stop_time" field.
- func (bmuo *BatchMsgUpdateOne) ClearStopTime() *BatchMsgUpdateOne {
- bmuo.mutation.ClearStopTime()
- return bmuo
- }
- // SetSendTime sets the "send_time" field.
- func (bmuo *BatchMsgUpdateOne) SetSendTime(t time.Time) *BatchMsgUpdateOne {
- bmuo.mutation.SetSendTime(t)
- return bmuo
- }
- // SetNillableSendTime sets the "send_time" field if the given value is not nil.
- func (bmuo *BatchMsgUpdateOne) SetNillableSendTime(t *time.Time) *BatchMsgUpdateOne {
- if t != nil {
- bmuo.SetSendTime(*t)
- }
- return bmuo
- }
- // ClearSendTime clears the value of the "send_time" field.
- func (bmuo *BatchMsgUpdateOne) ClearSendTime() *BatchMsgUpdateOne {
- bmuo.mutation.ClearSendTime()
- return bmuo
- }
- // SetType sets the "type" field.
- func (bmuo *BatchMsgUpdateOne) SetType(i int32) *BatchMsgUpdateOne {
- bmuo.mutation.ResetType()
- bmuo.mutation.SetType(i)
- return bmuo
- }
- // SetNillableType sets the "type" field if the given value is not nil.
- func (bmuo *BatchMsgUpdateOne) SetNillableType(i *int32) *BatchMsgUpdateOne {
- if i != nil {
- bmuo.SetType(*i)
- }
- return bmuo
- }
- // AddType adds i to the "type" field.
- func (bmuo *BatchMsgUpdateOne) AddType(i int32) *BatchMsgUpdateOne {
- bmuo.mutation.AddType(i)
- return bmuo
- }
- // ClearType clears the value of the "type" field.
- func (bmuo *BatchMsgUpdateOne) ClearType() *BatchMsgUpdateOne {
- bmuo.mutation.ClearType()
- return bmuo
- }
- // SetOrganizationID sets the "organization_id" field.
- func (bmuo *BatchMsgUpdateOne) SetOrganizationID(u uint64) *BatchMsgUpdateOne {
- bmuo.mutation.ResetOrganizationID()
- bmuo.mutation.SetOrganizationID(u)
- return bmuo
- }
- // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
- func (bmuo *BatchMsgUpdateOne) SetNillableOrganizationID(u *uint64) *BatchMsgUpdateOne {
- if u != nil {
- bmuo.SetOrganizationID(*u)
- }
- return bmuo
- }
- // AddOrganizationID adds u to the "organization_id" field.
- func (bmuo *BatchMsgUpdateOne) AddOrganizationID(u int64) *BatchMsgUpdateOne {
- bmuo.mutation.AddOrganizationID(u)
- return bmuo
- }
- // SetCtype sets the "ctype" field.
- func (bmuo *BatchMsgUpdateOne) SetCtype(u uint64) *BatchMsgUpdateOne {
- bmuo.mutation.ResetCtype()
- bmuo.mutation.SetCtype(u)
- return bmuo
- }
- // SetNillableCtype sets the "ctype" field if the given value is not nil.
- func (bmuo *BatchMsgUpdateOne) SetNillableCtype(u *uint64) *BatchMsgUpdateOne {
- if u != nil {
- bmuo.SetCtype(*u)
- }
- return bmuo
- }
- // AddCtype adds u to the "ctype" field.
- func (bmuo *BatchMsgUpdateOne) AddCtype(u int64) *BatchMsgUpdateOne {
- bmuo.mutation.AddCtype(u)
- return bmuo
- }
- // SetCc sets the "cc" field.
- func (bmuo *BatchMsgUpdateOne) SetCc(s string) *BatchMsgUpdateOne {
- bmuo.mutation.SetCc(s)
- return bmuo
- }
- // SetNillableCc sets the "cc" field if the given value is not nil.
- func (bmuo *BatchMsgUpdateOne) SetNillableCc(s *string) *BatchMsgUpdateOne {
- if s != nil {
- bmuo.SetCc(*s)
- }
- return bmuo
- }
- // ClearCc clears the value of the "cc" field.
- func (bmuo *BatchMsgUpdateOne) ClearCc() *BatchMsgUpdateOne {
- bmuo.mutation.ClearCc()
- return bmuo
- }
- // SetPhone sets the "phone" field.
- func (bmuo *BatchMsgUpdateOne) SetPhone(s string) *BatchMsgUpdateOne {
- bmuo.mutation.SetPhone(s)
- return bmuo
- }
- // SetNillablePhone sets the "phone" field if the given value is not nil.
- func (bmuo *BatchMsgUpdateOne) SetNillablePhone(s *string) *BatchMsgUpdateOne {
- if s != nil {
- bmuo.SetPhone(*s)
- }
- return bmuo
- }
- // ClearPhone clears the value of the "phone" field.
- func (bmuo *BatchMsgUpdateOne) ClearPhone() *BatchMsgUpdateOne {
- bmuo.mutation.ClearPhone()
- return bmuo
- }
- // SetTemplateName sets the "template_name" field.
- func (bmuo *BatchMsgUpdateOne) SetTemplateName(s string) *BatchMsgUpdateOne {
- bmuo.mutation.SetTemplateName(s)
- return bmuo
- }
- // SetNillableTemplateName sets the "template_name" field if the given value is not nil.
- func (bmuo *BatchMsgUpdateOne) SetNillableTemplateName(s *string) *BatchMsgUpdateOne {
- if s != nil {
- bmuo.SetTemplateName(*s)
- }
- return bmuo
- }
- // ClearTemplateName clears the value of the "template_name" field.
- func (bmuo *BatchMsgUpdateOne) ClearTemplateName() *BatchMsgUpdateOne {
- bmuo.mutation.ClearTemplateName()
- return bmuo
- }
- // SetTemplateCode sets the "template_code" field.
- func (bmuo *BatchMsgUpdateOne) SetTemplateCode(s string) *BatchMsgUpdateOne {
- bmuo.mutation.SetTemplateCode(s)
- return bmuo
- }
- // SetNillableTemplateCode sets the "template_code" field if the given value is not nil.
- func (bmuo *BatchMsgUpdateOne) SetNillableTemplateCode(s *string) *BatchMsgUpdateOne {
- if s != nil {
- bmuo.SetTemplateCode(*s)
- }
- return bmuo
- }
- // ClearTemplateCode clears the value of the "template_code" field.
- func (bmuo *BatchMsgUpdateOne) ClearTemplateCode() *BatchMsgUpdateOne {
- bmuo.mutation.ClearTemplateCode()
- return bmuo
- }
- // SetLang sets the "lang" field.
- func (bmuo *BatchMsgUpdateOne) SetLang(s string) *BatchMsgUpdateOne {
- bmuo.mutation.SetLang(s)
- return bmuo
- }
- // SetNillableLang sets the "lang" field if the given value is not nil.
- func (bmuo *BatchMsgUpdateOne) SetNillableLang(s *string) *BatchMsgUpdateOne {
- if s != nil {
- bmuo.SetLang(*s)
- }
- return bmuo
- }
- // ClearLang clears the value of the "lang" field.
- func (bmuo *BatchMsgUpdateOne) ClearLang() *BatchMsgUpdateOne {
- bmuo.mutation.ClearLang()
- return bmuo
- }
- // Mutation returns the BatchMsgMutation object of the builder.
- func (bmuo *BatchMsgUpdateOne) Mutation() *BatchMsgMutation {
- return bmuo.mutation
- }
- // Where appends a list predicates to the BatchMsgUpdate builder.
- func (bmuo *BatchMsgUpdateOne) Where(ps ...predicate.BatchMsg) *BatchMsgUpdateOne {
- bmuo.mutation.Where(ps...)
- return bmuo
- }
- // Select allows selecting one or more fields (columns) of the returned entity.
- // The default is selecting all fields defined in the entity schema.
- func (bmuo *BatchMsgUpdateOne) Select(field string, fields ...string) *BatchMsgUpdateOne {
- bmuo.fields = append([]string{field}, fields...)
- return bmuo
- }
- // Save executes the query and returns the updated BatchMsg entity.
- func (bmuo *BatchMsgUpdateOne) Save(ctx context.Context) (*BatchMsg, error) {
- if err := bmuo.defaults(); err != nil {
- return nil, err
- }
- return withHooks(ctx, bmuo.sqlSave, bmuo.mutation, bmuo.hooks)
- }
- // SaveX is like Save, but panics if an error occurs.
- func (bmuo *BatchMsgUpdateOne) SaveX(ctx context.Context) *BatchMsg {
- node, err := bmuo.Save(ctx)
- if err != nil {
- panic(err)
- }
- return node
- }
- // Exec executes the query on the entity.
- func (bmuo *BatchMsgUpdateOne) Exec(ctx context.Context) error {
- _, err := bmuo.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (bmuo *BatchMsgUpdateOne) ExecX(ctx context.Context) {
- if err := bmuo.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (bmuo *BatchMsgUpdateOne) defaults() error {
- if _, ok := bmuo.mutation.UpdatedAt(); !ok {
- if batchmsg.UpdateDefaultUpdatedAt == nil {
- return fmt.Errorf("ent: uninitialized batchmsg.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
- }
- v := batchmsg.UpdateDefaultUpdatedAt()
- bmuo.mutation.SetUpdatedAt(v)
- }
- return nil
- }
- // check runs all checks and user-defined validators on the builder.
- func (bmuo *BatchMsgUpdateOne) check() error {
- if v, ok := bmuo.mutation.OrganizationID(); ok {
- if err := batchmsg.OrganizationIDValidator(v); err != nil {
- return &ValidationError{Name: "organization_id", err: fmt.Errorf(`ent: validator failed for field "BatchMsg.organization_id": %w`, err)}
- }
- }
- return nil
- }
- func (bmuo *BatchMsgUpdateOne) sqlSave(ctx context.Context) (_node *BatchMsg, err error) {
- if err := bmuo.check(); err != nil {
- return _node, err
- }
- _spec := sqlgraph.NewUpdateSpec(batchmsg.Table, batchmsg.Columns, sqlgraph.NewFieldSpec(batchmsg.FieldID, field.TypeUint64))
- id, ok := bmuo.mutation.ID()
- if !ok {
- return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "BatchMsg.id" for update`)}
- }
- _spec.Node.ID.Value = id
- if fields := bmuo.fields; len(fields) > 0 {
- _spec.Node.Columns = make([]string, 0, len(fields))
- _spec.Node.Columns = append(_spec.Node.Columns, batchmsg.FieldID)
- for _, f := range fields {
- if !batchmsg.ValidColumn(f) {
- return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
- }
- if f != batchmsg.FieldID {
- _spec.Node.Columns = append(_spec.Node.Columns, f)
- }
- }
- }
- if ps := bmuo.mutation.predicates; len(ps) > 0 {
- _spec.Predicate = func(selector *sql.Selector) {
- for i := range ps {
- ps[i](selector)
- }
- }
- }
- if value, ok := bmuo.mutation.UpdatedAt(); ok {
- _spec.SetField(batchmsg.FieldUpdatedAt, field.TypeTime, value)
- }
- if value, ok := bmuo.mutation.DeletedAt(); ok {
- _spec.SetField(batchmsg.FieldDeletedAt, field.TypeTime, value)
- }
- if bmuo.mutation.DeletedAtCleared() {
- _spec.ClearField(batchmsg.FieldDeletedAt, field.TypeTime)
- }
- if value, ok := bmuo.mutation.Status(); ok {
- _spec.SetField(batchmsg.FieldStatus, field.TypeUint8, value)
- }
- if value, ok := bmuo.mutation.AddedStatus(); ok {
- _spec.AddField(batchmsg.FieldStatus, field.TypeUint8, value)
- }
- if bmuo.mutation.StatusCleared() {
- _spec.ClearField(batchmsg.FieldStatus, field.TypeUint8)
- }
- if value, ok := bmuo.mutation.BatchNo(); ok {
- _spec.SetField(batchmsg.FieldBatchNo, field.TypeString, value)
- }
- if bmuo.mutation.BatchNoCleared() {
- _spec.ClearField(batchmsg.FieldBatchNo, field.TypeString)
- }
- if value, ok := bmuo.mutation.TaskName(); ok {
- _spec.SetField(batchmsg.FieldTaskName, field.TypeString, value)
- }
- if bmuo.mutation.TaskNameCleared() {
- _spec.ClearField(batchmsg.FieldTaskName, field.TypeString)
- }
- if value, ok := bmuo.mutation.Fromwxid(); ok {
- _spec.SetField(batchmsg.FieldFromwxid, field.TypeString, value)
- }
- if bmuo.mutation.FromwxidCleared() {
- _spec.ClearField(batchmsg.FieldFromwxid, field.TypeString)
- }
- if value, ok := bmuo.mutation.Msg(); ok {
- _spec.SetField(batchmsg.FieldMsg, field.TypeString, value)
- }
- if bmuo.mutation.MsgCleared() {
- _spec.ClearField(batchmsg.FieldMsg, field.TypeString)
- }
- if value, ok := bmuo.mutation.Tag(); ok {
- _spec.SetField(batchmsg.FieldTag, field.TypeString, value)
- }
- if bmuo.mutation.TagCleared() {
- _spec.ClearField(batchmsg.FieldTag, field.TypeString)
- }
- if value, ok := bmuo.mutation.Tagids(); ok {
- _spec.SetField(batchmsg.FieldTagids, field.TypeString, value)
- }
- if bmuo.mutation.TagidsCleared() {
- _spec.ClearField(batchmsg.FieldTagids, field.TypeString)
- }
- if value, ok := bmuo.mutation.Total(); ok {
- _spec.SetField(batchmsg.FieldTotal, field.TypeInt32, value)
- }
- if value, ok := bmuo.mutation.AddedTotal(); ok {
- _spec.AddField(batchmsg.FieldTotal, field.TypeInt32, value)
- }
- if bmuo.mutation.TotalCleared() {
- _spec.ClearField(batchmsg.FieldTotal, field.TypeInt32)
- }
- if value, ok := bmuo.mutation.Success(); ok {
- _spec.SetField(batchmsg.FieldSuccess, field.TypeInt32, value)
- }
- if value, ok := bmuo.mutation.AddedSuccess(); ok {
- _spec.AddField(batchmsg.FieldSuccess, field.TypeInt32, value)
- }
- if bmuo.mutation.SuccessCleared() {
- _spec.ClearField(batchmsg.FieldSuccess, field.TypeInt32)
- }
- if value, ok := bmuo.mutation.Fail(); ok {
- _spec.SetField(batchmsg.FieldFail, field.TypeInt32, value)
- }
- if value, ok := bmuo.mutation.AddedFail(); ok {
- _spec.AddField(batchmsg.FieldFail, field.TypeInt32, value)
- }
- if bmuo.mutation.FailCleared() {
- _spec.ClearField(batchmsg.FieldFail, field.TypeInt32)
- }
- if value, ok := bmuo.mutation.StartTime(); ok {
- _spec.SetField(batchmsg.FieldStartTime, field.TypeTime, value)
- }
- if bmuo.mutation.StartTimeCleared() {
- _spec.ClearField(batchmsg.FieldStartTime, field.TypeTime)
- }
- if value, ok := bmuo.mutation.StopTime(); ok {
- _spec.SetField(batchmsg.FieldStopTime, field.TypeTime, value)
- }
- if bmuo.mutation.StopTimeCleared() {
- _spec.ClearField(batchmsg.FieldStopTime, field.TypeTime)
- }
- if value, ok := bmuo.mutation.SendTime(); ok {
- _spec.SetField(batchmsg.FieldSendTime, field.TypeTime, value)
- }
- if bmuo.mutation.SendTimeCleared() {
- _spec.ClearField(batchmsg.FieldSendTime, field.TypeTime)
- }
- if value, ok := bmuo.mutation.GetType(); ok {
- _spec.SetField(batchmsg.FieldType, field.TypeInt32, value)
- }
- if value, ok := bmuo.mutation.AddedType(); ok {
- _spec.AddField(batchmsg.FieldType, field.TypeInt32, value)
- }
- if bmuo.mutation.TypeCleared() {
- _spec.ClearField(batchmsg.FieldType, field.TypeInt32)
- }
- if value, ok := bmuo.mutation.OrganizationID(); ok {
- _spec.SetField(batchmsg.FieldOrganizationID, field.TypeUint64, value)
- }
- if value, ok := bmuo.mutation.AddedOrganizationID(); ok {
- _spec.AddField(batchmsg.FieldOrganizationID, field.TypeUint64, value)
- }
- if value, ok := bmuo.mutation.Ctype(); ok {
- _spec.SetField(batchmsg.FieldCtype, field.TypeUint64, value)
- }
- if value, ok := bmuo.mutation.AddedCtype(); ok {
- _spec.AddField(batchmsg.FieldCtype, field.TypeUint64, value)
- }
- if value, ok := bmuo.mutation.Cc(); ok {
- _spec.SetField(batchmsg.FieldCc, field.TypeString, value)
- }
- if bmuo.mutation.CcCleared() {
- _spec.ClearField(batchmsg.FieldCc, field.TypeString)
- }
- if value, ok := bmuo.mutation.Phone(); ok {
- _spec.SetField(batchmsg.FieldPhone, field.TypeString, value)
- }
- if bmuo.mutation.PhoneCleared() {
- _spec.ClearField(batchmsg.FieldPhone, field.TypeString)
- }
- if value, ok := bmuo.mutation.TemplateName(); ok {
- _spec.SetField(batchmsg.FieldTemplateName, field.TypeString, value)
- }
- if bmuo.mutation.TemplateNameCleared() {
- _spec.ClearField(batchmsg.FieldTemplateName, field.TypeString)
- }
- if value, ok := bmuo.mutation.TemplateCode(); ok {
- _spec.SetField(batchmsg.FieldTemplateCode, field.TypeString, value)
- }
- if bmuo.mutation.TemplateCodeCleared() {
- _spec.ClearField(batchmsg.FieldTemplateCode, field.TypeString)
- }
- if value, ok := bmuo.mutation.Lang(); ok {
- _spec.SetField(batchmsg.FieldLang, field.TypeString, value)
- }
- if bmuo.mutation.LangCleared() {
- _spec.ClearField(batchmsg.FieldLang, field.TypeString)
- }
- _node = &BatchMsg{config: bmuo.config}
- _spec.Assign = _node.assignValues
- _spec.ScanValues = _node.scanValues
- if err = sqlgraph.UpdateNode(ctx, bmuo.driver, _spec); err != nil {
- if _, ok := err.(*sqlgraph.NotFoundError); ok {
- err = &NotFoundError{batchmsg.Label}
- } else if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return nil, err
- }
- bmuo.mutation.done = true
- return _node, nil
- }
|