12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061 |
- // 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
- }
- // SetMessage sets the "message" field.
- func (awflu *AddWechatFriendLogUpdate) SetMessage(s string) *AddWechatFriendLogUpdate {
- awflu.mutation.SetMessage(s)
- return awflu
- }
- // SetNillableMessage sets the "message" field if the given value is not nil.
- func (awflu *AddWechatFriendLogUpdate) SetNillableMessage(s *string) *AddWechatFriendLogUpdate {
- if s != nil {
- awflu.SetMessage(*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
- }
- // SetTaskCount sets the "task_count" field.
- func (awflu *AddWechatFriendLogUpdate) SetTaskCount(i int) *AddWechatFriendLogUpdate {
- awflu.mutation.ResetTaskCount()
- awflu.mutation.SetTaskCount(i)
- return awflu
- }
- // SetNillableTaskCount sets the "task_count" field if the given value is not nil.
- func (awflu *AddWechatFriendLogUpdate) SetNillableTaskCount(i *int) *AddWechatFriendLogUpdate {
- if i != nil {
- awflu.SetTaskCount(*i)
- }
- return awflu
- }
- // AddTaskCount adds i to the "task_count" field.
- func (awflu *AddWechatFriendLogUpdate) AddTaskCount(i int) *AddWechatFriendLogUpdate {
- awflu.mutation.AddTaskCount(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
- }
- // SetSource sets the "source" field.
- func (awflu *AddWechatFriendLogUpdate) SetSource(i int) *AddWechatFriendLogUpdate {
- awflu.mutation.ResetSource()
- awflu.mutation.SetSource(i)
- return awflu
- }
- // SetNillableSource sets the "source" field if the given value is not nil.
- func (awflu *AddWechatFriendLogUpdate) SetNillableSource(i *int) *AddWechatFriendLogUpdate {
- if i != nil {
- awflu.SetSource(*i)
- }
- return awflu
- }
- // AddSource adds i to the "source" field.
- func (awflu *AddWechatFriendLogUpdate) AddSource(i int) *AddWechatFriendLogUpdate {
- awflu.mutation.AddSource(i)
- return awflu
- }
- // ClearSource clears the value of the "source" field.
- func (awflu *AddWechatFriendLogUpdate) ClearSource() *AddWechatFriendLogUpdate {
- awflu.mutation.ClearSource()
- return awflu
- }
- // SetNickName sets the "nick_name" field.
- func (awflu *AddWechatFriendLogUpdate) SetNickName(s string) *AddWechatFriendLogUpdate {
- awflu.mutation.SetNickName(s)
- return awflu
- }
- // SetNillableNickName sets the "nick_name" field if the given value is not nil.
- func (awflu *AddWechatFriendLogUpdate) SetNillableNickName(s *string) *AddWechatFriendLogUpdate {
- if s != nil {
- awflu.SetNickName(*s)
- }
- return awflu
- }
- // ClearNickName clears the value of the "nick_name" field.
- func (awflu *AddWechatFriendLogUpdate) ClearNickName() *AddWechatFriendLogUpdate {
- awflu.mutation.ClearNickName()
- return awflu
- }
- // SetAvatar sets the "avatar" field.
- func (awflu *AddWechatFriendLogUpdate) SetAvatar(s string) *AddWechatFriendLogUpdate {
- awflu.mutation.SetAvatar(s)
- return awflu
- }
- // SetNillableAvatar sets the "avatar" field if the given value is not nil.
- func (awflu *AddWechatFriendLogUpdate) SetNillableAvatar(s *string) *AddWechatFriendLogUpdate {
- if s != nil {
- awflu.SetAvatar(*s)
- }
- return awflu
- }
- // ClearAvatar clears the value of the "avatar" field.
- func (awflu *AddWechatFriendLogUpdate) ClearAvatar() *AddWechatFriendLogUpdate {
- awflu.mutation.ClearAvatar()
- return awflu
- }
- // SetOrganizationID sets the "organization_id" field.
- func (awflu *AddWechatFriendLogUpdate) SetOrganizationID(i int64) *AddWechatFriendLogUpdate {
- awflu.mutation.ResetOrganizationID()
- awflu.mutation.SetOrganizationID(i)
- return awflu
- }
- // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
- func (awflu *AddWechatFriendLogUpdate) SetNillableOrganizationID(i *int64) *AddWechatFriendLogUpdate {
- if i != nil {
- awflu.SetOrganizationID(*i)
- }
- return awflu
- }
- // AddOrganizationID adds i to the "organization_id" field.
- func (awflu *AddWechatFriendLogUpdate) AddOrganizationID(i int64) *AddWechatFriendLogUpdate {
- awflu.mutation.AddOrganizationID(i)
- return awflu
- }
- // ClearOrganizationID clears the value of the "organization_id" field.
- func (awflu *AddWechatFriendLogUpdate) ClearOrganizationID() *AddWechatFriendLogUpdate {
- awflu.mutation.ClearOrganizationID()
- 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)}
- }
- }
- if v, ok := awflu.mutation.Message(); ok {
- if err := addwechatfriendlog.MessageValidator(v); err != nil {
- return &ValidationError{Name: "message", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.message": %w`, err)}
- }
- }
- if v, ok := awflu.mutation.NickName(); ok {
- if err := addwechatfriendlog.NickNameValidator(v); err != nil {
- return &ValidationError{Name: "nick_name", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.nick_name": %w`, err)}
- }
- }
- if v, ok := awflu.mutation.Avatar(); ok {
- if err := addwechatfriendlog.AvatarValidator(v); err != nil {
- return &ValidationError{Name: "avatar", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.avatar": %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.Message(); ok {
- _spec.SetField(addwechatfriendlog.FieldMessage, 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.TaskCount(); ok {
- _spec.SetField(addwechatfriendlog.FieldTaskCount, field.TypeInt, value)
- }
- if value, ok := awflu.mutation.AddedTaskCount(); ok {
- _spec.AddField(addwechatfriendlog.FieldTaskCount, 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 value, ok := awflu.mutation.Source(); ok {
- _spec.SetField(addwechatfriendlog.FieldSource, field.TypeInt, value)
- }
- if value, ok := awflu.mutation.AddedSource(); ok {
- _spec.AddField(addwechatfriendlog.FieldSource, field.TypeInt, value)
- }
- if awflu.mutation.SourceCleared() {
- _spec.ClearField(addwechatfriendlog.FieldSource, field.TypeInt)
- }
- if value, ok := awflu.mutation.NickName(); ok {
- _spec.SetField(addwechatfriendlog.FieldNickName, field.TypeString, value)
- }
- if awflu.mutation.NickNameCleared() {
- _spec.ClearField(addwechatfriendlog.FieldNickName, field.TypeString)
- }
- if value, ok := awflu.mutation.Avatar(); ok {
- _spec.SetField(addwechatfriendlog.FieldAvatar, field.TypeString, value)
- }
- if awflu.mutation.AvatarCleared() {
- _spec.ClearField(addwechatfriendlog.FieldAvatar, field.TypeString)
- }
- if value, ok := awflu.mutation.OrganizationID(); ok {
- _spec.SetField(addwechatfriendlog.FieldOrganizationID, field.TypeInt64, value)
- }
- if value, ok := awflu.mutation.AddedOrganizationID(); ok {
- _spec.AddField(addwechatfriendlog.FieldOrganizationID, field.TypeInt64, value)
- }
- if awflu.mutation.OrganizationIDCleared() {
- _spec.ClearField(addwechatfriendlog.FieldOrganizationID, field.TypeInt64)
- }
- 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
- }
- // SetMessage sets the "message" field.
- func (awfluo *AddWechatFriendLogUpdateOne) SetMessage(s string) *AddWechatFriendLogUpdateOne {
- awfluo.mutation.SetMessage(s)
- return awfluo
- }
- // SetNillableMessage sets the "message" field if the given value is not nil.
- func (awfluo *AddWechatFriendLogUpdateOne) SetNillableMessage(s *string) *AddWechatFriendLogUpdateOne {
- if s != nil {
- awfluo.SetMessage(*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
- }
- // SetTaskCount sets the "task_count" field.
- func (awfluo *AddWechatFriendLogUpdateOne) SetTaskCount(i int) *AddWechatFriendLogUpdateOne {
- awfluo.mutation.ResetTaskCount()
- awfluo.mutation.SetTaskCount(i)
- return awfluo
- }
- // SetNillableTaskCount sets the "task_count" field if the given value is not nil.
- func (awfluo *AddWechatFriendLogUpdateOne) SetNillableTaskCount(i *int) *AddWechatFriendLogUpdateOne {
- if i != nil {
- awfluo.SetTaskCount(*i)
- }
- return awfluo
- }
- // AddTaskCount adds i to the "task_count" field.
- func (awfluo *AddWechatFriendLogUpdateOne) AddTaskCount(i int) *AddWechatFriendLogUpdateOne {
- awfluo.mutation.AddTaskCount(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
- }
- // SetSource sets the "source" field.
- func (awfluo *AddWechatFriendLogUpdateOne) SetSource(i int) *AddWechatFriendLogUpdateOne {
- awfluo.mutation.ResetSource()
- awfluo.mutation.SetSource(i)
- return awfluo
- }
- // SetNillableSource sets the "source" field if the given value is not nil.
- func (awfluo *AddWechatFriendLogUpdateOne) SetNillableSource(i *int) *AddWechatFriendLogUpdateOne {
- if i != nil {
- awfluo.SetSource(*i)
- }
- return awfluo
- }
- // AddSource adds i to the "source" field.
- func (awfluo *AddWechatFriendLogUpdateOne) AddSource(i int) *AddWechatFriendLogUpdateOne {
- awfluo.mutation.AddSource(i)
- return awfluo
- }
- // ClearSource clears the value of the "source" field.
- func (awfluo *AddWechatFriendLogUpdateOne) ClearSource() *AddWechatFriendLogUpdateOne {
- awfluo.mutation.ClearSource()
- return awfluo
- }
- // SetNickName sets the "nick_name" field.
- func (awfluo *AddWechatFriendLogUpdateOne) SetNickName(s string) *AddWechatFriendLogUpdateOne {
- awfluo.mutation.SetNickName(s)
- return awfluo
- }
- // SetNillableNickName sets the "nick_name" field if the given value is not nil.
- func (awfluo *AddWechatFriendLogUpdateOne) SetNillableNickName(s *string) *AddWechatFriendLogUpdateOne {
- if s != nil {
- awfluo.SetNickName(*s)
- }
- return awfluo
- }
- // ClearNickName clears the value of the "nick_name" field.
- func (awfluo *AddWechatFriendLogUpdateOne) ClearNickName() *AddWechatFriendLogUpdateOne {
- awfluo.mutation.ClearNickName()
- return awfluo
- }
- // SetAvatar sets the "avatar" field.
- func (awfluo *AddWechatFriendLogUpdateOne) SetAvatar(s string) *AddWechatFriendLogUpdateOne {
- awfluo.mutation.SetAvatar(s)
- return awfluo
- }
- // SetNillableAvatar sets the "avatar" field if the given value is not nil.
- func (awfluo *AddWechatFriendLogUpdateOne) SetNillableAvatar(s *string) *AddWechatFriendLogUpdateOne {
- if s != nil {
- awfluo.SetAvatar(*s)
- }
- return awfluo
- }
- // ClearAvatar clears the value of the "avatar" field.
- func (awfluo *AddWechatFriendLogUpdateOne) ClearAvatar() *AddWechatFriendLogUpdateOne {
- awfluo.mutation.ClearAvatar()
- return awfluo
- }
- // SetOrganizationID sets the "organization_id" field.
- func (awfluo *AddWechatFriendLogUpdateOne) SetOrganizationID(i int64) *AddWechatFriendLogUpdateOne {
- awfluo.mutation.ResetOrganizationID()
- awfluo.mutation.SetOrganizationID(i)
- return awfluo
- }
- // SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
- func (awfluo *AddWechatFriendLogUpdateOne) SetNillableOrganizationID(i *int64) *AddWechatFriendLogUpdateOne {
- if i != nil {
- awfluo.SetOrganizationID(*i)
- }
- return awfluo
- }
- // AddOrganizationID adds i to the "organization_id" field.
- func (awfluo *AddWechatFriendLogUpdateOne) AddOrganizationID(i int64) *AddWechatFriendLogUpdateOne {
- awfluo.mutation.AddOrganizationID(i)
- return awfluo
- }
- // ClearOrganizationID clears the value of the "organization_id" field.
- func (awfluo *AddWechatFriendLogUpdateOne) ClearOrganizationID() *AddWechatFriendLogUpdateOne {
- awfluo.mutation.ClearOrganizationID()
- 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)}
- }
- }
- if v, ok := awfluo.mutation.Message(); ok {
- if err := addwechatfriendlog.MessageValidator(v); err != nil {
- return &ValidationError{Name: "message", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.message": %w`, err)}
- }
- }
- if v, ok := awfluo.mutation.NickName(); ok {
- if err := addwechatfriendlog.NickNameValidator(v); err != nil {
- return &ValidationError{Name: "nick_name", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.nick_name": %w`, err)}
- }
- }
- if v, ok := awfluo.mutation.Avatar(); ok {
- if err := addwechatfriendlog.AvatarValidator(v); err != nil {
- return &ValidationError{Name: "avatar", err: fmt.Errorf(`ent: validator failed for field "AddWechatFriendLog.avatar": %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.Message(); ok {
- _spec.SetField(addwechatfriendlog.FieldMessage, 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.TaskCount(); ok {
- _spec.SetField(addwechatfriendlog.FieldTaskCount, field.TypeInt, value)
- }
- if value, ok := awfluo.mutation.AddedTaskCount(); ok {
- _spec.AddField(addwechatfriendlog.FieldTaskCount, 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)
- }
- if value, ok := awfluo.mutation.Source(); ok {
- _spec.SetField(addwechatfriendlog.FieldSource, field.TypeInt, value)
- }
- if value, ok := awfluo.mutation.AddedSource(); ok {
- _spec.AddField(addwechatfriendlog.FieldSource, field.TypeInt, value)
- }
- if awfluo.mutation.SourceCleared() {
- _spec.ClearField(addwechatfriendlog.FieldSource, field.TypeInt)
- }
- if value, ok := awfluo.mutation.NickName(); ok {
- _spec.SetField(addwechatfriendlog.FieldNickName, field.TypeString, value)
- }
- if awfluo.mutation.NickNameCleared() {
- _spec.ClearField(addwechatfriendlog.FieldNickName, field.TypeString)
- }
- if value, ok := awfluo.mutation.Avatar(); ok {
- _spec.SetField(addwechatfriendlog.FieldAvatar, field.TypeString, value)
- }
- if awfluo.mutation.AvatarCleared() {
- _spec.ClearField(addwechatfriendlog.FieldAvatar, field.TypeString)
- }
- if value, ok := awfluo.mutation.OrganizationID(); ok {
- _spec.SetField(addwechatfriendlog.FieldOrganizationID, field.TypeInt64, value)
- }
- if value, ok := awfluo.mutation.AddedOrganizationID(); ok {
- _spec.AddField(addwechatfriendlog.FieldOrganizationID, field.TypeInt64, value)
- }
- if awfluo.mutation.OrganizationIDCleared() {
- _spec.ClearField(addwechatfriendlog.FieldOrganizationID, field.TypeInt64)
- }
- _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
- }
|