|
@@ -18,6 +18,8 @@ import (
|
|
|
"wechat-api/ent/chatrecords"
|
|
|
"wechat-api/ent/chatsession"
|
|
|
"wechat-api/ent/contact"
|
|
|
+ "wechat-api/ent/contactfield"
|
|
|
+ "wechat-api/ent/contactfieldtemplate"
|
|
|
"wechat-api/ent/creditbalance"
|
|
|
"wechat-api/ent/creditusage"
|
|
|
"wechat-api/ent/custom_types"
|
|
@@ -67,47 +69,49 @@ const (
|
|
|
OpUpdateOne = ent.OpUpdateOne
|
|
|
|
|
|
// Node types.
|
|
|
- TypeAgent = "Agent"
|
|
|
- TypeAgentBase = "AgentBase"
|
|
|
- TypeAliyunAvatar = "AliyunAvatar"
|
|
|
- TypeAllocAgent = "AllocAgent"
|
|
|
- TypeApiKey = "ApiKey"
|
|
|
- TypeBatchMsg = "BatchMsg"
|
|
|
- TypeCategory = "Category"
|
|
|
- TypeChatRecords = "ChatRecords"
|
|
|
- TypeChatSession = "ChatSession"
|
|
|
- TypeContact = "Contact"
|
|
|
- TypeCreditBalance = "CreditBalance"
|
|
|
- TypeCreditUsage = "CreditUsage"
|
|
|
- TypeEmployee = "Employee"
|
|
|
- TypeEmployeeConfig = "EmployeeConfig"
|
|
|
- TypeLabel = "Label"
|
|
|
- TypeLabelRelationship = "LabelRelationship"
|
|
|
- TypeLabelTagging = "LabelTagging"
|
|
|
- TypeMessage = "Message"
|
|
|
- TypeMessageRecords = "MessageRecords"
|
|
|
- TypeMsg = "Msg"
|
|
|
- TypePayRecharge = "PayRecharge"
|
|
|
- TypeServer = "Server"
|
|
|
- TypeSopNode = "SopNode"
|
|
|
- TypeSopStage = "SopStage"
|
|
|
- TypeSopTask = "SopTask"
|
|
|
- TypeToken = "Token"
|
|
|
- TypeTutorial = "Tutorial"
|
|
|
- TypeUsageDetail = "UsageDetail"
|
|
|
- TypeUsageStatisticDay = "UsageStatisticDay"
|
|
|
- TypeUsageStatisticHour = "UsageStatisticHour"
|
|
|
- TypeUsageStatisticMonth = "UsageStatisticMonth"
|
|
|
- TypeUsageTotal = "UsageTotal"
|
|
|
- TypeWhatsapp = "Whatsapp"
|
|
|
- TypeWhatsappChannel = "WhatsappChannel"
|
|
|
- TypeWorkExperience = "WorkExperience"
|
|
|
- TypeWpChatroom = "WpChatroom"
|
|
|
- TypeWpChatroomMember = "WpChatroomMember"
|
|
|
- TypeWx = "Wx"
|
|
|
- TypeWxCard = "WxCard"
|
|
|
- TypeWxCardUser = "WxCardUser"
|
|
|
- TypeWxCardVisit = "WxCardVisit"
|
|
|
+ TypeAgent = "Agent"
|
|
|
+ TypeAgentBase = "AgentBase"
|
|
|
+ TypeAliyunAvatar = "AliyunAvatar"
|
|
|
+ TypeAllocAgent = "AllocAgent"
|
|
|
+ TypeApiKey = "ApiKey"
|
|
|
+ TypeBatchMsg = "BatchMsg"
|
|
|
+ TypeCategory = "Category"
|
|
|
+ TypeChatRecords = "ChatRecords"
|
|
|
+ TypeChatSession = "ChatSession"
|
|
|
+ TypeContact = "Contact"
|
|
|
+ TypeContactField = "ContactField"
|
|
|
+ TypeContactFieldTemplate = "ContactFieldTemplate"
|
|
|
+ TypeCreditBalance = "CreditBalance"
|
|
|
+ TypeCreditUsage = "CreditUsage"
|
|
|
+ TypeEmployee = "Employee"
|
|
|
+ TypeEmployeeConfig = "EmployeeConfig"
|
|
|
+ TypeLabel = "Label"
|
|
|
+ TypeLabelRelationship = "LabelRelationship"
|
|
|
+ TypeLabelTagging = "LabelTagging"
|
|
|
+ TypeMessage = "Message"
|
|
|
+ TypeMessageRecords = "MessageRecords"
|
|
|
+ TypeMsg = "Msg"
|
|
|
+ TypePayRecharge = "PayRecharge"
|
|
|
+ TypeServer = "Server"
|
|
|
+ TypeSopNode = "SopNode"
|
|
|
+ TypeSopStage = "SopStage"
|
|
|
+ TypeSopTask = "SopTask"
|
|
|
+ TypeToken = "Token"
|
|
|
+ TypeTutorial = "Tutorial"
|
|
|
+ TypeUsageDetail = "UsageDetail"
|
|
|
+ TypeUsageStatisticDay = "UsageStatisticDay"
|
|
|
+ TypeUsageStatisticHour = "UsageStatisticHour"
|
|
|
+ TypeUsageStatisticMonth = "UsageStatisticMonth"
|
|
|
+ TypeUsageTotal = "UsageTotal"
|
|
|
+ TypeWhatsapp = "Whatsapp"
|
|
|
+ TypeWhatsappChannel = "WhatsappChannel"
|
|
|
+ TypeWorkExperience = "WorkExperience"
|
|
|
+ TypeWpChatroom = "WpChatroom"
|
|
|
+ TypeWpChatroomMember = "WpChatroomMember"
|
|
|
+ TypeWx = "Wx"
|
|
|
+ TypeWxCard = "WxCard"
|
|
|
+ TypeWxCardUser = "WxCardUser"
|
|
|
+ TypeWxCardVisit = "WxCardVisit"
|
|
|
TypeXunji = "Xunji"
|
|
|
TypeXunjiService = "XunjiService"
|
|
|
)
|
|
@@ -10197,6 +10201,9 @@ type ContactMutation struct {
|
|
|
contact_relationships map[uint64]struct{}
|
|
|
removedcontact_relationships map[uint64]struct{}
|
|
|
clearedcontact_relationships bool
|
|
|
+ contact_fields map[uint64]struct{}
|
|
|
+ removedcontact_fields map[uint64]struct{}
|
|
|
+ clearedcontact_fields bool
|
|
|
contact_messages map[uint64]struct{}
|
|
|
removedcontact_messages map[uint64]struct{}
|
|
|
clearedcontact_messages bool
|
|
@@ -11658,6 +11665,60 @@ func (m *ContactMutation) ResetContactRelationships() {
|
|
|
m.removedcontact_relationships = nil
|
|
|
}
|
|
|
|
|
|
+// AddContactFieldIDs adds the "contact_fields" edge to the ContactField entity by ids.
|
|
|
+func (m *ContactMutation) AddContactFieldIDs(ids ...uint64) {
|
|
|
+ if m.contact_fields == nil {
|
|
|
+ m.contact_fields = make(map[uint64]struct{})
|
|
|
+ }
|
|
|
+ for i := range ids {
|
|
|
+ m.contact_fields[ids[i]] = struct{}{}
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// ClearContactFields clears the "contact_fields" edge to the ContactField entity.
|
|
|
+func (m *ContactMutation) ClearContactFields() {
|
|
|
+ m.clearedcontact_fields = true
|
|
|
+}
|
|
|
+
|
|
|
+// ContactFieldsCleared reports if the "contact_fields" edge to the ContactField entity was cleared.
|
|
|
+func (m *ContactMutation) ContactFieldsCleared() bool {
|
|
|
+ return m.clearedcontact_fields
|
|
|
+}
|
|
|
+
|
|
|
+// RemoveContactFieldIDs removes the "contact_fields" edge to the ContactField entity by IDs.
|
|
|
+func (m *ContactMutation) RemoveContactFieldIDs(ids ...uint64) {
|
|
|
+ if m.removedcontact_fields == nil {
|
|
|
+ m.removedcontact_fields = make(map[uint64]struct{})
|
|
|
+ }
|
|
|
+ for i := range ids {
|
|
|
+ delete(m.contact_fields, ids[i])
|
|
|
+ m.removedcontact_fields[ids[i]] = struct{}{}
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// RemovedContactFields returns the removed IDs of the "contact_fields" edge to the ContactField entity.
|
|
|
+func (m *ContactMutation) RemovedContactFieldsIDs() (ids []uint64) {
|
|
|
+ for id := range m.removedcontact_fields {
|
|
|
+ ids = append(ids, id)
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// ContactFieldsIDs returns the "contact_fields" edge IDs in the mutation.
|
|
|
+func (m *ContactMutation) ContactFieldsIDs() (ids []uint64) {
|
|
|
+ for id := range m.contact_fields {
|
|
|
+ ids = append(ids, id)
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// ResetContactFields resets all changes to the "contact_fields" edge.
|
|
|
+func (m *ContactMutation) ResetContactFields() {
|
|
|
+ m.contact_fields = nil
|
|
|
+ m.clearedcontact_fields = false
|
|
|
+ m.removedcontact_fields = nil
|
|
|
+}
|
|
|
+
|
|
|
// AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
|
|
|
func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
|
|
|
if m.contact_messages == nil {
|
|
@@ -12464,10 +12525,13 @@ func (m *ContactMutation) ResetField(name string) error {
|
|
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
|
func (m *ContactMutation) AddedEdges() []string {
|
|
|
- edges := make([]string, 0, 2)
|
|
|
+ edges := make([]string, 0, 3)
|
|
|
if m.contact_relationships != nil {
|
|
|
edges = append(edges, contact.EdgeContactRelationships)
|
|
|
}
|
|
|
+ if m.contact_fields != nil {
|
|
|
+ edges = append(edges, contact.EdgeContactFields)
|
|
|
+ }
|
|
|
if m.contact_messages != nil {
|
|
|
edges = append(edges, contact.EdgeContactMessages)
|
|
|
}
|
|
@@ -12484,6 +12548,12 @@ func (m *ContactMutation) AddedIDs(name string) []ent.Value {
|
|
|
ids = append(ids, id)
|
|
|
}
|
|
|
return ids
|
|
|
+ case contact.EdgeContactFields:
|
|
|
+ ids := make([]ent.Value, 0, len(m.contact_fields))
|
|
|
+ for id := range m.contact_fields {
|
|
|
+ ids = append(ids, id)
|
|
|
+ }
|
|
|
+ return ids
|
|
|
case contact.EdgeContactMessages:
|
|
|
ids := make([]ent.Value, 0, len(m.contact_messages))
|
|
|
for id := range m.contact_messages {
|
|
@@ -12496,10 +12566,13 @@ func (m *ContactMutation) AddedIDs(name string) []ent.Value {
|
|
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
|
func (m *ContactMutation) RemovedEdges() []string {
|
|
|
- edges := make([]string, 0, 2)
|
|
|
+ edges := make([]string, 0, 3)
|
|
|
if m.removedcontact_relationships != nil {
|
|
|
edges = append(edges, contact.EdgeContactRelationships)
|
|
|
}
|
|
|
+ if m.removedcontact_fields != nil {
|
|
|
+ edges = append(edges, contact.EdgeContactFields)
|
|
|
+ }
|
|
|
if m.removedcontact_messages != nil {
|
|
|
edges = append(edges, contact.EdgeContactMessages)
|
|
|
}
|
|
@@ -12516,6 +12589,12 @@ func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
|
|
|
ids = append(ids, id)
|
|
|
}
|
|
|
return ids
|
|
|
+ case contact.EdgeContactFields:
|
|
|
+ ids := make([]ent.Value, 0, len(m.removedcontact_fields))
|
|
|
+ for id := range m.removedcontact_fields {
|
|
|
+ ids = append(ids, id)
|
|
|
+ }
|
|
|
+ return ids
|
|
|
case contact.EdgeContactMessages:
|
|
|
ids := make([]ent.Value, 0, len(m.removedcontact_messages))
|
|
|
for id := range m.removedcontact_messages {
|
|
@@ -12528,10 +12607,13 @@ func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
|
|
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
|
func (m *ContactMutation) ClearedEdges() []string {
|
|
|
- edges := make([]string, 0, 2)
|
|
|
+ edges := make([]string, 0, 3)
|
|
|
if m.clearedcontact_relationships {
|
|
|
edges = append(edges, contact.EdgeContactRelationships)
|
|
|
}
|
|
|
+ if m.clearedcontact_fields {
|
|
|
+ edges = append(edges, contact.EdgeContactFields)
|
|
|
+ }
|
|
|
if m.clearedcontact_messages {
|
|
|
edges = append(edges, contact.EdgeContactMessages)
|
|
|
}
|
|
@@ -12544,6 +12626,8 @@ func (m *ContactMutation) EdgeCleared(name string) bool {
|
|
|
switch name {
|
|
|
case contact.EdgeContactRelationships:
|
|
|
return m.clearedcontact_relationships
|
|
|
+ case contact.EdgeContactFields:
|
|
|
+ return m.clearedcontact_fields
|
|
|
case contact.EdgeContactMessages:
|
|
|
return m.clearedcontact_messages
|
|
|
}
|
|
@@ -12565,6 +12649,9 @@ func (m *ContactMutation) ResetEdge(name string) error {
|
|
|
case contact.EdgeContactRelationships:
|
|
|
m.ResetContactRelationships()
|
|
|
return nil
|
|
|
+ case contact.EdgeContactFields:
|
|
|
+ m.ResetContactFields()
|
|
|
+ return nil
|
|
|
case contact.EdgeContactMessages:
|
|
|
m.ResetContactMessages()
|
|
|
return nil
|
|
@@ -12572,6 +12659,1552 @@ func (m *ContactMutation) ResetEdge(name string) error {
|
|
|
return fmt.Errorf("unknown Contact edge %s", name)
|
|
|
}
|
|
|
|
|
|
+// ContactFieldMutation represents an operation that mutates the ContactField nodes in the graph.
|
|
|
+type ContactFieldMutation struct {
|
|
|
+ config
|
|
|
+ op Op
|
|
|
+ typ string
|
|
|
+ id *uint64
|
|
|
+ created_at *time.Time
|
|
|
+ updated_at *time.Time
|
|
|
+ status *uint8
|
|
|
+ addstatus *int8
|
|
|
+ deleted_at *time.Time
|
|
|
+ form_id *string
|
|
|
+ value *[]string
|
|
|
+ appendvalue []string
|
|
|
+ clearedFields map[string]struct{}
|
|
|
+ field_contact *uint64
|
|
|
+ clearedfield_contact bool
|
|
|
+ done bool
|
|
|
+ oldValue func(context.Context) (*ContactField, error)
|
|
|
+ predicates []predicate.ContactField
|
|
|
+}
|
|
|
+
|
|
|
+var _ ent.Mutation = (*ContactFieldMutation)(nil)
|
|
|
+
|
|
|
+// contactfieldOption allows management of the mutation configuration using functional options.
|
|
|
+type contactfieldOption func(*ContactFieldMutation)
|
|
|
+
|
|
|
+// newContactFieldMutation creates new mutation for the ContactField entity.
|
|
|
+func newContactFieldMutation(c config, op Op, opts ...contactfieldOption) *ContactFieldMutation {
|
|
|
+ m := &ContactFieldMutation{
|
|
|
+ config: c,
|
|
|
+ op: op,
|
|
|
+ typ: TypeContactField,
|
|
|
+ clearedFields: make(map[string]struct{}),
|
|
|
+ }
|
|
|
+ for _, opt := range opts {
|
|
|
+ opt(m)
|
|
|
+ }
|
|
|
+ return m
|
|
|
+}
|
|
|
+
|
|
|
+// withContactFieldID sets the ID field of the mutation.
|
|
|
+func withContactFieldID(id uint64) contactfieldOption {
|
|
|
+ return func(m *ContactFieldMutation) {
|
|
|
+ var (
|
|
|
+ err error
|
|
|
+ once sync.Once
|
|
|
+ value *ContactField
|
|
|
+ )
|
|
|
+ m.oldValue = func(ctx context.Context) (*ContactField, error) {
|
|
|
+ once.Do(func() {
|
|
|
+ if m.done {
|
|
|
+ err = errors.New("querying old values post mutation is not allowed")
|
|
|
+ } else {
|
|
|
+ value, err = m.Client().ContactField.Get(ctx, id)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return value, err
|
|
|
+ }
|
|
|
+ m.id = &id
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// withContactField sets the old ContactField of the mutation.
|
|
|
+func withContactField(node *ContactField) contactfieldOption {
|
|
|
+ return func(m *ContactFieldMutation) {
|
|
|
+ m.oldValue = func(context.Context) (*ContactField, error) {
|
|
|
+ return node, nil
|
|
|
+ }
|
|
|
+ m.id = &node.ID
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// Client returns a new `ent.Client` from the mutation. If the mutation was
|
|
|
+// executed in a transaction (ent.Tx), a transactional client is returned.
|
|
|
+func (m ContactFieldMutation) Client() *Client {
|
|
|
+ client := &Client{config: m.config}
|
|
|
+ client.init()
|
|
|
+ return client
|
|
|
+}
|
|
|
+
|
|
|
+// Tx returns an `ent.Tx` for mutations that were executed in transactions;
|
|
|
+// it returns an error otherwise.
|
|
|
+func (m ContactFieldMutation) Tx() (*Tx, error) {
|
|
|
+ if _, ok := m.driver.(*txDriver); !ok {
|
|
|
+ return nil, errors.New("ent: mutation is not running in a transaction")
|
|
|
+ }
|
|
|
+ tx := &Tx{config: m.config}
|
|
|
+ tx.init()
|
|
|
+ return tx, nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetID sets the value of the id field. Note that this
|
|
|
+// operation is only accepted on creation of ContactField entities.
|
|
|
+func (m *ContactFieldMutation) SetID(id uint64) {
|
|
|
+ m.id = &id
|
|
|
+}
|
|
|
+
|
|
|
+// ID returns the ID value in the mutation. Note that the ID is only available
|
|
|
+// if it was provided to the builder or after it was returned from the database.
|
|
|
+func (m *ContactFieldMutation) ID() (id uint64, exists bool) {
|
|
|
+ if m.id == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *m.id, true
|
|
|
+}
|
|
|
+
|
|
|
+// IDs queries the database and returns the entity ids that match the mutation's predicate.
|
|
|
+// That means, if the mutation is applied within a transaction with an isolation level such
|
|
|
+// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
|
|
|
+// or updated by the mutation.
|
|
|
+func (m *ContactFieldMutation) IDs(ctx context.Context) ([]uint64, error) {
|
|
|
+ switch {
|
|
|
+ case m.op.Is(OpUpdateOne | OpDeleteOne):
|
|
|
+ id, exists := m.ID()
|
|
|
+ if exists {
|
|
|
+ return []uint64{id}, nil
|
|
|
+ }
|
|
|
+ fallthrough
|
|
|
+ case m.op.Is(OpUpdate | OpDelete):
|
|
|
+ return m.Client().ContactField.Query().Where(m.predicates...).IDs(ctx)
|
|
|
+ default:
|
|
|
+ return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// SetCreatedAt sets the "created_at" field.
|
|
|
+func (m *ContactFieldMutation) SetCreatedAt(t time.Time) {
|
|
|
+ m.created_at = &t
|
|
|
+}
|
|
|
+
|
|
|
+// CreatedAt returns the value of the "created_at" field in the mutation.
|
|
|
+func (m *ContactFieldMutation) CreatedAt() (r time.Time, exists bool) {
|
|
|
+ v := m.created_at
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldCreatedAt returns the old "created_at" field's value of the ContactField entity.
|
|
|
+// If the ContactField object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *ContactFieldMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldCreatedAt requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.CreatedAt, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ResetCreatedAt resets all changes to the "created_at" field.
|
|
|
+func (m *ContactFieldMutation) ResetCreatedAt() {
|
|
|
+ m.created_at = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetUpdatedAt sets the "updated_at" field.
|
|
|
+func (m *ContactFieldMutation) SetUpdatedAt(t time.Time) {
|
|
|
+ m.updated_at = &t
|
|
|
+}
|
|
|
+
|
|
|
+// UpdatedAt returns the value of the "updated_at" field in the mutation.
|
|
|
+func (m *ContactFieldMutation) UpdatedAt() (r time.Time, exists bool) {
|
|
|
+ v := m.updated_at
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldUpdatedAt returns the old "updated_at" field's value of the ContactField entity.
|
|
|
+// If the ContactField object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *ContactFieldMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.UpdatedAt, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ResetUpdatedAt resets all changes to the "updated_at" field.
|
|
|
+func (m *ContactFieldMutation) ResetUpdatedAt() {
|
|
|
+ m.updated_at = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetStatus sets the "status" field.
|
|
|
+func (m *ContactFieldMutation) SetStatus(u uint8) {
|
|
|
+ m.status = &u
|
|
|
+ m.addstatus = nil
|
|
|
+}
|
|
|
+
|
|
|
+// Status returns the value of the "status" field in the mutation.
|
|
|
+func (m *ContactFieldMutation) Status() (r uint8, exists bool) {
|
|
|
+ v := m.status
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldStatus returns the old "status" field's value of the ContactField entity.
|
|
|
+// If the ContactField object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *ContactFieldMutation) OldStatus(ctx context.Context) (v uint8, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldStatus is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldStatus requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldStatus: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.Status, nil
|
|
|
+}
|
|
|
+
|
|
|
+// AddStatus adds u to the "status" field.
|
|
|
+func (m *ContactFieldMutation) AddStatus(u int8) {
|
|
|
+ if m.addstatus != nil {
|
|
|
+ *m.addstatus += u
|
|
|
+ } else {
|
|
|
+ m.addstatus = &u
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// AddedStatus returns the value that was added to the "status" field in this mutation.
|
|
|
+func (m *ContactFieldMutation) AddedStatus() (r int8, exists bool) {
|
|
|
+ v := m.addstatus
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// ClearStatus clears the value of the "status" field.
|
|
|
+func (m *ContactFieldMutation) ClearStatus() {
|
|
|
+ m.status = nil
|
|
|
+ m.addstatus = nil
|
|
|
+ m.clearedFields[contactfield.FieldStatus] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// StatusCleared returns if the "status" field was cleared in this mutation.
|
|
|
+func (m *ContactFieldMutation) StatusCleared() bool {
|
|
|
+ _, ok := m.clearedFields[contactfield.FieldStatus]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetStatus resets all changes to the "status" field.
|
|
|
+func (m *ContactFieldMutation) ResetStatus() {
|
|
|
+ m.status = nil
|
|
|
+ m.addstatus = nil
|
|
|
+ delete(m.clearedFields, contactfield.FieldStatus)
|
|
|
+}
|
|
|
+
|
|
|
+// SetDeletedAt sets the "deleted_at" field.
|
|
|
+func (m *ContactFieldMutation) SetDeletedAt(t time.Time) {
|
|
|
+ m.deleted_at = &t
|
|
|
+}
|
|
|
+
|
|
|
+// DeletedAt returns the value of the "deleted_at" field in the mutation.
|
|
|
+func (m *ContactFieldMutation) DeletedAt() (r time.Time, exists bool) {
|
|
|
+ v := m.deleted_at
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldDeletedAt returns the old "deleted_at" field's value of the ContactField entity.
|
|
|
+// If the ContactField object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *ContactFieldMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldDeletedAt requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.DeletedAt, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
|
+func (m *ContactFieldMutation) ClearDeletedAt() {
|
|
|
+ m.deleted_at = nil
|
|
|
+ m.clearedFields[contactfield.FieldDeletedAt] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
|
|
|
+func (m *ContactFieldMutation) DeletedAtCleared() bool {
|
|
|
+ _, ok := m.clearedFields[contactfield.FieldDeletedAt]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetDeletedAt resets all changes to the "deleted_at" field.
|
|
|
+func (m *ContactFieldMutation) ResetDeletedAt() {
|
|
|
+ m.deleted_at = nil
|
|
|
+ delete(m.clearedFields, contactfield.FieldDeletedAt)
|
|
|
+}
|
|
|
+
|
|
|
+// SetContactID sets the "contact_id" field.
|
|
|
+func (m *ContactFieldMutation) SetContactID(u uint64) {
|
|
|
+ m.field_contact = &u
|
|
|
+}
|
|
|
+
|
|
|
+// ContactID returns the value of the "contact_id" field in the mutation.
|
|
|
+func (m *ContactFieldMutation) ContactID() (r uint64, exists bool) {
|
|
|
+ v := m.field_contact
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldContactID returns the old "contact_id" field's value of the ContactField entity.
|
|
|
+// If the ContactField object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *ContactFieldMutation) OldContactID(ctx context.Context) (v uint64, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldContactID is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldContactID requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldContactID: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.ContactID, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ResetContactID resets all changes to the "contact_id" field.
|
|
|
+func (m *ContactFieldMutation) ResetContactID() {
|
|
|
+ m.field_contact = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetFormID sets the "form_id" field.
|
|
|
+func (m *ContactFieldMutation) SetFormID(s string) {
|
|
|
+ m.form_id = &s
|
|
|
+}
|
|
|
+
|
|
|
+// FormID returns the value of the "form_id" field in the mutation.
|
|
|
+func (m *ContactFieldMutation) FormID() (r string, exists bool) {
|
|
|
+ v := m.form_id
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldFormID returns the old "form_id" field's value of the ContactField entity.
|
|
|
+// If the ContactField object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *ContactFieldMutation) OldFormID(ctx context.Context) (v string, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldFormID is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldFormID requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldFormID: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.FormID, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ResetFormID resets all changes to the "form_id" field.
|
|
|
+func (m *ContactFieldMutation) ResetFormID() {
|
|
|
+ m.form_id = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetValue sets the "value" field.
|
|
|
+func (m *ContactFieldMutation) SetValue(s []string) {
|
|
|
+ m.value = &s
|
|
|
+ m.appendvalue = nil
|
|
|
+}
|
|
|
+
|
|
|
+// Value returns the value of the "value" field in the mutation.
|
|
|
+func (m *ContactFieldMutation) Value() (r []string, exists bool) {
|
|
|
+ v := m.value
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldValue returns the old "value" field's value of the ContactField entity.
|
|
|
+// If the ContactField object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *ContactFieldMutation) OldValue(ctx context.Context) (v []string, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldValue is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldValue requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldValue: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.Value, nil
|
|
|
+}
|
|
|
+
|
|
|
+// AppendValue adds s to the "value" field.
|
|
|
+func (m *ContactFieldMutation) AppendValue(s []string) {
|
|
|
+ m.appendvalue = append(m.appendvalue, s...)
|
|
|
+}
|
|
|
+
|
|
|
+// AppendedValue returns the list of values that were appended to the "value" field in this mutation.
|
|
|
+func (m *ContactFieldMutation) AppendedValue() ([]string, bool) {
|
|
|
+ if len(m.appendvalue) == 0 {
|
|
|
+ return nil, false
|
|
|
+ }
|
|
|
+ return m.appendvalue, true
|
|
|
+}
|
|
|
+
|
|
|
+// ResetValue resets all changes to the "value" field.
|
|
|
+func (m *ContactFieldMutation) ResetValue() {
|
|
|
+ m.value = nil
|
|
|
+ m.appendvalue = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetFieldContactID sets the "field_contact" edge to the Contact entity by id.
|
|
|
+func (m *ContactFieldMutation) SetFieldContactID(id uint64) {
|
|
|
+ m.field_contact = &id
|
|
|
+}
|
|
|
+
|
|
|
+// ClearFieldContact clears the "field_contact" edge to the Contact entity.
|
|
|
+func (m *ContactFieldMutation) ClearFieldContact() {
|
|
|
+ m.clearedfield_contact = true
|
|
|
+ m.clearedFields[contactfield.FieldContactID] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// FieldContactCleared reports if the "field_contact" edge to the Contact entity was cleared.
|
|
|
+func (m *ContactFieldMutation) FieldContactCleared() bool {
|
|
|
+ return m.clearedfield_contact
|
|
|
+}
|
|
|
+
|
|
|
+// FieldContactID returns the "field_contact" edge ID in the mutation.
|
|
|
+func (m *ContactFieldMutation) FieldContactID() (id uint64, exists bool) {
|
|
|
+ if m.field_contact != nil {
|
|
|
+ return *m.field_contact, true
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// FieldContactIDs returns the "field_contact" edge IDs in the mutation.
|
|
|
+// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
|
|
|
+// FieldContactID instead. It exists only for internal usage by the builders.
|
|
|
+func (m *ContactFieldMutation) FieldContactIDs() (ids []uint64) {
|
|
|
+ if id := m.field_contact; id != nil {
|
|
|
+ ids = append(ids, *id)
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// ResetFieldContact resets all changes to the "field_contact" edge.
|
|
|
+func (m *ContactFieldMutation) ResetFieldContact() {
|
|
|
+ m.field_contact = nil
|
|
|
+ m.clearedfield_contact = false
|
|
|
+}
|
|
|
+
|
|
|
+// Where appends a list predicates to the ContactFieldMutation builder.
|
|
|
+func (m *ContactFieldMutation) Where(ps ...predicate.ContactField) {
|
|
|
+ m.predicates = append(m.predicates, ps...)
|
|
|
+}
|
|
|
+
|
|
|
+// WhereP appends storage-level predicates to the ContactFieldMutation builder. Using this method,
|
|
|
+// users can use type-assertion to append predicates that do not depend on any generated package.
|
|
|
+func (m *ContactFieldMutation) WhereP(ps ...func(*sql.Selector)) {
|
|
|
+ p := make([]predicate.ContactField, len(ps))
|
|
|
+ for i := range ps {
|
|
|
+ p[i] = ps[i]
|
|
|
+ }
|
|
|
+ m.Where(p...)
|
|
|
+}
|
|
|
+
|
|
|
+// Op returns the operation name.
|
|
|
+func (m *ContactFieldMutation) Op() Op {
|
|
|
+ return m.op
|
|
|
+}
|
|
|
+
|
|
|
+// SetOp allows setting the mutation operation.
|
|
|
+func (m *ContactFieldMutation) SetOp(op Op) {
|
|
|
+ m.op = op
|
|
|
+}
|
|
|
+
|
|
|
+// Type returns the node type of this mutation (ContactField).
|
|
|
+func (m *ContactFieldMutation) Type() string {
|
|
|
+ return m.typ
|
|
|
+}
|
|
|
+
|
|
|
+// Fields returns all fields that were changed during this mutation. Note that in
|
|
|
+// order to get all numeric fields that were incremented/decremented, call
|
|
|
+// AddedFields().
|
|
|
+func (m *ContactFieldMutation) Fields() []string {
|
|
|
+ fields := make([]string, 0, 7)
|
|
|
+ if m.created_at != nil {
|
|
|
+ fields = append(fields, contactfield.FieldCreatedAt)
|
|
|
+ }
|
|
|
+ if m.updated_at != nil {
|
|
|
+ fields = append(fields, contactfield.FieldUpdatedAt)
|
|
|
+ }
|
|
|
+ if m.status != nil {
|
|
|
+ fields = append(fields, contactfield.FieldStatus)
|
|
|
+ }
|
|
|
+ if m.deleted_at != nil {
|
|
|
+ fields = append(fields, contactfield.FieldDeletedAt)
|
|
|
+ }
|
|
|
+ if m.field_contact != nil {
|
|
|
+ fields = append(fields, contactfield.FieldContactID)
|
|
|
+ }
|
|
|
+ if m.form_id != nil {
|
|
|
+ fields = append(fields, contactfield.FieldFormID)
|
|
|
+ }
|
|
|
+ if m.value != nil {
|
|
|
+ fields = append(fields, contactfield.FieldValue)
|
|
|
+ }
|
|
|
+ return fields
|
|
|
+}
|
|
|
+
|
|
|
+// Field returns the value of a field with the given name. The second boolean
|
|
|
+// return value indicates that this field was not set, or was not defined in the
|
|
|
+// schema.
|
|
|
+func (m *ContactFieldMutation) Field(name string) (ent.Value, bool) {
|
|
|
+ switch name {
|
|
|
+ case contactfield.FieldCreatedAt:
|
|
|
+ return m.CreatedAt()
|
|
|
+ case contactfield.FieldUpdatedAt:
|
|
|
+ return m.UpdatedAt()
|
|
|
+ case contactfield.FieldStatus:
|
|
|
+ return m.Status()
|
|
|
+ case contactfield.FieldDeletedAt:
|
|
|
+ return m.DeletedAt()
|
|
|
+ case contactfield.FieldContactID:
|
|
|
+ return m.ContactID()
|
|
|
+ case contactfield.FieldFormID:
|
|
|
+ return m.FormID()
|
|
|
+ case contactfield.FieldValue:
|
|
|
+ return m.Value()
|
|
|
+ }
|
|
|
+ return nil, false
|
|
|
+}
|
|
|
+
|
|
|
+// OldField returns the old value of the field from the database. An error is
|
|
|
+// returned if the mutation operation is not UpdateOne, or the query to the
|
|
|
+// database failed.
|
|
|
+func (m *ContactFieldMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
|
+ switch name {
|
|
|
+ case contactfield.FieldCreatedAt:
|
|
|
+ return m.OldCreatedAt(ctx)
|
|
|
+ case contactfield.FieldUpdatedAt:
|
|
|
+ return m.OldUpdatedAt(ctx)
|
|
|
+ case contactfield.FieldStatus:
|
|
|
+ return m.OldStatus(ctx)
|
|
|
+ case contactfield.FieldDeletedAt:
|
|
|
+ return m.OldDeletedAt(ctx)
|
|
|
+ case contactfield.FieldContactID:
|
|
|
+ return m.OldContactID(ctx)
|
|
|
+ case contactfield.FieldFormID:
|
|
|
+ return m.OldFormID(ctx)
|
|
|
+ case contactfield.FieldValue:
|
|
|
+ return m.OldValue(ctx)
|
|
|
+ }
|
|
|
+ return nil, fmt.Errorf("unknown ContactField field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// SetField sets the value of a field with the given name. It returns an error if
|
|
|
+// the field is not defined in the schema, or if the type mismatched the field
|
|
|
+// type.
|
|
|
+func (m *ContactFieldMutation) SetField(name string, value ent.Value) error {
|
|
|
+ switch name {
|
|
|
+ case contactfield.FieldCreatedAt:
|
|
|
+ v, ok := value.(time.Time)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetCreatedAt(v)
|
|
|
+ return nil
|
|
|
+ case contactfield.FieldUpdatedAt:
|
|
|
+ v, ok := value.(time.Time)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetUpdatedAt(v)
|
|
|
+ return nil
|
|
|
+ case contactfield.FieldStatus:
|
|
|
+ v, ok := value.(uint8)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetStatus(v)
|
|
|
+ return nil
|
|
|
+ case contactfield.FieldDeletedAt:
|
|
|
+ v, ok := value.(time.Time)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetDeletedAt(v)
|
|
|
+ return nil
|
|
|
+ case contactfield.FieldContactID:
|
|
|
+ v, ok := value.(uint64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetContactID(v)
|
|
|
+ return nil
|
|
|
+ case contactfield.FieldFormID:
|
|
|
+ v, ok := value.(string)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetFormID(v)
|
|
|
+ return nil
|
|
|
+ case contactfield.FieldValue:
|
|
|
+ v, ok := value.([]string)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetValue(v)
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown ContactField field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// AddedFields returns all numeric fields that were incremented/decremented during
|
|
|
+// this mutation.
|
|
|
+func (m *ContactFieldMutation) AddedFields() []string {
|
|
|
+ var fields []string
|
|
|
+ if m.addstatus != nil {
|
|
|
+ fields = append(fields, contactfield.FieldStatus)
|
|
|
+ }
|
|
|
+ return fields
|
|
|
+}
|
|
|
+
|
|
|
+// AddedField returns the numeric value that was incremented/decremented on a field
|
|
|
+// with the given name. The second boolean return value indicates that this field
|
|
|
+// was not set, or was not defined in the schema.
|
|
|
+func (m *ContactFieldMutation) AddedField(name string) (ent.Value, bool) {
|
|
|
+ switch name {
|
|
|
+ case contactfield.FieldStatus:
|
|
|
+ return m.AddedStatus()
|
|
|
+ }
|
|
|
+ return nil, false
|
|
|
+}
|
|
|
+
|
|
|
+// AddField adds the value to the field with the given name. It returns an error if
|
|
|
+// the field is not defined in the schema, or if the type mismatched the field
|
|
|
+// type.
|
|
|
+func (m *ContactFieldMutation) AddField(name string, value ent.Value) error {
|
|
|
+ switch name {
|
|
|
+ case contactfield.FieldStatus:
|
|
|
+ v, ok := value.(int8)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.AddStatus(v)
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown ContactField numeric field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// ClearedFields returns all nullable fields that were cleared during this
|
|
|
+// mutation.
|
|
|
+func (m *ContactFieldMutation) ClearedFields() []string {
|
|
|
+ var fields []string
|
|
|
+ if m.FieldCleared(contactfield.FieldStatus) {
|
|
|
+ fields = append(fields, contactfield.FieldStatus)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(contactfield.FieldDeletedAt) {
|
|
|
+ fields = append(fields, contactfield.FieldDeletedAt)
|
|
|
+ }
|
|
|
+ return fields
|
|
|
+}
|
|
|
+
|
|
|
+// FieldCleared returns a boolean indicating if a field with the given name was
|
|
|
+// cleared in this mutation.
|
|
|
+func (m *ContactFieldMutation) FieldCleared(name string) bool {
|
|
|
+ _, ok := m.clearedFields[name]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ClearField clears the value of the field with the given name. It returns an
|
|
|
+// error if the field is not defined in the schema.
|
|
|
+func (m *ContactFieldMutation) ClearField(name string) error {
|
|
|
+ switch name {
|
|
|
+ case contactfield.FieldStatus:
|
|
|
+ m.ClearStatus()
|
|
|
+ return nil
|
|
|
+ case contactfield.FieldDeletedAt:
|
|
|
+ m.ClearDeletedAt()
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown ContactField nullable field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// ResetField resets all changes in the mutation for the field with the given name.
|
|
|
+// It returns an error if the field is not defined in the schema.
|
|
|
+func (m *ContactFieldMutation) ResetField(name string) error {
|
|
|
+ switch name {
|
|
|
+ case contactfield.FieldCreatedAt:
|
|
|
+ m.ResetCreatedAt()
|
|
|
+ return nil
|
|
|
+ case contactfield.FieldUpdatedAt:
|
|
|
+ m.ResetUpdatedAt()
|
|
|
+ return nil
|
|
|
+ case contactfield.FieldStatus:
|
|
|
+ m.ResetStatus()
|
|
|
+ return nil
|
|
|
+ case contactfield.FieldDeletedAt:
|
|
|
+ m.ResetDeletedAt()
|
|
|
+ return nil
|
|
|
+ case contactfield.FieldContactID:
|
|
|
+ m.ResetContactID()
|
|
|
+ return nil
|
|
|
+ case contactfield.FieldFormID:
|
|
|
+ m.ResetFormID()
|
|
|
+ return nil
|
|
|
+ case contactfield.FieldValue:
|
|
|
+ m.ResetValue()
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown ContactField field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// AddedEdges returns all edge names that were set/added in this mutation.
|
|
|
+func (m *ContactFieldMutation) AddedEdges() []string {
|
|
|
+ edges := make([]string, 0, 1)
|
|
|
+ if m.field_contact != nil {
|
|
|
+ edges = append(edges, contactfield.EdgeFieldContact)
|
|
|
+ }
|
|
|
+ return edges
|
|
|
+}
|
|
|
+
|
|
|
+// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
|
+// name in this mutation.
|
|
|
+func (m *ContactFieldMutation) AddedIDs(name string) []ent.Value {
|
|
|
+ switch name {
|
|
|
+ case contactfield.EdgeFieldContact:
|
|
|
+ if id := m.field_contact; id != nil {
|
|
|
+ return []ent.Value{*id}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+// RemovedEdges returns all edge names that were removed in this mutation.
|
|
|
+func (m *ContactFieldMutation) RemovedEdges() []string {
|
|
|
+ edges := make([]string, 0, 1)
|
|
|
+ return edges
|
|
|
+}
|
|
|
+
|
|
|
+// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
|
+// the given name in this mutation.
|
|
|
+func (m *ContactFieldMutation) RemovedIDs(name string) []ent.Value {
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
|
+func (m *ContactFieldMutation) ClearedEdges() []string {
|
|
|
+ edges := make([]string, 0, 1)
|
|
|
+ if m.clearedfield_contact {
|
|
|
+ edges = append(edges, contactfield.EdgeFieldContact)
|
|
|
+ }
|
|
|
+ return edges
|
|
|
+}
|
|
|
+
|
|
|
+// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
|
+// was cleared in this mutation.
|
|
|
+func (m *ContactFieldMutation) EdgeCleared(name string) bool {
|
|
|
+ switch name {
|
|
|
+ case contactfield.EdgeFieldContact:
|
|
|
+ return m.clearedfield_contact
|
|
|
+ }
|
|
|
+ return false
|
|
|
+}
|
|
|
+
|
|
|
+// ClearEdge clears the value of the edge with the given name. It returns an error
|
|
|
+// if that edge is not defined in the schema.
|
|
|
+func (m *ContactFieldMutation) ClearEdge(name string) error {
|
|
|
+ switch name {
|
|
|
+ case contactfield.EdgeFieldContact:
|
|
|
+ m.ClearFieldContact()
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown ContactField unique edge %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// ResetEdge resets all changes to the edge with the given name in this mutation.
|
|
|
+// It returns an error if the edge is not defined in the schema.
|
|
|
+func (m *ContactFieldMutation) ResetEdge(name string) error {
|
|
|
+ switch name {
|
|
|
+ case contactfield.EdgeFieldContact:
|
|
|
+ m.ResetFieldContact()
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown ContactField edge %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// ContactFieldTemplateMutation represents an operation that mutates the ContactFieldTemplate nodes in the graph.
|
|
|
+type ContactFieldTemplateMutation struct {
|
|
|
+ config
|
|
|
+ op Op
|
|
|
+ typ string
|
|
|
+ id *uint64
|
|
|
+ created_at *time.Time
|
|
|
+ updated_at *time.Time
|
|
|
+ status *uint8
|
|
|
+ addstatus *int8
|
|
|
+ deleted_at *time.Time
|
|
|
+ organization_id *uint64
|
|
|
+ addorganization_id *int64
|
|
|
+ template *[]custom_types.ContactFieldTemplate
|
|
|
+ appendtemplate []custom_types.ContactFieldTemplate
|
|
|
+ clearedFields map[string]struct{}
|
|
|
+ done bool
|
|
|
+ oldValue func(context.Context) (*ContactFieldTemplate, error)
|
|
|
+ predicates []predicate.ContactFieldTemplate
|
|
|
+}
|
|
|
+
|
|
|
+var _ ent.Mutation = (*ContactFieldTemplateMutation)(nil)
|
|
|
+
|
|
|
+// contactfieldtemplateOption allows management of the mutation configuration using functional options.
|
|
|
+type contactfieldtemplateOption func(*ContactFieldTemplateMutation)
|
|
|
+
|
|
|
+// newContactFieldTemplateMutation creates new mutation for the ContactFieldTemplate entity.
|
|
|
+func newContactFieldTemplateMutation(c config, op Op, opts ...contactfieldtemplateOption) *ContactFieldTemplateMutation {
|
|
|
+ m := &ContactFieldTemplateMutation{
|
|
|
+ config: c,
|
|
|
+ op: op,
|
|
|
+ typ: TypeContactFieldTemplate,
|
|
|
+ clearedFields: make(map[string]struct{}),
|
|
|
+ }
|
|
|
+ for _, opt := range opts {
|
|
|
+ opt(m)
|
|
|
+ }
|
|
|
+ return m
|
|
|
+}
|
|
|
+
|
|
|
+// withContactFieldTemplateID sets the ID field of the mutation.
|
|
|
+func withContactFieldTemplateID(id uint64) contactfieldtemplateOption {
|
|
|
+ return func(m *ContactFieldTemplateMutation) {
|
|
|
+ var (
|
|
|
+ err error
|
|
|
+ once sync.Once
|
|
|
+ value *ContactFieldTemplate
|
|
|
+ )
|
|
|
+ m.oldValue = func(ctx context.Context) (*ContactFieldTemplate, error) {
|
|
|
+ once.Do(func() {
|
|
|
+ if m.done {
|
|
|
+ err = errors.New("querying old values post mutation is not allowed")
|
|
|
+ } else {
|
|
|
+ value, err = m.Client().ContactFieldTemplate.Get(ctx, id)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return value, err
|
|
|
+ }
|
|
|
+ m.id = &id
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// withContactFieldTemplate sets the old ContactFieldTemplate of the mutation.
|
|
|
+func withContactFieldTemplate(node *ContactFieldTemplate) contactfieldtemplateOption {
|
|
|
+ return func(m *ContactFieldTemplateMutation) {
|
|
|
+ m.oldValue = func(context.Context) (*ContactFieldTemplate, error) {
|
|
|
+ return node, nil
|
|
|
+ }
|
|
|
+ m.id = &node.ID
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// Client returns a new `ent.Client` from the mutation. If the mutation was
|
|
|
+// executed in a transaction (ent.Tx), a transactional client is returned.
|
|
|
+func (m ContactFieldTemplateMutation) Client() *Client {
|
|
|
+ client := &Client{config: m.config}
|
|
|
+ client.init()
|
|
|
+ return client
|
|
|
+}
|
|
|
+
|
|
|
+// Tx returns an `ent.Tx` for mutations that were executed in transactions;
|
|
|
+// it returns an error otherwise.
|
|
|
+func (m ContactFieldTemplateMutation) Tx() (*Tx, error) {
|
|
|
+ if _, ok := m.driver.(*txDriver); !ok {
|
|
|
+ return nil, errors.New("ent: mutation is not running in a transaction")
|
|
|
+ }
|
|
|
+ tx := &Tx{config: m.config}
|
|
|
+ tx.init()
|
|
|
+ return tx, nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetID sets the value of the id field. Note that this
|
|
|
+// operation is only accepted on creation of ContactFieldTemplate entities.
|
|
|
+func (m *ContactFieldTemplateMutation) SetID(id uint64) {
|
|
|
+ m.id = &id
|
|
|
+}
|
|
|
+
|
|
|
+// ID returns the ID value in the mutation. Note that the ID is only available
|
|
|
+// if it was provided to the builder or after it was returned from the database.
|
|
|
+func (m *ContactFieldTemplateMutation) ID() (id uint64, exists bool) {
|
|
|
+ if m.id == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *m.id, true
|
|
|
+}
|
|
|
+
|
|
|
+// IDs queries the database and returns the entity ids that match the mutation's predicate.
|
|
|
+// That means, if the mutation is applied within a transaction with an isolation level such
|
|
|
+// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
|
|
|
+// or updated by the mutation.
|
|
|
+func (m *ContactFieldTemplateMutation) IDs(ctx context.Context) ([]uint64, error) {
|
|
|
+ switch {
|
|
|
+ case m.op.Is(OpUpdateOne | OpDeleteOne):
|
|
|
+ id, exists := m.ID()
|
|
|
+ if exists {
|
|
|
+ return []uint64{id}, nil
|
|
|
+ }
|
|
|
+ fallthrough
|
|
|
+ case m.op.Is(OpUpdate | OpDelete):
|
|
|
+ return m.Client().ContactFieldTemplate.Query().Where(m.predicates...).IDs(ctx)
|
|
|
+ default:
|
|
|
+ return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// SetCreatedAt sets the "created_at" field.
|
|
|
+func (m *ContactFieldTemplateMutation) SetCreatedAt(t time.Time) {
|
|
|
+ m.created_at = &t
|
|
|
+}
|
|
|
+
|
|
|
+// CreatedAt returns the value of the "created_at" field in the mutation.
|
|
|
+func (m *ContactFieldTemplateMutation) CreatedAt() (r time.Time, exists bool) {
|
|
|
+ v := m.created_at
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldCreatedAt returns the old "created_at" field's value of the ContactFieldTemplate entity.
|
|
|
+// If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *ContactFieldTemplateMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldCreatedAt requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.CreatedAt, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ResetCreatedAt resets all changes to the "created_at" field.
|
|
|
+func (m *ContactFieldTemplateMutation) ResetCreatedAt() {
|
|
|
+ m.created_at = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetUpdatedAt sets the "updated_at" field.
|
|
|
+func (m *ContactFieldTemplateMutation) SetUpdatedAt(t time.Time) {
|
|
|
+ m.updated_at = &t
|
|
|
+}
|
|
|
+
|
|
|
+// UpdatedAt returns the value of the "updated_at" field in the mutation.
|
|
|
+func (m *ContactFieldTemplateMutation) UpdatedAt() (r time.Time, exists bool) {
|
|
|
+ v := m.updated_at
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldUpdatedAt returns the old "updated_at" field's value of the ContactFieldTemplate entity.
|
|
|
+// If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *ContactFieldTemplateMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.UpdatedAt, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ResetUpdatedAt resets all changes to the "updated_at" field.
|
|
|
+func (m *ContactFieldTemplateMutation) ResetUpdatedAt() {
|
|
|
+ m.updated_at = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetStatus sets the "status" field.
|
|
|
+func (m *ContactFieldTemplateMutation) SetStatus(u uint8) {
|
|
|
+ m.status = &u
|
|
|
+ m.addstatus = nil
|
|
|
+}
|
|
|
+
|
|
|
+// Status returns the value of the "status" field in the mutation.
|
|
|
+func (m *ContactFieldTemplateMutation) Status() (r uint8, exists bool) {
|
|
|
+ v := m.status
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldStatus returns the old "status" field's value of the ContactFieldTemplate entity.
|
|
|
+// If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *ContactFieldTemplateMutation) OldStatus(ctx context.Context) (v uint8, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldStatus is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldStatus requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldStatus: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.Status, nil
|
|
|
+}
|
|
|
+
|
|
|
+// AddStatus adds u to the "status" field.
|
|
|
+func (m *ContactFieldTemplateMutation) AddStatus(u int8) {
|
|
|
+ if m.addstatus != nil {
|
|
|
+ *m.addstatus += u
|
|
|
+ } else {
|
|
|
+ m.addstatus = &u
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// AddedStatus returns the value that was added to the "status" field in this mutation.
|
|
|
+func (m *ContactFieldTemplateMutation) AddedStatus() (r int8, exists bool) {
|
|
|
+ v := m.addstatus
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// ClearStatus clears the value of the "status" field.
|
|
|
+func (m *ContactFieldTemplateMutation) ClearStatus() {
|
|
|
+ m.status = nil
|
|
|
+ m.addstatus = nil
|
|
|
+ m.clearedFields[contactfieldtemplate.FieldStatus] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// StatusCleared returns if the "status" field was cleared in this mutation.
|
|
|
+func (m *ContactFieldTemplateMutation) StatusCleared() bool {
|
|
|
+ _, ok := m.clearedFields[contactfieldtemplate.FieldStatus]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetStatus resets all changes to the "status" field.
|
|
|
+func (m *ContactFieldTemplateMutation) ResetStatus() {
|
|
|
+ m.status = nil
|
|
|
+ m.addstatus = nil
|
|
|
+ delete(m.clearedFields, contactfieldtemplate.FieldStatus)
|
|
|
+}
|
|
|
+
|
|
|
+// SetDeletedAt sets the "deleted_at" field.
|
|
|
+func (m *ContactFieldTemplateMutation) SetDeletedAt(t time.Time) {
|
|
|
+ m.deleted_at = &t
|
|
|
+}
|
|
|
+
|
|
|
+// DeletedAt returns the value of the "deleted_at" field in the mutation.
|
|
|
+func (m *ContactFieldTemplateMutation) DeletedAt() (r time.Time, exists bool) {
|
|
|
+ v := m.deleted_at
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldDeletedAt returns the old "deleted_at" field's value of the ContactFieldTemplate entity.
|
|
|
+// If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *ContactFieldTemplateMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldDeletedAt requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.DeletedAt, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ClearDeletedAt clears the value of the "deleted_at" field.
|
|
|
+func (m *ContactFieldTemplateMutation) ClearDeletedAt() {
|
|
|
+ m.deleted_at = nil
|
|
|
+ m.clearedFields[contactfieldtemplate.FieldDeletedAt] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
|
|
|
+func (m *ContactFieldTemplateMutation) DeletedAtCleared() bool {
|
|
|
+ _, ok := m.clearedFields[contactfieldtemplate.FieldDeletedAt]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetDeletedAt resets all changes to the "deleted_at" field.
|
|
|
+func (m *ContactFieldTemplateMutation) ResetDeletedAt() {
|
|
|
+ m.deleted_at = nil
|
|
|
+ delete(m.clearedFields, contactfieldtemplate.FieldDeletedAt)
|
|
|
+}
|
|
|
+
|
|
|
+// SetOrganizationID sets the "organization_id" field.
|
|
|
+func (m *ContactFieldTemplateMutation) SetOrganizationID(u uint64) {
|
|
|
+ m.organization_id = &u
|
|
|
+ m.addorganization_id = nil
|
|
|
+}
|
|
|
+
|
|
|
+// OrganizationID returns the value of the "organization_id" field in the mutation.
|
|
|
+func (m *ContactFieldTemplateMutation) OrganizationID() (r uint64, exists bool) {
|
|
|
+ v := m.organization_id
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldOrganizationID returns the old "organization_id" field's value of the ContactFieldTemplate entity.
|
|
|
+// If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *ContactFieldTemplateMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldOrganizationID requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.OrganizationID, nil
|
|
|
+}
|
|
|
+
|
|
|
+// AddOrganizationID adds u to the "organization_id" field.
|
|
|
+func (m *ContactFieldTemplateMutation) AddOrganizationID(u int64) {
|
|
|
+ if m.addorganization_id != nil {
|
|
|
+ *m.addorganization_id += u
|
|
|
+ } else {
|
|
|
+ m.addorganization_id = &u
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
|
|
|
+func (m *ContactFieldTemplateMutation) AddedOrganizationID() (r int64, exists bool) {
|
|
|
+ v := m.addorganization_id
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// ResetOrganizationID resets all changes to the "organization_id" field.
|
|
|
+func (m *ContactFieldTemplateMutation) ResetOrganizationID() {
|
|
|
+ m.organization_id = nil
|
|
|
+ m.addorganization_id = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetTemplate sets the "template" field.
|
|
|
+func (m *ContactFieldTemplateMutation) SetTemplate(ctft []custom_types.ContactFieldTemplate) {
|
|
|
+ m.template = &ctft
|
|
|
+ m.appendtemplate = nil
|
|
|
+}
|
|
|
+
|
|
|
+// Template returns the value of the "template" field in the mutation.
|
|
|
+func (m *ContactFieldTemplateMutation) Template() (r []custom_types.ContactFieldTemplate, exists bool) {
|
|
|
+ v := m.template
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldTemplate returns the old "template" field's value of the ContactFieldTemplate entity.
|
|
|
+// If the ContactFieldTemplate object wasn't provided to the builder, the object is fetched from the database.
|
|
|
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
|
|
+func (m *ContactFieldTemplateMutation) OldTemplate(ctx context.Context) (v []custom_types.ContactFieldTemplate, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldTemplate is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldTemplate requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldTemplate: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.Template, nil
|
|
|
+}
|
|
|
+
|
|
|
+// AppendTemplate adds ctft to the "template" field.
|
|
|
+func (m *ContactFieldTemplateMutation) AppendTemplate(ctft []custom_types.ContactFieldTemplate) {
|
|
|
+ m.appendtemplate = append(m.appendtemplate, ctft...)
|
|
|
+}
|
|
|
+
|
|
|
+// AppendedTemplate returns the list of values that were appended to the "template" field in this mutation.
|
|
|
+func (m *ContactFieldTemplateMutation) AppendedTemplate() ([]custom_types.ContactFieldTemplate, bool) {
|
|
|
+ if len(m.appendtemplate) == 0 {
|
|
|
+ return nil, false
|
|
|
+ }
|
|
|
+ return m.appendtemplate, true
|
|
|
+}
|
|
|
+
|
|
|
+// ResetTemplate resets all changes to the "template" field.
|
|
|
+func (m *ContactFieldTemplateMutation) ResetTemplate() {
|
|
|
+ m.template = nil
|
|
|
+ m.appendtemplate = nil
|
|
|
+}
|
|
|
+
|
|
|
+// Where appends a list predicates to the ContactFieldTemplateMutation builder.
|
|
|
+func (m *ContactFieldTemplateMutation) Where(ps ...predicate.ContactFieldTemplate) {
|
|
|
+ m.predicates = append(m.predicates, ps...)
|
|
|
+}
|
|
|
+
|
|
|
+// WhereP appends storage-level predicates to the ContactFieldTemplateMutation builder. Using this method,
|
|
|
+// users can use type-assertion to append predicates that do not depend on any generated package.
|
|
|
+func (m *ContactFieldTemplateMutation) WhereP(ps ...func(*sql.Selector)) {
|
|
|
+ p := make([]predicate.ContactFieldTemplate, len(ps))
|
|
|
+ for i := range ps {
|
|
|
+ p[i] = ps[i]
|
|
|
+ }
|
|
|
+ m.Where(p...)
|
|
|
+}
|
|
|
+
|
|
|
+// Op returns the operation name.
|
|
|
+func (m *ContactFieldTemplateMutation) Op() Op {
|
|
|
+ return m.op
|
|
|
+}
|
|
|
+
|
|
|
+// SetOp allows setting the mutation operation.
|
|
|
+func (m *ContactFieldTemplateMutation) SetOp(op Op) {
|
|
|
+ m.op = op
|
|
|
+}
|
|
|
+
|
|
|
+// Type returns the node type of this mutation (ContactFieldTemplate).
|
|
|
+func (m *ContactFieldTemplateMutation) Type() string {
|
|
|
+ return m.typ
|
|
|
+}
|
|
|
+
|
|
|
+// Fields returns all fields that were changed during this mutation. Note that in
|
|
|
+// order to get all numeric fields that were incremented/decremented, call
|
|
|
+// AddedFields().
|
|
|
+func (m *ContactFieldTemplateMutation) Fields() []string {
|
|
|
+ fields := make([]string, 0, 6)
|
|
|
+ if m.created_at != nil {
|
|
|
+ fields = append(fields, contactfieldtemplate.FieldCreatedAt)
|
|
|
+ }
|
|
|
+ if m.updated_at != nil {
|
|
|
+ fields = append(fields, contactfieldtemplate.FieldUpdatedAt)
|
|
|
+ }
|
|
|
+ if m.status != nil {
|
|
|
+ fields = append(fields, contactfieldtemplate.FieldStatus)
|
|
|
+ }
|
|
|
+ if m.deleted_at != nil {
|
|
|
+ fields = append(fields, contactfieldtemplate.FieldDeletedAt)
|
|
|
+ }
|
|
|
+ if m.organization_id != nil {
|
|
|
+ fields = append(fields, contactfieldtemplate.FieldOrganizationID)
|
|
|
+ }
|
|
|
+ if m.template != nil {
|
|
|
+ fields = append(fields, contactfieldtemplate.FieldTemplate)
|
|
|
+ }
|
|
|
+ return fields
|
|
|
+}
|
|
|
+
|
|
|
+// Field returns the value of a field with the given name. The second boolean
|
|
|
+// return value indicates that this field was not set, or was not defined in the
|
|
|
+// schema.
|
|
|
+func (m *ContactFieldTemplateMutation) Field(name string) (ent.Value, bool) {
|
|
|
+ switch name {
|
|
|
+ case contactfieldtemplate.FieldCreatedAt:
|
|
|
+ return m.CreatedAt()
|
|
|
+ case contactfieldtemplate.FieldUpdatedAt:
|
|
|
+ return m.UpdatedAt()
|
|
|
+ case contactfieldtemplate.FieldStatus:
|
|
|
+ return m.Status()
|
|
|
+ case contactfieldtemplate.FieldDeletedAt:
|
|
|
+ return m.DeletedAt()
|
|
|
+ case contactfieldtemplate.FieldOrganizationID:
|
|
|
+ return m.OrganizationID()
|
|
|
+ case contactfieldtemplate.FieldTemplate:
|
|
|
+ return m.Template()
|
|
|
+ }
|
|
|
+ return nil, false
|
|
|
+}
|
|
|
+
|
|
|
+// OldField returns the old value of the field from the database. An error is
|
|
|
+// returned if the mutation operation is not UpdateOne, or the query to the
|
|
|
+// database failed.
|
|
|
+func (m *ContactFieldTemplateMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
|
+ switch name {
|
|
|
+ case contactfieldtemplate.FieldCreatedAt:
|
|
|
+ return m.OldCreatedAt(ctx)
|
|
|
+ case contactfieldtemplate.FieldUpdatedAt:
|
|
|
+ return m.OldUpdatedAt(ctx)
|
|
|
+ case contactfieldtemplate.FieldStatus:
|
|
|
+ return m.OldStatus(ctx)
|
|
|
+ case contactfieldtemplate.FieldDeletedAt:
|
|
|
+ return m.OldDeletedAt(ctx)
|
|
|
+ case contactfieldtemplate.FieldOrganizationID:
|
|
|
+ return m.OldOrganizationID(ctx)
|
|
|
+ case contactfieldtemplate.FieldTemplate:
|
|
|
+ return m.OldTemplate(ctx)
|
|
|
+ }
|
|
|
+ return nil, fmt.Errorf("unknown ContactFieldTemplate field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// SetField sets the value of a field with the given name. It returns an error if
|
|
|
+// the field is not defined in the schema, or if the type mismatched the field
|
|
|
+// type.
|
|
|
+func (m *ContactFieldTemplateMutation) SetField(name string, value ent.Value) error {
|
|
|
+ switch name {
|
|
|
+ case contactfieldtemplate.FieldCreatedAt:
|
|
|
+ v, ok := value.(time.Time)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetCreatedAt(v)
|
|
|
+ return nil
|
|
|
+ case contactfieldtemplate.FieldUpdatedAt:
|
|
|
+ v, ok := value.(time.Time)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetUpdatedAt(v)
|
|
|
+ return nil
|
|
|
+ case contactfieldtemplate.FieldStatus:
|
|
|
+ v, ok := value.(uint8)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetStatus(v)
|
|
|
+ return nil
|
|
|
+ case contactfieldtemplate.FieldDeletedAt:
|
|
|
+ v, ok := value.(time.Time)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetDeletedAt(v)
|
|
|
+ return nil
|
|
|
+ case contactfieldtemplate.FieldOrganizationID:
|
|
|
+ v, ok := value.(uint64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetOrganizationID(v)
|
|
|
+ return nil
|
|
|
+ case contactfieldtemplate.FieldTemplate:
|
|
|
+ v, ok := value.([]custom_types.ContactFieldTemplate)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetTemplate(v)
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// AddedFields returns all numeric fields that were incremented/decremented during
|
|
|
+// this mutation.
|
|
|
+func (m *ContactFieldTemplateMutation) AddedFields() []string {
|
|
|
+ var fields []string
|
|
|
+ if m.addstatus != nil {
|
|
|
+ fields = append(fields, contactfieldtemplate.FieldStatus)
|
|
|
+ }
|
|
|
+ if m.addorganization_id != nil {
|
|
|
+ fields = append(fields, contactfieldtemplate.FieldOrganizationID)
|
|
|
+ }
|
|
|
+ return fields
|
|
|
+}
|
|
|
+
|
|
|
+// AddedField returns the numeric value that was incremented/decremented on a field
|
|
|
+// with the given name. The second boolean return value indicates that this field
|
|
|
+// was not set, or was not defined in the schema.
|
|
|
+func (m *ContactFieldTemplateMutation) AddedField(name string) (ent.Value, bool) {
|
|
|
+ switch name {
|
|
|
+ case contactfieldtemplate.FieldStatus:
|
|
|
+ return m.AddedStatus()
|
|
|
+ case contactfieldtemplate.FieldOrganizationID:
|
|
|
+ return m.AddedOrganizationID()
|
|
|
+ }
|
|
|
+ return nil, false
|
|
|
+}
|
|
|
+
|
|
|
+// AddField adds the value to the field with the given name. It returns an error if
|
|
|
+// the field is not defined in the schema, or if the type mismatched the field
|
|
|
+// type.
|
|
|
+func (m *ContactFieldTemplateMutation) AddField(name string, value ent.Value) error {
|
|
|
+ switch name {
|
|
|
+ case contactfieldtemplate.FieldStatus:
|
|
|
+ v, ok := value.(int8)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.AddStatus(v)
|
|
|
+ return nil
|
|
|
+ case contactfieldtemplate.FieldOrganizationID:
|
|
|
+ v, ok := value.(int64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.AddOrganizationID(v)
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown ContactFieldTemplate numeric field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// ClearedFields returns all nullable fields that were cleared during this
|
|
|
+// mutation.
|
|
|
+func (m *ContactFieldTemplateMutation) ClearedFields() []string {
|
|
|
+ var fields []string
|
|
|
+ if m.FieldCleared(contactfieldtemplate.FieldStatus) {
|
|
|
+ fields = append(fields, contactfieldtemplate.FieldStatus)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(contactfieldtemplate.FieldDeletedAt) {
|
|
|
+ fields = append(fields, contactfieldtemplate.FieldDeletedAt)
|
|
|
+ }
|
|
|
+ return fields
|
|
|
+}
|
|
|
+
|
|
|
+// FieldCleared returns a boolean indicating if a field with the given name was
|
|
|
+// cleared in this mutation.
|
|
|
+func (m *ContactFieldTemplateMutation) FieldCleared(name string) bool {
|
|
|
+ _, ok := m.clearedFields[name]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ClearField clears the value of the field with the given name. It returns an
|
|
|
+// error if the field is not defined in the schema.
|
|
|
+func (m *ContactFieldTemplateMutation) ClearField(name string) error {
|
|
|
+ switch name {
|
|
|
+ case contactfieldtemplate.FieldStatus:
|
|
|
+ m.ClearStatus()
|
|
|
+ return nil
|
|
|
+ case contactfieldtemplate.FieldDeletedAt:
|
|
|
+ m.ClearDeletedAt()
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown ContactFieldTemplate nullable field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// ResetField resets all changes in the mutation for the field with the given name.
|
|
|
+// It returns an error if the field is not defined in the schema.
|
|
|
+func (m *ContactFieldTemplateMutation) ResetField(name string) error {
|
|
|
+ switch name {
|
|
|
+ case contactfieldtemplate.FieldCreatedAt:
|
|
|
+ m.ResetCreatedAt()
|
|
|
+ return nil
|
|
|
+ case contactfieldtemplate.FieldUpdatedAt:
|
|
|
+ m.ResetUpdatedAt()
|
|
|
+ return nil
|
|
|
+ case contactfieldtemplate.FieldStatus:
|
|
|
+ m.ResetStatus()
|
|
|
+ return nil
|
|
|
+ case contactfieldtemplate.FieldDeletedAt:
|
|
|
+ m.ResetDeletedAt()
|
|
|
+ return nil
|
|
|
+ case contactfieldtemplate.FieldOrganizationID:
|
|
|
+ m.ResetOrganizationID()
|
|
|
+ return nil
|
|
|
+ case contactfieldtemplate.FieldTemplate:
|
|
|
+ m.ResetTemplate()
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown ContactFieldTemplate field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// AddedEdges returns all edge names that were set/added in this mutation.
|
|
|
+func (m *ContactFieldTemplateMutation) AddedEdges() []string {
|
|
|
+ edges := make([]string, 0, 0)
|
|
|
+ return edges
|
|
|
+}
|
|
|
+
|
|
|
+// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
|
+// name in this mutation.
|
|
|
+func (m *ContactFieldTemplateMutation) AddedIDs(name string) []ent.Value {
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+// RemovedEdges returns all edge names that were removed in this mutation.
|
|
|
+func (m *ContactFieldTemplateMutation) RemovedEdges() []string {
|
|
|
+ edges := make([]string, 0, 0)
|
|
|
+ return edges
|
|
|
+}
|
|
|
+
|
|
|
+// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
|
|
|
+// the given name in this mutation.
|
|
|
+func (m *ContactFieldTemplateMutation) RemovedIDs(name string) []ent.Value {
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
|
+func (m *ContactFieldTemplateMutation) ClearedEdges() []string {
|
|
|
+ edges := make([]string, 0, 0)
|
|
|
+ return edges
|
|
|
+}
|
|
|
+
|
|
|
+// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
|
+// was cleared in this mutation.
|
|
|
+func (m *ContactFieldTemplateMutation) EdgeCleared(name string) bool {
|
|
|
+ return false
|
|
|
+}
|
|
|
+
|
|
|
+// ClearEdge clears the value of the edge with the given name. It returns an error
|
|
|
+// if that edge is not defined in the schema.
|
|
|
+func (m *ContactFieldTemplateMutation) ClearEdge(name string) error {
|
|
|
+ return fmt.Errorf("unknown ContactFieldTemplate unique edge %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// ResetEdge resets all changes to the edge with the given name in this mutation.
|
|
|
+// It returns an error if the edge is not defined in the schema.
|
|
|
+func (m *ContactFieldTemplateMutation) ResetEdge(name string) error {
|
|
|
+ return fmt.Errorf("unknown ContactFieldTemplate edge %s", name)
|
|
|
+}
|
|
|
+
|
|
|
// CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
|
|
|
type CreditBalanceMutation struct {
|
|
|
config
|