123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876 |
- // 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
- }
- // 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
- }
- // 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
- }
- // 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
- }
- func (bmu *BatchMsgUpdate) sqlSave(ctx context.Context) (n int, err error) {
- _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.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.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 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
- }
- // 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
- }
- // 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
- }
- // 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
- }
- func (bmuo *BatchMsgUpdateOne) sqlSave(ctx context.Context) (_node *BatchMsg, err error) {
- _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.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.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)
- }
- _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
- }
|