|
@@ -7,8 +7,11 @@ import (
|
|
|
"errors"
|
|
|
"fmt"
|
|
|
"time"
|
|
|
+ "wechat-api/ent/contact"
|
|
|
"wechat-api/ent/messagerecords"
|
|
|
"wechat-api/ent/predicate"
|
|
|
+ "wechat-api/ent/sopnode"
|
|
|
+ "wechat-api/ent/sopstage"
|
|
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
@@ -96,23 +99,22 @@ func (mru *MessageRecordsUpdate) SetNillableBotWxid(s *string) *MessageRecordsUp
|
|
|
}
|
|
|
|
|
|
// SetContactID sets the "contact_id" field.
|
|
|
-func (mru *MessageRecordsUpdate) SetContactID(i int) *MessageRecordsUpdate {
|
|
|
- mru.mutation.ResetContactID()
|
|
|
- mru.mutation.SetContactID(i)
|
|
|
+func (mru *MessageRecordsUpdate) SetContactID(u uint64) *MessageRecordsUpdate {
|
|
|
+ mru.mutation.SetContactID(u)
|
|
|
return mru
|
|
|
}
|
|
|
|
|
|
// SetNillableContactID sets the "contact_id" field if the given value is not nil.
|
|
|
-func (mru *MessageRecordsUpdate) SetNillableContactID(i *int) *MessageRecordsUpdate {
|
|
|
- if i != nil {
|
|
|
- mru.SetContactID(*i)
|
|
|
+func (mru *MessageRecordsUpdate) SetNillableContactID(u *uint64) *MessageRecordsUpdate {
|
|
|
+ if u != nil {
|
|
|
+ mru.SetContactID(*u)
|
|
|
}
|
|
|
return mru
|
|
|
}
|
|
|
|
|
|
-// AddContactID adds i to the "contact_id" field.
|
|
|
-func (mru *MessageRecordsUpdate) AddContactID(i int) *MessageRecordsUpdate {
|
|
|
- mru.mutation.AddContactID(i)
|
|
|
+// ClearContactID clears the value of the "contact_id" field.
|
|
|
+func (mru *MessageRecordsUpdate) ClearContactID() *MessageRecordsUpdate {
|
|
|
+ mru.mutation.ClearContactID()
|
|
|
return mru
|
|
|
}
|
|
|
|
|
@@ -242,52 +244,125 @@ func (mru *MessageRecordsUpdate) AddSourceType(i int) *MessageRecordsUpdate {
|
|
|
}
|
|
|
|
|
|
// SetSourceID sets the "source_id" field.
|
|
|
-func (mru *MessageRecordsUpdate) SetSourceID(i int) *MessageRecordsUpdate {
|
|
|
- mru.mutation.ResetSourceID()
|
|
|
- mru.mutation.SetSourceID(i)
|
|
|
+func (mru *MessageRecordsUpdate) SetSourceID(u uint64) *MessageRecordsUpdate {
|
|
|
+ mru.mutation.SetSourceID(u)
|
|
|
return mru
|
|
|
}
|
|
|
|
|
|
// SetNillableSourceID sets the "source_id" field if the given value is not nil.
|
|
|
-func (mru *MessageRecordsUpdate) SetNillableSourceID(i *int) *MessageRecordsUpdate {
|
|
|
- if i != nil {
|
|
|
- mru.SetSourceID(*i)
|
|
|
+func (mru *MessageRecordsUpdate) SetNillableSourceID(u *uint64) *MessageRecordsUpdate {
|
|
|
+ if u != nil {
|
|
|
+ mru.SetSourceID(*u)
|
|
|
}
|
|
|
return mru
|
|
|
}
|
|
|
|
|
|
-// AddSourceID adds i to the "source_id" field.
|
|
|
-func (mru *MessageRecordsUpdate) AddSourceID(i int) *MessageRecordsUpdate {
|
|
|
- mru.mutation.AddSourceID(i)
|
|
|
+// ClearSourceID clears the value of the "source_id" field.
|
|
|
+func (mru *MessageRecordsUpdate) ClearSourceID() *MessageRecordsUpdate {
|
|
|
+ mru.mutation.ClearSourceID()
|
|
|
return mru
|
|
|
}
|
|
|
|
|
|
// SetSubSourceID sets the "sub_source_id" field.
|
|
|
-func (mru *MessageRecordsUpdate) SetSubSourceID(i int) *MessageRecordsUpdate {
|
|
|
- mru.mutation.ResetSubSourceID()
|
|
|
- mru.mutation.SetSubSourceID(i)
|
|
|
+func (mru *MessageRecordsUpdate) SetSubSourceID(u uint64) *MessageRecordsUpdate {
|
|
|
+ mru.mutation.SetSubSourceID(u)
|
|
|
return mru
|
|
|
}
|
|
|
|
|
|
// SetNillableSubSourceID sets the "sub_source_id" field if the given value is not nil.
|
|
|
-func (mru *MessageRecordsUpdate) SetNillableSubSourceID(i *int) *MessageRecordsUpdate {
|
|
|
- if i != nil {
|
|
|
- mru.SetSubSourceID(*i)
|
|
|
+func (mru *MessageRecordsUpdate) SetNillableSubSourceID(u *uint64) *MessageRecordsUpdate {
|
|
|
+ if u != nil {
|
|
|
+ mru.SetSubSourceID(*u)
|
|
|
+ }
|
|
|
+ return mru
|
|
|
+}
|
|
|
+
|
|
|
+// ClearSubSourceID clears the value of the "sub_source_id" field.
|
|
|
+func (mru *MessageRecordsUpdate) ClearSubSourceID() *MessageRecordsUpdate {
|
|
|
+ mru.mutation.ClearSubSourceID()
|
|
|
+ return mru
|
|
|
+}
|
|
|
+
|
|
|
+// SetSopStageID sets the "sop_stage" edge to the SopStage entity by ID.
|
|
|
+func (mru *MessageRecordsUpdate) SetSopStageID(id uint64) *MessageRecordsUpdate {
|
|
|
+ mru.mutation.SetSopStageID(id)
|
|
|
+ return mru
|
|
|
+}
|
|
|
+
|
|
|
+// SetNillableSopStageID sets the "sop_stage" edge to the SopStage entity by ID if the given value is not nil.
|
|
|
+func (mru *MessageRecordsUpdate) SetNillableSopStageID(id *uint64) *MessageRecordsUpdate {
|
|
|
+ if id != nil {
|
|
|
+ mru = mru.SetSopStageID(*id)
|
|
|
+ }
|
|
|
+ return mru
|
|
|
+}
|
|
|
+
|
|
|
+// SetSopStage sets the "sop_stage" edge to the SopStage entity.
|
|
|
+func (mru *MessageRecordsUpdate) SetSopStage(s *SopStage) *MessageRecordsUpdate {
|
|
|
+ return mru.SetSopStageID(s.ID)
|
|
|
+}
|
|
|
+
|
|
|
+// SetSopNodeID sets the "sop_node" edge to the SopNode entity by ID.
|
|
|
+func (mru *MessageRecordsUpdate) SetSopNodeID(id uint64) *MessageRecordsUpdate {
|
|
|
+ mru.mutation.SetSopNodeID(id)
|
|
|
+ return mru
|
|
|
+}
|
|
|
+
|
|
|
+// SetNillableSopNodeID sets the "sop_node" edge to the SopNode entity by ID if the given value is not nil.
|
|
|
+func (mru *MessageRecordsUpdate) SetNillableSopNodeID(id *uint64) *MessageRecordsUpdate {
|
|
|
+ if id != nil {
|
|
|
+ mru = mru.SetSopNodeID(*id)
|
|
|
}
|
|
|
return mru
|
|
|
}
|
|
|
|
|
|
-// AddSubSourceID adds i to the "sub_source_id" field.
|
|
|
-func (mru *MessageRecordsUpdate) AddSubSourceID(i int) *MessageRecordsUpdate {
|
|
|
- mru.mutation.AddSubSourceID(i)
|
|
|
+// SetSopNode sets the "sop_node" edge to the SopNode entity.
|
|
|
+func (mru *MessageRecordsUpdate) SetSopNode(s *SopNode) *MessageRecordsUpdate {
|
|
|
+ return mru.SetSopNodeID(s.ID)
|
|
|
+}
|
|
|
+
|
|
|
+// SetMessageContactID sets the "message_contact" edge to the Contact entity by ID.
|
|
|
+func (mru *MessageRecordsUpdate) SetMessageContactID(id uint64) *MessageRecordsUpdate {
|
|
|
+ mru.mutation.SetMessageContactID(id)
|
|
|
+ return mru
|
|
|
+}
|
|
|
+
|
|
|
+// SetNillableMessageContactID sets the "message_contact" edge to the Contact entity by ID if the given value is not nil.
|
|
|
+func (mru *MessageRecordsUpdate) SetNillableMessageContactID(id *uint64) *MessageRecordsUpdate {
|
|
|
+ if id != nil {
|
|
|
+ mru = mru.SetMessageContactID(*id)
|
|
|
+ }
|
|
|
return mru
|
|
|
}
|
|
|
|
|
|
+// SetMessageContact sets the "message_contact" edge to the Contact entity.
|
|
|
+func (mru *MessageRecordsUpdate) SetMessageContact(c *Contact) *MessageRecordsUpdate {
|
|
|
+ return mru.SetMessageContactID(c.ID)
|
|
|
+}
|
|
|
+
|
|
|
// Mutation returns the MessageRecordsMutation object of the builder.
|
|
|
func (mru *MessageRecordsUpdate) Mutation() *MessageRecordsMutation {
|
|
|
return mru.mutation
|
|
|
}
|
|
|
|
|
|
+// ClearSopStage clears the "sop_stage" edge to the SopStage entity.
|
|
|
+func (mru *MessageRecordsUpdate) ClearSopStage() *MessageRecordsUpdate {
|
|
|
+ mru.mutation.ClearSopStage()
|
|
|
+ return mru
|
|
|
+}
|
|
|
+
|
|
|
+// ClearSopNode clears the "sop_node" edge to the SopNode entity.
|
|
|
+func (mru *MessageRecordsUpdate) ClearSopNode() *MessageRecordsUpdate {
|
|
|
+ mru.mutation.ClearSopNode()
|
|
|
+ return mru
|
|
|
+}
|
|
|
+
|
|
|
+// ClearMessageContact clears the "message_contact" edge to the Contact entity.
|
|
|
+func (mru *MessageRecordsUpdate) ClearMessageContact() *MessageRecordsUpdate {
|
|
|
+ mru.mutation.ClearMessageContact()
|
|
|
+ return mru
|
|
|
+}
|
|
|
+
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
|
func (mru *MessageRecordsUpdate) Save(ctx context.Context) (int, error) {
|
|
|
if err := mru.defaults(); err != nil {
|
|
@@ -360,12 +435,6 @@ func (mru *MessageRecordsUpdate) sqlSave(ctx context.Context) (n int, err error)
|
|
|
if value, ok := mru.mutation.BotWxid(); ok {
|
|
|
_spec.SetField(messagerecords.FieldBotWxid, field.TypeString, value)
|
|
|
}
|
|
|
- if value, ok := mru.mutation.ContactID(); ok {
|
|
|
- _spec.SetField(messagerecords.FieldContactID, field.TypeInt, value)
|
|
|
- }
|
|
|
- if value, ok := mru.mutation.AddedContactID(); ok {
|
|
|
- _spec.AddField(messagerecords.FieldContactID, field.TypeInt, value)
|
|
|
- }
|
|
|
if value, ok := mru.mutation.ContactType(); ok {
|
|
|
_spec.SetField(messagerecords.FieldContactType, field.TypeInt, value)
|
|
|
}
|
|
@@ -399,17 +468,92 @@ func (mru *MessageRecordsUpdate) sqlSave(ctx context.Context) (n int, err error)
|
|
|
if value, ok := mru.mutation.AddedSourceType(); ok {
|
|
|
_spec.AddField(messagerecords.FieldSourceType, field.TypeInt, value)
|
|
|
}
|
|
|
- if value, ok := mru.mutation.SourceID(); ok {
|
|
|
- _spec.SetField(messagerecords.FieldSourceID, field.TypeInt, value)
|
|
|
- }
|
|
|
- if value, ok := mru.mutation.AddedSourceID(); ok {
|
|
|
- _spec.AddField(messagerecords.FieldSourceID, field.TypeInt, value)
|
|
|
- }
|
|
|
- if value, ok := mru.mutation.SubSourceID(); ok {
|
|
|
- _spec.SetField(messagerecords.FieldSubSourceID, field.TypeInt, value)
|
|
|
- }
|
|
|
- if value, ok := mru.mutation.AddedSubSourceID(); ok {
|
|
|
- _spec.AddField(messagerecords.FieldSubSourceID, field.TypeInt, value)
|
|
|
+ if mru.mutation.SopStageCleared() {
|
|
|
+ edge := &sqlgraph.EdgeSpec{
|
|
|
+ Rel: sqlgraph.M2O,
|
|
|
+ Inverse: true,
|
|
|
+ Table: messagerecords.SopStageTable,
|
|
|
+ Columns: []string{messagerecords.SopStageColumn},
|
|
|
+ Bidi: false,
|
|
|
+ Target: &sqlgraph.EdgeTarget{
|
|
|
+ IDSpec: sqlgraph.NewFieldSpec(sopstage.FieldID, field.TypeUint64),
|
|
|
+ },
|
|
|
+ }
|
|
|
+ _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
|
+ }
|
|
|
+ if nodes := mru.mutation.SopStageIDs(); len(nodes) > 0 {
|
|
|
+ edge := &sqlgraph.EdgeSpec{
|
|
|
+ Rel: sqlgraph.M2O,
|
|
|
+ Inverse: true,
|
|
|
+ Table: messagerecords.SopStageTable,
|
|
|
+ Columns: []string{messagerecords.SopStageColumn},
|
|
|
+ Bidi: false,
|
|
|
+ Target: &sqlgraph.EdgeTarget{
|
|
|
+ IDSpec: sqlgraph.NewFieldSpec(sopstage.FieldID, field.TypeUint64),
|
|
|
+ },
|
|
|
+ }
|
|
|
+ for _, k := range nodes {
|
|
|
+ edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
|
+ }
|
|
|
+ _spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
|
+ }
|
|
|
+ if mru.mutation.SopNodeCleared() {
|
|
|
+ edge := &sqlgraph.EdgeSpec{
|
|
|
+ Rel: sqlgraph.M2O,
|
|
|
+ Inverse: true,
|
|
|
+ Table: messagerecords.SopNodeTable,
|
|
|
+ Columns: []string{messagerecords.SopNodeColumn},
|
|
|
+ Bidi: false,
|
|
|
+ Target: &sqlgraph.EdgeTarget{
|
|
|
+ IDSpec: sqlgraph.NewFieldSpec(sopnode.FieldID, field.TypeUint64),
|
|
|
+ },
|
|
|
+ }
|
|
|
+ _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
|
+ }
|
|
|
+ if nodes := mru.mutation.SopNodeIDs(); len(nodes) > 0 {
|
|
|
+ edge := &sqlgraph.EdgeSpec{
|
|
|
+ Rel: sqlgraph.M2O,
|
|
|
+ Inverse: true,
|
|
|
+ Table: messagerecords.SopNodeTable,
|
|
|
+ Columns: []string{messagerecords.SopNodeColumn},
|
|
|
+ Bidi: false,
|
|
|
+ Target: &sqlgraph.EdgeTarget{
|
|
|
+ IDSpec: sqlgraph.NewFieldSpec(sopnode.FieldID, field.TypeUint64),
|
|
|
+ },
|
|
|
+ }
|
|
|
+ for _, k := range nodes {
|
|
|
+ edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
|
+ }
|
|
|
+ _spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
|
+ }
|
|
|
+ if mru.mutation.MessageContactCleared() {
|
|
|
+ edge := &sqlgraph.EdgeSpec{
|
|
|
+ Rel: sqlgraph.M2O,
|
|
|
+ Inverse: true,
|
|
|
+ Table: messagerecords.MessageContactTable,
|
|
|
+ Columns: []string{messagerecords.MessageContactColumn},
|
|
|
+ Bidi: false,
|
|
|
+ Target: &sqlgraph.EdgeTarget{
|
|
|
+ IDSpec: sqlgraph.NewFieldSpec(contact.FieldID, field.TypeUint64),
|
|
|
+ },
|
|
|
+ }
|
|
|
+ _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
|
+ }
|
|
|
+ if nodes := mru.mutation.MessageContactIDs(); len(nodes) > 0 {
|
|
|
+ edge := &sqlgraph.EdgeSpec{
|
|
|
+ Rel: sqlgraph.M2O,
|
|
|
+ Inverse: true,
|
|
|
+ Table: messagerecords.MessageContactTable,
|
|
|
+ Columns: []string{messagerecords.MessageContactColumn},
|
|
|
+ Bidi: false,
|
|
|
+ Target: &sqlgraph.EdgeTarget{
|
|
|
+ IDSpec: sqlgraph.NewFieldSpec(contact.FieldID, field.TypeUint64),
|
|
|
+ },
|
|
|
+ }
|
|
|
+ for _, k := range nodes {
|
|
|
+ edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
|
+ }
|
|
|
+ _spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
|
}
|
|
|
if n, err = sqlgraph.UpdateNodes(ctx, mru.driver, _spec); err != nil {
|
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
@@ -499,23 +643,22 @@ func (mruo *MessageRecordsUpdateOne) SetNillableBotWxid(s *string) *MessageRecor
|
|
|
}
|
|
|
|
|
|
// SetContactID sets the "contact_id" field.
|
|
|
-func (mruo *MessageRecordsUpdateOne) SetContactID(i int) *MessageRecordsUpdateOne {
|
|
|
- mruo.mutation.ResetContactID()
|
|
|
- mruo.mutation.SetContactID(i)
|
|
|
+func (mruo *MessageRecordsUpdateOne) SetContactID(u uint64) *MessageRecordsUpdateOne {
|
|
|
+ mruo.mutation.SetContactID(u)
|
|
|
return mruo
|
|
|
}
|
|
|
|
|
|
// SetNillableContactID sets the "contact_id" field if the given value is not nil.
|
|
|
-func (mruo *MessageRecordsUpdateOne) SetNillableContactID(i *int) *MessageRecordsUpdateOne {
|
|
|
- if i != nil {
|
|
|
- mruo.SetContactID(*i)
|
|
|
+func (mruo *MessageRecordsUpdateOne) SetNillableContactID(u *uint64) *MessageRecordsUpdateOne {
|
|
|
+ if u != nil {
|
|
|
+ mruo.SetContactID(*u)
|
|
|
}
|
|
|
return mruo
|
|
|
}
|
|
|
|
|
|
-// AddContactID adds i to the "contact_id" field.
|
|
|
-func (mruo *MessageRecordsUpdateOne) AddContactID(i int) *MessageRecordsUpdateOne {
|
|
|
- mruo.mutation.AddContactID(i)
|
|
|
+// ClearContactID clears the value of the "contact_id" field.
|
|
|
+func (mruo *MessageRecordsUpdateOne) ClearContactID() *MessageRecordsUpdateOne {
|
|
|
+ mruo.mutation.ClearContactID()
|
|
|
return mruo
|
|
|
}
|
|
|
|
|
@@ -645,52 +788,125 @@ func (mruo *MessageRecordsUpdateOne) AddSourceType(i int) *MessageRecordsUpdateO
|
|
|
}
|
|
|
|
|
|
// SetSourceID sets the "source_id" field.
|
|
|
-func (mruo *MessageRecordsUpdateOne) SetSourceID(i int) *MessageRecordsUpdateOne {
|
|
|
- mruo.mutation.ResetSourceID()
|
|
|
- mruo.mutation.SetSourceID(i)
|
|
|
+func (mruo *MessageRecordsUpdateOne) SetSourceID(u uint64) *MessageRecordsUpdateOne {
|
|
|
+ mruo.mutation.SetSourceID(u)
|
|
|
return mruo
|
|
|
}
|
|
|
|
|
|
// SetNillableSourceID sets the "source_id" field if the given value is not nil.
|
|
|
-func (mruo *MessageRecordsUpdateOne) SetNillableSourceID(i *int) *MessageRecordsUpdateOne {
|
|
|
- if i != nil {
|
|
|
- mruo.SetSourceID(*i)
|
|
|
+func (mruo *MessageRecordsUpdateOne) SetNillableSourceID(u *uint64) *MessageRecordsUpdateOne {
|
|
|
+ if u != nil {
|
|
|
+ mruo.SetSourceID(*u)
|
|
|
}
|
|
|
return mruo
|
|
|
}
|
|
|
|
|
|
-// AddSourceID adds i to the "source_id" field.
|
|
|
-func (mruo *MessageRecordsUpdateOne) AddSourceID(i int) *MessageRecordsUpdateOne {
|
|
|
- mruo.mutation.AddSourceID(i)
|
|
|
+// ClearSourceID clears the value of the "source_id" field.
|
|
|
+func (mruo *MessageRecordsUpdateOne) ClearSourceID() *MessageRecordsUpdateOne {
|
|
|
+ mruo.mutation.ClearSourceID()
|
|
|
return mruo
|
|
|
}
|
|
|
|
|
|
// SetSubSourceID sets the "sub_source_id" field.
|
|
|
-func (mruo *MessageRecordsUpdateOne) SetSubSourceID(i int) *MessageRecordsUpdateOne {
|
|
|
- mruo.mutation.ResetSubSourceID()
|
|
|
- mruo.mutation.SetSubSourceID(i)
|
|
|
+func (mruo *MessageRecordsUpdateOne) SetSubSourceID(u uint64) *MessageRecordsUpdateOne {
|
|
|
+ mruo.mutation.SetSubSourceID(u)
|
|
|
return mruo
|
|
|
}
|
|
|
|
|
|
// SetNillableSubSourceID sets the "sub_source_id" field if the given value is not nil.
|
|
|
-func (mruo *MessageRecordsUpdateOne) SetNillableSubSourceID(i *int) *MessageRecordsUpdateOne {
|
|
|
- if i != nil {
|
|
|
- mruo.SetSubSourceID(*i)
|
|
|
+func (mruo *MessageRecordsUpdateOne) SetNillableSubSourceID(u *uint64) *MessageRecordsUpdateOne {
|
|
|
+ if u != nil {
|
|
|
+ mruo.SetSubSourceID(*u)
|
|
|
+ }
|
|
|
+ return mruo
|
|
|
+}
|
|
|
+
|
|
|
+// ClearSubSourceID clears the value of the "sub_source_id" field.
|
|
|
+func (mruo *MessageRecordsUpdateOne) ClearSubSourceID() *MessageRecordsUpdateOne {
|
|
|
+ mruo.mutation.ClearSubSourceID()
|
|
|
+ return mruo
|
|
|
+}
|
|
|
+
|
|
|
+// SetSopStageID sets the "sop_stage" edge to the SopStage entity by ID.
|
|
|
+func (mruo *MessageRecordsUpdateOne) SetSopStageID(id uint64) *MessageRecordsUpdateOne {
|
|
|
+ mruo.mutation.SetSopStageID(id)
|
|
|
+ return mruo
|
|
|
+}
|
|
|
+
|
|
|
+// SetNillableSopStageID sets the "sop_stage" edge to the SopStage entity by ID if the given value is not nil.
|
|
|
+func (mruo *MessageRecordsUpdateOne) SetNillableSopStageID(id *uint64) *MessageRecordsUpdateOne {
|
|
|
+ if id != nil {
|
|
|
+ mruo = mruo.SetSopStageID(*id)
|
|
|
+ }
|
|
|
+ return mruo
|
|
|
+}
|
|
|
+
|
|
|
+// SetSopStage sets the "sop_stage" edge to the SopStage entity.
|
|
|
+func (mruo *MessageRecordsUpdateOne) SetSopStage(s *SopStage) *MessageRecordsUpdateOne {
|
|
|
+ return mruo.SetSopStageID(s.ID)
|
|
|
+}
|
|
|
+
|
|
|
+// SetSopNodeID sets the "sop_node" edge to the SopNode entity by ID.
|
|
|
+func (mruo *MessageRecordsUpdateOne) SetSopNodeID(id uint64) *MessageRecordsUpdateOne {
|
|
|
+ mruo.mutation.SetSopNodeID(id)
|
|
|
+ return mruo
|
|
|
+}
|
|
|
+
|
|
|
+// SetNillableSopNodeID sets the "sop_node" edge to the SopNode entity by ID if the given value is not nil.
|
|
|
+func (mruo *MessageRecordsUpdateOne) SetNillableSopNodeID(id *uint64) *MessageRecordsUpdateOne {
|
|
|
+ if id != nil {
|
|
|
+ mruo = mruo.SetSopNodeID(*id)
|
|
|
}
|
|
|
return mruo
|
|
|
}
|
|
|
|
|
|
-// AddSubSourceID adds i to the "sub_source_id" field.
|
|
|
-func (mruo *MessageRecordsUpdateOne) AddSubSourceID(i int) *MessageRecordsUpdateOne {
|
|
|
- mruo.mutation.AddSubSourceID(i)
|
|
|
+// SetSopNode sets the "sop_node" edge to the SopNode entity.
|
|
|
+func (mruo *MessageRecordsUpdateOne) SetSopNode(s *SopNode) *MessageRecordsUpdateOne {
|
|
|
+ return mruo.SetSopNodeID(s.ID)
|
|
|
+}
|
|
|
+
|
|
|
+// SetMessageContactID sets the "message_contact" edge to the Contact entity by ID.
|
|
|
+func (mruo *MessageRecordsUpdateOne) SetMessageContactID(id uint64) *MessageRecordsUpdateOne {
|
|
|
+ mruo.mutation.SetMessageContactID(id)
|
|
|
+ return mruo
|
|
|
+}
|
|
|
+
|
|
|
+// SetNillableMessageContactID sets the "message_contact" edge to the Contact entity by ID if the given value is not nil.
|
|
|
+func (mruo *MessageRecordsUpdateOne) SetNillableMessageContactID(id *uint64) *MessageRecordsUpdateOne {
|
|
|
+ if id != nil {
|
|
|
+ mruo = mruo.SetMessageContactID(*id)
|
|
|
+ }
|
|
|
return mruo
|
|
|
}
|
|
|
|
|
|
+// SetMessageContact sets the "message_contact" edge to the Contact entity.
|
|
|
+func (mruo *MessageRecordsUpdateOne) SetMessageContact(c *Contact) *MessageRecordsUpdateOne {
|
|
|
+ return mruo.SetMessageContactID(c.ID)
|
|
|
+}
|
|
|
+
|
|
|
// Mutation returns the MessageRecordsMutation object of the builder.
|
|
|
func (mruo *MessageRecordsUpdateOne) Mutation() *MessageRecordsMutation {
|
|
|
return mruo.mutation
|
|
|
}
|
|
|
|
|
|
+// ClearSopStage clears the "sop_stage" edge to the SopStage entity.
|
|
|
+func (mruo *MessageRecordsUpdateOne) ClearSopStage() *MessageRecordsUpdateOne {
|
|
|
+ mruo.mutation.ClearSopStage()
|
|
|
+ return mruo
|
|
|
+}
|
|
|
+
|
|
|
+// ClearSopNode clears the "sop_node" edge to the SopNode entity.
|
|
|
+func (mruo *MessageRecordsUpdateOne) ClearSopNode() *MessageRecordsUpdateOne {
|
|
|
+ mruo.mutation.ClearSopNode()
|
|
|
+ return mruo
|
|
|
+}
|
|
|
+
|
|
|
+// ClearMessageContact clears the "message_contact" edge to the Contact entity.
|
|
|
+func (mruo *MessageRecordsUpdateOne) ClearMessageContact() *MessageRecordsUpdateOne {
|
|
|
+ mruo.mutation.ClearMessageContact()
|
|
|
+ return mruo
|
|
|
+}
|
|
|
+
|
|
|
// Where appends a list predicates to the MessageRecordsUpdate builder.
|
|
|
func (mruo *MessageRecordsUpdateOne) Where(ps ...predicate.MessageRecords) *MessageRecordsUpdateOne {
|
|
|
mruo.mutation.Where(ps...)
|
|
@@ -793,12 +1009,6 @@ func (mruo *MessageRecordsUpdateOne) sqlSave(ctx context.Context) (_node *Messag
|
|
|
if value, ok := mruo.mutation.BotWxid(); ok {
|
|
|
_spec.SetField(messagerecords.FieldBotWxid, field.TypeString, value)
|
|
|
}
|
|
|
- if value, ok := mruo.mutation.ContactID(); ok {
|
|
|
- _spec.SetField(messagerecords.FieldContactID, field.TypeInt, value)
|
|
|
- }
|
|
|
- if value, ok := mruo.mutation.AddedContactID(); ok {
|
|
|
- _spec.AddField(messagerecords.FieldContactID, field.TypeInt, value)
|
|
|
- }
|
|
|
if value, ok := mruo.mutation.ContactType(); ok {
|
|
|
_spec.SetField(messagerecords.FieldContactType, field.TypeInt, value)
|
|
|
}
|
|
@@ -832,17 +1042,92 @@ func (mruo *MessageRecordsUpdateOne) sqlSave(ctx context.Context) (_node *Messag
|
|
|
if value, ok := mruo.mutation.AddedSourceType(); ok {
|
|
|
_spec.AddField(messagerecords.FieldSourceType, field.TypeInt, value)
|
|
|
}
|
|
|
- if value, ok := mruo.mutation.SourceID(); ok {
|
|
|
- _spec.SetField(messagerecords.FieldSourceID, field.TypeInt, value)
|
|
|
- }
|
|
|
- if value, ok := mruo.mutation.AddedSourceID(); ok {
|
|
|
- _spec.AddField(messagerecords.FieldSourceID, field.TypeInt, value)
|
|
|
- }
|
|
|
- if value, ok := mruo.mutation.SubSourceID(); ok {
|
|
|
- _spec.SetField(messagerecords.FieldSubSourceID, field.TypeInt, value)
|
|
|
- }
|
|
|
- if value, ok := mruo.mutation.AddedSubSourceID(); ok {
|
|
|
- _spec.AddField(messagerecords.FieldSubSourceID, field.TypeInt, value)
|
|
|
+ if mruo.mutation.SopStageCleared() {
|
|
|
+ edge := &sqlgraph.EdgeSpec{
|
|
|
+ Rel: sqlgraph.M2O,
|
|
|
+ Inverse: true,
|
|
|
+ Table: messagerecords.SopStageTable,
|
|
|
+ Columns: []string{messagerecords.SopStageColumn},
|
|
|
+ Bidi: false,
|
|
|
+ Target: &sqlgraph.EdgeTarget{
|
|
|
+ IDSpec: sqlgraph.NewFieldSpec(sopstage.FieldID, field.TypeUint64),
|
|
|
+ },
|
|
|
+ }
|
|
|
+ _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
|
+ }
|
|
|
+ if nodes := mruo.mutation.SopStageIDs(); len(nodes) > 0 {
|
|
|
+ edge := &sqlgraph.EdgeSpec{
|
|
|
+ Rel: sqlgraph.M2O,
|
|
|
+ Inverse: true,
|
|
|
+ Table: messagerecords.SopStageTable,
|
|
|
+ Columns: []string{messagerecords.SopStageColumn},
|
|
|
+ Bidi: false,
|
|
|
+ Target: &sqlgraph.EdgeTarget{
|
|
|
+ IDSpec: sqlgraph.NewFieldSpec(sopstage.FieldID, field.TypeUint64),
|
|
|
+ },
|
|
|
+ }
|
|
|
+ for _, k := range nodes {
|
|
|
+ edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
|
+ }
|
|
|
+ _spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
|
+ }
|
|
|
+ if mruo.mutation.SopNodeCleared() {
|
|
|
+ edge := &sqlgraph.EdgeSpec{
|
|
|
+ Rel: sqlgraph.M2O,
|
|
|
+ Inverse: true,
|
|
|
+ Table: messagerecords.SopNodeTable,
|
|
|
+ Columns: []string{messagerecords.SopNodeColumn},
|
|
|
+ Bidi: false,
|
|
|
+ Target: &sqlgraph.EdgeTarget{
|
|
|
+ IDSpec: sqlgraph.NewFieldSpec(sopnode.FieldID, field.TypeUint64),
|
|
|
+ },
|
|
|
+ }
|
|
|
+ _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
|
+ }
|
|
|
+ if nodes := mruo.mutation.SopNodeIDs(); len(nodes) > 0 {
|
|
|
+ edge := &sqlgraph.EdgeSpec{
|
|
|
+ Rel: sqlgraph.M2O,
|
|
|
+ Inverse: true,
|
|
|
+ Table: messagerecords.SopNodeTable,
|
|
|
+ Columns: []string{messagerecords.SopNodeColumn},
|
|
|
+ Bidi: false,
|
|
|
+ Target: &sqlgraph.EdgeTarget{
|
|
|
+ IDSpec: sqlgraph.NewFieldSpec(sopnode.FieldID, field.TypeUint64),
|
|
|
+ },
|
|
|
+ }
|
|
|
+ for _, k := range nodes {
|
|
|
+ edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
|
+ }
|
|
|
+ _spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
|
+ }
|
|
|
+ if mruo.mutation.MessageContactCleared() {
|
|
|
+ edge := &sqlgraph.EdgeSpec{
|
|
|
+ Rel: sqlgraph.M2O,
|
|
|
+ Inverse: true,
|
|
|
+ Table: messagerecords.MessageContactTable,
|
|
|
+ Columns: []string{messagerecords.MessageContactColumn},
|
|
|
+ Bidi: false,
|
|
|
+ Target: &sqlgraph.EdgeTarget{
|
|
|
+ IDSpec: sqlgraph.NewFieldSpec(contact.FieldID, field.TypeUint64),
|
|
|
+ },
|
|
|
+ }
|
|
|
+ _spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
|
+ }
|
|
|
+ if nodes := mruo.mutation.MessageContactIDs(); len(nodes) > 0 {
|
|
|
+ edge := &sqlgraph.EdgeSpec{
|
|
|
+ Rel: sqlgraph.M2O,
|
|
|
+ Inverse: true,
|
|
|
+ Table: messagerecords.MessageContactTable,
|
|
|
+ Columns: []string{messagerecords.MessageContactColumn},
|
|
|
+ Bidi: false,
|
|
|
+ Target: &sqlgraph.EdgeTarget{
|
|
|
+ IDSpec: sqlgraph.NewFieldSpec(contact.FieldID, field.TypeUint64),
|
|
|
+ },
|
|
|
+ }
|
|
|
+ for _, k := range nodes {
|
|
|
+ edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
|
+ }
|
|
|
+ _spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
|
}
|
|
|
_node = &MessageRecords{config: mruo.config}
|
|
|
_spec.Assign = _node.assignValues
|