123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "context"
- "errors"
- "fmt"
- "wechat-api/ent/addwechatfriendlog"
- "wechat-api/ent/predicate"
- "entgo.io/ent/dialect/sql"
- "entgo.io/ent/dialect/sql/sqlgraph"
- "entgo.io/ent/schema/field"
- )
- // AddWechatFriendLogUpdate is the builder for updating AddWechatFriendLog entities.
- type AddWechatFriendLogUpdate struct {
- config
- hooks []Hook
- mutation *AddWechatFriendLogMutation
- }
- // Where appends a list predicates to the AddWechatFriendLogUpdate builder.
- func (awflu *AddWechatFriendLogUpdate) Where(ps ...predicate.AddWechatFriendLog) *AddWechatFriendLogUpdate {
- awflu.mutation.Where(ps...)
- return awflu
- }
- // SetOwnerWxID sets the "owner_wx_id" field.
- func (awflu *AddWechatFriendLogUpdate) SetOwnerWxID(s string) *AddWechatFriendLogUpdate {
- awflu.mutation.SetOwnerWxID(s)
- return awflu
- }
- // SetNillableOwnerWxID sets the "owner_wx_id" field if the given value is not nil.
- func (awflu *AddWechatFriendLogUpdate) SetNillableOwnerWxID(s *string) *AddWechatFriendLogUpdate {
- if s != nil {
- awflu.SetOwnerWxID(*s)
- }
- return awflu
- }
- // SetOwnerWxType sets the "owner_wx_type" field.
- func (awflu *AddWechatFriendLogUpdate) SetOwnerWxType(i int) *AddWechatFriendLogUpdate {
- awflu.mutation.ResetOwnerWxType()
- awflu.mutation.SetOwnerWxType(i)
- return awflu
- }
- // SetNillableOwnerWxType sets the "owner_wx_type" field if the given value is not nil.
- func (awflu *AddWechatFriendLogUpdate) SetNillableOwnerWxType(i *int) *AddWechatFriendLogUpdate {
- if i != nil {
- awflu.SetOwnerWxType(*i)
- }
- return awflu
- }
- // AddOwnerWxType adds i to the "owner_wx_type" field.
- func (awflu *AddWechatFriendLogUpdate) AddOwnerWxType(i int) *AddWechatFriendLogUpdate {
- awflu.mutation.AddOwnerWxType(i)
- return awflu
- }
- // SetFindContent sets the "find_content" field.
- func (awflu *AddWechatFriendLogUpdate) SetFindContent(s string) *AddWechatFriendLogUpdate {
- awflu.mutation.SetFindContent(s)
- return awflu
- }
- // SetNillableFindContent sets the "find_content" field if the given value is not nil.
- func (awflu *AddWechatFriendLogUpdate) SetNillableFindContent(s *string) *AddWechatFriendLogUpdate {
- if s != nil {
- awflu.SetFindContent(*s)
- }
- return awflu
- }
- // SetFindRequest sets the "find_request" field.
- func (awflu *AddWechatFriendLogUpdate) SetFindRequest(m map[string]interface{}) *AddWechatFriendLogUpdate {
- awflu.mutation.SetFindRequest(m)
- return awflu
- }
- // ClearFindRequest clears the value of the "find_request" field.
- func (awflu *AddWechatFriendLogUpdate) ClearFindRequest() *AddWechatFriendLogUpdate {
- awflu.mutation.ClearFindRequest()
- return awflu
- }
- // SetFindResult sets the "find_result" field.
- func (awflu *AddWechatFriendLogUpdate) SetFindResult(m map[string]interface{}) *AddWechatFriendLogUpdate {
- awflu.mutation.SetFindResult(m)
- return awflu
- }
- // ClearFindResult clears the value of the "find_result" field.
- func (awflu *AddWechatFriendLogUpdate) ClearFindResult() *AddWechatFriendLogUpdate {
- awflu.mutation.ClearFindResult()
- return awflu
- }
- // SetIsCanAdd sets the "is_can_add" field.
- func (awflu *AddWechatFriendLogUpdate) SetIsCanAdd(i int) *AddWechatFriendLogUpdate {
- awflu.mutation.ResetIsCanAdd()
- awflu.mutation.SetIsCanAdd(i)
- return awflu
- }
- // SetNillableIsCanAdd sets the "is_can_add" field if the given value is not nil.
- func (awflu *AddWechatFriendLogUpdate) SetNillableIsCanAdd(i *int) *AddWechatFriendLogUpdate {
- if i != nil {
- awflu.SetIsCanAdd(*i)
- }
- return awflu
- }
- // AddIsCanAdd adds i to the "is_can_add" field.
- func (awflu *AddWechatFriendLogUpdate) AddIsCanAdd(i int) *AddWechatFriendLogUpdate {
- awflu.mutation.AddIsCanAdd(i)
- return awflu
- }
- // SetTaskID sets the "task_id" field.
- func (awflu *AddWechatFriendLogUpdate) SetTaskID(i int64) *AddWechatFriendLogUpdate {
- awflu.mutation.ResetTaskID()
- awflu.mutation.SetTaskID(i)
- return awflu
- }
- // SetNillableTaskID sets the "task_id" field if the given value is not nil.
- func (awflu *AddWechatFriendLogUpdate) SetNillableTaskID(i *int64) *AddWechatFriendLogUpdate {
- if i != nil {
- awflu.SetTaskID(*i)
- }
- return awflu
- }
- // AddTaskID adds i to the "task_id" field.
- func (awflu *AddWechatFriendLogUpdate) AddTaskID(i int64) *AddWechatFriendLogUpdate {
- awflu.mutation.AddTaskID(i)
- return awflu
- }
- // SetAddRequest sets the "add_request" field.
- func (awflu *AddWechatFriendLogUpdate) SetAddRequest(m map[string]interface{}) *AddWechatFriendLogUpdate {
- awflu.mutation.SetAddRequest(m)
- return awflu
- }
- // ClearAddRequest clears the value of the "add_request" field.
- func (awflu *AddWechatFriendLogUpdate) ClearAddRequest() *AddWechatFriendLogUpdate {
- awflu.mutation.ClearAddRequest()
- return awflu
- }
- // SetAddResult sets the "add_result" field.
- func (awflu *AddWechatFriendLogUpdate) SetAddResult(m map[string]interface{}) *AddWechatFriendLogUpdate {
- awflu.mutation.SetAddResult(m)
- return awflu
- }
- // ClearAddResult clears the value of the "add_result" field.
- func (awflu *AddWechatFriendLogUpdate) ClearAddResult() *AddWechatFriendLogUpdate {
- awflu.mutation.ClearAddResult()
- return awflu
- }
- // SetCreatedAt sets the "created_at" field.
- func (awflu *AddWechatFriendLogUpdate) SetCreatedAt(i int64) *AddWechatFriendLogUpdate {
- awflu.mutation.ResetCreatedAt()
- awflu.mutation.SetCreatedAt(i)
- return awflu
- }
- // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
- func (awflu *AddWechatFriendLogUpdate) SetNillableCreatedAt(i *int64) *AddWechatFriendLogUpdate {
- if i != nil {
- awflu.SetCreatedAt(*i)
- }
- return awflu
- }
- // AddCreatedAt adds i to the "created_at" field.
- func (awflu *AddWechatFriendLogUpdate) AddCreatedAt(i int64) *AddWechatFriendLogUpdate {
- awflu.mutation.AddCreatedAt(i)
- return awflu
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (awflu *AddWechatFriendLogUpdate) SetUpdatedAt(i int64) *AddWechatFriendLogUpdate {
- awflu.mutation.ResetUpdatedAt()
- awflu.mutation.SetUpdatedAt(i)
- return awflu
- }
- // AddUpdatedAt adds i to the "updated_at" field.
- func (awflu *AddWechatFriendLogUpdate) AddUpdatedAt(i int64) *AddWechatFriendLogUpdate {
- awflu.mutation.AddUpdatedAt(i)
- return awflu
- }
- // Mutation returns the AddWechatFriendLogMutation object of the builder.
- func (awflu *AddWechatFriendLogUpdate) Mutation() *AddWechatFriendLogMutation {
- return awflu.mutation
- }
- // Save executes the query and returns the number of nodes affected by the update operation.
- func (awflu *AddWechatFriendLogUpdate) Save(ctx context.Context) (int, error) {
- awflu.defaults()
- return withHooks(ctx, awflu.sqlSave, awflu.mutation, awflu.hooks)
- }
- // SaveX is like Save, but panics if an error occurs.
- func (awflu *AddWechatFriendLogUpdate) SaveX(ctx context.Context) int {
- affected, err := awflu.Save(ctx)
- if err != nil {
- panic(err)
- }
- return affected
- }
- // Exec executes the query.
- func (awflu *AddWechatFriendLogUpdate) Exec(ctx context.Context) error {
- _, err := awflu.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (awflu *AddWechatFriendLogUpdate) ExecX(ctx context.Context) {
- if err := awflu.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (awflu *AddWechatFriendLogUpdate) defaults() {
- if _, ok := awflu.mutation.UpdatedAt(); !ok {
- v := addwechatfriendlog.UpdateDefaultUpdatedAt()
- awflu.mutation.SetUpdatedAt(v)
- }
- }
- // check runs all checks and user-defined validators on the builder.
- func (awflu *AddWechatFriendLogUpdate) check() error {
- if v, ok := awflu.mutation.OwnerWxID(); ok {
- if err := addwechatfriendlog.OwnerWxIDValidator(v); err != nil {
- return &ValidationError{Name: "owner_wx_id", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.owner_wx_id": %w`, err)}
- }
- }
- if v, ok := awflu.mutation.FindContent(); ok {
- if err := addwechatfriendlog.FindContentValidator(v); err != nil {
- return &ValidationError{Name: "find_content", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.find_content": %w`, err)}
- }
- }
- return nil
- }
- func (awflu *AddWechatFriendLogUpdate) sqlSave(ctx context.Context) (n int, err error) {
- if err := awflu.check(); err != nil {
- return n, err
- }
- _spec := sqlgraph.NewUpdateSpec(addwechatfriendlog.Table, addwechatfriendlog.Columns, sqlgraph.NewFieldSpec(addwechatfriendlog.FieldID, field.TypeInt64))
- if ps := awflu.mutation.predicates; len(ps) > 0 {
- _spec.Predicate = func(selector *sql.Selector) {
- for i := range ps {
- ps[i](selector)
- }
- }
- }
- if value, ok := awflu.mutation.OwnerWxID(); ok {
- _spec.SetField(addwechatfriendlog.FieldOwnerWxID, field.TypeString, value)
- }
- if value, ok := awflu.mutation.OwnerWxType(); ok {
- _spec.SetField(addwechatfriendlog.FieldOwnerWxType, field.TypeInt, value)
- }
- if value, ok := awflu.mutation.AddedOwnerWxType(); ok {
- _spec.AddField(addwechatfriendlog.FieldOwnerWxType, field.TypeInt, value)
- }
- if value, ok := awflu.mutation.FindContent(); ok {
- _spec.SetField(addwechatfriendlog.FieldFindContent, field.TypeString, value)
- }
- if value, ok := awflu.mutation.FindRequest(); ok {
- _spec.SetField(addwechatfriendlog.FieldFindRequest, field.TypeJSON, value)
- }
- if awflu.mutation.FindRequestCleared() {
- _spec.ClearField(addwechatfriendlog.FieldFindRequest, field.TypeJSON)
- }
- if value, ok := awflu.mutation.FindResult(); ok {
- _spec.SetField(addwechatfriendlog.FieldFindResult, field.TypeJSON, value)
- }
- if awflu.mutation.FindResultCleared() {
- _spec.ClearField(addwechatfriendlog.FieldFindResult, field.TypeJSON)
- }
- if value, ok := awflu.mutation.IsCanAdd(); ok {
- _spec.SetField(addwechatfriendlog.FieldIsCanAdd, field.TypeInt, value)
- }
- if value, ok := awflu.mutation.AddedIsCanAdd(); ok {
- _spec.AddField(addwechatfriendlog.FieldIsCanAdd, field.TypeInt, value)
- }
- if value, ok := awflu.mutation.TaskID(); ok {
- _spec.SetField(addwechatfriendlog.FieldTaskID, field.TypeInt64, value)
- }
- if value, ok := awflu.mutation.AddedTaskID(); ok {
- _spec.AddField(addwechatfriendlog.FieldTaskID, field.TypeInt64, value)
- }
- if value, ok := awflu.mutation.AddRequest(); ok {
- _spec.SetField(addwechatfriendlog.FieldAddRequest, field.TypeJSON, value)
- }
- if awflu.mutation.AddRequestCleared() {
- _spec.ClearField(addwechatfriendlog.FieldAddRequest, field.TypeJSON)
- }
- if value, ok := awflu.mutation.AddResult(); ok {
- _spec.SetField(addwechatfriendlog.FieldAddResult, field.TypeJSON, value)
- }
- if awflu.mutation.AddResultCleared() {
- _spec.ClearField(addwechatfriendlog.FieldAddResult, field.TypeJSON)
- }
- if value, ok := awflu.mutation.CreatedAt(); ok {
- _spec.SetField(addwechatfriendlog.FieldCreatedAt, field.TypeInt64, value)
- }
- if value, ok := awflu.mutation.AddedCreatedAt(); ok {
- _spec.AddField(addwechatfriendlog.FieldCreatedAt, field.TypeInt64, value)
- }
- if value, ok := awflu.mutation.UpdatedAt(); ok {
- _spec.SetField(addwechatfriendlog.FieldUpdatedAt, field.TypeInt64, value)
- }
- if value, ok := awflu.mutation.AddedUpdatedAt(); ok {
- _spec.AddField(addwechatfriendlog.FieldUpdatedAt, field.TypeInt64, value)
- }
- if n, err = sqlgraph.UpdateNodes(ctx, awflu.driver, _spec); err != nil {
- if _, ok := err.(*sqlgraph.NotFoundError); ok {
- err = &NotFoundError{addwechatfriendlog.Label}
- } else if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return 0, err
- }
- awflu.mutation.done = true
- return n, nil
- }
- // AddWechatFriendLogUpdateOne is the builder for updating a single AddWechatFriendLog entity.
- type AddWechatFriendLogUpdateOne struct {
- config
- fields []string
- hooks []Hook
- mutation *AddWechatFriendLogMutation
- }
- // SetOwnerWxID sets the "owner_wx_id" field.
- func (awfluo *AddWechatFriendLogUpdateOne) SetOwnerWxID(s string) *AddWechatFriendLogUpdateOne {
- awfluo.mutation.SetOwnerWxID(s)
- return awfluo
- }
- // SetNillableOwnerWxID sets the "owner_wx_id" field if the given value is not nil.
- func (awfluo *AddWechatFriendLogUpdateOne) SetNillableOwnerWxID(s *string) *AddWechatFriendLogUpdateOne {
- if s != nil {
- awfluo.SetOwnerWxID(*s)
- }
- return awfluo
- }
- // SetOwnerWxType sets the "owner_wx_type" field.
- func (awfluo *AddWechatFriendLogUpdateOne) SetOwnerWxType(i int) *AddWechatFriendLogUpdateOne {
- awfluo.mutation.ResetOwnerWxType()
- awfluo.mutation.SetOwnerWxType(i)
- return awfluo
- }
- // SetNillableOwnerWxType sets the "owner_wx_type" field if the given value is not nil.
- func (awfluo *AddWechatFriendLogUpdateOne) SetNillableOwnerWxType(i *int) *AddWechatFriendLogUpdateOne {
- if i != nil {
- awfluo.SetOwnerWxType(*i)
- }
- return awfluo
- }
- // AddOwnerWxType adds i to the "owner_wx_type" field.
- func (awfluo *AddWechatFriendLogUpdateOne) AddOwnerWxType(i int) *AddWechatFriendLogUpdateOne {
- awfluo.mutation.AddOwnerWxType(i)
- return awfluo
- }
- // SetFindContent sets the "find_content" field.
- func (awfluo *AddWechatFriendLogUpdateOne) SetFindContent(s string) *AddWechatFriendLogUpdateOne {
- awfluo.mutation.SetFindContent(s)
- return awfluo
- }
- // SetNillableFindContent sets the "find_content" field if the given value is not nil.
- func (awfluo *AddWechatFriendLogUpdateOne) SetNillableFindContent(s *string) *AddWechatFriendLogUpdateOne {
- if s != nil {
- awfluo.SetFindContent(*s)
- }
- return awfluo
- }
- // SetFindRequest sets the "find_request" field.
- func (awfluo *AddWechatFriendLogUpdateOne) SetFindRequest(m map[string]interface{}) *AddWechatFriendLogUpdateOne {
- awfluo.mutation.SetFindRequest(m)
- return awfluo
- }
- // ClearFindRequest clears the value of the "find_request" field.
- func (awfluo *AddWechatFriendLogUpdateOne) ClearFindRequest() *AddWechatFriendLogUpdateOne {
- awfluo.mutation.ClearFindRequest()
- return awfluo
- }
- // SetFindResult sets the "find_result" field.
- func (awfluo *AddWechatFriendLogUpdateOne) SetFindResult(m map[string]interface{}) *AddWechatFriendLogUpdateOne {
- awfluo.mutation.SetFindResult(m)
- return awfluo
- }
- // ClearFindResult clears the value of the "find_result" field.
- func (awfluo *AddWechatFriendLogUpdateOne) ClearFindResult() *AddWechatFriendLogUpdateOne {
- awfluo.mutation.ClearFindResult()
- return awfluo
- }
- // SetIsCanAdd sets the "is_can_add" field.
- func (awfluo *AddWechatFriendLogUpdateOne) SetIsCanAdd(i int) *AddWechatFriendLogUpdateOne {
- awfluo.mutation.ResetIsCanAdd()
- awfluo.mutation.SetIsCanAdd(i)
- return awfluo
- }
- // SetNillableIsCanAdd sets the "is_can_add" field if the given value is not nil.
- func (awfluo *AddWechatFriendLogUpdateOne) SetNillableIsCanAdd(i *int) *AddWechatFriendLogUpdateOne {
- if i != nil {
- awfluo.SetIsCanAdd(*i)
- }
- return awfluo
- }
- // AddIsCanAdd adds i to the "is_can_add" field.
- func (awfluo *AddWechatFriendLogUpdateOne) AddIsCanAdd(i int) *AddWechatFriendLogUpdateOne {
- awfluo.mutation.AddIsCanAdd(i)
- return awfluo
- }
- // SetTaskID sets the "task_id" field.
- func (awfluo *AddWechatFriendLogUpdateOne) SetTaskID(i int64) *AddWechatFriendLogUpdateOne {
- awfluo.mutation.ResetTaskID()
- awfluo.mutation.SetTaskID(i)
- return awfluo
- }
- // SetNillableTaskID sets the "task_id" field if the given value is not nil.
- func (awfluo *AddWechatFriendLogUpdateOne) SetNillableTaskID(i *int64) *AddWechatFriendLogUpdateOne {
- if i != nil {
- awfluo.SetTaskID(*i)
- }
- return awfluo
- }
- // AddTaskID adds i to the "task_id" field.
- func (awfluo *AddWechatFriendLogUpdateOne) AddTaskID(i int64) *AddWechatFriendLogUpdateOne {
- awfluo.mutation.AddTaskID(i)
- return awfluo
- }
- // SetAddRequest sets the "add_request" field.
- func (awfluo *AddWechatFriendLogUpdateOne) SetAddRequest(m map[string]interface{}) *AddWechatFriendLogUpdateOne {
- awfluo.mutation.SetAddRequest(m)
- return awfluo
- }
- // ClearAddRequest clears the value of the "add_request" field.
- func (awfluo *AddWechatFriendLogUpdateOne) ClearAddRequest() *AddWechatFriendLogUpdateOne {
- awfluo.mutation.ClearAddRequest()
- return awfluo
- }
- // SetAddResult sets the "add_result" field.
- func (awfluo *AddWechatFriendLogUpdateOne) SetAddResult(m map[string]interface{}) *AddWechatFriendLogUpdateOne {
- awfluo.mutation.SetAddResult(m)
- return awfluo
- }
- // ClearAddResult clears the value of the "add_result" field.
- func (awfluo *AddWechatFriendLogUpdateOne) ClearAddResult() *AddWechatFriendLogUpdateOne {
- awfluo.mutation.ClearAddResult()
- return awfluo
- }
- // SetCreatedAt sets the "created_at" field.
- func (awfluo *AddWechatFriendLogUpdateOne) SetCreatedAt(i int64) *AddWechatFriendLogUpdateOne {
- awfluo.mutation.ResetCreatedAt()
- awfluo.mutation.SetCreatedAt(i)
- return awfluo
- }
- // SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
- func (awfluo *AddWechatFriendLogUpdateOne) SetNillableCreatedAt(i *int64) *AddWechatFriendLogUpdateOne {
- if i != nil {
- awfluo.SetCreatedAt(*i)
- }
- return awfluo
- }
- // AddCreatedAt adds i to the "created_at" field.
- func (awfluo *AddWechatFriendLogUpdateOne) AddCreatedAt(i int64) *AddWechatFriendLogUpdateOne {
- awfluo.mutation.AddCreatedAt(i)
- return awfluo
- }
- // SetUpdatedAt sets the "updated_at" field.
- func (awfluo *AddWechatFriendLogUpdateOne) SetUpdatedAt(i int64) *AddWechatFriendLogUpdateOne {
- awfluo.mutation.ResetUpdatedAt()
- awfluo.mutation.SetUpdatedAt(i)
- return awfluo
- }
- // AddUpdatedAt adds i to the "updated_at" field.
- func (awfluo *AddWechatFriendLogUpdateOne) AddUpdatedAt(i int64) *AddWechatFriendLogUpdateOne {
- awfluo.mutation.AddUpdatedAt(i)
- return awfluo
- }
- // Mutation returns the AddWechatFriendLogMutation object of the builder.
- func (awfluo *AddWechatFriendLogUpdateOne) Mutation() *AddWechatFriendLogMutation {
- return awfluo.mutation
- }
- // Where appends a list predicates to the AddWechatFriendLogUpdate builder.
- func (awfluo *AddWechatFriendLogUpdateOne) Where(ps ...predicate.AddWechatFriendLog) *AddWechatFriendLogUpdateOne {
- awfluo.mutation.Where(ps...)
- return awfluo
- }
- // Select allows selecting one or more fields (columns) of the returned entity.
- // The default is selecting all fields defined in the entity schema.
- func (awfluo *AddWechatFriendLogUpdateOne) Select(field string, fields ...string) *AddWechatFriendLogUpdateOne {
- awfluo.fields = append([]string{field}, fields...)
- return awfluo
- }
- // Save executes the query and returns the updated AddWechatFriendLog entity.
- func (awfluo *AddWechatFriendLogUpdateOne) Save(ctx context.Context) (*AddWechatFriendLog, error) {
- awfluo.defaults()
- return withHooks(ctx, awfluo.sqlSave, awfluo.mutation, awfluo.hooks)
- }
- // SaveX is like Save, but panics if an error occurs.
- func (awfluo *AddWechatFriendLogUpdateOne) SaveX(ctx context.Context) *AddWechatFriendLog {
- node, err := awfluo.Save(ctx)
- if err != nil {
- panic(err)
- }
- return node
- }
- // Exec executes the query on the entity.
- func (awfluo *AddWechatFriendLogUpdateOne) Exec(ctx context.Context) error {
- _, err := awfluo.Save(ctx)
- return err
- }
- // ExecX is like Exec, but panics if an error occurs.
- func (awfluo *AddWechatFriendLogUpdateOne) ExecX(ctx context.Context) {
- if err := awfluo.Exec(ctx); err != nil {
- panic(err)
- }
- }
- // defaults sets the default values of the builder before save.
- func (awfluo *AddWechatFriendLogUpdateOne) defaults() {
- if _, ok := awfluo.mutation.UpdatedAt(); !ok {
- v := addwechatfriendlog.UpdateDefaultUpdatedAt()
- awfluo.mutation.SetUpdatedAt(v)
- }
- }
- // check runs all checks and user-defined validators on the builder.
- func (awfluo *AddWechatFriendLogUpdateOne) check() error {
- if v, ok := awfluo.mutation.OwnerWxID(); ok {
- if err := addwechatfriendlog.OwnerWxIDValidator(v); err != nil {
- return &ValidationError{Name: "owner_wx_id", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.owner_wx_id": %w`, err)}
- }
- }
- if v, ok := awfluo.mutation.FindContent(); ok {
- if err := addwechatfriendlog.FindContentValidator(v); err != nil {
- return &ValidationError{Name: "find_content", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.find_content": %w`, err)}
- }
- }
- return nil
- }
- func (awfluo *AddWechatFriendLogUpdateOne) sqlSave(ctx context.Context) (_node *AddWechatFriendLog, err error) {
- if err := awfluo.check(); err != nil {
- return _node, err
- }
- _spec := sqlgraph.NewUpdateSpec(addwechatfriendlog.Table, addwechatfriendlog.Columns, sqlgraph.NewFieldSpec(addwechatfriendlog.FieldID, field.TypeInt64))
- id, ok := awfluo.mutation.ID()
- if !ok {
- return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "AddWechatFriendLog.id" for update`)}
- }
- _spec.Node.ID.Value = id
- if fields := awfluo.fields; len(fields) > 0 {
- _spec.Node.Columns = make([]string, 0, len(fields))
- _spec.Node.Columns = append(_spec.Node.Columns, addwechatfriendlog.FieldID)
- for _, f := range fields {
- if !addwechatfriendlog.ValidColumn(f) {
- return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
- }
- if f != addwechatfriendlog.FieldID {
- _spec.Node.Columns = append(_spec.Node.Columns, f)
- }
- }
- }
- if ps := awfluo.mutation.predicates; len(ps) > 0 {
- _spec.Predicate = func(selector *sql.Selector) {
- for i := range ps {
- ps[i](selector)
- }
- }
- }
- if value, ok := awfluo.mutation.OwnerWxID(); ok {
- _spec.SetField(addwechatfriendlog.FieldOwnerWxID, field.TypeString, value)
- }
- if value, ok := awfluo.mutation.OwnerWxType(); ok {
- _spec.SetField(addwechatfriendlog.FieldOwnerWxType, field.TypeInt, value)
- }
- if value, ok := awfluo.mutation.AddedOwnerWxType(); ok {
- _spec.AddField(addwechatfriendlog.FieldOwnerWxType, field.TypeInt, value)
- }
- if value, ok := awfluo.mutation.FindContent(); ok {
- _spec.SetField(addwechatfriendlog.FieldFindContent, field.TypeString, value)
- }
- if value, ok := awfluo.mutation.FindRequest(); ok {
- _spec.SetField(addwechatfriendlog.FieldFindRequest, field.TypeJSON, value)
- }
- if awfluo.mutation.FindRequestCleared() {
- _spec.ClearField(addwechatfriendlog.FieldFindRequest, field.TypeJSON)
- }
- if value, ok := awfluo.mutation.FindResult(); ok {
- _spec.SetField(addwechatfriendlog.FieldFindResult, field.TypeJSON, value)
- }
- if awfluo.mutation.FindResultCleared() {
- _spec.ClearField(addwechatfriendlog.FieldFindResult, field.TypeJSON)
- }
- if value, ok := awfluo.mutation.IsCanAdd(); ok {
- _spec.SetField(addwechatfriendlog.FieldIsCanAdd, field.TypeInt, value)
- }
- if value, ok := awfluo.mutation.AddedIsCanAdd(); ok {
- _spec.AddField(addwechatfriendlog.FieldIsCanAdd, field.TypeInt, value)
- }
- if value, ok := awfluo.mutation.TaskID(); ok {
- _spec.SetField(addwechatfriendlog.FieldTaskID, field.TypeInt64, value)
- }
- if value, ok := awfluo.mutation.AddedTaskID(); ok {
- _spec.AddField(addwechatfriendlog.FieldTaskID, field.TypeInt64, value)
- }
- if value, ok := awfluo.mutation.AddRequest(); ok {
- _spec.SetField(addwechatfriendlog.FieldAddRequest, field.TypeJSON, value)
- }
- if awfluo.mutation.AddRequestCleared() {
- _spec.ClearField(addwechatfriendlog.FieldAddRequest, field.TypeJSON)
- }
- if value, ok := awfluo.mutation.AddResult(); ok {
- _spec.SetField(addwechatfriendlog.FieldAddResult, field.TypeJSON, value)
- }
- if awfluo.mutation.AddResultCleared() {
- _spec.ClearField(addwechatfriendlog.FieldAddResult, field.TypeJSON)
- }
- if value, ok := awfluo.mutation.CreatedAt(); ok {
- _spec.SetField(addwechatfriendlog.FieldCreatedAt, field.TypeInt64, value)
- }
- if value, ok := awfluo.mutation.AddedCreatedAt(); ok {
- _spec.AddField(addwechatfriendlog.FieldCreatedAt, field.TypeInt64, value)
- }
- if value, ok := awfluo.mutation.UpdatedAt(); ok {
- _spec.SetField(addwechatfriendlog.FieldUpdatedAt, field.TypeInt64, value)
- }
- if value, ok := awfluo.mutation.AddedUpdatedAt(); ok {
- _spec.AddField(addwechatfriendlog.FieldUpdatedAt, field.TypeInt64, value)
- }
- _node = &AddWechatFriendLog{config: awfluo.config}
- _spec.Assign = _node.assignValues
- _spec.ScanValues = _node.scanValues
- if err = sqlgraph.UpdateNode(ctx, awfluo.driver, _spec); err != nil {
- if _, ok := err.(*sqlgraph.NotFoundError); ok {
- err = &NotFoundError{addwechatfriendlog.Label}
- } else if sqlgraph.IsConstraintError(err) {
- err = &ConstraintError{msg: err.Error(), wrap: err}
- }
- return nil, err
- }
- awfluo.mutation.done = true
- return _node, nil
- }
|