|
@@ -51,6 +51,8 @@ import (
|
|
|
"wechat-api/ent/wxcard"
|
|
|
"wechat-api/ent/wxcarduser"
|
|
|
"wechat-api/ent/wxcardvisit"
|
|
|
+ "wechat-api/ent/xunji"
|
|
|
+ "wechat-api/ent/xunjiservice"
|
|
|
|
|
|
"entgo.io/ent"
|
|
|
"entgo.io/ent/dialect/sql"
|
|
@@ -106,6 +108,8 @@ const (
|
|
|
TypeWxCard = "WxCard"
|
|
|
TypeWxCardUser = "WxCardUser"
|
|
|
TypeWxCardVisit = "WxCardVisit"
|
|
|
+ TypeXunji = "Xunji"
|
|
|
+ TypeXunjiService = "XunjiService"
|
|
|
)
|
|
|
|
|
|
// AgentMutation represents an operation that mutates the Agent nodes in the graph.
|
|
@@ -140,6 +144,9 @@ type AgentMutation struct {
|
|
|
key_agent map[uint64]struct{}
|
|
|
removedkey_agent map[uint64]struct{}
|
|
|
clearedkey_agent bool
|
|
|
+ xjs_agent map[uint64]struct{}
|
|
|
+ removedxjs_agent map[uint64]struct{}
|
|
|
+ clearedxjs_agent bool
|
|
|
done bool
|
|
|
oldValue func(context.Context) (*Agent, error)
|
|
|
predicates []predicate.Agent
|
|
@@ -954,6 +961,60 @@ func (m *AgentMutation) ResetKeyAgent() {
|
|
|
m.removedkey_agent = nil
|
|
|
}
|
|
|
|
|
|
+// AddXjsAgentIDs adds the "xjs_agent" edge to the XunjiService entity by ids.
|
|
|
+func (m *AgentMutation) AddXjsAgentIDs(ids ...uint64) {
|
|
|
+ if m.xjs_agent == nil {
|
|
|
+ m.xjs_agent = make(map[uint64]struct{})
|
|
|
+ }
|
|
|
+ for i := range ids {
|
|
|
+ m.xjs_agent[ids[i]] = struct{}{}
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// ClearXjsAgent clears the "xjs_agent" edge to the XunjiService entity.
|
|
|
+func (m *AgentMutation) ClearXjsAgent() {
|
|
|
+ m.clearedxjs_agent = true
|
|
|
+}
|
|
|
+
|
|
|
+// XjsAgentCleared reports if the "xjs_agent" edge to the XunjiService entity was cleared.
|
|
|
+func (m *AgentMutation) XjsAgentCleared() bool {
|
|
|
+ return m.clearedxjs_agent
|
|
|
+}
|
|
|
+
|
|
|
+// RemoveXjsAgentIDs removes the "xjs_agent" edge to the XunjiService entity by IDs.
|
|
|
+func (m *AgentMutation) RemoveXjsAgentIDs(ids ...uint64) {
|
|
|
+ if m.removedxjs_agent == nil {
|
|
|
+ m.removedxjs_agent = make(map[uint64]struct{})
|
|
|
+ }
|
|
|
+ for i := range ids {
|
|
|
+ delete(m.xjs_agent, ids[i])
|
|
|
+ m.removedxjs_agent[ids[i]] = struct{}{}
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// RemovedXjsAgent returns the removed IDs of the "xjs_agent" edge to the XunjiService entity.
|
|
|
+func (m *AgentMutation) RemovedXjsAgentIDs() (ids []uint64) {
|
|
|
+ for id := range m.removedxjs_agent {
|
|
|
+ ids = append(ids, id)
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// XjsAgentIDs returns the "xjs_agent" edge IDs in the mutation.
|
|
|
+func (m *AgentMutation) XjsAgentIDs() (ids []uint64) {
|
|
|
+ for id := range m.xjs_agent {
|
|
|
+ ids = append(ids, id)
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// ResetXjsAgent resets all changes to the "xjs_agent" edge.
|
|
|
+func (m *AgentMutation) ResetXjsAgent() {
|
|
|
+ m.xjs_agent = nil
|
|
|
+ m.clearedxjs_agent = false
|
|
|
+ m.removedxjs_agent = nil
|
|
|
+}
|
|
|
+
|
|
|
// Where appends a list predicates to the AgentMutation builder.
|
|
|
func (m *AgentMutation) Where(ps ...predicate.Agent) {
|
|
|
m.predicates = append(m.predicates, ps...)
|
|
@@ -1311,7 +1372,7 @@ func (m *AgentMutation) ResetField(name string) error {
|
|
|
|
|
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
|
|
func (m *AgentMutation) AddedEdges() []string {
|
|
|
- edges := make([]string, 0, 4)
|
|
|
+ edges := make([]string, 0, 5)
|
|
|
if m.wx_agent != nil {
|
|
|
edges = append(edges, agent.EdgeWxAgent)
|
|
|
}
|
|
@@ -1324,6 +1385,9 @@ func (m *AgentMutation) AddedEdges() []string {
|
|
|
if m.key_agent != nil {
|
|
|
edges = append(edges, agent.EdgeKeyAgent)
|
|
|
}
|
|
|
+ if m.xjs_agent != nil {
|
|
|
+ edges = append(edges, agent.EdgeXjsAgent)
|
|
|
+ }
|
|
|
return edges
|
|
|
}
|
|
|
|
|
@@ -1355,13 +1419,19 @@ func (m *AgentMutation) AddedIDs(name string) []ent.Value {
|
|
|
ids = append(ids, id)
|
|
|
}
|
|
|
return ids
|
|
|
+ case agent.EdgeXjsAgent:
|
|
|
+ ids := make([]ent.Value, 0, len(m.xjs_agent))
|
|
|
+ for id := range m.xjs_agent {
|
|
|
+ ids = append(ids, id)
|
|
|
+ }
|
|
|
+ return ids
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
// RemovedEdges returns all edge names that were removed in this mutation.
|
|
|
func (m *AgentMutation) RemovedEdges() []string {
|
|
|
- edges := make([]string, 0, 4)
|
|
|
+ edges := make([]string, 0, 5)
|
|
|
if m.removedwx_agent != nil {
|
|
|
edges = append(edges, agent.EdgeWxAgent)
|
|
|
}
|
|
@@ -1374,6 +1444,9 @@ func (m *AgentMutation) RemovedEdges() []string {
|
|
|
if m.removedkey_agent != nil {
|
|
|
edges = append(edges, agent.EdgeKeyAgent)
|
|
|
}
|
|
|
+ if m.removedxjs_agent != nil {
|
|
|
+ edges = append(edges, agent.EdgeXjsAgent)
|
|
|
+ }
|
|
|
return edges
|
|
|
}
|
|
|
|
|
@@ -1405,13 +1478,19 @@ func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
|
|
|
ids = append(ids, id)
|
|
|
}
|
|
|
return ids
|
|
|
+ case agent.EdgeXjsAgent:
|
|
|
+ ids := make([]ent.Value, 0, len(m.removedxjs_agent))
|
|
|
+ for id := range m.removedxjs_agent {
|
|
|
+ ids = append(ids, id)
|
|
|
+ }
|
|
|
+ return ids
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
|
func (m *AgentMutation) ClearedEdges() []string {
|
|
|
- edges := make([]string, 0, 4)
|
|
|
+ edges := make([]string, 0, 5)
|
|
|
if m.clearedwx_agent {
|
|
|
edges = append(edges, agent.EdgeWxAgent)
|
|
|
}
|
|
@@ -1424,6 +1503,9 @@ func (m *AgentMutation) ClearedEdges() []string {
|
|
|
if m.clearedkey_agent {
|
|
|
edges = append(edges, agent.EdgeKeyAgent)
|
|
|
}
|
|
|
+ if m.clearedxjs_agent {
|
|
|
+ edges = append(edges, agent.EdgeXjsAgent)
|
|
|
+ }
|
|
|
return edges
|
|
|
}
|
|
|
|
|
@@ -1439,6 +1521,8 @@ func (m *AgentMutation) EdgeCleared(name string) bool {
|
|
|
return m.clearedwa_agent
|
|
|
case agent.EdgeKeyAgent:
|
|
|
return m.clearedkey_agent
|
|
|
+ case agent.EdgeXjsAgent:
|
|
|
+ return m.clearedxjs_agent
|
|
|
}
|
|
|
return false
|
|
|
}
|
|
@@ -1467,6 +1551,9 @@ func (m *AgentMutation) ResetEdge(name string) error {
|
|
|
case agent.EdgeKeyAgent:
|
|
|
m.ResetKeyAgent()
|
|
|
return nil
|
|
|
+ case agent.EdgeXjsAgent:
|
|
|
+ m.ResetXjsAgent()
|
|
|
+ return nil
|
|
|
}
|
|
|
return fmt.Errorf("unknown Agent edge %s", name)
|
|
|
}
|
|
@@ -49944,3 +50031,2019 @@ func (m *WxCardVisitMutation) ClearEdge(name string) error {
|
|
|
func (m *WxCardVisitMutation) ResetEdge(name string) error {
|
|
|
return fmt.Errorf("unknown WxCardVisit edge %s", name)
|
|
|
}
|
|
|
+
|
|
|
+// XunjiMutation represents an operation that mutates the Xunji nodes in the graph.
|
|
|
+type XunjiMutation struct {
|
|
|
+ config
|
|
|
+ op Op
|
|
|
+ typ string
|
|
|
+ id *uint64
|
|
|
+ created_at *time.Time
|
|
|
+ updated_at *time.Time
|
|
|
+ status *uint8
|
|
|
+ addstatus *int8
|
|
|
+ deleted_at *time.Time
|
|
|
+ app_key *string
|
|
|
+ app_secret *string
|
|
|
+ token *string
|
|
|
+ encoding_key *string
|
|
|
+ agent_id *uint64
|
|
|
+ addagent_id *int64
|
|
|
+ organization_id *uint64
|
|
|
+ addorganization_id *int64
|
|
|
+ clearedFields map[string]struct{}
|
|
|
+ done bool
|
|
|
+ oldValue func(context.Context) (*Xunji, error)
|
|
|
+ predicates []predicate.Xunji
|
|
|
+}
|
|
|
+
|
|
|
+var _ ent.Mutation = (*XunjiMutation)(nil)
|
|
|
+
|
|
|
+// xunjiOption allows management of the mutation configuration using functional options.
|
|
|
+type xunjiOption func(*XunjiMutation)
|
|
|
+
|
|
|
+// newXunjiMutation creates new mutation for the Xunji entity.
|
|
|
+func newXunjiMutation(c config, op Op, opts ...xunjiOption) *XunjiMutation {
|
|
|
+ m := &XunjiMutation{
|
|
|
+ config: c,
|
|
|
+ op: op,
|
|
|
+ typ: TypeXunji,
|
|
|
+ clearedFields: make(map[string]struct{}),
|
|
|
+ }
|
|
|
+ for _, opt := range opts {
|
|
|
+ opt(m)
|
|
|
+ }
|
|
|
+ return m
|
|
|
+}
|
|
|
+
|
|
|
+// withXunjiID sets the ID field of the mutation.
|
|
|
+func withXunjiID(id uint64) xunjiOption {
|
|
|
+ return func(m *XunjiMutation) {
|
|
|
+ var (
|
|
|
+ err error
|
|
|
+ once sync.Once
|
|
|
+ value *Xunji
|
|
|
+ )
|
|
|
+ m.oldValue = func(ctx context.Context) (*Xunji, error) {
|
|
|
+ once.Do(func() {
|
|
|
+ if m.done {
|
|
|
+ err = errors.New("querying old values post mutation is not allowed")
|
|
|
+ } else {
|
|
|
+ value, err = m.Client().Xunji.Get(ctx, id)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return value, err
|
|
|
+ }
|
|
|
+ m.id = &id
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// withXunji sets the old Xunji of the mutation.
|
|
|
+func withXunji(node *Xunji) xunjiOption {
|
|
|
+ return func(m *XunjiMutation) {
|
|
|
+ m.oldValue = func(context.Context) (*Xunji, 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 XunjiMutation) 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 XunjiMutation) 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 Xunji entities.
|
|
|
+func (m *XunjiMutation) 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 *XunjiMutation) 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 *XunjiMutation) 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().Xunji.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 *XunjiMutation) SetCreatedAt(t time.Time) {
|
|
|
+ m.created_at = &t
|
|
|
+}
|
|
|
+
|
|
|
+// CreatedAt returns the value of the "created_at" field in the mutation.
|
|
|
+func (m *XunjiMutation) 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 Xunji entity.
|
|
|
+// If the Xunji 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 *XunjiMutation) 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 *XunjiMutation) ResetCreatedAt() {
|
|
|
+ m.created_at = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetUpdatedAt sets the "updated_at" field.
|
|
|
+func (m *XunjiMutation) SetUpdatedAt(t time.Time) {
|
|
|
+ m.updated_at = &t
|
|
|
+}
|
|
|
+
|
|
|
+// UpdatedAt returns the value of the "updated_at" field in the mutation.
|
|
|
+func (m *XunjiMutation) 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 Xunji entity.
|
|
|
+// If the Xunji 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 *XunjiMutation) 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 *XunjiMutation) ResetUpdatedAt() {
|
|
|
+ m.updated_at = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetStatus sets the "status" field.
|
|
|
+func (m *XunjiMutation) SetStatus(u uint8) {
|
|
|
+ m.status = &u
|
|
|
+ m.addstatus = nil
|
|
|
+}
|
|
|
+
|
|
|
+// Status returns the value of the "status" field in the mutation.
|
|
|
+func (m *XunjiMutation) 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 Xunji entity.
|
|
|
+// If the Xunji 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 *XunjiMutation) 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 *XunjiMutation) 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 *XunjiMutation) 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 *XunjiMutation) ClearStatus() {
|
|
|
+ m.status = nil
|
|
|
+ m.addstatus = nil
|
|
|
+ m.clearedFields[xunji.FieldStatus] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// StatusCleared returns if the "status" field was cleared in this mutation.
|
|
|
+func (m *XunjiMutation) StatusCleared() bool {
|
|
|
+ _, ok := m.clearedFields[xunji.FieldStatus]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetStatus resets all changes to the "status" field.
|
|
|
+func (m *XunjiMutation) ResetStatus() {
|
|
|
+ m.status = nil
|
|
|
+ m.addstatus = nil
|
|
|
+ delete(m.clearedFields, xunji.FieldStatus)
|
|
|
+}
|
|
|
+
|
|
|
+// SetDeletedAt sets the "deleted_at" field.
|
|
|
+func (m *XunjiMutation) SetDeletedAt(t time.Time) {
|
|
|
+ m.deleted_at = &t
|
|
|
+}
|
|
|
+
|
|
|
+// DeletedAt returns the value of the "deleted_at" field in the mutation.
|
|
|
+func (m *XunjiMutation) 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 Xunji entity.
|
|
|
+// If the Xunji 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 *XunjiMutation) 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 *XunjiMutation) ClearDeletedAt() {
|
|
|
+ m.deleted_at = nil
|
|
|
+ m.clearedFields[xunji.FieldDeletedAt] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
|
|
|
+func (m *XunjiMutation) DeletedAtCleared() bool {
|
|
|
+ _, ok := m.clearedFields[xunji.FieldDeletedAt]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetDeletedAt resets all changes to the "deleted_at" field.
|
|
|
+func (m *XunjiMutation) ResetDeletedAt() {
|
|
|
+ m.deleted_at = nil
|
|
|
+ delete(m.clearedFields, xunji.FieldDeletedAt)
|
|
|
+}
|
|
|
+
|
|
|
+// SetAppKey sets the "app_key" field.
|
|
|
+func (m *XunjiMutation) SetAppKey(s string) {
|
|
|
+ m.app_key = &s
|
|
|
+}
|
|
|
+
|
|
|
+// AppKey returns the value of the "app_key" field in the mutation.
|
|
|
+func (m *XunjiMutation) AppKey() (r string, exists bool) {
|
|
|
+ v := m.app_key
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldAppKey returns the old "app_key" field's value of the Xunji entity.
|
|
|
+// If the Xunji 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 *XunjiMutation) OldAppKey(ctx context.Context) (v string, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldAppKey is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldAppKey requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldAppKey: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.AppKey, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ResetAppKey resets all changes to the "app_key" field.
|
|
|
+func (m *XunjiMutation) ResetAppKey() {
|
|
|
+ m.app_key = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetAppSecret sets the "app_secret" field.
|
|
|
+func (m *XunjiMutation) SetAppSecret(s string) {
|
|
|
+ m.app_secret = &s
|
|
|
+}
|
|
|
+
|
|
|
+// AppSecret returns the value of the "app_secret" field in the mutation.
|
|
|
+func (m *XunjiMutation) AppSecret() (r string, exists bool) {
|
|
|
+ v := m.app_secret
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldAppSecret returns the old "app_secret" field's value of the Xunji entity.
|
|
|
+// If the Xunji 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 *XunjiMutation) OldAppSecret(ctx context.Context) (v string, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldAppSecret is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldAppSecret requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldAppSecret: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.AppSecret, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ResetAppSecret resets all changes to the "app_secret" field.
|
|
|
+func (m *XunjiMutation) ResetAppSecret() {
|
|
|
+ m.app_secret = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetToken sets the "token" field.
|
|
|
+func (m *XunjiMutation) SetToken(s string) {
|
|
|
+ m.token = &s
|
|
|
+}
|
|
|
+
|
|
|
+// Token returns the value of the "token" field in the mutation.
|
|
|
+func (m *XunjiMutation) Token() (r string, exists bool) {
|
|
|
+ v := m.token
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldToken returns the old "token" field's value of the Xunji entity.
|
|
|
+// If the Xunji 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 *XunjiMutation) OldToken(ctx context.Context) (v string, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldToken is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldToken requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldToken: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.Token, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ResetToken resets all changes to the "token" field.
|
|
|
+func (m *XunjiMutation) ResetToken() {
|
|
|
+ m.token = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetEncodingKey sets the "encoding_key" field.
|
|
|
+func (m *XunjiMutation) SetEncodingKey(s string) {
|
|
|
+ m.encoding_key = &s
|
|
|
+}
|
|
|
+
|
|
|
+// EncodingKey returns the value of the "encoding_key" field in the mutation.
|
|
|
+func (m *XunjiMutation) EncodingKey() (r string, exists bool) {
|
|
|
+ v := m.encoding_key
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldEncodingKey returns the old "encoding_key" field's value of the Xunji entity.
|
|
|
+// If the Xunji 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 *XunjiMutation) OldEncodingKey(ctx context.Context) (v string, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldEncodingKey is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldEncodingKey requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldEncodingKey: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.EncodingKey, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ResetEncodingKey resets all changes to the "encoding_key" field.
|
|
|
+func (m *XunjiMutation) ResetEncodingKey() {
|
|
|
+ m.encoding_key = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetAgentID sets the "agent_id" field.
|
|
|
+func (m *XunjiMutation) SetAgentID(u uint64) {
|
|
|
+ m.agent_id = &u
|
|
|
+ m.addagent_id = nil
|
|
|
+}
|
|
|
+
|
|
|
+// AgentID returns the value of the "agent_id" field in the mutation.
|
|
|
+func (m *XunjiMutation) AgentID() (r uint64, exists bool) {
|
|
|
+ v := m.agent_id
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldAgentID returns the old "agent_id" field's value of the Xunji entity.
|
|
|
+// If the Xunji 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 *XunjiMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldAgentID requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.AgentID, nil
|
|
|
+}
|
|
|
+
|
|
|
+// AddAgentID adds u to the "agent_id" field.
|
|
|
+func (m *XunjiMutation) AddAgentID(u int64) {
|
|
|
+ if m.addagent_id != nil {
|
|
|
+ *m.addagent_id += u
|
|
|
+ } else {
|
|
|
+ m.addagent_id = &u
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// AddedAgentID returns the value that was added to the "agent_id" field in this mutation.
|
|
|
+func (m *XunjiMutation) AddedAgentID() (r int64, exists bool) {
|
|
|
+ v := m.addagent_id
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// ResetAgentID resets all changes to the "agent_id" field.
|
|
|
+func (m *XunjiMutation) ResetAgentID() {
|
|
|
+ m.agent_id = nil
|
|
|
+ m.addagent_id = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetOrganizationID sets the "organization_id" field.
|
|
|
+func (m *XunjiMutation) 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 *XunjiMutation) 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 Xunji entity.
|
|
|
+// If the Xunji 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 *XunjiMutation) 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 *XunjiMutation) 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 *XunjiMutation) 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 *XunjiMutation) ResetOrganizationID() {
|
|
|
+ m.organization_id = nil
|
|
|
+ m.addorganization_id = nil
|
|
|
+}
|
|
|
+
|
|
|
+// Where appends a list predicates to the XunjiMutation builder.
|
|
|
+func (m *XunjiMutation) Where(ps ...predicate.Xunji) {
|
|
|
+ m.predicates = append(m.predicates, ps...)
|
|
|
+}
|
|
|
+
|
|
|
+// WhereP appends storage-level predicates to the XunjiMutation builder. Using this method,
|
|
|
+// users can use type-assertion to append predicates that do not depend on any generated package.
|
|
|
+func (m *XunjiMutation) WhereP(ps ...func(*sql.Selector)) {
|
|
|
+ p := make([]predicate.Xunji, len(ps))
|
|
|
+ for i := range ps {
|
|
|
+ p[i] = ps[i]
|
|
|
+ }
|
|
|
+ m.Where(p...)
|
|
|
+}
|
|
|
+
|
|
|
+// Op returns the operation name.
|
|
|
+func (m *XunjiMutation) Op() Op {
|
|
|
+ return m.op
|
|
|
+}
|
|
|
+
|
|
|
+// SetOp allows setting the mutation operation.
|
|
|
+func (m *XunjiMutation) SetOp(op Op) {
|
|
|
+ m.op = op
|
|
|
+}
|
|
|
+
|
|
|
+// Type returns the node type of this mutation (Xunji).
|
|
|
+func (m *XunjiMutation) 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 *XunjiMutation) Fields() []string {
|
|
|
+ fields := make([]string, 0, 10)
|
|
|
+ if m.created_at != nil {
|
|
|
+ fields = append(fields, xunji.FieldCreatedAt)
|
|
|
+ }
|
|
|
+ if m.updated_at != nil {
|
|
|
+ fields = append(fields, xunji.FieldUpdatedAt)
|
|
|
+ }
|
|
|
+ if m.status != nil {
|
|
|
+ fields = append(fields, xunji.FieldStatus)
|
|
|
+ }
|
|
|
+ if m.deleted_at != nil {
|
|
|
+ fields = append(fields, xunji.FieldDeletedAt)
|
|
|
+ }
|
|
|
+ if m.app_key != nil {
|
|
|
+ fields = append(fields, xunji.FieldAppKey)
|
|
|
+ }
|
|
|
+ if m.app_secret != nil {
|
|
|
+ fields = append(fields, xunji.FieldAppSecret)
|
|
|
+ }
|
|
|
+ if m.token != nil {
|
|
|
+ fields = append(fields, xunji.FieldToken)
|
|
|
+ }
|
|
|
+ if m.encoding_key != nil {
|
|
|
+ fields = append(fields, xunji.FieldEncodingKey)
|
|
|
+ }
|
|
|
+ if m.agent_id != nil {
|
|
|
+ fields = append(fields, xunji.FieldAgentID)
|
|
|
+ }
|
|
|
+ if m.organization_id != nil {
|
|
|
+ fields = append(fields, xunji.FieldOrganizationID)
|
|
|
+ }
|
|
|
+ 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 *XunjiMutation) Field(name string) (ent.Value, bool) {
|
|
|
+ switch name {
|
|
|
+ case xunji.FieldCreatedAt:
|
|
|
+ return m.CreatedAt()
|
|
|
+ case xunji.FieldUpdatedAt:
|
|
|
+ return m.UpdatedAt()
|
|
|
+ case xunji.FieldStatus:
|
|
|
+ return m.Status()
|
|
|
+ case xunji.FieldDeletedAt:
|
|
|
+ return m.DeletedAt()
|
|
|
+ case xunji.FieldAppKey:
|
|
|
+ return m.AppKey()
|
|
|
+ case xunji.FieldAppSecret:
|
|
|
+ return m.AppSecret()
|
|
|
+ case xunji.FieldToken:
|
|
|
+ return m.Token()
|
|
|
+ case xunji.FieldEncodingKey:
|
|
|
+ return m.EncodingKey()
|
|
|
+ case xunji.FieldAgentID:
|
|
|
+ return m.AgentID()
|
|
|
+ case xunji.FieldOrganizationID:
|
|
|
+ return m.OrganizationID()
|
|
|
+ }
|
|
|
+ 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 *XunjiMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
|
+ switch name {
|
|
|
+ case xunji.FieldCreatedAt:
|
|
|
+ return m.OldCreatedAt(ctx)
|
|
|
+ case xunji.FieldUpdatedAt:
|
|
|
+ return m.OldUpdatedAt(ctx)
|
|
|
+ case xunji.FieldStatus:
|
|
|
+ return m.OldStatus(ctx)
|
|
|
+ case xunji.FieldDeletedAt:
|
|
|
+ return m.OldDeletedAt(ctx)
|
|
|
+ case xunji.FieldAppKey:
|
|
|
+ return m.OldAppKey(ctx)
|
|
|
+ case xunji.FieldAppSecret:
|
|
|
+ return m.OldAppSecret(ctx)
|
|
|
+ case xunji.FieldToken:
|
|
|
+ return m.OldToken(ctx)
|
|
|
+ case xunji.FieldEncodingKey:
|
|
|
+ return m.OldEncodingKey(ctx)
|
|
|
+ case xunji.FieldAgentID:
|
|
|
+ return m.OldAgentID(ctx)
|
|
|
+ case xunji.FieldOrganizationID:
|
|
|
+ return m.OldOrganizationID(ctx)
|
|
|
+ }
|
|
|
+ return nil, fmt.Errorf("unknown Xunji 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 *XunjiMutation) SetField(name string, value ent.Value) error {
|
|
|
+ switch name {
|
|
|
+ case xunji.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 xunji.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 xunji.FieldStatus:
|
|
|
+ v, ok := value.(uint8)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetStatus(v)
|
|
|
+ return nil
|
|
|
+ case xunji.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 xunji.FieldAppKey:
|
|
|
+ v, ok := value.(string)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetAppKey(v)
|
|
|
+ return nil
|
|
|
+ case xunji.FieldAppSecret:
|
|
|
+ v, ok := value.(string)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetAppSecret(v)
|
|
|
+ return nil
|
|
|
+ case xunji.FieldToken:
|
|
|
+ v, ok := value.(string)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetToken(v)
|
|
|
+ return nil
|
|
|
+ case xunji.FieldEncodingKey:
|
|
|
+ v, ok := value.(string)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetEncodingKey(v)
|
|
|
+ return nil
|
|
|
+ case xunji.FieldAgentID:
|
|
|
+ v, ok := value.(uint64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetAgentID(v)
|
|
|
+ return nil
|
|
|
+ case xunji.FieldOrganizationID:
|
|
|
+ v, ok := value.(uint64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetOrganizationID(v)
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown Xunji field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// AddedFields returns all numeric fields that were incremented/decremented during
|
|
|
+// this mutation.
|
|
|
+func (m *XunjiMutation) AddedFields() []string {
|
|
|
+ var fields []string
|
|
|
+ if m.addstatus != nil {
|
|
|
+ fields = append(fields, xunji.FieldStatus)
|
|
|
+ }
|
|
|
+ if m.addagent_id != nil {
|
|
|
+ fields = append(fields, xunji.FieldAgentID)
|
|
|
+ }
|
|
|
+ if m.addorganization_id != nil {
|
|
|
+ fields = append(fields, xunji.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 *XunjiMutation) AddedField(name string) (ent.Value, bool) {
|
|
|
+ switch name {
|
|
|
+ case xunji.FieldStatus:
|
|
|
+ return m.AddedStatus()
|
|
|
+ case xunji.FieldAgentID:
|
|
|
+ return m.AddedAgentID()
|
|
|
+ case xunji.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 *XunjiMutation) AddField(name string, value ent.Value) error {
|
|
|
+ switch name {
|
|
|
+ case xunji.FieldStatus:
|
|
|
+ v, ok := value.(int8)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.AddStatus(v)
|
|
|
+ return nil
|
|
|
+ case xunji.FieldAgentID:
|
|
|
+ v, ok := value.(int64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.AddAgentID(v)
|
|
|
+ return nil
|
|
|
+ case xunji.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 Xunji numeric field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// ClearedFields returns all nullable fields that were cleared during this
|
|
|
+// mutation.
|
|
|
+func (m *XunjiMutation) ClearedFields() []string {
|
|
|
+ var fields []string
|
|
|
+ if m.FieldCleared(xunji.FieldStatus) {
|
|
|
+ fields = append(fields, xunji.FieldStatus)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(xunji.FieldDeletedAt) {
|
|
|
+ fields = append(fields, xunji.FieldDeletedAt)
|
|
|
+ }
|
|
|
+ return fields
|
|
|
+}
|
|
|
+
|
|
|
+// FieldCleared returns a boolean indicating if a field with the given name was
|
|
|
+// cleared in this mutation.
|
|
|
+func (m *XunjiMutation) 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 *XunjiMutation) ClearField(name string) error {
|
|
|
+ switch name {
|
|
|
+ case xunji.FieldStatus:
|
|
|
+ m.ClearStatus()
|
|
|
+ return nil
|
|
|
+ case xunji.FieldDeletedAt:
|
|
|
+ m.ClearDeletedAt()
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown Xunji 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 *XunjiMutation) ResetField(name string) error {
|
|
|
+ switch name {
|
|
|
+ case xunji.FieldCreatedAt:
|
|
|
+ m.ResetCreatedAt()
|
|
|
+ return nil
|
|
|
+ case xunji.FieldUpdatedAt:
|
|
|
+ m.ResetUpdatedAt()
|
|
|
+ return nil
|
|
|
+ case xunji.FieldStatus:
|
|
|
+ m.ResetStatus()
|
|
|
+ return nil
|
|
|
+ case xunji.FieldDeletedAt:
|
|
|
+ m.ResetDeletedAt()
|
|
|
+ return nil
|
|
|
+ case xunji.FieldAppKey:
|
|
|
+ m.ResetAppKey()
|
|
|
+ return nil
|
|
|
+ case xunji.FieldAppSecret:
|
|
|
+ m.ResetAppSecret()
|
|
|
+ return nil
|
|
|
+ case xunji.FieldToken:
|
|
|
+ m.ResetToken()
|
|
|
+ return nil
|
|
|
+ case xunji.FieldEncodingKey:
|
|
|
+ m.ResetEncodingKey()
|
|
|
+ return nil
|
|
|
+ case xunji.FieldAgentID:
|
|
|
+ m.ResetAgentID()
|
|
|
+ return nil
|
|
|
+ case xunji.FieldOrganizationID:
|
|
|
+ m.ResetOrganizationID()
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown Xunji field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// AddedEdges returns all edge names that were set/added in this mutation.
|
|
|
+func (m *XunjiMutation) 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 *XunjiMutation) AddedIDs(name string) []ent.Value {
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+// RemovedEdges returns all edge names that were removed in this mutation.
|
|
|
+func (m *XunjiMutation) 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 *XunjiMutation) RemovedIDs(name string) []ent.Value {
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
|
+func (m *XunjiMutation) 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 *XunjiMutation) 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 *XunjiMutation) ClearEdge(name string) error {
|
|
|
+ return fmt.Errorf("unknown Xunji 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 *XunjiMutation) ResetEdge(name string) error {
|
|
|
+ return fmt.Errorf("unknown Xunji edge %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// XunjiServiceMutation represents an operation that mutates the XunjiService nodes in the graph.
|
|
|
+type XunjiServiceMutation struct {
|
|
|
+ config
|
|
|
+ op Op
|
|
|
+ typ string
|
|
|
+ id *uint64
|
|
|
+ created_at *time.Time
|
|
|
+ updated_at *time.Time
|
|
|
+ status *uint8
|
|
|
+ addstatus *int8
|
|
|
+ deleted_at *time.Time
|
|
|
+ xunji_id *uint64
|
|
|
+ addxunji_id *int64
|
|
|
+ organization_id *uint64
|
|
|
+ addorganization_id *int64
|
|
|
+ wxid *string
|
|
|
+ api_base *string
|
|
|
+ api_key *string
|
|
|
+ clearedFields map[string]struct{}
|
|
|
+ agent *uint64
|
|
|
+ clearedagent bool
|
|
|
+ done bool
|
|
|
+ oldValue func(context.Context) (*XunjiService, error)
|
|
|
+ predicates []predicate.XunjiService
|
|
|
+}
|
|
|
+
|
|
|
+var _ ent.Mutation = (*XunjiServiceMutation)(nil)
|
|
|
+
|
|
|
+// xunjiserviceOption allows management of the mutation configuration using functional options.
|
|
|
+type xunjiserviceOption func(*XunjiServiceMutation)
|
|
|
+
|
|
|
+// newXunjiServiceMutation creates new mutation for the XunjiService entity.
|
|
|
+func newXunjiServiceMutation(c config, op Op, opts ...xunjiserviceOption) *XunjiServiceMutation {
|
|
|
+ m := &XunjiServiceMutation{
|
|
|
+ config: c,
|
|
|
+ op: op,
|
|
|
+ typ: TypeXunjiService,
|
|
|
+ clearedFields: make(map[string]struct{}),
|
|
|
+ }
|
|
|
+ for _, opt := range opts {
|
|
|
+ opt(m)
|
|
|
+ }
|
|
|
+ return m
|
|
|
+}
|
|
|
+
|
|
|
+// withXunjiServiceID sets the ID field of the mutation.
|
|
|
+func withXunjiServiceID(id uint64) xunjiserviceOption {
|
|
|
+ return func(m *XunjiServiceMutation) {
|
|
|
+ var (
|
|
|
+ err error
|
|
|
+ once sync.Once
|
|
|
+ value *XunjiService
|
|
|
+ )
|
|
|
+ m.oldValue = func(ctx context.Context) (*XunjiService, error) {
|
|
|
+ once.Do(func() {
|
|
|
+ if m.done {
|
|
|
+ err = errors.New("querying old values post mutation is not allowed")
|
|
|
+ } else {
|
|
|
+ value, err = m.Client().XunjiService.Get(ctx, id)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return value, err
|
|
|
+ }
|
|
|
+ m.id = &id
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// withXunjiService sets the old XunjiService of the mutation.
|
|
|
+func withXunjiService(node *XunjiService) xunjiserviceOption {
|
|
|
+ return func(m *XunjiServiceMutation) {
|
|
|
+ m.oldValue = func(context.Context) (*XunjiService, 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 XunjiServiceMutation) 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 XunjiServiceMutation) 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 XunjiService entities.
|
|
|
+func (m *XunjiServiceMutation) 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 *XunjiServiceMutation) 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 *XunjiServiceMutation) 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().XunjiService.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 *XunjiServiceMutation) SetCreatedAt(t time.Time) {
|
|
|
+ m.created_at = &t
|
|
|
+}
|
|
|
+
|
|
|
+// CreatedAt returns the value of the "created_at" field in the mutation.
|
|
|
+func (m *XunjiServiceMutation) 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 XunjiService entity.
|
|
|
+// If the XunjiService 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 *XunjiServiceMutation) 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 *XunjiServiceMutation) ResetCreatedAt() {
|
|
|
+ m.created_at = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetUpdatedAt sets the "updated_at" field.
|
|
|
+func (m *XunjiServiceMutation) SetUpdatedAt(t time.Time) {
|
|
|
+ m.updated_at = &t
|
|
|
+}
|
|
|
+
|
|
|
+// UpdatedAt returns the value of the "updated_at" field in the mutation.
|
|
|
+func (m *XunjiServiceMutation) 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 XunjiService entity.
|
|
|
+// If the XunjiService 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 *XunjiServiceMutation) 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 *XunjiServiceMutation) ResetUpdatedAt() {
|
|
|
+ m.updated_at = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetStatus sets the "status" field.
|
|
|
+func (m *XunjiServiceMutation) SetStatus(u uint8) {
|
|
|
+ m.status = &u
|
|
|
+ m.addstatus = nil
|
|
|
+}
|
|
|
+
|
|
|
+// Status returns the value of the "status" field in the mutation.
|
|
|
+func (m *XunjiServiceMutation) 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 XunjiService entity.
|
|
|
+// If the XunjiService 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 *XunjiServiceMutation) 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 *XunjiServiceMutation) 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 *XunjiServiceMutation) 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 *XunjiServiceMutation) ClearStatus() {
|
|
|
+ m.status = nil
|
|
|
+ m.addstatus = nil
|
|
|
+ m.clearedFields[xunjiservice.FieldStatus] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// StatusCleared returns if the "status" field was cleared in this mutation.
|
|
|
+func (m *XunjiServiceMutation) StatusCleared() bool {
|
|
|
+ _, ok := m.clearedFields[xunjiservice.FieldStatus]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetStatus resets all changes to the "status" field.
|
|
|
+func (m *XunjiServiceMutation) ResetStatus() {
|
|
|
+ m.status = nil
|
|
|
+ m.addstatus = nil
|
|
|
+ delete(m.clearedFields, xunjiservice.FieldStatus)
|
|
|
+}
|
|
|
+
|
|
|
+// SetDeletedAt sets the "deleted_at" field.
|
|
|
+func (m *XunjiServiceMutation) SetDeletedAt(t time.Time) {
|
|
|
+ m.deleted_at = &t
|
|
|
+}
|
|
|
+
|
|
|
+// DeletedAt returns the value of the "deleted_at" field in the mutation.
|
|
|
+func (m *XunjiServiceMutation) 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 XunjiService entity.
|
|
|
+// If the XunjiService 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 *XunjiServiceMutation) 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 *XunjiServiceMutation) ClearDeletedAt() {
|
|
|
+ m.deleted_at = nil
|
|
|
+ m.clearedFields[xunjiservice.FieldDeletedAt] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
|
|
|
+func (m *XunjiServiceMutation) DeletedAtCleared() bool {
|
|
|
+ _, ok := m.clearedFields[xunjiservice.FieldDeletedAt]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetDeletedAt resets all changes to the "deleted_at" field.
|
|
|
+func (m *XunjiServiceMutation) ResetDeletedAt() {
|
|
|
+ m.deleted_at = nil
|
|
|
+ delete(m.clearedFields, xunjiservice.FieldDeletedAt)
|
|
|
+}
|
|
|
+
|
|
|
+// SetXunjiID sets the "xunji_id" field.
|
|
|
+func (m *XunjiServiceMutation) SetXunjiID(u uint64) {
|
|
|
+ m.xunji_id = &u
|
|
|
+ m.addxunji_id = nil
|
|
|
+}
|
|
|
+
|
|
|
+// XunjiID returns the value of the "xunji_id" field in the mutation.
|
|
|
+func (m *XunjiServiceMutation) XunjiID() (r uint64, exists bool) {
|
|
|
+ v := m.xunji_id
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldXunjiID returns the old "xunji_id" field's value of the XunjiService entity.
|
|
|
+// If the XunjiService 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 *XunjiServiceMutation) OldXunjiID(ctx context.Context) (v uint64, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldXunjiID is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldXunjiID requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldXunjiID: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.XunjiID, nil
|
|
|
+}
|
|
|
+
|
|
|
+// AddXunjiID adds u to the "xunji_id" field.
|
|
|
+func (m *XunjiServiceMutation) AddXunjiID(u int64) {
|
|
|
+ if m.addxunji_id != nil {
|
|
|
+ *m.addxunji_id += u
|
|
|
+ } else {
|
|
|
+ m.addxunji_id = &u
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// AddedXunjiID returns the value that was added to the "xunji_id" field in this mutation.
|
|
|
+func (m *XunjiServiceMutation) AddedXunjiID() (r int64, exists bool) {
|
|
|
+ v := m.addxunji_id
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// ResetXunjiID resets all changes to the "xunji_id" field.
|
|
|
+func (m *XunjiServiceMutation) ResetXunjiID() {
|
|
|
+ m.xunji_id = nil
|
|
|
+ m.addxunji_id = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetAgentID sets the "agent_id" field.
|
|
|
+func (m *XunjiServiceMutation) SetAgentID(u uint64) {
|
|
|
+ m.agent = &u
|
|
|
+}
|
|
|
+
|
|
|
+// AgentID returns the value of the "agent_id" field in the mutation.
|
|
|
+func (m *XunjiServiceMutation) AgentID() (r uint64, exists bool) {
|
|
|
+ v := m.agent
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldAgentID returns the old "agent_id" field's value of the XunjiService entity.
|
|
|
+// If the XunjiService 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 *XunjiServiceMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldAgentID requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.AgentID, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ResetAgentID resets all changes to the "agent_id" field.
|
|
|
+func (m *XunjiServiceMutation) ResetAgentID() {
|
|
|
+ m.agent = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetOrganizationID sets the "organization_id" field.
|
|
|
+func (m *XunjiServiceMutation) 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 *XunjiServiceMutation) 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 XunjiService entity.
|
|
|
+// If the XunjiService 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 *XunjiServiceMutation) 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 *XunjiServiceMutation) 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 *XunjiServiceMutation) 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 *XunjiServiceMutation) ResetOrganizationID() {
|
|
|
+ m.organization_id = nil
|
|
|
+ m.addorganization_id = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetWxid sets the "wxid" field.
|
|
|
+func (m *XunjiServiceMutation) SetWxid(s string) {
|
|
|
+ m.wxid = &s
|
|
|
+}
|
|
|
+
|
|
|
+// Wxid returns the value of the "wxid" field in the mutation.
|
|
|
+func (m *XunjiServiceMutation) Wxid() (r string, exists bool) {
|
|
|
+ v := m.wxid
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldWxid returns the old "wxid" field's value of the XunjiService entity.
|
|
|
+// If the XunjiService 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 *XunjiServiceMutation) OldWxid(ctx context.Context) (v string, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldWxid is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldWxid requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldWxid: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.Wxid, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ResetWxid resets all changes to the "wxid" field.
|
|
|
+func (m *XunjiServiceMutation) ResetWxid() {
|
|
|
+ m.wxid = nil
|
|
|
+}
|
|
|
+
|
|
|
+// SetAPIBase sets the "api_base" field.
|
|
|
+func (m *XunjiServiceMutation) SetAPIBase(s string) {
|
|
|
+ m.api_base = &s
|
|
|
+}
|
|
|
+
|
|
|
+// APIBase returns the value of the "api_base" field in the mutation.
|
|
|
+func (m *XunjiServiceMutation) APIBase() (r string, exists bool) {
|
|
|
+ v := m.api_base
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldAPIBase returns the old "api_base" field's value of the XunjiService entity.
|
|
|
+// If the XunjiService 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 *XunjiServiceMutation) OldAPIBase(ctx context.Context) (v string, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldAPIBase requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.APIBase, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ClearAPIBase clears the value of the "api_base" field.
|
|
|
+func (m *XunjiServiceMutation) ClearAPIBase() {
|
|
|
+ m.api_base = nil
|
|
|
+ m.clearedFields[xunjiservice.FieldAPIBase] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// APIBaseCleared returns if the "api_base" field was cleared in this mutation.
|
|
|
+func (m *XunjiServiceMutation) APIBaseCleared() bool {
|
|
|
+ _, ok := m.clearedFields[xunjiservice.FieldAPIBase]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetAPIBase resets all changes to the "api_base" field.
|
|
|
+func (m *XunjiServiceMutation) ResetAPIBase() {
|
|
|
+ m.api_base = nil
|
|
|
+ delete(m.clearedFields, xunjiservice.FieldAPIBase)
|
|
|
+}
|
|
|
+
|
|
|
+// SetAPIKey sets the "api_key" field.
|
|
|
+func (m *XunjiServiceMutation) SetAPIKey(s string) {
|
|
|
+ m.api_key = &s
|
|
|
+}
|
|
|
+
|
|
|
+// APIKey returns the value of the "api_key" field in the mutation.
|
|
|
+func (m *XunjiServiceMutation) APIKey() (r string, exists bool) {
|
|
|
+ v := m.api_key
|
|
|
+ if v == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return *v, true
|
|
|
+}
|
|
|
+
|
|
|
+// OldAPIKey returns the old "api_key" field's value of the XunjiService entity.
|
|
|
+// If the XunjiService 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 *XunjiServiceMutation) OldAPIKey(ctx context.Context) (v string, err error) {
|
|
|
+ if !m.op.Is(OpUpdateOne) {
|
|
|
+ return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
|
|
|
+ }
|
|
|
+ if m.id == nil || m.oldValue == nil {
|
|
|
+ return v, errors.New("OldAPIKey requires an ID field in the mutation")
|
|
|
+ }
|
|
|
+ oldValue, err := m.oldValue(ctx)
|
|
|
+ if err != nil {
|
|
|
+ return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
|
|
|
+ }
|
|
|
+ return oldValue.APIKey, nil
|
|
|
+}
|
|
|
+
|
|
|
+// ClearAPIKey clears the value of the "api_key" field.
|
|
|
+func (m *XunjiServiceMutation) ClearAPIKey() {
|
|
|
+ m.api_key = nil
|
|
|
+ m.clearedFields[xunjiservice.FieldAPIKey] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// APIKeyCleared returns if the "api_key" field was cleared in this mutation.
|
|
|
+func (m *XunjiServiceMutation) APIKeyCleared() bool {
|
|
|
+ _, ok := m.clearedFields[xunjiservice.FieldAPIKey]
|
|
|
+ return ok
|
|
|
+}
|
|
|
+
|
|
|
+// ResetAPIKey resets all changes to the "api_key" field.
|
|
|
+func (m *XunjiServiceMutation) ResetAPIKey() {
|
|
|
+ m.api_key = nil
|
|
|
+ delete(m.clearedFields, xunjiservice.FieldAPIKey)
|
|
|
+}
|
|
|
+
|
|
|
+// ClearAgent clears the "agent" edge to the Agent entity.
|
|
|
+func (m *XunjiServiceMutation) ClearAgent() {
|
|
|
+ m.clearedagent = true
|
|
|
+ m.clearedFields[xunjiservice.FieldAgentID] = struct{}{}
|
|
|
+}
|
|
|
+
|
|
|
+// AgentCleared reports if the "agent" edge to the Agent entity was cleared.
|
|
|
+func (m *XunjiServiceMutation) AgentCleared() bool {
|
|
|
+ return m.clearedagent
|
|
|
+}
|
|
|
+
|
|
|
+// AgentIDs returns the "agent" edge IDs in the mutation.
|
|
|
+// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
|
|
|
+// AgentID instead. It exists only for internal usage by the builders.
|
|
|
+func (m *XunjiServiceMutation) AgentIDs() (ids []uint64) {
|
|
|
+ if id := m.agent; id != nil {
|
|
|
+ ids = append(ids, *id)
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// ResetAgent resets all changes to the "agent" edge.
|
|
|
+func (m *XunjiServiceMutation) ResetAgent() {
|
|
|
+ m.agent = nil
|
|
|
+ m.clearedagent = false
|
|
|
+}
|
|
|
+
|
|
|
+// Where appends a list predicates to the XunjiServiceMutation builder.
|
|
|
+func (m *XunjiServiceMutation) Where(ps ...predicate.XunjiService) {
|
|
|
+ m.predicates = append(m.predicates, ps...)
|
|
|
+}
|
|
|
+
|
|
|
+// WhereP appends storage-level predicates to the XunjiServiceMutation builder. Using this method,
|
|
|
+// users can use type-assertion to append predicates that do not depend on any generated package.
|
|
|
+func (m *XunjiServiceMutation) WhereP(ps ...func(*sql.Selector)) {
|
|
|
+ p := make([]predicate.XunjiService, len(ps))
|
|
|
+ for i := range ps {
|
|
|
+ p[i] = ps[i]
|
|
|
+ }
|
|
|
+ m.Where(p...)
|
|
|
+}
|
|
|
+
|
|
|
+// Op returns the operation name.
|
|
|
+func (m *XunjiServiceMutation) Op() Op {
|
|
|
+ return m.op
|
|
|
+}
|
|
|
+
|
|
|
+// SetOp allows setting the mutation operation.
|
|
|
+func (m *XunjiServiceMutation) SetOp(op Op) {
|
|
|
+ m.op = op
|
|
|
+}
|
|
|
+
|
|
|
+// Type returns the node type of this mutation (XunjiService).
|
|
|
+func (m *XunjiServiceMutation) 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 *XunjiServiceMutation) Fields() []string {
|
|
|
+ fields := make([]string, 0, 10)
|
|
|
+ if m.created_at != nil {
|
|
|
+ fields = append(fields, xunjiservice.FieldCreatedAt)
|
|
|
+ }
|
|
|
+ if m.updated_at != nil {
|
|
|
+ fields = append(fields, xunjiservice.FieldUpdatedAt)
|
|
|
+ }
|
|
|
+ if m.status != nil {
|
|
|
+ fields = append(fields, xunjiservice.FieldStatus)
|
|
|
+ }
|
|
|
+ if m.deleted_at != nil {
|
|
|
+ fields = append(fields, xunjiservice.FieldDeletedAt)
|
|
|
+ }
|
|
|
+ if m.xunji_id != nil {
|
|
|
+ fields = append(fields, xunjiservice.FieldXunjiID)
|
|
|
+ }
|
|
|
+ if m.agent != nil {
|
|
|
+ fields = append(fields, xunjiservice.FieldAgentID)
|
|
|
+ }
|
|
|
+ if m.organization_id != nil {
|
|
|
+ fields = append(fields, xunjiservice.FieldOrganizationID)
|
|
|
+ }
|
|
|
+ if m.wxid != nil {
|
|
|
+ fields = append(fields, xunjiservice.FieldWxid)
|
|
|
+ }
|
|
|
+ if m.api_base != nil {
|
|
|
+ fields = append(fields, xunjiservice.FieldAPIBase)
|
|
|
+ }
|
|
|
+ if m.api_key != nil {
|
|
|
+ fields = append(fields, xunjiservice.FieldAPIKey)
|
|
|
+ }
|
|
|
+ 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 *XunjiServiceMutation) Field(name string) (ent.Value, bool) {
|
|
|
+ switch name {
|
|
|
+ case xunjiservice.FieldCreatedAt:
|
|
|
+ return m.CreatedAt()
|
|
|
+ case xunjiservice.FieldUpdatedAt:
|
|
|
+ return m.UpdatedAt()
|
|
|
+ case xunjiservice.FieldStatus:
|
|
|
+ return m.Status()
|
|
|
+ case xunjiservice.FieldDeletedAt:
|
|
|
+ return m.DeletedAt()
|
|
|
+ case xunjiservice.FieldXunjiID:
|
|
|
+ return m.XunjiID()
|
|
|
+ case xunjiservice.FieldAgentID:
|
|
|
+ return m.AgentID()
|
|
|
+ case xunjiservice.FieldOrganizationID:
|
|
|
+ return m.OrganizationID()
|
|
|
+ case xunjiservice.FieldWxid:
|
|
|
+ return m.Wxid()
|
|
|
+ case xunjiservice.FieldAPIBase:
|
|
|
+ return m.APIBase()
|
|
|
+ case xunjiservice.FieldAPIKey:
|
|
|
+ return m.APIKey()
|
|
|
+ }
|
|
|
+ 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 *XunjiServiceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
|
|
+ switch name {
|
|
|
+ case xunjiservice.FieldCreatedAt:
|
|
|
+ return m.OldCreatedAt(ctx)
|
|
|
+ case xunjiservice.FieldUpdatedAt:
|
|
|
+ return m.OldUpdatedAt(ctx)
|
|
|
+ case xunjiservice.FieldStatus:
|
|
|
+ return m.OldStatus(ctx)
|
|
|
+ case xunjiservice.FieldDeletedAt:
|
|
|
+ return m.OldDeletedAt(ctx)
|
|
|
+ case xunjiservice.FieldXunjiID:
|
|
|
+ return m.OldXunjiID(ctx)
|
|
|
+ case xunjiservice.FieldAgentID:
|
|
|
+ return m.OldAgentID(ctx)
|
|
|
+ case xunjiservice.FieldOrganizationID:
|
|
|
+ return m.OldOrganizationID(ctx)
|
|
|
+ case xunjiservice.FieldWxid:
|
|
|
+ return m.OldWxid(ctx)
|
|
|
+ case xunjiservice.FieldAPIBase:
|
|
|
+ return m.OldAPIBase(ctx)
|
|
|
+ case xunjiservice.FieldAPIKey:
|
|
|
+ return m.OldAPIKey(ctx)
|
|
|
+ }
|
|
|
+ return nil, fmt.Errorf("unknown XunjiService 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 *XunjiServiceMutation) SetField(name string, value ent.Value) error {
|
|
|
+ switch name {
|
|
|
+ case xunjiservice.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 xunjiservice.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 xunjiservice.FieldStatus:
|
|
|
+ v, ok := value.(uint8)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetStatus(v)
|
|
|
+ return nil
|
|
|
+ case xunjiservice.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 xunjiservice.FieldXunjiID:
|
|
|
+ v, ok := value.(uint64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetXunjiID(v)
|
|
|
+ return nil
|
|
|
+ case xunjiservice.FieldAgentID:
|
|
|
+ v, ok := value.(uint64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetAgentID(v)
|
|
|
+ return nil
|
|
|
+ case xunjiservice.FieldOrganizationID:
|
|
|
+ v, ok := value.(uint64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetOrganizationID(v)
|
|
|
+ return nil
|
|
|
+ case xunjiservice.FieldWxid:
|
|
|
+ v, ok := value.(string)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetWxid(v)
|
|
|
+ return nil
|
|
|
+ case xunjiservice.FieldAPIBase:
|
|
|
+ v, ok := value.(string)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetAPIBase(v)
|
|
|
+ return nil
|
|
|
+ case xunjiservice.FieldAPIKey:
|
|
|
+ v, ok := value.(string)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.SetAPIKey(v)
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown XunjiService field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// AddedFields returns all numeric fields that were incremented/decremented during
|
|
|
+// this mutation.
|
|
|
+func (m *XunjiServiceMutation) AddedFields() []string {
|
|
|
+ var fields []string
|
|
|
+ if m.addstatus != nil {
|
|
|
+ fields = append(fields, xunjiservice.FieldStatus)
|
|
|
+ }
|
|
|
+ if m.addxunji_id != nil {
|
|
|
+ fields = append(fields, xunjiservice.FieldXunjiID)
|
|
|
+ }
|
|
|
+ if m.addorganization_id != nil {
|
|
|
+ fields = append(fields, xunjiservice.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 *XunjiServiceMutation) AddedField(name string) (ent.Value, bool) {
|
|
|
+ switch name {
|
|
|
+ case xunjiservice.FieldStatus:
|
|
|
+ return m.AddedStatus()
|
|
|
+ case xunjiservice.FieldXunjiID:
|
|
|
+ return m.AddedXunjiID()
|
|
|
+ case xunjiservice.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 *XunjiServiceMutation) AddField(name string, value ent.Value) error {
|
|
|
+ switch name {
|
|
|
+ case xunjiservice.FieldStatus:
|
|
|
+ v, ok := value.(int8)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.AddStatus(v)
|
|
|
+ return nil
|
|
|
+ case xunjiservice.FieldXunjiID:
|
|
|
+ v, ok := value.(int64)
|
|
|
+ if !ok {
|
|
|
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
|
|
|
+ }
|
|
|
+ m.AddXunjiID(v)
|
|
|
+ return nil
|
|
|
+ case xunjiservice.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 XunjiService numeric field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// ClearedFields returns all nullable fields that were cleared during this
|
|
|
+// mutation.
|
|
|
+func (m *XunjiServiceMutation) ClearedFields() []string {
|
|
|
+ var fields []string
|
|
|
+ if m.FieldCleared(xunjiservice.FieldStatus) {
|
|
|
+ fields = append(fields, xunjiservice.FieldStatus)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(xunjiservice.FieldDeletedAt) {
|
|
|
+ fields = append(fields, xunjiservice.FieldDeletedAt)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(xunjiservice.FieldAPIBase) {
|
|
|
+ fields = append(fields, xunjiservice.FieldAPIBase)
|
|
|
+ }
|
|
|
+ if m.FieldCleared(xunjiservice.FieldAPIKey) {
|
|
|
+ fields = append(fields, xunjiservice.FieldAPIKey)
|
|
|
+ }
|
|
|
+ return fields
|
|
|
+}
|
|
|
+
|
|
|
+// FieldCleared returns a boolean indicating if a field with the given name was
|
|
|
+// cleared in this mutation.
|
|
|
+func (m *XunjiServiceMutation) 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 *XunjiServiceMutation) ClearField(name string) error {
|
|
|
+ switch name {
|
|
|
+ case xunjiservice.FieldStatus:
|
|
|
+ m.ClearStatus()
|
|
|
+ return nil
|
|
|
+ case xunjiservice.FieldDeletedAt:
|
|
|
+ m.ClearDeletedAt()
|
|
|
+ return nil
|
|
|
+ case xunjiservice.FieldAPIBase:
|
|
|
+ m.ClearAPIBase()
|
|
|
+ return nil
|
|
|
+ case xunjiservice.FieldAPIKey:
|
|
|
+ m.ClearAPIKey()
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown XunjiService 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 *XunjiServiceMutation) ResetField(name string) error {
|
|
|
+ switch name {
|
|
|
+ case xunjiservice.FieldCreatedAt:
|
|
|
+ m.ResetCreatedAt()
|
|
|
+ return nil
|
|
|
+ case xunjiservice.FieldUpdatedAt:
|
|
|
+ m.ResetUpdatedAt()
|
|
|
+ return nil
|
|
|
+ case xunjiservice.FieldStatus:
|
|
|
+ m.ResetStatus()
|
|
|
+ return nil
|
|
|
+ case xunjiservice.FieldDeletedAt:
|
|
|
+ m.ResetDeletedAt()
|
|
|
+ return nil
|
|
|
+ case xunjiservice.FieldXunjiID:
|
|
|
+ m.ResetXunjiID()
|
|
|
+ return nil
|
|
|
+ case xunjiservice.FieldAgentID:
|
|
|
+ m.ResetAgentID()
|
|
|
+ return nil
|
|
|
+ case xunjiservice.FieldOrganizationID:
|
|
|
+ m.ResetOrganizationID()
|
|
|
+ return nil
|
|
|
+ case xunjiservice.FieldWxid:
|
|
|
+ m.ResetWxid()
|
|
|
+ return nil
|
|
|
+ case xunjiservice.FieldAPIBase:
|
|
|
+ m.ResetAPIBase()
|
|
|
+ return nil
|
|
|
+ case xunjiservice.FieldAPIKey:
|
|
|
+ m.ResetAPIKey()
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown XunjiService field %s", name)
|
|
|
+}
|
|
|
+
|
|
|
+// AddedEdges returns all edge names that were set/added in this mutation.
|
|
|
+func (m *XunjiServiceMutation) AddedEdges() []string {
|
|
|
+ edges := make([]string, 0, 1)
|
|
|
+ if m.agent != nil {
|
|
|
+ edges = append(edges, xunjiservice.EdgeAgent)
|
|
|
+ }
|
|
|
+ return edges
|
|
|
+}
|
|
|
+
|
|
|
+// AddedIDs returns all IDs (to other nodes) that were added for the given edge
|
|
|
+// name in this mutation.
|
|
|
+func (m *XunjiServiceMutation) AddedIDs(name string) []ent.Value {
|
|
|
+ switch name {
|
|
|
+ case xunjiservice.EdgeAgent:
|
|
|
+ if id := m.agent; id != nil {
|
|
|
+ return []ent.Value{*id}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+// RemovedEdges returns all edge names that were removed in this mutation.
|
|
|
+func (m *XunjiServiceMutation) 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 *XunjiServiceMutation) RemovedIDs(name string) []ent.Value {
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
+// ClearedEdges returns all edge names that were cleared in this mutation.
|
|
|
+func (m *XunjiServiceMutation) ClearedEdges() []string {
|
|
|
+ edges := make([]string, 0, 1)
|
|
|
+ if m.clearedagent {
|
|
|
+ edges = append(edges, xunjiservice.EdgeAgent)
|
|
|
+ }
|
|
|
+ return edges
|
|
|
+}
|
|
|
+
|
|
|
+// EdgeCleared returns a boolean which indicates if the edge with the given name
|
|
|
+// was cleared in this mutation.
|
|
|
+func (m *XunjiServiceMutation) EdgeCleared(name string) bool {
|
|
|
+ switch name {
|
|
|
+ case xunjiservice.EdgeAgent:
|
|
|
+ return m.clearedagent
|
|
|
+ }
|
|
|
+ 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 *XunjiServiceMutation) ClearEdge(name string) error {
|
|
|
+ switch name {
|
|
|
+ case xunjiservice.EdgeAgent:
|
|
|
+ m.ClearAgent()
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown XunjiService 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 *XunjiServiceMutation) ResetEdge(name string) error {
|
|
|
+ switch name {
|
|
|
+ case xunjiservice.EdgeAgent:
|
|
|
+ m.ResetAgent()
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ return fmt.Errorf("unknown XunjiService edge %s", name)
|
|
|
+}
|