浏览代码

fix:save 1

jimmyyem 1 月之前
父节点
当前提交
d80c3b3428

+ 17 - 1
ent/agent.go

@@ -55,9 +55,11 @@ type AgentEdges struct {
 	WaAgent []*Whatsapp `json:"wa_agent,omitempty"`
 	// KeyAgent holds the value of the key_agent edge.
 	KeyAgent []*ApiKey `json:"key_agent,omitempty"`
+	// XjsAgent holds the value of the xjs_agent edge.
+	XjsAgent []*XunjiService `json:"xjs_agent,omitempty"`
 	// loadedTypes holds the information for reporting if a
 	// type was loaded (or requested) in eager-loading or not.
-	loadedTypes [4]bool
+	loadedTypes [5]bool
 }
 
 // WxAgentOrErr returns the WxAgent value or an error if the edge
@@ -96,6 +98,15 @@ func (e AgentEdges) KeyAgentOrErr() ([]*ApiKey, error) {
 	return nil, &NotLoadedError{edge: "key_agent"}
 }
 
+// XjsAgentOrErr returns the XjsAgent value or an error if the edge
+// was not loaded in eager-loading.
+func (e AgentEdges) XjsAgentOrErr() ([]*XunjiService, error) {
+	if e.loadedTypes[4] {
+		return e.XjsAgent, nil
+	}
+	return nil, &NotLoadedError{edge: "xjs_agent"}
+}
+
 // scanValues returns the types for scanning values from sql.Rows.
 func (*Agent) scanValues(columns []string) ([]any, error) {
 	values := make([]any, len(columns))
@@ -227,6 +238,11 @@ func (a *Agent) QueryKeyAgent() *ApiKeyQuery {
 	return NewAgentClient(a.config).QueryKeyAgent(a)
 }
 
+// QueryXjsAgent queries the "xjs_agent" edge of the Agent entity.
+func (a *Agent) QueryXjsAgent() *XunjiServiceQuery {
+	return NewAgentClient(a.config).QueryXjsAgent(a)
+}
+
 // Update returns a builder for updating this Agent.
 // Note that you need to call Agent.Unwrap() before calling this method if this Agent
 // was returned from a transaction, and the transaction was committed or rolled back.

+ 30 - 0
ent/agent/agent.go

@@ -45,6 +45,8 @@ const (
 	EdgeWaAgent = "wa_agent"
 	// EdgeKeyAgent holds the string denoting the key_agent edge name in mutations.
 	EdgeKeyAgent = "key_agent"
+	// EdgeXjsAgent holds the string denoting the xjs_agent edge name in mutations.
+	EdgeXjsAgent = "xjs_agent"
 	// Table holds the table name of the agent in the database.
 	Table = "agent"
 	// WxAgentTable is the table that holds the wx_agent relation/edge.
@@ -75,6 +77,13 @@ const (
 	KeyAgentInverseTable = "api_key"
 	// KeyAgentColumn is the table column denoting the key_agent relation/edge.
 	KeyAgentColumn = "agent_id"
+	// XjsAgentTable is the table that holds the xjs_agent relation/edge.
+	XjsAgentTable = "xunji_service"
+	// XjsAgentInverseTable is the table name for the XunjiService entity.
+	// It exists in this package in order to avoid circular dependency with the "xunjiservice" package.
+	XjsAgentInverseTable = "xunji_service"
+	// XjsAgentColumn is the table column denoting the xjs_agent relation/edge.
+	XjsAgentColumn = "agent_id"
 )
 
 // Columns holds all SQL columns for agent fields.
@@ -257,6 +266,20 @@ func ByKeyAgent(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
 		sqlgraph.OrderByNeighborTerms(s, newKeyAgentStep(), append([]sql.OrderTerm{term}, terms...)...)
 	}
 }
+
+// ByXjsAgentCount orders the results by xjs_agent count.
+func ByXjsAgentCount(opts ...sql.OrderTermOption) OrderOption {
+	return func(s *sql.Selector) {
+		sqlgraph.OrderByNeighborsCount(s, newXjsAgentStep(), opts...)
+	}
+}
+
+// ByXjsAgent orders the results by xjs_agent terms.
+func ByXjsAgent(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
+	return func(s *sql.Selector) {
+		sqlgraph.OrderByNeighborTerms(s, newXjsAgentStep(), append([]sql.OrderTerm{term}, terms...)...)
+	}
+}
 func newWxAgentStep() *sqlgraph.Step {
 	return sqlgraph.NewStep(
 		sqlgraph.From(Table, FieldID),
@@ -285,3 +308,10 @@ func newKeyAgentStep() *sqlgraph.Step {
 		sqlgraph.Edge(sqlgraph.O2M, false, KeyAgentTable, KeyAgentColumn),
 	)
 }
+func newXjsAgentStep() *sqlgraph.Step {
+	return sqlgraph.NewStep(
+		sqlgraph.From(Table, FieldID),
+		sqlgraph.To(XjsAgentInverseTable, FieldID),
+		sqlgraph.Edge(sqlgraph.O2M, false, XjsAgentTable, XjsAgentColumn),
+	)
+}

+ 23 - 0
ent/agent/where.go

@@ -832,6 +832,29 @@ func HasKeyAgentWith(preds ...predicate.ApiKey) predicate.Agent {
 	})
 }
 
+// HasXjsAgent applies the HasEdge predicate on the "xjs_agent" edge.
+func HasXjsAgent() predicate.Agent {
+	return predicate.Agent(func(s *sql.Selector) {
+		step := sqlgraph.NewStep(
+			sqlgraph.From(Table, FieldID),
+			sqlgraph.Edge(sqlgraph.O2M, false, XjsAgentTable, XjsAgentColumn),
+		)
+		sqlgraph.HasNeighbors(s, step)
+	})
+}
+
+// HasXjsAgentWith applies the HasEdge predicate on the "xjs_agent" edge with a given conditions (other predicates).
+func HasXjsAgentWith(preds ...predicate.XunjiService) predicate.Agent {
+	return predicate.Agent(func(s *sql.Selector) {
+		step := newXjsAgentStep()
+		sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
+			for _, p := range preds {
+				p(s)
+			}
+		})
+	})
+}
+
 // And groups predicates with the AND operator between them.
 func And(predicates ...predicate.Agent) predicate.Agent {
 	return predicate.Agent(sql.AndPredicates(predicates...))

+ 32 - 0
ent/agent_create.go

@@ -12,6 +12,7 @@ import (
 	"wechat-api/ent/token"
 	"wechat-api/ent/whatsapp"
 	"wechat-api/ent/wx"
+	"wechat-api/ent/xunjiservice"
 
 	"entgo.io/ent/dialect/sql"
 	"entgo.io/ent/dialect/sql/sqlgraph"
@@ -222,6 +223,21 @@ func (ac *AgentCreate) AddKeyAgent(a ...*ApiKey) *AgentCreate {
 	return ac.AddKeyAgentIDs(ids...)
 }
 
+// AddXjsAgentIDs adds the "xjs_agent" edge to the XunjiService entity by IDs.
+func (ac *AgentCreate) AddXjsAgentIDs(ids ...uint64) *AgentCreate {
+	ac.mutation.AddXjsAgentIDs(ids...)
+	return ac
+}
+
+// AddXjsAgent adds the "xjs_agent" edges to the XunjiService entity.
+func (ac *AgentCreate) AddXjsAgent(x ...*XunjiService) *AgentCreate {
+	ids := make([]uint64, len(x))
+	for i := range x {
+		ids[i] = x[i].ID
+	}
+	return ac.AddXjsAgentIDs(ids...)
+}
+
 // Mutation returns the AgentMutation object of the builder.
 func (ac *AgentCreate) Mutation() *AgentMutation {
 	return ac.mutation
@@ -485,6 +501,22 @@ func (ac *AgentCreate) createSpec() (*Agent, *sqlgraph.CreateSpec) {
 		}
 		_spec.Edges = append(_spec.Edges, edge)
 	}
+	if nodes := ac.mutation.XjsAgentIDs(); len(nodes) > 0 {
+		edge := &sqlgraph.EdgeSpec{
+			Rel:     sqlgraph.O2M,
+			Inverse: false,
+			Table:   agent.XjsAgentTable,
+			Columns: []string{agent.XjsAgentColumn},
+			Bidi:    false,
+			Target: &sqlgraph.EdgeTarget{
+				IDSpec: sqlgraph.NewFieldSpec(xunjiservice.FieldID, field.TypeUint64),
+			},
+		}
+		for _, k := range nodes {
+			edge.Target.Nodes = append(edge.Target.Nodes, k)
+		}
+		_spec.Edges = append(_spec.Edges, edge)
+	}
 	return _node, _spec
 }
 

+ 75 - 1
ent/agent_query.go

@@ -13,6 +13,7 @@ import (
 	"wechat-api/ent/token"
 	"wechat-api/ent/whatsapp"
 	"wechat-api/ent/wx"
+	"wechat-api/ent/xunjiservice"
 
 	"entgo.io/ent/dialect/sql"
 	"entgo.io/ent/dialect/sql/sqlgraph"
@@ -30,6 +31,7 @@ type AgentQuery struct {
 	withTokenAgent *TokenQuery
 	withWaAgent    *WhatsappQuery
 	withKeyAgent   *ApiKeyQuery
+	withXjsAgent   *XunjiServiceQuery
 	// intermediate query (i.e. traversal path).
 	sql  *sql.Selector
 	path func(context.Context) (*sql.Selector, error)
@@ -154,6 +156,28 @@ func (aq *AgentQuery) QueryKeyAgent() *ApiKeyQuery {
 	return query
 }
 
+// QueryXjsAgent chains the current query on the "xjs_agent" edge.
+func (aq *AgentQuery) QueryXjsAgent() *XunjiServiceQuery {
+	query := (&XunjiServiceClient{config: aq.config}).Query()
+	query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
+		if err := aq.prepareQuery(ctx); err != nil {
+			return nil, err
+		}
+		selector := aq.sqlQuery(ctx)
+		if err := selector.Err(); err != nil {
+			return nil, err
+		}
+		step := sqlgraph.NewStep(
+			sqlgraph.From(agent.Table, agent.FieldID, selector),
+			sqlgraph.To(xunjiservice.Table, xunjiservice.FieldID),
+			sqlgraph.Edge(sqlgraph.O2M, false, agent.XjsAgentTable, agent.XjsAgentColumn),
+		)
+		fromU = sqlgraph.SetNeighbors(aq.driver.Dialect(), step)
+		return fromU, nil
+	}
+	return query
+}
+
 // First returns the first Agent entity from the query.
 // Returns a *NotFoundError when no Agent was found.
 func (aq *AgentQuery) First(ctx context.Context) (*Agent, error) {
@@ -350,6 +374,7 @@ func (aq *AgentQuery) Clone() *AgentQuery {
 		withTokenAgent: aq.withTokenAgent.Clone(),
 		withWaAgent:    aq.withWaAgent.Clone(),
 		withKeyAgent:   aq.withKeyAgent.Clone(),
+		withXjsAgent:   aq.withXjsAgent.Clone(),
 		// clone intermediate query.
 		sql:  aq.sql.Clone(),
 		path: aq.path,
@@ -400,6 +425,17 @@ func (aq *AgentQuery) WithKeyAgent(opts ...func(*ApiKeyQuery)) *AgentQuery {
 	return aq
 }
 
+// WithXjsAgent tells the query-builder to eager-load the nodes that are connected to
+// the "xjs_agent" edge. The optional arguments are used to configure the query builder of the edge.
+func (aq *AgentQuery) WithXjsAgent(opts ...func(*XunjiServiceQuery)) *AgentQuery {
+	query := (&XunjiServiceClient{config: aq.config}).Query()
+	for _, opt := range opts {
+		opt(query)
+	}
+	aq.withXjsAgent = query
+	return aq
+}
+
 // GroupBy is used to group vertices by one or more fields/columns.
 // It is often used with aggregate functions, like: count, max, mean, min, sum.
 //
@@ -478,11 +514,12 @@ func (aq *AgentQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Agent,
 	var (
 		nodes       = []*Agent{}
 		_spec       = aq.querySpec()
-		loadedTypes = [4]bool{
+		loadedTypes = [5]bool{
 			aq.withWxAgent != nil,
 			aq.withTokenAgent != nil,
 			aq.withWaAgent != nil,
 			aq.withKeyAgent != nil,
+			aq.withXjsAgent != nil,
 		}
 	)
 	_spec.ScanValues = func(columns []string) ([]any, error) {
@@ -531,6 +568,13 @@ func (aq *AgentQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Agent,
 			return nil, err
 		}
 	}
+	if query := aq.withXjsAgent; query != nil {
+		if err := aq.loadXjsAgent(ctx, query, nodes,
+			func(n *Agent) { n.Edges.XjsAgent = []*XunjiService{} },
+			func(n *Agent, e *XunjiService) { n.Edges.XjsAgent = append(n.Edges.XjsAgent, e) }); err != nil {
+			return nil, err
+		}
+	}
 	return nodes, nil
 }
 
@@ -655,6 +699,36 @@ func (aq *AgentQuery) loadKeyAgent(ctx context.Context, query *ApiKeyQuery, node
 	}
 	return nil
 }
+func (aq *AgentQuery) loadXjsAgent(ctx context.Context, query *XunjiServiceQuery, nodes []*Agent, init func(*Agent), assign func(*Agent, *XunjiService)) error {
+	fks := make([]driver.Value, 0, len(nodes))
+	nodeids := make(map[uint64]*Agent)
+	for i := range nodes {
+		fks = append(fks, nodes[i].ID)
+		nodeids[nodes[i].ID] = nodes[i]
+		if init != nil {
+			init(nodes[i])
+		}
+	}
+	if len(query.ctx.Fields) > 0 {
+		query.ctx.AppendFieldOnce(xunjiservice.FieldAgentID)
+	}
+	query.Where(predicate.XunjiService(func(s *sql.Selector) {
+		s.Where(sql.InValues(s.C(agent.XjsAgentColumn), fks...))
+	}))
+	neighbors, err := query.All(ctx)
+	if err != nil {
+		return err
+	}
+	for _, n := range neighbors {
+		fk := n.AgentID
+		node, ok := nodeids[fk]
+		if !ok {
+			return fmt.Errorf(`unexpected referenced foreign-key "agent_id" returned %v for node %v`, fk, n.ID)
+		}
+		assign(node, n)
+	}
+	return nil
+}
 
 func (aq *AgentQuery) sqlCount(ctx context.Context) (int, error) {
 	_spec := aq.querySpec()

+ 163 - 0
ent/agent_update.go

@@ -13,6 +13,7 @@ import (
 	"wechat-api/ent/token"
 	"wechat-api/ent/whatsapp"
 	"wechat-api/ent/wx"
+	"wechat-api/ent/xunjiservice"
 
 	"entgo.io/ent/dialect/sql"
 	"entgo.io/ent/dialect/sql/sqlgraph"
@@ -262,6 +263,21 @@ func (au *AgentUpdate) AddKeyAgent(a ...*ApiKey) *AgentUpdate {
 	return au.AddKeyAgentIDs(ids...)
 }
 
+// AddXjsAgentIDs adds the "xjs_agent" edge to the XunjiService entity by IDs.
+func (au *AgentUpdate) AddXjsAgentIDs(ids ...uint64) *AgentUpdate {
+	au.mutation.AddXjsAgentIDs(ids...)
+	return au
+}
+
+// AddXjsAgent adds the "xjs_agent" edges to the XunjiService entity.
+func (au *AgentUpdate) AddXjsAgent(x ...*XunjiService) *AgentUpdate {
+	ids := make([]uint64, len(x))
+	for i := range x {
+		ids[i] = x[i].ID
+	}
+	return au.AddXjsAgentIDs(ids...)
+}
+
 // Mutation returns the AgentMutation object of the builder.
 func (au *AgentUpdate) Mutation() *AgentMutation {
 	return au.mutation
@@ -351,6 +367,27 @@ func (au *AgentUpdate) RemoveKeyAgent(a ...*ApiKey) *AgentUpdate {
 	return au.RemoveKeyAgentIDs(ids...)
 }
 
+// ClearXjsAgent clears all "xjs_agent" edges to the XunjiService entity.
+func (au *AgentUpdate) ClearXjsAgent() *AgentUpdate {
+	au.mutation.ClearXjsAgent()
+	return au
+}
+
+// RemoveXjsAgentIDs removes the "xjs_agent" edge to XunjiService entities by IDs.
+func (au *AgentUpdate) RemoveXjsAgentIDs(ids ...uint64) *AgentUpdate {
+	au.mutation.RemoveXjsAgentIDs(ids...)
+	return au
+}
+
+// RemoveXjsAgent removes "xjs_agent" edges to XunjiService entities.
+func (au *AgentUpdate) RemoveXjsAgent(x ...*XunjiService) *AgentUpdate {
+	ids := make([]uint64, len(x))
+	for i := range x {
+		ids[i] = x[i].ID
+	}
+	return au.RemoveXjsAgentIDs(ids...)
+}
+
 // Save executes the query and returns the number of nodes affected by the update operation.
 func (au *AgentUpdate) Save(ctx context.Context) (int, error) {
 	if err := au.defaults(); err != nil {
@@ -663,6 +700,51 @@ func (au *AgentUpdate) sqlSave(ctx context.Context) (n int, err error) {
 		}
 		_spec.Edges.Add = append(_spec.Edges.Add, edge)
 	}
+	if au.mutation.XjsAgentCleared() {
+		edge := &sqlgraph.EdgeSpec{
+			Rel:     sqlgraph.O2M,
+			Inverse: false,
+			Table:   agent.XjsAgentTable,
+			Columns: []string{agent.XjsAgentColumn},
+			Bidi:    false,
+			Target: &sqlgraph.EdgeTarget{
+				IDSpec: sqlgraph.NewFieldSpec(xunjiservice.FieldID, field.TypeUint64),
+			},
+		}
+		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
+	}
+	if nodes := au.mutation.RemovedXjsAgentIDs(); len(nodes) > 0 && !au.mutation.XjsAgentCleared() {
+		edge := &sqlgraph.EdgeSpec{
+			Rel:     sqlgraph.O2M,
+			Inverse: false,
+			Table:   agent.XjsAgentTable,
+			Columns: []string{agent.XjsAgentColumn},
+			Bidi:    false,
+			Target: &sqlgraph.EdgeTarget{
+				IDSpec: sqlgraph.NewFieldSpec(xunjiservice.FieldID, field.TypeUint64),
+			},
+		}
+		for _, k := range nodes {
+			edge.Target.Nodes = append(edge.Target.Nodes, k)
+		}
+		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
+	}
+	if nodes := au.mutation.XjsAgentIDs(); len(nodes) > 0 {
+		edge := &sqlgraph.EdgeSpec{
+			Rel:     sqlgraph.O2M,
+			Inverse: false,
+			Table:   agent.XjsAgentTable,
+			Columns: []string{agent.XjsAgentColumn},
+			Bidi:    false,
+			Target: &sqlgraph.EdgeTarget{
+				IDSpec: sqlgraph.NewFieldSpec(xunjiservice.FieldID, field.TypeUint64),
+			},
+		}
+		for _, k := range nodes {
+			edge.Target.Nodes = append(edge.Target.Nodes, k)
+		}
+		_spec.Edges.Add = append(_spec.Edges.Add, edge)
+	}
 	if n, err = sqlgraph.UpdateNodes(ctx, au.driver, _spec); err != nil {
 		if _, ok := err.(*sqlgraph.NotFoundError); ok {
 			err = &NotFoundError{agent.Label}
@@ -913,6 +995,21 @@ func (auo *AgentUpdateOne) AddKeyAgent(a ...*ApiKey) *AgentUpdateOne {
 	return auo.AddKeyAgentIDs(ids...)
 }
 
+// AddXjsAgentIDs adds the "xjs_agent" edge to the XunjiService entity by IDs.
+func (auo *AgentUpdateOne) AddXjsAgentIDs(ids ...uint64) *AgentUpdateOne {
+	auo.mutation.AddXjsAgentIDs(ids...)
+	return auo
+}
+
+// AddXjsAgent adds the "xjs_agent" edges to the XunjiService entity.
+func (auo *AgentUpdateOne) AddXjsAgent(x ...*XunjiService) *AgentUpdateOne {
+	ids := make([]uint64, len(x))
+	for i := range x {
+		ids[i] = x[i].ID
+	}
+	return auo.AddXjsAgentIDs(ids...)
+}
+
 // Mutation returns the AgentMutation object of the builder.
 func (auo *AgentUpdateOne) Mutation() *AgentMutation {
 	return auo.mutation
@@ -1002,6 +1099,27 @@ func (auo *AgentUpdateOne) RemoveKeyAgent(a ...*ApiKey) *AgentUpdateOne {
 	return auo.RemoveKeyAgentIDs(ids...)
 }
 
+// ClearXjsAgent clears all "xjs_agent" edges to the XunjiService entity.
+func (auo *AgentUpdateOne) ClearXjsAgent() *AgentUpdateOne {
+	auo.mutation.ClearXjsAgent()
+	return auo
+}
+
+// RemoveXjsAgentIDs removes the "xjs_agent" edge to XunjiService entities by IDs.
+func (auo *AgentUpdateOne) RemoveXjsAgentIDs(ids ...uint64) *AgentUpdateOne {
+	auo.mutation.RemoveXjsAgentIDs(ids...)
+	return auo
+}
+
+// RemoveXjsAgent removes "xjs_agent" edges to XunjiService entities.
+func (auo *AgentUpdateOne) RemoveXjsAgent(x ...*XunjiService) *AgentUpdateOne {
+	ids := make([]uint64, len(x))
+	for i := range x {
+		ids[i] = x[i].ID
+	}
+	return auo.RemoveXjsAgentIDs(ids...)
+}
+
 // Where appends a list predicates to the AgentUpdate builder.
 func (auo *AgentUpdateOne) Where(ps ...predicate.Agent) *AgentUpdateOne {
 	auo.mutation.Where(ps...)
@@ -1344,6 +1462,51 @@ func (auo *AgentUpdateOne) sqlSave(ctx context.Context) (_node *Agent, err error
 		}
 		_spec.Edges.Add = append(_spec.Edges.Add, edge)
 	}
+	if auo.mutation.XjsAgentCleared() {
+		edge := &sqlgraph.EdgeSpec{
+			Rel:     sqlgraph.O2M,
+			Inverse: false,
+			Table:   agent.XjsAgentTable,
+			Columns: []string{agent.XjsAgentColumn},
+			Bidi:    false,
+			Target: &sqlgraph.EdgeTarget{
+				IDSpec: sqlgraph.NewFieldSpec(xunjiservice.FieldID, field.TypeUint64),
+			},
+		}
+		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
+	}
+	if nodes := auo.mutation.RemovedXjsAgentIDs(); len(nodes) > 0 && !auo.mutation.XjsAgentCleared() {
+		edge := &sqlgraph.EdgeSpec{
+			Rel:     sqlgraph.O2M,
+			Inverse: false,
+			Table:   agent.XjsAgentTable,
+			Columns: []string{agent.XjsAgentColumn},
+			Bidi:    false,
+			Target: &sqlgraph.EdgeTarget{
+				IDSpec: sqlgraph.NewFieldSpec(xunjiservice.FieldID, field.TypeUint64),
+			},
+		}
+		for _, k := range nodes {
+			edge.Target.Nodes = append(edge.Target.Nodes, k)
+		}
+		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
+	}
+	if nodes := auo.mutation.XjsAgentIDs(); len(nodes) > 0 {
+		edge := &sqlgraph.EdgeSpec{
+			Rel:     sqlgraph.O2M,
+			Inverse: false,
+			Table:   agent.XjsAgentTable,
+			Columns: []string{agent.XjsAgentColumn},
+			Bidi:    false,
+			Target: &sqlgraph.EdgeTarget{
+				IDSpec: sqlgraph.NewFieldSpec(xunjiservice.FieldID, field.TypeUint64),
+			},
+		}
+		for _, k := range nodes {
+			edge.Target.Nodes = append(edge.Target.Nodes, k)
+		}
+		_spec.Edges.Add = append(_spec.Edges.Add, edge)
+	}
 	_node = &Agent{config: auo.config}
 	_spec.Assign = _node.assignValues
 	_spec.ScanValues = _node.scanValues

+ 326 - 5
ent/client.go

@@ -52,6 +52,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"
@@ -148,6 +150,10 @@ type Client struct {
 	WxCardUser *WxCardUserClient
 	// WxCardVisit is the client for interacting with the WxCardVisit builders.
 	WxCardVisit *WxCardVisitClient
+	// Xunji is the client for interacting with the Xunji builders.
+	Xunji *XunjiClient
+	// XunjiService is the client for interacting with the XunjiService builders.
+	XunjiService *XunjiServiceClient
 }
 
 // NewClient creates a new client configured with the given options.
@@ -200,6 +206,8 @@ func (c *Client) init() {
 	c.WxCard = NewWxCardClient(c.config)
 	c.WxCardUser = NewWxCardUserClient(c.config)
 	c.WxCardVisit = NewWxCardVisitClient(c.config)
+	c.Xunji = NewXunjiClient(c.config)
+	c.XunjiService = NewXunjiServiceClient(c.config)
 }
 
 type (
@@ -333,6 +341,8 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
 		WxCard:              NewWxCardClient(cfg),
 		WxCardUser:          NewWxCardUserClient(cfg),
 		WxCardVisit:         NewWxCardVisitClient(cfg),
+		Xunji:               NewXunjiClient(cfg),
+		XunjiService:        NewXunjiServiceClient(cfg),
 	}, nil
 }
 
@@ -393,6 +403,8 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
 		WxCard:              NewWxCardClient(cfg),
 		WxCardUser:          NewWxCardUserClient(cfg),
 		WxCardVisit:         NewWxCardVisitClient(cfg),
+		Xunji:               NewXunjiClient(cfg),
+		XunjiService:        NewXunjiServiceClient(cfg),
 	}, nil
 }
 
@@ -429,7 +441,8 @@ func (c *Client) Use(hooks ...Hook) {
 		c.SopNode, c.SopStage, c.SopTask, c.Token, c.Tutorial, c.UsageDetail,
 		c.UsageStatisticDay, c.UsageStatisticHour, c.UsageStatisticMonth, c.UsageTotal,
 		c.Whatsapp, c.WhatsappChannel, c.WorkExperience, c.WpChatroom,
-		c.WpChatroomMember, c.Wx, c.WxCard, c.WxCardUser, c.WxCardVisit,
+		c.WpChatroomMember, c.Wx, c.WxCard, c.WxCardUser, c.WxCardVisit, c.Xunji,
+		c.XunjiService,
 	} {
 		n.Use(hooks...)
 	}
@@ -446,7 +459,8 @@ func (c *Client) Intercept(interceptors ...Interceptor) {
 		c.SopNode, c.SopStage, c.SopTask, c.Token, c.Tutorial, c.UsageDetail,
 		c.UsageStatisticDay, c.UsageStatisticHour, c.UsageStatisticMonth, c.UsageTotal,
 		c.Whatsapp, c.WhatsappChannel, c.WorkExperience, c.WpChatroom,
-		c.WpChatroomMember, c.Wx, c.WxCard, c.WxCardUser, c.WxCardVisit,
+		c.WpChatroomMember, c.Wx, c.WxCard, c.WxCardUser, c.WxCardVisit, c.Xunji,
+		c.XunjiService,
 	} {
 		n.Intercept(interceptors...)
 	}
@@ -537,6 +551,10 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
 		return c.WxCardUser.mutate(ctx, m)
 	case *WxCardVisitMutation:
 		return c.WxCardVisit.mutate(ctx, m)
+	case *XunjiMutation:
+		return c.Xunji.mutate(ctx, m)
+	case *XunjiServiceMutation:
+		return c.XunjiService.mutate(ctx, m)
 	default:
 		return nil, fmt.Errorf("ent: unknown mutation type %T", m)
 	}
@@ -714,6 +732,22 @@ func (c *AgentClient) QueryKeyAgent(a *Agent) *ApiKeyQuery {
 	return query
 }
 
+// QueryXjsAgent queries the xjs_agent edge of a Agent.
+func (c *AgentClient) QueryXjsAgent(a *Agent) *XunjiServiceQuery {
+	query := (&XunjiServiceClient{config: c.config}).Query()
+	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
+		id := a.ID
+		step := sqlgraph.NewStep(
+			sqlgraph.From(agent.Table, agent.FieldID, id),
+			sqlgraph.To(xunjiservice.Table, xunjiservice.FieldID),
+			sqlgraph.Edge(sqlgraph.O2M, false, agent.XjsAgentTable, agent.XjsAgentColumn),
+		)
+		fromV = sqlgraph.Neighbors(a.driver.Dialect(), step)
+		return fromV, nil
+	}
+	return query
+}
+
 // Hooks returns the client hooks.
 func (c *AgentClient) Hooks() []Hook {
 	hooks := c.hooks.Agent
@@ -6523,6 +6557,292 @@ func (c *WxCardVisitClient) mutate(ctx context.Context, m *WxCardVisitMutation)
 	}
 }
 
+// XunjiClient is a client for the Xunji schema.
+type XunjiClient struct {
+	config
+}
+
+// NewXunjiClient returns a client for the Xunji from the given config.
+func NewXunjiClient(c config) *XunjiClient {
+	return &XunjiClient{config: c}
+}
+
+// Use adds a list of mutation hooks to the hooks stack.
+// A call to `Use(f, g, h)` equals to `xunji.Hooks(f(g(h())))`.
+func (c *XunjiClient) Use(hooks ...Hook) {
+	c.hooks.Xunji = append(c.hooks.Xunji, hooks...)
+}
+
+// Intercept adds a list of query interceptors to the interceptors stack.
+// A call to `Intercept(f, g, h)` equals to `xunji.Intercept(f(g(h())))`.
+func (c *XunjiClient) Intercept(interceptors ...Interceptor) {
+	c.inters.Xunji = append(c.inters.Xunji, interceptors...)
+}
+
+// Create returns a builder for creating a Xunji entity.
+func (c *XunjiClient) Create() *XunjiCreate {
+	mutation := newXunjiMutation(c.config, OpCreate)
+	return &XunjiCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// CreateBulk returns a builder for creating a bulk of Xunji entities.
+func (c *XunjiClient) CreateBulk(builders ...*XunjiCreate) *XunjiCreateBulk {
+	return &XunjiCreateBulk{config: c.config, builders: builders}
+}
+
+// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
+// a builder and applies setFunc on it.
+func (c *XunjiClient) MapCreateBulk(slice any, setFunc func(*XunjiCreate, int)) *XunjiCreateBulk {
+	rv := reflect.ValueOf(slice)
+	if rv.Kind() != reflect.Slice {
+		return &XunjiCreateBulk{err: fmt.Errorf("calling to XunjiClient.MapCreateBulk with wrong type %T, need slice", slice)}
+	}
+	builders := make([]*XunjiCreate, rv.Len())
+	for i := 0; i < rv.Len(); i++ {
+		builders[i] = c.Create()
+		setFunc(builders[i], i)
+	}
+	return &XunjiCreateBulk{config: c.config, builders: builders}
+}
+
+// Update returns an update builder for Xunji.
+func (c *XunjiClient) Update() *XunjiUpdate {
+	mutation := newXunjiMutation(c.config, OpUpdate)
+	return &XunjiUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// UpdateOne returns an update builder for the given entity.
+func (c *XunjiClient) UpdateOne(x *Xunji) *XunjiUpdateOne {
+	mutation := newXunjiMutation(c.config, OpUpdateOne, withXunji(x))
+	return &XunjiUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// UpdateOneID returns an update builder for the given id.
+func (c *XunjiClient) UpdateOneID(id uint64) *XunjiUpdateOne {
+	mutation := newXunjiMutation(c.config, OpUpdateOne, withXunjiID(id))
+	return &XunjiUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// Delete returns a delete builder for Xunji.
+func (c *XunjiClient) Delete() *XunjiDelete {
+	mutation := newXunjiMutation(c.config, OpDelete)
+	return &XunjiDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// DeleteOne returns a builder for deleting the given entity.
+func (c *XunjiClient) DeleteOne(x *Xunji) *XunjiDeleteOne {
+	return c.DeleteOneID(x.ID)
+}
+
+// DeleteOneID returns a builder for deleting the given entity by its id.
+func (c *XunjiClient) DeleteOneID(id uint64) *XunjiDeleteOne {
+	builder := c.Delete().Where(xunji.ID(id))
+	builder.mutation.id = &id
+	builder.mutation.op = OpDeleteOne
+	return &XunjiDeleteOne{builder}
+}
+
+// Query returns a query builder for Xunji.
+func (c *XunjiClient) Query() *XunjiQuery {
+	return &XunjiQuery{
+		config: c.config,
+		ctx:    &QueryContext{Type: TypeXunji},
+		inters: c.Interceptors(),
+	}
+}
+
+// Get returns a Xunji entity by its id.
+func (c *XunjiClient) Get(ctx context.Context, id uint64) (*Xunji, error) {
+	return c.Query().Where(xunji.ID(id)).Only(ctx)
+}
+
+// GetX is like Get, but panics if an error occurs.
+func (c *XunjiClient) GetX(ctx context.Context, id uint64) *Xunji {
+	obj, err := c.Get(ctx, id)
+	if err != nil {
+		panic(err)
+	}
+	return obj
+}
+
+// Hooks returns the client hooks.
+func (c *XunjiClient) Hooks() []Hook {
+	hooks := c.hooks.Xunji
+	return append(hooks[:len(hooks):len(hooks)], xunji.Hooks[:]...)
+}
+
+// Interceptors returns the client interceptors.
+func (c *XunjiClient) Interceptors() []Interceptor {
+	inters := c.inters.Xunji
+	return append(inters[:len(inters):len(inters)], xunji.Interceptors[:]...)
+}
+
+func (c *XunjiClient) mutate(ctx context.Context, m *XunjiMutation) (Value, error) {
+	switch m.Op() {
+	case OpCreate:
+		return (&XunjiCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
+	case OpUpdate:
+		return (&XunjiUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
+	case OpUpdateOne:
+		return (&XunjiUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
+	case OpDelete, OpDeleteOne:
+		return (&XunjiDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
+	default:
+		return nil, fmt.Errorf("ent: unknown Xunji mutation op: %q", m.Op())
+	}
+}
+
+// XunjiServiceClient is a client for the XunjiService schema.
+type XunjiServiceClient struct {
+	config
+}
+
+// NewXunjiServiceClient returns a client for the XunjiService from the given config.
+func NewXunjiServiceClient(c config) *XunjiServiceClient {
+	return &XunjiServiceClient{config: c}
+}
+
+// Use adds a list of mutation hooks to the hooks stack.
+// A call to `Use(f, g, h)` equals to `xunjiservice.Hooks(f(g(h())))`.
+func (c *XunjiServiceClient) Use(hooks ...Hook) {
+	c.hooks.XunjiService = append(c.hooks.XunjiService, hooks...)
+}
+
+// Intercept adds a list of query interceptors to the interceptors stack.
+// A call to `Intercept(f, g, h)` equals to `xunjiservice.Intercept(f(g(h())))`.
+func (c *XunjiServiceClient) Intercept(interceptors ...Interceptor) {
+	c.inters.XunjiService = append(c.inters.XunjiService, interceptors...)
+}
+
+// Create returns a builder for creating a XunjiService entity.
+func (c *XunjiServiceClient) Create() *XunjiServiceCreate {
+	mutation := newXunjiServiceMutation(c.config, OpCreate)
+	return &XunjiServiceCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// CreateBulk returns a builder for creating a bulk of XunjiService entities.
+func (c *XunjiServiceClient) CreateBulk(builders ...*XunjiServiceCreate) *XunjiServiceCreateBulk {
+	return &XunjiServiceCreateBulk{config: c.config, builders: builders}
+}
+
+// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
+// a builder and applies setFunc on it.
+func (c *XunjiServiceClient) MapCreateBulk(slice any, setFunc func(*XunjiServiceCreate, int)) *XunjiServiceCreateBulk {
+	rv := reflect.ValueOf(slice)
+	if rv.Kind() != reflect.Slice {
+		return &XunjiServiceCreateBulk{err: fmt.Errorf("calling to XunjiServiceClient.MapCreateBulk with wrong type %T, need slice", slice)}
+	}
+	builders := make([]*XunjiServiceCreate, rv.Len())
+	for i := 0; i < rv.Len(); i++ {
+		builders[i] = c.Create()
+		setFunc(builders[i], i)
+	}
+	return &XunjiServiceCreateBulk{config: c.config, builders: builders}
+}
+
+// Update returns an update builder for XunjiService.
+func (c *XunjiServiceClient) Update() *XunjiServiceUpdate {
+	mutation := newXunjiServiceMutation(c.config, OpUpdate)
+	return &XunjiServiceUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// UpdateOne returns an update builder for the given entity.
+func (c *XunjiServiceClient) UpdateOne(xs *XunjiService) *XunjiServiceUpdateOne {
+	mutation := newXunjiServiceMutation(c.config, OpUpdateOne, withXunjiService(xs))
+	return &XunjiServiceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// UpdateOneID returns an update builder for the given id.
+func (c *XunjiServiceClient) UpdateOneID(id uint64) *XunjiServiceUpdateOne {
+	mutation := newXunjiServiceMutation(c.config, OpUpdateOne, withXunjiServiceID(id))
+	return &XunjiServiceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// Delete returns a delete builder for XunjiService.
+func (c *XunjiServiceClient) Delete() *XunjiServiceDelete {
+	mutation := newXunjiServiceMutation(c.config, OpDelete)
+	return &XunjiServiceDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// DeleteOne returns a builder for deleting the given entity.
+func (c *XunjiServiceClient) DeleteOne(xs *XunjiService) *XunjiServiceDeleteOne {
+	return c.DeleteOneID(xs.ID)
+}
+
+// DeleteOneID returns a builder for deleting the given entity by its id.
+func (c *XunjiServiceClient) DeleteOneID(id uint64) *XunjiServiceDeleteOne {
+	builder := c.Delete().Where(xunjiservice.ID(id))
+	builder.mutation.id = &id
+	builder.mutation.op = OpDeleteOne
+	return &XunjiServiceDeleteOne{builder}
+}
+
+// Query returns a query builder for XunjiService.
+func (c *XunjiServiceClient) Query() *XunjiServiceQuery {
+	return &XunjiServiceQuery{
+		config: c.config,
+		ctx:    &QueryContext{Type: TypeXunjiService},
+		inters: c.Interceptors(),
+	}
+}
+
+// Get returns a XunjiService entity by its id.
+func (c *XunjiServiceClient) Get(ctx context.Context, id uint64) (*XunjiService, error) {
+	return c.Query().Where(xunjiservice.ID(id)).Only(ctx)
+}
+
+// GetX is like Get, but panics if an error occurs.
+func (c *XunjiServiceClient) GetX(ctx context.Context, id uint64) *XunjiService {
+	obj, err := c.Get(ctx, id)
+	if err != nil {
+		panic(err)
+	}
+	return obj
+}
+
+// QueryAgent queries the agent edge of a XunjiService.
+func (c *XunjiServiceClient) QueryAgent(xs *XunjiService) *AgentQuery {
+	query := (&AgentClient{config: c.config}).Query()
+	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
+		id := xs.ID
+		step := sqlgraph.NewStep(
+			sqlgraph.From(xunjiservice.Table, xunjiservice.FieldID, id),
+			sqlgraph.To(agent.Table, agent.FieldID),
+			sqlgraph.Edge(sqlgraph.M2O, true, xunjiservice.AgentTable, xunjiservice.AgentColumn),
+		)
+		fromV = sqlgraph.Neighbors(xs.driver.Dialect(), step)
+		return fromV, nil
+	}
+	return query
+}
+
+// Hooks returns the client hooks.
+func (c *XunjiServiceClient) Hooks() []Hook {
+	hooks := c.hooks.XunjiService
+	return append(hooks[:len(hooks):len(hooks)], xunjiservice.Hooks[:]...)
+}
+
+// Interceptors returns the client interceptors.
+func (c *XunjiServiceClient) Interceptors() []Interceptor {
+	inters := c.inters.XunjiService
+	return append(inters[:len(inters):len(inters)], xunjiservice.Interceptors[:]...)
+}
+
+func (c *XunjiServiceClient) mutate(ctx context.Context, m *XunjiServiceMutation) (Value, error) {
+	switch m.Op() {
+	case OpCreate:
+		return (&XunjiServiceCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
+	case OpUpdate:
+		return (&XunjiServiceUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
+	case OpUpdateOne:
+		return (&XunjiServiceUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
+	case OpDelete, OpDeleteOne:
+		return (&XunjiServiceDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
+	default:
+		return nil, fmt.Errorf("ent: unknown XunjiService mutation op: %q", m.Op())
+	}
+}
+
 // hooks and interceptors per client, for fast access.
 type (
 	hooks struct {
@@ -6532,7 +6852,8 @@ type (
 		MessageRecords, Msg, PayRecharge, Server, SopNode, SopStage, SopTask, Token,
 		Tutorial, UsageDetail, UsageStatisticDay, UsageStatisticHour,
 		UsageStatisticMonth, UsageTotal, Whatsapp, WhatsappChannel, WorkExperience,
-		WpChatroom, WpChatroomMember, Wx, WxCard, WxCardUser, WxCardVisit []ent.Hook
+		WpChatroom, WpChatroomMember, Wx, WxCard, WxCardUser, WxCardVisit, Xunji,
+		XunjiService []ent.Hook
 	}
 	inters struct {
 		Agent, AgentBase, AliyunAvatar, AllocAgent, ApiKey, BatchMsg, Category,
@@ -6541,8 +6862,8 @@ type (
 		MessageRecords, Msg, PayRecharge, Server, SopNode, SopStage, SopTask, Token,
 		Tutorial, UsageDetail, UsageStatisticDay, UsageStatisticHour,
 		UsageStatisticMonth, UsageTotal, Whatsapp, WhatsappChannel, WorkExperience,
-		WpChatroom, WpChatroomMember, Wx, WxCard, WxCardUser,
-		WxCardVisit []ent.Interceptor
+		WpChatroom, WpChatroomMember, Wx, WxCard, WxCardUser, WxCardVisit, Xunji,
+		XunjiService []ent.Interceptor
 	}
 )
 

+ 4 - 0
ent/ent.go

@@ -49,6 +49,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"
@@ -154,6 +156,8 @@ func checkColumn(table, column string) error {
 			wxcard.Table:              wxcard.ValidColumn,
 			wxcarduser.Table:          wxcarduser.ValidColumn,
 			wxcardvisit.Table:         wxcardvisit.ValidColumn,
+			xunji.Table:               xunji.ValidColumn,
+			xunjiservice.Table:        xunjiservice.ValidColumn,
 		})
 	})
 	return columnCheck(table, column)

+ 24 - 0
ent/hook/hook.go

@@ -500,6 +500,30 @@ func (f WxCardVisitFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value,
 	return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.WxCardVisitMutation", m)
 }
 
+// The XunjiFunc type is an adapter to allow the use of ordinary
+// function as Xunji mutator.
+type XunjiFunc func(context.Context, *ent.XunjiMutation) (ent.Value, error)
+
+// Mutate calls f(ctx, m).
+func (f XunjiFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
+	if mv, ok := m.(*ent.XunjiMutation); ok {
+		return f(ctx, mv)
+	}
+	return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.XunjiMutation", m)
+}
+
+// The XunjiServiceFunc type is an adapter to allow the use of ordinary
+// function as XunjiService mutator.
+type XunjiServiceFunc func(context.Context, *ent.XunjiServiceMutation) (ent.Value, error)
+
+// Mutate calls f(ctx, m).
+func (f XunjiServiceFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
+	if mv, ok := m.(*ent.XunjiServiceMutation); ok {
+		return f(ctx, mv)
+	}
+	return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.XunjiServiceMutation", m)
+}
+
 // Condition is a hook condition function.
 type Condition func(context.Context, ent.Mutation) bool
 

+ 60 - 0
ent/intercept/intercept.go

@@ -48,6 +48,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/dialect/sql"
 )
@@ -1215,6 +1217,60 @@ func (f TraverseWxCardVisit) Traverse(ctx context.Context, q ent.Query) error {
 	return fmt.Errorf("unexpected query type %T. expect *ent.WxCardVisitQuery", q)
 }
 
+// The XunjiFunc type is an adapter to allow the use of ordinary function as a Querier.
+type XunjiFunc func(context.Context, *ent.XunjiQuery) (ent.Value, error)
+
+// Query calls f(ctx, q).
+func (f XunjiFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
+	if q, ok := q.(*ent.XunjiQuery); ok {
+		return f(ctx, q)
+	}
+	return nil, fmt.Errorf("unexpected query type %T. expect *ent.XunjiQuery", q)
+}
+
+// The TraverseXunji type is an adapter to allow the use of ordinary function as Traverser.
+type TraverseXunji func(context.Context, *ent.XunjiQuery) error
+
+// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
+func (f TraverseXunji) Intercept(next ent.Querier) ent.Querier {
+	return next
+}
+
+// Traverse calls f(ctx, q).
+func (f TraverseXunji) Traverse(ctx context.Context, q ent.Query) error {
+	if q, ok := q.(*ent.XunjiQuery); ok {
+		return f(ctx, q)
+	}
+	return fmt.Errorf("unexpected query type %T. expect *ent.XunjiQuery", q)
+}
+
+// The XunjiServiceFunc type is an adapter to allow the use of ordinary function as a Querier.
+type XunjiServiceFunc func(context.Context, *ent.XunjiServiceQuery) (ent.Value, error)
+
+// Query calls f(ctx, q).
+func (f XunjiServiceFunc) Query(ctx context.Context, q ent.Query) (ent.Value, error) {
+	if q, ok := q.(*ent.XunjiServiceQuery); ok {
+		return f(ctx, q)
+	}
+	return nil, fmt.Errorf("unexpected query type %T. expect *ent.XunjiServiceQuery", q)
+}
+
+// The TraverseXunjiService type is an adapter to allow the use of ordinary function as Traverser.
+type TraverseXunjiService func(context.Context, *ent.XunjiServiceQuery) error
+
+// Intercept is a dummy implementation of Intercept that returns the next Querier in the pipeline.
+func (f TraverseXunjiService) Intercept(next ent.Querier) ent.Querier {
+	return next
+}
+
+// Traverse calls f(ctx, q).
+func (f TraverseXunjiService) Traverse(ctx context.Context, q ent.Query) error {
+	if q, ok := q.(*ent.XunjiServiceQuery); ok {
+		return f(ctx, q)
+	}
+	return fmt.Errorf("unexpected query type %T. expect *ent.XunjiServiceQuery", q)
+}
+
 // NewQuery returns the generic Query interface for the given typed query.
 func NewQuery(q ent.Query) (Query, error) {
 	switch q := q.(type) {
@@ -1300,6 +1356,10 @@ func NewQuery(q ent.Query) (Query, error) {
 		return &query[*ent.WxCardUserQuery, predicate.WxCardUser, wxcarduser.OrderOption]{typ: ent.TypeWxCardUser, tq: q}, nil
 	case *ent.WxCardVisitQuery:
 		return &query[*ent.WxCardVisitQuery, predicate.WxCardVisit, wxcardvisit.OrderOption]{typ: ent.TypeWxCardVisit, tq: q}, nil
+	case *ent.XunjiQuery:
+		return &query[*ent.XunjiQuery, predicate.Xunji, xunji.OrderOption]{typ: ent.TypeXunji, tq: q}, nil
+	case *ent.XunjiServiceQuery:
+		return &query[*ent.XunjiServiceQuery, predicate.XunjiService, xunjiservice.OrderOption]{typ: ent.TypeXunjiService, tq: q}, nil
 	default:
 		return nil, fmt.Errorf("unknown query type %T", q)
 	}

+ 76 - 0
ent/migrate/schema.go

@@ -1412,6 +1412,73 @@ var (
 			},
 		},
 	}
+	// XunjiColumns holds the columns for the "xunji" table.
+	XunjiColumns = []*schema.Column{
+		{Name: "id", Type: field.TypeUint64, Increment: true},
+		{Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"},
+		{Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"},
+		{Name: "status", Type: field.TypeUint8, Nullable: true, Comment: "Status 1: normal 2: ban | 状态 1 正常 2 禁用", Default: 1},
+		{Name: "deleted_at", Type: field.TypeTime, Nullable: true, Comment: "Delete Time | 删除日期"},
+		{Name: "app_key", Type: field.TypeString, Comment: "AppKey"},
+		{Name: "app_secret", Type: field.TypeString, Comment: "AppSecret"},
+		{Name: "token", Type: field.TypeString, Comment: "Token"},
+		{Name: "encoding_key", Type: field.TypeString, Comment: "加密key"},
+		{Name: "agent_id", Type: field.TypeUint64, Comment: "角色ID"},
+		{Name: "organization_id", Type: field.TypeUint64, Comment: "organization_id | 租户ID"},
+	}
+	// XunjiTable holds the schema information for the "xunji" table.
+	XunjiTable = &schema.Table{
+		Name:       "xunji",
+		Columns:    XunjiColumns,
+		PrimaryKey: []*schema.Column{XunjiColumns[0]},
+		Indexes: []*schema.Index{
+			{
+				Name:    "xunji_app_key_token",
+				Unique:  false,
+				Columns: []*schema.Column{XunjiColumns[5], XunjiColumns[7]},
+			},
+		},
+	}
+	// XunjiServiceColumns holds the columns for the "xunji_service" table.
+	XunjiServiceColumns = []*schema.Column{
+		{Name: "id", Type: field.TypeUint64, Increment: true},
+		{Name: "created_at", Type: field.TypeTime, Comment: "Create Time | 创建日期"},
+		{Name: "updated_at", Type: field.TypeTime, Comment: "Update Time | 修改日期"},
+		{Name: "status", Type: field.TypeUint8, Nullable: true, Comment: "Status 1: normal 2: ban | 状态 1 正常 2 禁用", Default: 1},
+		{Name: "deleted_at", Type: field.TypeTime, Nullable: true, Comment: "Delete Time | 删除日期"},
+		{Name: "xunji_id", Type: field.TypeUint64, Comment: "Xunji表ID"},
+		{Name: "organization_id", Type: field.TypeUint64, Comment: "organization_id | 租户ID"},
+		{Name: "wxid", Type: field.TypeString, Comment: "微信ID"},
+		{Name: "api_base", Type: field.TypeString, Nullable: true, Comment: "大模型服务地址", Default: ""},
+		{Name: "api_key", Type: field.TypeString, Nullable: true, Comment: "大模型服务密钥", Default: ""},
+		{Name: "agent_id", Type: field.TypeUint64, Comment: "智能体ID", Default: 0},
+	}
+	// XunjiServiceTable holds the schema information for the "xunji_service" table.
+	XunjiServiceTable = &schema.Table{
+		Name:       "xunji_service",
+		Columns:    XunjiServiceColumns,
+		PrimaryKey: []*schema.Column{XunjiServiceColumns[0]},
+		ForeignKeys: []*schema.ForeignKey{
+			{
+				Symbol:     "xunji_service_agent_xjs_agent",
+				Columns:    []*schema.Column{XunjiServiceColumns[10]},
+				RefColumns: []*schema.Column{AgentColumns[0]},
+				OnDelete:   schema.NoAction,
+			},
+		},
+		Indexes: []*schema.Index{
+			{
+				Name:    "xunjiservice_xunji_id",
+				Unique:  false,
+				Columns: []*schema.Column{XunjiServiceColumns[5]},
+			},
+			{
+				Name:    "xunjiservice_wxid",
+				Unique:  false,
+				Columns: []*schema.Column{XunjiServiceColumns[7]},
+			},
+		},
+	}
 	// Tables holds all the tables in the schema.
 	Tables = []*schema.Table{
 		AgentTable,
@@ -1455,6 +1522,8 @@ var (
 		WxCardTable,
 		WxCardUserTable,
 		WxCardVisitTable,
+		XunjiTable,
+		XunjiServiceTable,
 	}
 )
 
@@ -1597,4 +1666,11 @@ func init() {
 	WxCardVisitTable.Annotation = &entsql.Annotation{
 		Table: "wx_card_visit",
 	}
+	XunjiTable.Annotation = &entsql.Annotation{
+		Table: "xunji",
+	}
+	XunjiServiceTable.ForeignKeys[0].RefTable = AgentTable
+	XunjiServiceTable.Annotation = &entsql.Annotation{
+		Table: "xunji_service",
+	}
 }

+ 2106 - 3
ent/mutation.go

@@ -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)
+}

+ 164 - 0
ent/pagination.go

@@ -46,6 +46,8 @@ import (
 	"wechat-api/ent/wxcard"
 	"wechat-api/ent/wxcarduser"
 	"wechat-api/ent/wxcardvisit"
+	"wechat-api/ent/xunji"
+	"wechat-api/ent/xunjiservice"
 )
 
 const errInvalidPage = "INVALID_PAGE"
@@ -3414,3 +3416,165 @@ func (wcv *WxCardVisitQuery) Page(
 
 	return ret, nil
 }
+
+type XunjiPager struct {
+	Order  xunji.OrderOption
+	Filter func(*XunjiQuery) (*XunjiQuery, error)
+}
+
+// XunjiPaginateOption enables pagination customization.
+type XunjiPaginateOption func(*XunjiPager)
+
+// DefaultXunjiOrder is the default ordering of Xunji.
+var DefaultXunjiOrder = Desc(xunji.FieldID)
+
+func newXunjiPager(opts []XunjiPaginateOption) (*XunjiPager, error) {
+	pager := &XunjiPager{}
+	for _, opt := range opts {
+		opt(pager)
+	}
+	if pager.Order == nil {
+		pager.Order = DefaultXunjiOrder
+	}
+	return pager, nil
+}
+
+func (p *XunjiPager) ApplyFilter(query *XunjiQuery) (*XunjiQuery, error) {
+	if p.Filter != nil {
+		return p.Filter(query)
+	}
+	return query, nil
+}
+
+// XunjiPageList is Xunji PageList result.
+type XunjiPageList struct {
+	List        []*Xunji     `json:"list"`
+	PageDetails *PageDetails `json:"pageDetails"`
+}
+
+func (x *XunjiQuery) Page(
+	ctx context.Context, pageNum uint64, pageSize uint64, opts ...XunjiPaginateOption,
+) (*XunjiPageList, error) {
+
+	pager, err := newXunjiPager(opts)
+	if err != nil {
+		return nil, err
+	}
+
+	if x, err = pager.ApplyFilter(x); err != nil {
+		return nil, err
+	}
+
+	ret := &XunjiPageList{}
+
+	ret.PageDetails = &PageDetails{
+		Page: pageNum,
+		Size: pageSize,
+	}
+
+	query := x.Clone()
+	query.ctx.Fields = nil
+	count, err := query.Count(ctx)
+
+	if err != nil {
+		return nil, err
+	}
+
+	ret.PageDetails.Total = uint64(count)
+
+	if pager.Order != nil {
+		x = x.Order(pager.Order)
+	} else {
+		x = x.Order(DefaultXunjiOrder)
+	}
+
+	x = x.Offset(int((pageNum - 1) * pageSize)).Limit(int(pageSize))
+	list, err := x.All(ctx)
+	if err != nil {
+		return nil, err
+	}
+	ret.List = list
+
+	return ret, nil
+}
+
+type XunjiServicePager struct {
+	Order  xunjiservice.OrderOption
+	Filter func(*XunjiServiceQuery) (*XunjiServiceQuery, error)
+}
+
+// XunjiServicePaginateOption enables pagination customization.
+type XunjiServicePaginateOption func(*XunjiServicePager)
+
+// DefaultXunjiServiceOrder is the default ordering of XunjiService.
+var DefaultXunjiServiceOrder = Desc(xunjiservice.FieldID)
+
+func newXunjiServicePager(opts []XunjiServicePaginateOption) (*XunjiServicePager, error) {
+	pager := &XunjiServicePager{}
+	for _, opt := range opts {
+		opt(pager)
+	}
+	if pager.Order == nil {
+		pager.Order = DefaultXunjiServiceOrder
+	}
+	return pager, nil
+}
+
+func (p *XunjiServicePager) ApplyFilter(query *XunjiServiceQuery) (*XunjiServiceQuery, error) {
+	if p.Filter != nil {
+		return p.Filter(query)
+	}
+	return query, nil
+}
+
+// XunjiServicePageList is XunjiService PageList result.
+type XunjiServicePageList struct {
+	List        []*XunjiService `json:"list"`
+	PageDetails *PageDetails    `json:"pageDetails"`
+}
+
+func (xs *XunjiServiceQuery) Page(
+	ctx context.Context, pageNum uint64, pageSize uint64, opts ...XunjiServicePaginateOption,
+) (*XunjiServicePageList, error) {
+
+	pager, err := newXunjiServicePager(opts)
+	if err != nil {
+		return nil, err
+	}
+
+	if xs, err = pager.ApplyFilter(xs); err != nil {
+		return nil, err
+	}
+
+	ret := &XunjiServicePageList{}
+
+	ret.PageDetails = &PageDetails{
+		Page: pageNum,
+		Size: pageSize,
+	}
+
+	query := xs.Clone()
+	query.ctx.Fields = nil
+	count, err := query.Count(ctx)
+
+	if err != nil {
+		return nil, err
+	}
+
+	ret.PageDetails.Total = uint64(count)
+
+	if pager.Order != nil {
+		xs = xs.Order(pager.Order)
+	} else {
+		xs = xs.Order(DefaultXunjiServiceOrder)
+	}
+
+	xs = xs.Offset(int((pageNum - 1) * pageSize)).Limit(int(pageSize))
+	list, err := xs.All(ctx)
+	if err != nil {
+		return nil, err
+	}
+	ret.List = list
+
+	return ret, nil
+}

+ 6 - 0
ent/predicate/predicate.go

@@ -128,3 +128,9 @@ type WxCardUser func(*sql.Selector)
 
 // WxCardVisit is the predicate function for wxcardvisit builders.
 type WxCardVisit func(*sql.Selector)
+
+// Xunji is the predicate function for xunji builders.
+type Xunji func(*sql.Selector)
+
+// XunjiService is the predicate function for xunjiservice builders.
+type XunjiService func(*sql.Selector)

+ 72 - 0
ent/runtime/runtime.go

@@ -46,6 +46,8 @@ import (
 	"wechat-api/ent/wxcard"
 	"wechat-api/ent/wxcarduser"
 	"wechat-api/ent/wxcardvisit"
+	"wechat-api/ent/xunji"
+	"wechat-api/ent/xunjiservice"
 )
 
 // The init function reads all schema descriptors with runtime code
@@ -1845,6 +1847,76 @@ func init() {
 	wxcardvisitDescBotType := wxcardvisitFields[2].Descriptor()
 	// wxcardvisit.DefaultBotType holds the default value on creation for the bot_type field.
 	wxcardvisit.DefaultBotType = wxcardvisitDescBotType.Default.(uint8)
+	xunjiMixin := schema.Xunji{}.Mixin()
+	xunjiMixinHooks2 := xunjiMixin[2].Hooks()
+	xunji.Hooks[0] = xunjiMixinHooks2[0]
+	xunjiMixinInters2 := xunjiMixin[2].Interceptors()
+	xunji.Interceptors[0] = xunjiMixinInters2[0]
+	xunjiMixinFields0 := xunjiMixin[0].Fields()
+	_ = xunjiMixinFields0
+	xunjiMixinFields1 := xunjiMixin[1].Fields()
+	_ = xunjiMixinFields1
+	xunjiFields := schema.Xunji{}.Fields()
+	_ = xunjiFields
+	// xunjiDescCreatedAt is the schema descriptor for created_at field.
+	xunjiDescCreatedAt := xunjiMixinFields0[1].Descriptor()
+	// xunji.DefaultCreatedAt holds the default value on creation for the created_at field.
+	xunji.DefaultCreatedAt = xunjiDescCreatedAt.Default.(func() time.Time)
+	// xunjiDescUpdatedAt is the schema descriptor for updated_at field.
+	xunjiDescUpdatedAt := xunjiMixinFields0[2].Descriptor()
+	// xunji.DefaultUpdatedAt holds the default value on creation for the updated_at field.
+	xunji.DefaultUpdatedAt = xunjiDescUpdatedAt.Default.(func() time.Time)
+	// xunji.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
+	xunji.UpdateDefaultUpdatedAt = xunjiDescUpdatedAt.UpdateDefault.(func() time.Time)
+	// xunjiDescStatus is the schema descriptor for status field.
+	xunjiDescStatus := xunjiMixinFields1[0].Descriptor()
+	// xunji.DefaultStatus holds the default value on creation for the status field.
+	xunji.DefaultStatus = xunjiDescStatus.Default.(uint8)
+	// xunjiDescOrganizationID is the schema descriptor for organization_id field.
+	xunjiDescOrganizationID := xunjiFields[5].Descriptor()
+	// xunji.OrganizationIDValidator is a validator for the "organization_id" field. It is called by the builders before save.
+	xunji.OrganizationIDValidator = xunjiDescOrganizationID.Validators[0].(func(uint64) error)
+	xunjiserviceMixin := schema.XunjiService{}.Mixin()
+	xunjiserviceMixinHooks2 := xunjiserviceMixin[2].Hooks()
+	xunjiservice.Hooks[0] = xunjiserviceMixinHooks2[0]
+	xunjiserviceMixinInters2 := xunjiserviceMixin[2].Interceptors()
+	xunjiservice.Interceptors[0] = xunjiserviceMixinInters2[0]
+	xunjiserviceMixinFields0 := xunjiserviceMixin[0].Fields()
+	_ = xunjiserviceMixinFields0
+	xunjiserviceMixinFields1 := xunjiserviceMixin[1].Fields()
+	_ = xunjiserviceMixinFields1
+	xunjiserviceFields := schema.XunjiService{}.Fields()
+	_ = xunjiserviceFields
+	// xunjiserviceDescCreatedAt is the schema descriptor for created_at field.
+	xunjiserviceDescCreatedAt := xunjiserviceMixinFields0[1].Descriptor()
+	// xunjiservice.DefaultCreatedAt holds the default value on creation for the created_at field.
+	xunjiservice.DefaultCreatedAt = xunjiserviceDescCreatedAt.Default.(func() time.Time)
+	// xunjiserviceDescUpdatedAt is the schema descriptor for updated_at field.
+	xunjiserviceDescUpdatedAt := xunjiserviceMixinFields0[2].Descriptor()
+	// xunjiservice.DefaultUpdatedAt holds the default value on creation for the updated_at field.
+	xunjiservice.DefaultUpdatedAt = xunjiserviceDescUpdatedAt.Default.(func() time.Time)
+	// xunjiservice.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
+	xunjiservice.UpdateDefaultUpdatedAt = xunjiserviceDescUpdatedAt.UpdateDefault.(func() time.Time)
+	// xunjiserviceDescStatus is the schema descriptor for status field.
+	xunjiserviceDescStatus := xunjiserviceMixinFields1[0].Descriptor()
+	// xunjiservice.DefaultStatus holds the default value on creation for the status field.
+	xunjiservice.DefaultStatus = xunjiserviceDescStatus.Default.(uint8)
+	// xunjiserviceDescAgentID is the schema descriptor for agent_id field.
+	xunjiserviceDescAgentID := xunjiserviceFields[1].Descriptor()
+	// xunjiservice.DefaultAgentID holds the default value on creation for the agent_id field.
+	xunjiservice.DefaultAgentID = xunjiserviceDescAgentID.Default.(uint64)
+	// xunjiserviceDescOrganizationID is the schema descriptor for organization_id field.
+	xunjiserviceDescOrganizationID := xunjiserviceFields[2].Descriptor()
+	// xunjiservice.OrganizationIDValidator is a validator for the "organization_id" field. It is called by the builders before save.
+	xunjiservice.OrganizationIDValidator = xunjiserviceDescOrganizationID.Validators[0].(func(uint64) error)
+	// xunjiserviceDescAPIBase is the schema descriptor for api_base field.
+	xunjiserviceDescAPIBase := xunjiserviceFields[4].Descriptor()
+	// xunjiservice.DefaultAPIBase holds the default value on creation for the api_base field.
+	xunjiservice.DefaultAPIBase = xunjiserviceDescAPIBase.Default.(string)
+	// xunjiserviceDescAPIKey is the schema descriptor for api_key field.
+	xunjiserviceDescAPIKey := xunjiserviceFields[5].Descriptor()
+	// xunjiservice.DefaultAPIKey holds the default value on creation for the api_key field.
+	xunjiservice.DefaultAPIKey = xunjiserviceDescAPIKey.Default.(string)
 }
 
 const (

+ 1 - 0
ent/schema/agent.go

@@ -42,6 +42,7 @@ func (Agent) Edges() []ent.Edge {
 		edge.To("token_agent", Token.Type),
 		edge.To("wa_agent", Whatsapp.Type),
 		edge.To("key_agent", ApiKey.Type),
+		edge.To("xjs_agent", XunjiService.Type),
 	}
 }
 

+ 52 - 0
ent/schema/xunji.go

@@ -0,0 +1,52 @@
+package schema
+
+import (
+	"wechat-api/ent/schema/localmixin"
+
+	"entgo.io/ent"
+	"entgo.io/ent/dialect/entsql"
+	"entgo.io/ent/schema"
+	"entgo.io/ent/schema/field"
+	"entgo.io/ent/schema/index"
+	"github.com/suyuan32/simple-admin-common/orm/ent/mixins"
+)
+
+type Xunji struct {
+	ent.Schema
+}
+
+func (Xunji) Fields() []ent.Field {
+	return []ent.Field{
+		field.String("app_key").Comment("AppKey"),
+		field.String("app_secret").Comment("AppSecret"),
+		field.String("token").Comment("Token"),
+		field.String("encoding_key").Comment("加密key"),
+		field.Uint64("agent_id").Comment("角色ID"),
+		field.Uint64("organization_id").Positive().Comment("organization_id | 租户ID"),
+	}
+}
+
+func (Xunji) Mixin() []ent.Mixin {
+	return []ent.Mixin{
+		mixins.IDMixin{},
+		mixins.StatusMixin{},
+		localmixin.SoftDeleteMixin{},
+	}
+}
+
+func (Xunji) Indexes() []ent.Index {
+	return []ent.Index{
+		index.Fields("app_key", "token"),
+	}
+}
+
+func (Xunji) Edges() []ent.Edge {
+	return []ent.Edge{}
+}
+
+func (Xunji) Annotations() []schema.Annotation {
+	return []schema.Annotation{
+		entsql.WithComments(true),
+		entsql.Annotation{Table: "xunji"},
+	}
+}

+ 60 - 0
ent/schema/xunji_service.go

@@ -0,0 +1,60 @@
+package schema
+
+import (
+	"entgo.io/ent/schema/edge"
+	"wechat-api/ent/schema/localmixin"
+
+	"entgo.io/ent"
+	"entgo.io/ent/dialect/entsql"
+	"entgo.io/ent/schema"
+	"entgo.io/ent/schema/field"
+	"entgo.io/ent/schema/index"
+	"github.com/suyuan32/simple-admin-common/orm/ent/mixins"
+)
+
+type XunjiService struct {
+	ent.Schema
+}
+
+func (XunjiService) Fields() []ent.Field {
+	return []ent.Field{
+		field.Uint64("xunji_id").Comment("Xunji表ID"),
+		field.Uint64("agent_id").Default(0).Comment("智能体ID"),
+		field.Uint64("organization_id").Positive().Comment("organization_id | 租户ID"),
+		field.String("wxid").Comment("微信ID"),
+		field.String("api_base").Optional().Default("").Comment("大模型服务地址"),
+		field.String("api_key").Optional().Default("").Comment("大模型服务密钥"),
+	}
+}
+
+func (XunjiService) Mixin() []ent.Mixin {
+	return []ent.Mixin{
+		mixins.IDMixin{},
+		mixins.StatusMixin{},
+		localmixin.SoftDeleteMixin{},
+	}
+}
+
+func (XunjiService) Indexes() []ent.Index {
+	return []ent.Index{
+		index.Fields("xunji_id"),
+		index.Fields("wxid"),
+	}
+}
+
+func (XunjiService) Edges() []ent.Edge {
+	return []ent.Edge{
+		edge.From("agent", Agent.Type).
+			Ref("xjs_agent").
+			Unique().
+			Field("agent_id").
+			Required(),
+	}
+}
+
+func (XunjiService) Annotations() []schema.Annotation {
+	return []schema.Annotation{
+		entsql.WithComments(true),
+		entsql.Annotation{Table: "xunji_service"},
+	}
+}

+ 432 - 0
ent/set_not_nil.go

@@ -11022,3 +11022,435 @@ func (wcv *WxCardVisitCreate) SetNotNilBotType(value *uint8) *WxCardVisitCreate
 	}
 	return wcv
 }
+
+// set field if value's pointer is not nil.
+func (x *XunjiUpdate) SetNotNilUpdatedAt(value *time.Time) *XunjiUpdate {
+	if value != nil {
+		return x.SetUpdatedAt(*value)
+	}
+	return x
+}
+
+// set field if value's pointer is not nil.
+func (x *XunjiUpdateOne) SetNotNilUpdatedAt(value *time.Time) *XunjiUpdateOne {
+	if value != nil {
+		return x.SetUpdatedAt(*value)
+	}
+	return x
+}
+
+// set field if value's pointer is not nil.
+func (x *XunjiCreate) SetNotNilUpdatedAt(value *time.Time) *XunjiCreate {
+	if value != nil {
+		return x.SetUpdatedAt(*value)
+	}
+	return x
+}
+
+// set field if value's pointer is not nil.
+func (x *XunjiUpdate) SetNotNilStatus(value *uint8) *XunjiUpdate {
+	if value != nil {
+		return x.SetStatus(*value)
+	}
+	return x
+}
+
+// set field if value's pointer is not nil.
+func (x *XunjiUpdateOne) SetNotNilStatus(value *uint8) *XunjiUpdateOne {
+	if value != nil {
+		return x.SetStatus(*value)
+	}
+	return x
+}
+
+// set field if value's pointer is not nil.
+func (x *XunjiCreate) SetNotNilStatus(value *uint8) *XunjiCreate {
+	if value != nil {
+		return x.SetStatus(*value)
+	}
+	return x
+}
+
+// set field if value's pointer is not nil.
+func (x *XunjiUpdate) SetNotNilDeletedAt(value *time.Time) *XunjiUpdate {
+	if value != nil {
+		return x.SetDeletedAt(*value)
+	}
+	return x
+}
+
+// set field if value's pointer is not nil.
+func (x *XunjiUpdateOne) SetNotNilDeletedAt(value *time.Time) *XunjiUpdateOne {
+	if value != nil {
+		return x.SetDeletedAt(*value)
+	}
+	return x
+}
+
+// set field if value's pointer is not nil.
+func (x *XunjiCreate) SetNotNilDeletedAt(value *time.Time) *XunjiCreate {
+	if value != nil {
+		return x.SetDeletedAt(*value)
+	}
+	return x
+}
+
+// set field if value's pointer is not nil.
+func (x *XunjiUpdate) SetNotNilAppKey(value *string) *XunjiUpdate {
+	if value != nil {
+		return x.SetAppKey(*value)
+	}
+	return x
+}
+
+// set field if value's pointer is not nil.
+func (x *XunjiUpdateOne) SetNotNilAppKey(value *string) *XunjiUpdateOne {
+	if value != nil {
+		return x.SetAppKey(*value)
+	}
+	return x
+}
+
+// set field if value's pointer is not nil.
+func (x *XunjiCreate) SetNotNilAppKey(value *string) *XunjiCreate {
+	if value != nil {
+		return x.SetAppKey(*value)
+	}
+	return x
+}
+
+// set field if value's pointer is not nil.
+func (x *XunjiUpdate) SetNotNilAppSecret(value *string) *XunjiUpdate {
+	if value != nil {
+		return x.SetAppSecret(*value)
+	}
+	return x
+}
+
+// set field if value's pointer is not nil.
+func (x *XunjiUpdateOne) SetNotNilAppSecret(value *string) *XunjiUpdateOne {
+	if value != nil {
+		return x.SetAppSecret(*value)
+	}
+	return x
+}
+
+// set field if value's pointer is not nil.
+func (x *XunjiCreate) SetNotNilAppSecret(value *string) *XunjiCreate {
+	if value != nil {
+		return x.SetAppSecret(*value)
+	}
+	return x
+}
+
+// set field if value's pointer is not nil.
+func (x *XunjiUpdate) SetNotNilToken(value *string) *XunjiUpdate {
+	if value != nil {
+		return x.SetToken(*value)
+	}
+	return x
+}
+
+// set field if value's pointer is not nil.
+func (x *XunjiUpdateOne) SetNotNilToken(value *string) *XunjiUpdateOne {
+	if value != nil {
+		return x.SetToken(*value)
+	}
+	return x
+}
+
+// set field if value's pointer is not nil.
+func (x *XunjiCreate) SetNotNilToken(value *string) *XunjiCreate {
+	if value != nil {
+		return x.SetToken(*value)
+	}
+	return x
+}
+
+// set field if value's pointer is not nil.
+func (x *XunjiUpdate) SetNotNilEncodingKey(value *string) *XunjiUpdate {
+	if value != nil {
+		return x.SetEncodingKey(*value)
+	}
+	return x
+}
+
+// set field if value's pointer is not nil.
+func (x *XunjiUpdateOne) SetNotNilEncodingKey(value *string) *XunjiUpdateOne {
+	if value != nil {
+		return x.SetEncodingKey(*value)
+	}
+	return x
+}
+
+// set field if value's pointer is not nil.
+func (x *XunjiCreate) SetNotNilEncodingKey(value *string) *XunjiCreate {
+	if value != nil {
+		return x.SetEncodingKey(*value)
+	}
+	return x
+}
+
+// set field if value's pointer is not nil.
+func (x *XunjiUpdate) SetNotNilAgentID(value *uint64) *XunjiUpdate {
+	if value != nil {
+		return x.SetAgentID(*value)
+	}
+	return x
+}
+
+// set field if value's pointer is not nil.
+func (x *XunjiUpdateOne) SetNotNilAgentID(value *uint64) *XunjiUpdateOne {
+	if value != nil {
+		return x.SetAgentID(*value)
+	}
+	return x
+}
+
+// set field if value's pointer is not nil.
+func (x *XunjiCreate) SetNotNilAgentID(value *uint64) *XunjiCreate {
+	if value != nil {
+		return x.SetAgentID(*value)
+	}
+	return x
+}
+
+// set field if value's pointer is not nil.
+func (x *XunjiUpdate) SetNotNilOrganizationID(value *uint64) *XunjiUpdate {
+	if value != nil {
+		return x.SetOrganizationID(*value)
+	}
+	return x
+}
+
+// set field if value's pointer is not nil.
+func (x *XunjiUpdateOne) SetNotNilOrganizationID(value *uint64) *XunjiUpdateOne {
+	if value != nil {
+		return x.SetOrganizationID(*value)
+	}
+	return x
+}
+
+// set field if value's pointer is not nil.
+func (x *XunjiCreate) SetNotNilOrganizationID(value *uint64) *XunjiCreate {
+	if value != nil {
+		return x.SetOrganizationID(*value)
+	}
+	return x
+}
+
+// set field if value's pointer is not nil.
+func (xs *XunjiServiceUpdate) SetNotNilUpdatedAt(value *time.Time) *XunjiServiceUpdate {
+	if value != nil {
+		return xs.SetUpdatedAt(*value)
+	}
+	return xs
+}
+
+// set field if value's pointer is not nil.
+func (xs *XunjiServiceUpdateOne) SetNotNilUpdatedAt(value *time.Time) *XunjiServiceUpdateOne {
+	if value != nil {
+		return xs.SetUpdatedAt(*value)
+	}
+	return xs
+}
+
+// set field if value's pointer is not nil.
+func (xs *XunjiServiceCreate) SetNotNilUpdatedAt(value *time.Time) *XunjiServiceCreate {
+	if value != nil {
+		return xs.SetUpdatedAt(*value)
+	}
+	return xs
+}
+
+// set field if value's pointer is not nil.
+func (xs *XunjiServiceUpdate) SetNotNilStatus(value *uint8) *XunjiServiceUpdate {
+	if value != nil {
+		return xs.SetStatus(*value)
+	}
+	return xs
+}
+
+// set field if value's pointer is not nil.
+func (xs *XunjiServiceUpdateOne) SetNotNilStatus(value *uint8) *XunjiServiceUpdateOne {
+	if value != nil {
+		return xs.SetStatus(*value)
+	}
+	return xs
+}
+
+// set field if value's pointer is not nil.
+func (xs *XunjiServiceCreate) SetNotNilStatus(value *uint8) *XunjiServiceCreate {
+	if value != nil {
+		return xs.SetStatus(*value)
+	}
+	return xs
+}
+
+// set field if value's pointer is not nil.
+func (xs *XunjiServiceUpdate) SetNotNilDeletedAt(value *time.Time) *XunjiServiceUpdate {
+	if value != nil {
+		return xs.SetDeletedAt(*value)
+	}
+	return xs
+}
+
+// set field if value's pointer is not nil.
+func (xs *XunjiServiceUpdateOne) SetNotNilDeletedAt(value *time.Time) *XunjiServiceUpdateOne {
+	if value != nil {
+		return xs.SetDeletedAt(*value)
+	}
+	return xs
+}
+
+// set field if value's pointer is not nil.
+func (xs *XunjiServiceCreate) SetNotNilDeletedAt(value *time.Time) *XunjiServiceCreate {
+	if value != nil {
+		return xs.SetDeletedAt(*value)
+	}
+	return xs
+}
+
+// set field if value's pointer is not nil.
+func (xs *XunjiServiceUpdate) SetNotNilXunjiID(value *uint64) *XunjiServiceUpdate {
+	if value != nil {
+		return xs.SetXunjiID(*value)
+	}
+	return xs
+}
+
+// set field if value's pointer is not nil.
+func (xs *XunjiServiceUpdateOne) SetNotNilXunjiID(value *uint64) *XunjiServiceUpdateOne {
+	if value != nil {
+		return xs.SetXunjiID(*value)
+	}
+	return xs
+}
+
+// set field if value's pointer is not nil.
+func (xs *XunjiServiceCreate) SetNotNilXunjiID(value *uint64) *XunjiServiceCreate {
+	if value != nil {
+		return xs.SetXunjiID(*value)
+	}
+	return xs
+}
+
+// set field if value's pointer is not nil.
+func (xs *XunjiServiceUpdate) SetNotNilAgentID(value *uint64) *XunjiServiceUpdate {
+	if value != nil {
+		return xs.SetAgentID(*value)
+	}
+	return xs
+}
+
+// set field if value's pointer is not nil.
+func (xs *XunjiServiceUpdateOne) SetNotNilAgentID(value *uint64) *XunjiServiceUpdateOne {
+	if value != nil {
+		return xs.SetAgentID(*value)
+	}
+	return xs
+}
+
+// set field if value's pointer is not nil.
+func (xs *XunjiServiceCreate) SetNotNilAgentID(value *uint64) *XunjiServiceCreate {
+	if value != nil {
+		return xs.SetAgentID(*value)
+	}
+	return xs
+}
+
+// set field if value's pointer is not nil.
+func (xs *XunjiServiceUpdate) SetNotNilOrganizationID(value *uint64) *XunjiServiceUpdate {
+	if value != nil {
+		return xs.SetOrganizationID(*value)
+	}
+	return xs
+}
+
+// set field if value's pointer is not nil.
+func (xs *XunjiServiceUpdateOne) SetNotNilOrganizationID(value *uint64) *XunjiServiceUpdateOne {
+	if value != nil {
+		return xs.SetOrganizationID(*value)
+	}
+	return xs
+}
+
+// set field if value's pointer is not nil.
+func (xs *XunjiServiceCreate) SetNotNilOrganizationID(value *uint64) *XunjiServiceCreate {
+	if value != nil {
+		return xs.SetOrganizationID(*value)
+	}
+	return xs
+}
+
+// set field if value's pointer is not nil.
+func (xs *XunjiServiceUpdate) SetNotNilWxid(value *string) *XunjiServiceUpdate {
+	if value != nil {
+		return xs.SetWxid(*value)
+	}
+	return xs
+}
+
+// set field if value's pointer is not nil.
+func (xs *XunjiServiceUpdateOne) SetNotNilWxid(value *string) *XunjiServiceUpdateOne {
+	if value != nil {
+		return xs.SetWxid(*value)
+	}
+	return xs
+}
+
+// set field if value's pointer is not nil.
+func (xs *XunjiServiceCreate) SetNotNilWxid(value *string) *XunjiServiceCreate {
+	if value != nil {
+		return xs.SetWxid(*value)
+	}
+	return xs
+}
+
+// set field if value's pointer is not nil.
+func (xs *XunjiServiceUpdate) SetNotNilAPIBase(value *string) *XunjiServiceUpdate {
+	if value != nil {
+		return xs.SetAPIBase(*value)
+	}
+	return xs
+}
+
+// set field if value's pointer is not nil.
+func (xs *XunjiServiceUpdateOne) SetNotNilAPIBase(value *string) *XunjiServiceUpdateOne {
+	if value != nil {
+		return xs.SetAPIBase(*value)
+	}
+	return xs
+}
+
+// set field if value's pointer is not nil.
+func (xs *XunjiServiceCreate) SetNotNilAPIBase(value *string) *XunjiServiceCreate {
+	if value != nil {
+		return xs.SetAPIBase(*value)
+	}
+	return xs
+}
+
+// set field if value's pointer is not nil.
+func (xs *XunjiServiceUpdate) SetNotNilAPIKey(value *string) *XunjiServiceUpdate {
+	if value != nil {
+		return xs.SetAPIKey(*value)
+	}
+	return xs
+}
+
+// set field if value's pointer is not nil.
+func (xs *XunjiServiceUpdateOne) SetNotNilAPIKey(value *string) *XunjiServiceUpdateOne {
+	if value != nil {
+		return xs.SetAPIKey(*value)
+	}
+	return xs
+}
+
+// set field if value's pointer is not nil.
+func (xs *XunjiServiceCreate) SetNotNilAPIKey(value *string) *XunjiServiceCreate {
+	if value != nil {
+		return xs.SetAPIKey(*value)
+	}
+	return xs
+}

+ 6 - 0
ent/tx.go

@@ -96,6 +96,10 @@ type Tx struct {
 	WxCardUser *WxCardUserClient
 	// WxCardVisit is the client for interacting with the WxCardVisit builders.
 	WxCardVisit *WxCardVisitClient
+	// Xunji is the client for interacting with the Xunji builders.
+	Xunji *XunjiClient
+	// XunjiService is the client for interacting with the XunjiService builders.
+	XunjiService *XunjiServiceClient
 
 	// lazily loaded.
 	client     *Client
@@ -268,6 +272,8 @@ func (tx *Tx) init() {
 	tx.WxCard = NewWxCardClient(tx.config)
 	tx.WxCardUser = NewWxCardUserClient(tx.config)
 	tx.WxCardVisit = NewWxCardVisitClient(tx.config)
+	tx.Xunji = NewXunjiClient(tx.config)
+	tx.XunjiService = NewXunjiServiceClient(tx.config)
 }
 
 // txDriver wraps the given dialect.Tx with a nop dialect.Driver implementation.

+ 205 - 0
ent/xunji.go

@@ -0,0 +1,205 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+	"fmt"
+	"strings"
+	"time"
+	"wechat-api/ent/xunji"
+
+	"entgo.io/ent"
+	"entgo.io/ent/dialect/sql"
+)
+
+// Xunji is the model entity for the Xunji schema.
+type Xunji struct {
+	config `json:"-"`
+	// ID of the ent.
+	ID uint64 `json:"id,omitempty"`
+	// Create Time | 创建日期
+	CreatedAt time.Time `json:"created_at,omitempty"`
+	// Update Time | 修改日期
+	UpdatedAt time.Time `json:"updated_at,omitempty"`
+	// Status 1: normal 2: ban | 状态 1 正常 2 禁用
+	Status uint8 `json:"status,omitempty"`
+	// Delete Time | 删除日期
+	DeletedAt time.Time `json:"deleted_at,omitempty"`
+	// AppKey
+	AppKey string `json:"app_key,omitempty"`
+	// AppSecret
+	AppSecret string `json:"app_secret,omitempty"`
+	// Token
+	Token string `json:"token,omitempty"`
+	// 加密key
+	EncodingKey string `json:"encoding_key,omitempty"`
+	// 角色ID
+	AgentID uint64 `json:"agent_id,omitempty"`
+	// organization_id | 租户ID
+	OrganizationID uint64 `json:"organization_id,omitempty"`
+	selectValues   sql.SelectValues
+}
+
+// scanValues returns the types for scanning values from sql.Rows.
+func (*Xunji) scanValues(columns []string) ([]any, error) {
+	values := make([]any, len(columns))
+	for i := range columns {
+		switch columns[i] {
+		case xunji.FieldID, xunji.FieldStatus, xunji.FieldAgentID, xunji.FieldOrganizationID:
+			values[i] = new(sql.NullInt64)
+		case xunji.FieldAppKey, xunji.FieldAppSecret, xunji.FieldToken, xunji.FieldEncodingKey:
+			values[i] = new(sql.NullString)
+		case xunji.FieldCreatedAt, xunji.FieldUpdatedAt, xunji.FieldDeletedAt:
+			values[i] = new(sql.NullTime)
+		default:
+			values[i] = new(sql.UnknownType)
+		}
+	}
+	return values, nil
+}
+
+// assignValues assigns the values that were returned from sql.Rows (after scanning)
+// to the Xunji fields.
+func (x *Xunji) assignValues(columns []string, values []any) error {
+	if m, n := len(values), len(columns); m < n {
+		return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
+	}
+	for i := range columns {
+		switch columns[i] {
+		case xunji.FieldID:
+			value, ok := values[i].(*sql.NullInt64)
+			if !ok {
+				return fmt.Errorf("unexpected type %T for field id", value)
+			}
+			x.ID = uint64(value.Int64)
+		case xunji.FieldCreatedAt:
+			if value, ok := values[i].(*sql.NullTime); !ok {
+				return fmt.Errorf("unexpected type %T for field created_at", values[i])
+			} else if value.Valid {
+				x.CreatedAt = value.Time
+			}
+		case xunji.FieldUpdatedAt:
+			if value, ok := values[i].(*sql.NullTime); !ok {
+				return fmt.Errorf("unexpected type %T for field updated_at", values[i])
+			} else if value.Valid {
+				x.UpdatedAt = value.Time
+			}
+		case xunji.FieldStatus:
+			if value, ok := values[i].(*sql.NullInt64); !ok {
+				return fmt.Errorf("unexpected type %T for field status", values[i])
+			} else if value.Valid {
+				x.Status = uint8(value.Int64)
+			}
+		case xunji.FieldDeletedAt:
+			if value, ok := values[i].(*sql.NullTime); !ok {
+				return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
+			} else if value.Valid {
+				x.DeletedAt = value.Time
+			}
+		case xunji.FieldAppKey:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field app_key", values[i])
+			} else if value.Valid {
+				x.AppKey = value.String
+			}
+		case xunji.FieldAppSecret:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field app_secret", values[i])
+			} else if value.Valid {
+				x.AppSecret = value.String
+			}
+		case xunji.FieldToken:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field token", values[i])
+			} else if value.Valid {
+				x.Token = value.String
+			}
+		case xunji.FieldEncodingKey:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field encoding_key", values[i])
+			} else if value.Valid {
+				x.EncodingKey = value.String
+			}
+		case xunji.FieldAgentID:
+			if value, ok := values[i].(*sql.NullInt64); !ok {
+				return fmt.Errorf("unexpected type %T for field agent_id", values[i])
+			} else if value.Valid {
+				x.AgentID = uint64(value.Int64)
+			}
+		case xunji.FieldOrganizationID:
+			if value, ok := values[i].(*sql.NullInt64); !ok {
+				return fmt.Errorf("unexpected type %T for field organization_id", values[i])
+			} else if value.Valid {
+				x.OrganizationID = uint64(value.Int64)
+			}
+		default:
+			x.selectValues.Set(columns[i], values[i])
+		}
+	}
+	return nil
+}
+
+// Value returns the ent.Value that was dynamically selected and assigned to the Xunji.
+// This includes values selected through modifiers, order, etc.
+func (x *Xunji) Value(name string) (ent.Value, error) {
+	return x.selectValues.Get(name)
+}
+
+// Update returns a builder for updating this Xunji.
+// Note that you need to call Xunji.Unwrap() before calling this method if this Xunji
+// was returned from a transaction, and the transaction was committed or rolled back.
+func (x *Xunji) Update() *XunjiUpdateOne {
+	return NewXunjiClient(x.config).UpdateOne(x)
+}
+
+// Unwrap unwraps the Xunji entity that was returned from a transaction after it was closed,
+// so that all future queries will be executed through the driver which created the transaction.
+func (x *Xunji) Unwrap() *Xunji {
+	_tx, ok := x.config.driver.(*txDriver)
+	if !ok {
+		panic("ent: Xunji is not a transactional entity")
+	}
+	x.config.driver = _tx.drv
+	return x
+}
+
+// String implements the fmt.Stringer.
+func (x *Xunji) String() string {
+	var builder strings.Builder
+	builder.WriteString("Xunji(")
+	builder.WriteString(fmt.Sprintf("id=%v, ", x.ID))
+	builder.WriteString("created_at=")
+	builder.WriteString(x.CreatedAt.Format(time.ANSIC))
+	builder.WriteString(", ")
+	builder.WriteString("updated_at=")
+	builder.WriteString(x.UpdatedAt.Format(time.ANSIC))
+	builder.WriteString(", ")
+	builder.WriteString("status=")
+	builder.WriteString(fmt.Sprintf("%v", x.Status))
+	builder.WriteString(", ")
+	builder.WriteString("deleted_at=")
+	builder.WriteString(x.DeletedAt.Format(time.ANSIC))
+	builder.WriteString(", ")
+	builder.WriteString("app_key=")
+	builder.WriteString(x.AppKey)
+	builder.WriteString(", ")
+	builder.WriteString("app_secret=")
+	builder.WriteString(x.AppSecret)
+	builder.WriteString(", ")
+	builder.WriteString("token=")
+	builder.WriteString(x.Token)
+	builder.WriteString(", ")
+	builder.WriteString("encoding_key=")
+	builder.WriteString(x.EncodingKey)
+	builder.WriteString(", ")
+	builder.WriteString("agent_id=")
+	builder.WriteString(fmt.Sprintf("%v", x.AgentID))
+	builder.WriteString(", ")
+	builder.WriteString("organization_id=")
+	builder.WriteString(fmt.Sprintf("%v", x.OrganizationID))
+	builder.WriteByte(')')
+	return builder.String()
+}
+
+// Xunjis is a parsable slice of Xunji.
+type Xunjis []*Xunji

+ 640 - 0
ent/xunji/where.go

@@ -0,0 +1,640 @@
+// Code generated by ent, DO NOT EDIT.
+
+package xunji
+
+import (
+	"time"
+	"wechat-api/ent/predicate"
+
+	"entgo.io/ent/dialect/sql"
+)
+
+// ID filters vertices based on their ID field.
+func ID(id uint64) predicate.Xunji {
+	return predicate.Xunji(sql.FieldEQ(FieldID, id))
+}
+
+// IDEQ applies the EQ predicate on the ID field.
+func IDEQ(id uint64) predicate.Xunji {
+	return predicate.Xunji(sql.FieldEQ(FieldID, id))
+}
+
+// IDNEQ applies the NEQ predicate on the ID field.
+func IDNEQ(id uint64) predicate.Xunji {
+	return predicate.Xunji(sql.FieldNEQ(FieldID, id))
+}
+
+// IDIn applies the In predicate on the ID field.
+func IDIn(ids ...uint64) predicate.Xunji {
+	return predicate.Xunji(sql.FieldIn(FieldID, ids...))
+}
+
+// IDNotIn applies the NotIn predicate on the ID field.
+func IDNotIn(ids ...uint64) predicate.Xunji {
+	return predicate.Xunji(sql.FieldNotIn(FieldID, ids...))
+}
+
+// IDGT applies the GT predicate on the ID field.
+func IDGT(id uint64) predicate.Xunji {
+	return predicate.Xunji(sql.FieldGT(FieldID, id))
+}
+
+// IDGTE applies the GTE predicate on the ID field.
+func IDGTE(id uint64) predicate.Xunji {
+	return predicate.Xunji(sql.FieldGTE(FieldID, id))
+}
+
+// IDLT applies the LT predicate on the ID field.
+func IDLT(id uint64) predicate.Xunji {
+	return predicate.Xunji(sql.FieldLT(FieldID, id))
+}
+
+// IDLTE applies the LTE predicate on the ID field.
+func IDLTE(id uint64) predicate.Xunji {
+	return predicate.Xunji(sql.FieldLTE(FieldID, id))
+}
+
+// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
+func CreatedAt(v time.Time) predicate.Xunji {
+	return predicate.Xunji(sql.FieldEQ(FieldCreatedAt, v))
+}
+
+// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
+func UpdatedAt(v time.Time) predicate.Xunji {
+	return predicate.Xunji(sql.FieldEQ(FieldUpdatedAt, v))
+}
+
+// Status applies equality check predicate on the "status" field. It's identical to StatusEQ.
+func Status(v uint8) predicate.Xunji {
+	return predicate.Xunji(sql.FieldEQ(FieldStatus, v))
+}
+
+// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ.
+func DeletedAt(v time.Time) predicate.Xunji {
+	return predicate.Xunji(sql.FieldEQ(FieldDeletedAt, v))
+}
+
+// AppKey applies equality check predicate on the "app_key" field. It's identical to AppKeyEQ.
+func AppKey(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldEQ(FieldAppKey, v))
+}
+
+// AppSecret applies equality check predicate on the "app_secret" field. It's identical to AppSecretEQ.
+func AppSecret(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldEQ(FieldAppSecret, v))
+}
+
+// Token applies equality check predicate on the "token" field. It's identical to TokenEQ.
+func Token(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldEQ(FieldToken, v))
+}
+
+// EncodingKey applies equality check predicate on the "encoding_key" field. It's identical to EncodingKeyEQ.
+func EncodingKey(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldEQ(FieldEncodingKey, v))
+}
+
+// AgentID applies equality check predicate on the "agent_id" field. It's identical to AgentIDEQ.
+func AgentID(v uint64) predicate.Xunji {
+	return predicate.Xunji(sql.FieldEQ(FieldAgentID, v))
+}
+
+// OrganizationID applies equality check predicate on the "organization_id" field. It's identical to OrganizationIDEQ.
+func OrganizationID(v uint64) predicate.Xunji {
+	return predicate.Xunji(sql.FieldEQ(FieldOrganizationID, v))
+}
+
+// CreatedAtEQ applies the EQ predicate on the "created_at" field.
+func CreatedAtEQ(v time.Time) predicate.Xunji {
+	return predicate.Xunji(sql.FieldEQ(FieldCreatedAt, v))
+}
+
+// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
+func CreatedAtNEQ(v time.Time) predicate.Xunji {
+	return predicate.Xunji(sql.FieldNEQ(FieldCreatedAt, v))
+}
+
+// CreatedAtIn applies the In predicate on the "created_at" field.
+func CreatedAtIn(vs ...time.Time) predicate.Xunji {
+	return predicate.Xunji(sql.FieldIn(FieldCreatedAt, vs...))
+}
+
+// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
+func CreatedAtNotIn(vs ...time.Time) predicate.Xunji {
+	return predicate.Xunji(sql.FieldNotIn(FieldCreatedAt, vs...))
+}
+
+// CreatedAtGT applies the GT predicate on the "created_at" field.
+func CreatedAtGT(v time.Time) predicate.Xunji {
+	return predicate.Xunji(sql.FieldGT(FieldCreatedAt, v))
+}
+
+// CreatedAtGTE applies the GTE predicate on the "created_at" field.
+func CreatedAtGTE(v time.Time) predicate.Xunji {
+	return predicate.Xunji(sql.FieldGTE(FieldCreatedAt, v))
+}
+
+// CreatedAtLT applies the LT predicate on the "created_at" field.
+func CreatedAtLT(v time.Time) predicate.Xunji {
+	return predicate.Xunji(sql.FieldLT(FieldCreatedAt, v))
+}
+
+// CreatedAtLTE applies the LTE predicate on the "created_at" field.
+func CreatedAtLTE(v time.Time) predicate.Xunji {
+	return predicate.Xunji(sql.FieldLTE(FieldCreatedAt, v))
+}
+
+// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
+func UpdatedAtEQ(v time.Time) predicate.Xunji {
+	return predicate.Xunji(sql.FieldEQ(FieldUpdatedAt, v))
+}
+
+// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
+func UpdatedAtNEQ(v time.Time) predicate.Xunji {
+	return predicate.Xunji(sql.FieldNEQ(FieldUpdatedAt, v))
+}
+
+// UpdatedAtIn applies the In predicate on the "updated_at" field.
+func UpdatedAtIn(vs ...time.Time) predicate.Xunji {
+	return predicate.Xunji(sql.FieldIn(FieldUpdatedAt, vs...))
+}
+
+// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
+func UpdatedAtNotIn(vs ...time.Time) predicate.Xunji {
+	return predicate.Xunji(sql.FieldNotIn(FieldUpdatedAt, vs...))
+}
+
+// UpdatedAtGT applies the GT predicate on the "updated_at" field.
+func UpdatedAtGT(v time.Time) predicate.Xunji {
+	return predicate.Xunji(sql.FieldGT(FieldUpdatedAt, v))
+}
+
+// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
+func UpdatedAtGTE(v time.Time) predicate.Xunji {
+	return predicate.Xunji(sql.FieldGTE(FieldUpdatedAt, v))
+}
+
+// UpdatedAtLT applies the LT predicate on the "updated_at" field.
+func UpdatedAtLT(v time.Time) predicate.Xunji {
+	return predicate.Xunji(sql.FieldLT(FieldUpdatedAt, v))
+}
+
+// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
+func UpdatedAtLTE(v time.Time) predicate.Xunji {
+	return predicate.Xunji(sql.FieldLTE(FieldUpdatedAt, v))
+}
+
+// StatusEQ applies the EQ predicate on the "status" field.
+func StatusEQ(v uint8) predicate.Xunji {
+	return predicate.Xunji(sql.FieldEQ(FieldStatus, v))
+}
+
+// StatusNEQ applies the NEQ predicate on the "status" field.
+func StatusNEQ(v uint8) predicate.Xunji {
+	return predicate.Xunji(sql.FieldNEQ(FieldStatus, v))
+}
+
+// StatusIn applies the In predicate on the "status" field.
+func StatusIn(vs ...uint8) predicate.Xunji {
+	return predicate.Xunji(sql.FieldIn(FieldStatus, vs...))
+}
+
+// StatusNotIn applies the NotIn predicate on the "status" field.
+func StatusNotIn(vs ...uint8) predicate.Xunji {
+	return predicate.Xunji(sql.FieldNotIn(FieldStatus, vs...))
+}
+
+// StatusGT applies the GT predicate on the "status" field.
+func StatusGT(v uint8) predicate.Xunji {
+	return predicate.Xunji(sql.FieldGT(FieldStatus, v))
+}
+
+// StatusGTE applies the GTE predicate on the "status" field.
+func StatusGTE(v uint8) predicate.Xunji {
+	return predicate.Xunji(sql.FieldGTE(FieldStatus, v))
+}
+
+// StatusLT applies the LT predicate on the "status" field.
+func StatusLT(v uint8) predicate.Xunji {
+	return predicate.Xunji(sql.FieldLT(FieldStatus, v))
+}
+
+// StatusLTE applies the LTE predicate on the "status" field.
+func StatusLTE(v uint8) predicate.Xunji {
+	return predicate.Xunji(sql.FieldLTE(FieldStatus, v))
+}
+
+// StatusIsNil applies the IsNil predicate on the "status" field.
+func StatusIsNil() predicate.Xunji {
+	return predicate.Xunji(sql.FieldIsNull(FieldStatus))
+}
+
+// StatusNotNil applies the NotNil predicate on the "status" field.
+func StatusNotNil() predicate.Xunji {
+	return predicate.Xunji(sql.FieldNotNull(FieldStatus))
+}
+
+// DeletedAtEQ applies the EQ predicate on the "deleted_at" field.
+func DeletedAtEQ(v time.Time) predicate.Xunji {
+	return predicate.Xunji(sql.FieldEQ(FieldDeletedAt, v))
+}
+
+// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field.
+func DeletedAtNEQ(v time.Time) predicate.Xunji {
+	return predicate.Xunji(sql.FieldNEQ(FieldDeletedAt, v))
+}
+
+// DeletedAtIn applies the In predicate on the "deleted_at" field.
+func DeletedAtIn(vs ...time.Time) predicate.Xunji {
+	return predicate.Xunji(sql.FieldIn(FieldDeletedAt, vs...))
+}
+
+// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field.
+func DeletedAtNotIn(vs ...time.Time) predicate.Xunji {
+	return predicate.Xunji(sql.FieldNotIn(FieldDeletedAt, vs...))
+}
+
+// DeletedAtGT applies the GT predicate on the "deleted_at" field.
+func DeletedAtGT(v time.Time) predicate.Xunji {
+	return predicate.Xunji(sql.FieldGT(FieldDeletedAt, v))
+}
+
+// DeletedAtGTE applies the GTE predicate on the "deleted_at" field.
+func DeletedAtGTE(v time.Time) predicate.Xunji {
+	return predicate.Xunji(sql.FieldGTE(FieldDeletedAt, v))
+}
+
+// DeletedAtLT applies the LT predicate on the "deleted_at" field.
+func DeletedAtLT(v time.Time) predicate.Xunji {
+	return predicate.Xunji(sql.FieldLT(FieldDeletedAt, v))
+}
+
+// DeletedAtLTE applies the LTE predicate on the "deleted_at" field.
+func DeletedAtLTE(v time.Time) predicate.Xunji {
+	return predicate.Xunji(sql.FieldLTE(FieldDeletedAt, v))
+}
+
+// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field.
+func DeletedAtIsNil() predicate.Xunji {
+	return predicate.Xunji(sql.FieldIsNull(FieldDeletedAt))
+}
+
+// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field.
+func DeletedAtNotNil() predicate.Xunji {
+	return predicate.Xunji(sql.FieldNotNull(FieldDeletedAt))
+}
+
+// AppKeyEQ applies the EQ predicate on the "app_key" field.
+func AppKeyEQ(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldEQ(FieldAppKey, v))
+}
+
+// AppKeyNEQ applies the NEQ predicate on the "app_key" field.
+func AppKeyNEQ(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldNEQ(FieldAppKey, v))
+}
+
+// AppKeyIn applies the In predicate on the "app_key" field.
+func AppKeyIn(vs ...string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldIn(FieldAppKey, vs...))
+}
+
+// AppKeyNotIn applies the NotIn predicate on the "app_key" field.
+func AppKeyNotIn(vs ...string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldNotIn(FieldAppKey, vs...))
+}
+
+// AppKeyGT applies the GT predicate on the "app_key" field.
+func AppKeyGT(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldGT(FieldAppKey, v))
+}
+
+// AppKeyGTE applies the GTE predicate on the "app_key" field.
+func AppKeyGTE(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldGTE(FieldAppKey, v))
+}
+
+// AppKeyLT applies the LT predicate on the "app_key" field.
+func AppKeyLT(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldLT(FieldAppKey, v))
+}
+
+// AppKeyLTE applies the LTE predicate on the "app_key" field.
+func AppKeyLTE(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldLTE(FieldAppKey, v))
+}
+
+// AppKeyContains applies the Contains predicate on the "app_key" field.
+func AppKeyContains(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldContains(FieldAppKey, v))
+}
+
+// AppKeyHasPrefix applies the HasPrefix predicate on the "app_key" field.
+func AppKeyHasPrefix(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldHasPrefix(FieldAppKey, v))
+}
+
+// AppKeyHasSuffix applies the HasSuffix predicate on the "app_key" field.
+func AppKeyHasSuffix(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldHasSuffix(FieldAppKey, v))
+}
+
+// AppKeyEqualFold applies the EqualFold predicate on the "app_key" field.
+func AppKeyEqualFold(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldEqualFold(FieldAppKey, v))
+}
+
+// AppKeyContainsFold applies the ContainsFold predicate on the "app_key" field.
+func AppKeyContainsFold(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldContainsFold(FieldAppKey, v))
+}
+
+// AppSecretEQ applies the EQ predicate on the "app_secret" field.
+func AppSecretEQ(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldEQ(FieldAppSecret, v))
+}
+
+// AppSecretNEQ applies the NEQ predicate on the "app_secret" field.
+func AppSecretNEQ(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldNEQ(FieldAppSecret, v))
+}
+
+// AppSecretIn applies the In predicate on the "app_secret" field.
+func AppSecretIn(vs ...string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldIn(FieldAppSecret, vs...))
+}
+
+// AppSecretNotIn applies the NotIn predicate on the "app_secret" field.
+func AppSecretNotIn(vs ...string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldNotIn(FieldAppSecret, vs...))
+}
+
+// AppSecretGT applies the GT predicate on the "app_secret" field.
+func AppSecretGT(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldGT(FieldAppSecret, v))
+}
+
+// AppSecretGTE applies the GTE predicate on the "app_secret" field.
+func AppSecretGTE(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldGTE(FieldAppSecret, v))
+}
+
+// AppSecretLT applies the LT predicate on the "app_secret" field.
+func AppSecretLT(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldLT(FieldAppSecret, v))
+}
+
+// AppSecretLTE applies the LTE predicate on the "app_secret" field.
+func AppSecretLTE(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldLTE(FieldAppSecret, v))
+}
+
+// AppSecretContains applies the Contains predicate on the "app_secret" field.
+func AppSecretContains(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldContains(FieldAppSecret, v))
+}
+
+// AppSecretHasPrefix applies the HasPrefix predicate on the "app_secret" field.
+func AppSecretHasPrefix(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldHasPrefix(FieldAppSecret, v))
+}
+
+// AppSecretHasSuffix applies the HasSuffix predicate on the "app_secret" field.
+func AppSecretHasSuffix(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldHasSuffix(FieldAppSecret, v))
+}
+
+// AppSecretEqualFold applies the EqualFold predicate on the "app_secret" field.
+func AppSecretEqualFold(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldEqualFold(FieldAppSecret, v))
+}
+
+// AppSecretContainsFold applies the ContainsFold predicate on the "app_secret" field.
+func AppSecretContainsFold(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldContainsFold(FieldAppSecret, v))
+}
+
+// TokenEQ applies the EQ predicate on the "token" field.
+func TokenEQ(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldEQ(FieldToken, v))
+}
+
+// TokenNEQ applies the NEQ predicate on the "token" field.
+func TokenNEQ(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldNEQ(FieldToken, v))
+}
+
+// TokenIn applies the In predicate on the "token" field.
+func TokenIn(vs ...string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldIn(FieldToken, vs...))
+}
+
+// TokenNotIn applies the NotIn predicate on the "token" field.
+func TokenNotIn(vs ...string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldNotIn(FieldToken, vs...))
+}
+
+// TokenGT applies the GT predicate on the "token" field.
+func TokenGT(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldGT(FieldToken, v))
+}
+
+// TokenGTE applies the GTE predicate on the "token" field.
+func TokenGTE(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldGTE(FieldToken, v))
+}
+
+// TokenLT applies the LT predicate on the "token" field.
+func TokenLT(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldLT(FieldToken, v))
+}
+
+// TokenLTE applies the LTE predicate on the "token" field.
+func TokenLTE(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldLTE(FieldToken, v))
+}
+
+// TokenContains applies the Contains predicate on the "token" field.
+func TokenContains(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldContains(FieldToken, v))
+}
+
+// TokenHasPrefix applies the HasPrefix predicate on the "token" field.
+func TokenHasPrefix(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldHasPrefix(FieldToken, v))
+}
+
+// TokenHasSuffix applies the HasSuffix predicate on the "token" field.
+func TokenHasSuffix(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldHasSuffix(FieldToken, v))
+}
+
+// TokenEqualFold applies the EqualFold predicate on the "token" field.
+func TokenEqualFold(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldEqualFold(FieldToken, v))
+}
+
+// TokenContainsFold applies the ContainsFold predicate on the "token" field.
+func TokenContainsFold(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldContainsFold(FieldToken, v))
+}
+
+// EncodingKeyEQ applies the EQ predicate on the "encoding_key" field.
+func EncodingKeyEQ(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldEQ(FieldEncodingKey, v))
+}
+
+// EncodingKeyNEQ applies the NEQ predicate on the "encoding_key" field.
+func EncodingKeyNEQ(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldNEQ(FieldEncodingKey, v))
+}
+
+// EncodingKeyIn applies the In predicate on the "encoding_key" field.
+func EncodingKeyIn(vs ...string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldIn(FieldEncodingKey, vs...))
+}
+
+// EncodingKeyNotIn applies the NotIn predicate on the "encoding_key" field.
+func EncodingKeyNotIn(vs ...string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldNotIn(FieldEncodingKey, vs...))
+}
+
+// EncodingKeyGT applies the GT predicate on the "encoding_key" field.
+func EncodingKeyGT(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldGT(FieldEncodingKey, v))
+}
+
+// EncodingKeyGTE applies the GTE predicate on the "encoding_key" field.
+func EncodingKeyGTE(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldGTE(FieldEncodingKey, v))
+}
+
+// EncodingKeyLT applies the LT predicate on the "encoding_key" field.
+func EncodingKeyLT(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldLT(FieldEncodingKey, v))
+}
+
+// EncodingKeyLTE applies the LTE predicate on the "encoding_key" field.
+func EncodingKeyLTE(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldLTE(FieldEncodingKey, v))
+}
+
+// EncodingKeyContains applies the Contains predicate on the "encoding_key" field.
+func EncodingKeyContains(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldContains(FieldEncodingKey, v))
+}
+
+// EncodingKeyHasPrefix applies the HasPrefix predicate on the "encoding_key" field.
+func EncodingKeyHasPrefix(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldHasPrefix(FieldEncodingKey, v))
+}
+
+// EncodingKeyHasSuffix applies the HasSuffix predicate on the "encoding_key" field.
+func EncodingKeyHasSuffix(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldHasSuffix(FieldEncodingKey, v))
+}
+
+// EncodingKeyEqualFold applies the EqualFold predicate on the "encoding_key" field.
+func EncodingKeyEqualFold(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldEqualFold(FieldEncodingKey, v))
+}
+
+// EncodingKeyContainsFold applies the ContainsFold predicate on the "encoding_key" field.
+func EncodingKeyContainsFold(v string) predicate.Xunji {
+	return predicate.Xunji(sql.FieldContainsFold(FieldEncodingKey, v))
+}
+
+// AgentIDEQ applies the EQ predicate on the "agent_id" field.
+func AgentIDEQ(v uint64) predicate.Xunji {
+	return predicate.Xunji(sql.FieldEQ(FieldAgentID, v))
+}
+
+// AgentIDNEQ applies the NEQ predicate on the "agent_id" field.
+func AgentIDNEQ(v uint64) predicate.Xunji {
+	return predicate.Xunji(sql.FieldNEQ(FieldAgentID, v))
+}
+
+// AgentIDIn applies the In predicate on the "agent_id" field.
+func AgentIDIn(vs ...uint64) predicate.Xunji {
+	return predicate.Xunji(sql.FieldIn(FieldAgentID, vs...))
+}
+
+// AgentIDNotIn applies the NotIn predicate on the "agent_id" field.
+func AgentIDNotIn(vs ...uint64) predicate.Xunji {
+	return predicate.Xunji(sql.FieldNotIn(FieldAgentID, vs...))
+}
+
+// AgentIDGT applies the GT predicate on the "agent_id" field.
+func AgentIDGT(v uint64) predicate.Xunji {
+	return predicate.Xunji(sql.FieldGT(FieldAgentID, v))
+}
+
+// AgentIDGTE applies the GTE predicate on the "agent_id" field.
+func AgentIDGTE(v uint64) predicate.Xunji {
+	return predicate.Xunji(sql.FieldGTE(FieldAgentID, v))
+}
+
+// AgentIDLT applies the LT predicate on the "agent_id" field.
+func AgentIDLT(v uint64) predicate.Xunji {
+	return predicate.Xunji(sql.FieldLT(FieldAgentID, v))
+}
+
+// AgentIDLTE applies the LTE predicate on the "agent_id" field.
+func AgentIDLTE(v uint64) predicate.Xunji {
+	return predicate.Xunji(sql.FieldLTE(FieldAgentID, v))
+}
+
+// OrganizationIDEQ applies the EQ predicate on the "organization_id" field.
+func OrganizationIDEQ(v uint64) predicate.Xunji {
+	return predicate.Xunji(sql.FieldEQ(FieldOrganizationID, v))
+}
+
+// OrganizationIDNEQ applies the NEQ predicate on the "organization_id" field.
+func OrganizationIDNEQ(v uint64) predicate.Xunji {
+	return predicate.Xunji(sql.FieldNEQ(FieldOrganizationID, v))
+}
+
+// OrganizationIDIn applies the In predicate on the "organization_id" field.
+func OrganizationIDIn(vs ...uint64) predicate.Xunji {
+	return predicate.Xunji(sql.FieldIn(FieldOrganizationID, vs...))
+}
+
+// OrganizationIDNotIn applies the NotIn predicate on the "organization_id" field.
+func OrganizationIDNotIn(vs ...uint64) predicate.Xunji {
+	return predicate.Xunji(sql.FieldNotIn(FieldOrganizationID, vs...))
+}
+
+// OrganizationIDGT applies the GT predicate on the "organization_id" field.
+func OrganizationIDGT(v uint64) predicate.Xunji {
+	return predicate.Xunji(sql.FieldGT(FieldOrganizationID, v))
+}
+
+// OrganizationIDGTE applies the GTE predicate on the "organization_id" field.
+func OrganizationIDGTE(v uint64) predicate.Xunji {
+	return predicate.Xunji(sql.FieldGTE(FieldOrganizationID, v))
+}
+
+// OrganizationIDLT applies the LT predicate on the "organization_id" field.
+func OrganizationIDLT(v uint64) predicate.Xunji {
+	return predicate.Xunji(sql.FieldLT(FieldOrganizationID, v))
+}
+
+// OrganizationIDLTE applies the LTE predicate on the "organization_id" field.
+func OrganizationIDLTE(v uint64) predicate.Xunji {
+	return predicate.Xunji(sql.FieldLTE(FieldOrganizationID, v))
+}
+
+// And groups predicates with the AND operator between them.
+func And(predicates ...predicate.Xunji) predicate.Xunji {
+	return predicate.Xunji(sql.AndPredicates(predicates...))
+}
+
+// Or groups predicates with the OR operator between them.
+func Or(predicates ...predicate.Xunji) predicate.Xunji {
+	return predicate.Xunji(sql.OrPredicates(predicates...))
+}
+
+// Not applies the not operator on the given predicate.
+func Not(p predicate.Xunji) predicate.Xunji {
+	return predicate.Xunji(sql.NotPredicates(p))
+}

+ 142 - 0
ent/xunji/xunji.go

@@ -0,0 +1,142 @@
+// Code generated by ent, DO NOT EDIT.
+
+package xunji
+
+import (
+	"time"
+
+	"entgo.io/ent"
+	"entgo.io/ent/dialect/sql"
+)
+
+const (
+	// Label holds the string label denoting the xunji type in the database.
+	Label = "xunji"
+	// FieldID holds the string denoting the id field in the database.
+	FieldID = "id"
+	// FieldCreatedAt holds the string denoting the created_at field in the database.
+	FieldCreatedAt = "created_at"
+	// FieldUpdatedAt holds the string denoting the updated_at field in the database.
+	FieldUpdatedAt = "updated_at"
+	// FieldStatus holds the string denoting the status field in the database.
+	FieldStatus = "status"
+	// FieldDeletedAt holds the string denoting the deleted_at field in the database.
+	FieldDeletedAt = "deleted_at"
+	// FieldAppKey holds the string denoting the app_key field in the database.
+	FieldAppKey = "app_key"
+	// FieldAppSecret holds the string denoting the app_secret field in the database.
+	FieldAppSecret = "app_secret"
+	// FieldToken holds the string denoting the token field in the database.
+	FieldToken = "token"
+	// FieldEncodingKey holds the string denoting the encoding_key field in the database.
+	FieldEncodingKey = "encoding_key"
+	// FieldAgentID holds the string denoting the agent_id field in the database.
+	FieldAgentID = "agent_id"
+	// FieldOrganizationID holds the string denoting the organization_id field in the database.
+	FieldOrganizationID = "organization_id"
+	// Table holds the table name of the xunji in the database.
+	Table = "xunji"
+)
+
+// Columns holds all SQL columns for xunji fields.
+var Columns = []string{
+	FieldID,
+	FieldCreatedAt,
+	FieldUpdatedAt,
+	FieldStatus,
+	FieldDeletedAt,
+	FieldAppKey,
+	FieldAppSecret,
+	FieldToken,
+	FieldEncodingKey,
+	FieldAgentID,
+	FieldOrganizationID,
+}
+
+// ValidColumn reports if the column name is valid (part of the table columns).
+func ValidColumn(column string) bool {
+	for i := range Columns {
+		if column == Columns[i] {
+			return true
+		}
+	}
+	return false
+}
+
+// Note that the variables below are initialized by the runtime
+// package on the initialization of the application. Therefore,
+// it should be imported in the main as follows:
+//
+//	import _ "wechat-api/ent/runtime"
+var (
+	Hooks        [1]ent.Hook
+	Interceptors [1]ent.Interceptor
+	// DefaultCreatedAt holds the default value on creation for the "created_at" field.
+	DefaultCreatedAt func() time.Time
+	// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
+	DefaultUpdatedAt func() time.Time
+	// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
+	UpdateDefaultUpdatedAt func() time.Time
+	// DefaultStatus holds the default value on creation for the "status" field.
+	DefaultStatus uint8
+	// OrganizationIDValidator is a validator for the "organization_id" field. It is called by the builders before save.
+	OrganizationIDValidator func(uint64) error
+)
+
+// OrderOption defines the ordering options for the Xunji queries.
+type OrderOption func(*sql.Selector)
+
+// ByID orders the results by the id field.
+func ByID(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldID, opts...).ToFunc()
+}
+
+// ByCreatedAt orders the results by the created_at field.
+func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
+}
+
+// ByUpdatedAt orders the results by the updated_at field.
+func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
+}
+
+// ByStatus orders the results by the status field.
+func ByStatus(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldStatus, opts...).ToFunc()
+}
+
+// ByDeletedAt orders the results by the deleted_at field.
+func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldDeletedAt, opts...).ToFunc()
+}
+
+// ByAppKey orders the results by the app_key field.
+func ByAppKey(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldAppKey, opts...).ToFunc()
+}
+
+// ByAppSecret orders the results by the app_secret field.
+func ByAppSecret(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldAppSecret, opts...).ToFunc()
+}
+
+// ByToken orders the results by the token field.
+func ByToken(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldToken, opts...).ToFunc()
+}
+
+// ByEncodingKey orders the results by the encoding_key field.
+func ByEncodingKey(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldEncodingKey, opts...).ToFunc()
+}
+
+// ByAgentID orders the results by the agent_id field.
+func ByAgentID(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldAgentID, opts...).ToFunc()
+}
+
+// ByOrganizationID orders the results by the organization_id field.
+func ByOrganizationID(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldOrganizationID, opts...).ToFunc()
+}

+ 1086 - 0
ent/xunji_create.go

@@ -0,0 +1,1086 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+	"context"
+	"errors"
+	"fmt"
+	"time"
+	"wechat-api/ent/xunji"
+
+	"entgo.io/ent/dialect/sql"
+	"entgo.io/ent/dialect/sql/sqlgraph"
+	"entgo.io/ent/schema/field"
+)
+
+// XunjiCreate is the builder for creating a Xunji entity.
+type XunjiCreate struct {
+	config
+	mutation *XunjiMutation
+	hooks    []Hook
+	conflict []sql.ConflictOption
+}
+
+// SetCreatedAt sets the "created_at" field.
+func (xc *XunjiCreate) SetCreatedAt(t time.Time) *XunjiCreate {
+	xc.mutation.SetCreatedAt(t)
+	return xc
+}
+
+// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
+func (xc *XunjiCreate) SetNillableCreatedAt(t *time.Time) *XunjiCreate {
+	if t != nil {
+		xc.SetCreatedAt(*t)
+	}
+	return xc
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (xc *XunjiCreate) SetUpdatedAt(t time.Time) *XunjiCreate {
+	xc.mutation.SetUpdatedAt(t)
+	return xc
+}
+
+// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
+func (xc *XunjiCreate) SetNillableUpdatedAt(t *time.Time) *XunjiCreate {
+	if t != nil {
+		xc.SetUpdatedAt(*t)
+	}
+	return xc
+}
+
+// SetStatus sets the "status" field.
+func (xc *XunjiCreate) SetStatus(u uint8) *XunjiCreate {
+	xc.mutation.SetStatus(u)
+	return xc
+}
+
+// SetNillableStatus sets the "status" field if the given value is not nil.
+func (xc *XunjiCreate) SetNillableStatus(u *uint8) *XunjiCreate {
+	if u != nil {
+		xc.SetStatus(*u)
+	}
+	return xc
+}
+
+// SetDeletedAt sets the "deleted_at" field.
+func (xc *XunjiCreate) SetDeletedAt(t time.Time) *XunjiCreate {
+	xc.mutation.SetDeletedAt(t)
+	return xc
+}
+
+// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
+func (xc *XunjiCreate) SetNillableDeletedAt(t *time.Time) *XunjiCreate {
+	if t != nil {
+		xc.SetDeletedAt(*t)
+	}
+	return xc
+}
+
+// SetAppKey sets the "app_key" field.
+func (xc *XunjiCreate) SetAppKey(s string) *XunjiCreate {
+	xc.mutation.SetAppKey(s)
+	return xc
+}
+
+// SetAppSecret sets the "app_secret" field.
+func (xc *XunjiCreate) SetAppSecret(s string) *XunjiCreate {
+	xc.mutation.SetAppSecret(s)
+	return xc
+}
+
+// SetToken sets the "token" field.
+func (xc *XunjiCreate) SetToken(s string) *XunjiCreate {
+	xc.mutation.SetToken(s)
+	return xc
+}
+
+// SetEncodingKey sets the "encoding_key" field.
+func (xc *XunjiCreate) SetEncodingKey(s string) *XunjiCreate {
+	xc.mutation.SetEncodingKey(s)
+	return xc
+}
+
+// SetAgentID sets the "agent_id" field.
+func (xc *XunjiCreate) SetAgentID(u uint64) *XunjiCreate {
+	xc.mutation.SetAgentID(u)
+	return xc
+}
+
+// SetOrganizationID sets the "organization_id" field.
+func (xc *XunjiCreate) SetOrganizationID(u uint64) *XunjiCreate {
+	xc.mutation.SetOrganizationID(u)
+	return xc
+}
+
+// SetID sets the "id" field.
+func (xc *XunjiCreate) SetID(u uint64) *XunjiCreate {
+	xc.mutation.SetID(u)
+	return xc
+}
+
+// Mutation returns the XunjiMutation object of the builder.
+func (xc *XunjiCreate) Mutation() *XunjiMutation {
+	return xc.mutation
+}
+
+// Save creates the Xunji in the database.
+func (xc *XunjiCreate) Save(ctx context.Context) (*Xunji, error) {
+	if err := xc.defaults(); err != nil {
+		return nil, err
+	}
+	return withHooks(ctx, xc.sqlSave, xc.mutation, xc.hooks)
+}
+
+// SaveX calls Save and panics if Save returns an error.
+func (xc *XunjiCreate) SaveX(ctx context.Context) *Xunji {
+	v, err := xc.Save(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return v
+}
+
+// Exec executes the query.
+func (xc *XunjiCreate) Exec(ctx context.Context) error {
+	_, err := xc.Save(ctx)
+	return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (xc *XunjiCreate) ExecX(ctx context.Context) {
+	if err := xc.Exec(ctx); err != nil {
+		panic(err)
+	}
+}
+
+// defaults sets the default values of the builder before save.
+func (xc *XunjiCreate) defaults() error {
+	if _, ok := xc.mutation.CreatedAt(); !ok {
+		if xunji.DefaultCreatedAt == nil {
+			return fmt.Errorf("ent: uninitialized xunji.DefaultCreatedAt (forgotten import ent/runtime?)")
+		}
+		v := xunji.DefaultCreatedAt()
+		xc.mutation.SetCreatedAt(v)
+	}
+	if _, ok := xc.mutation.UpdatedAt(); !ok {
+		if xunji.DefaultUpdatedAt == nil {
+			return fmt.Errorf("ent: uninitialized xunji.DefaultUpdatedAt (forgotten import ent/runtime?)")
+		}
+		v := xunji.DefaultUpdatedAt()
+		xc.mutation.SetUpdatedAt(v)
+	}
+	if _, ok := xc.mutation.Status(); !ok {
+		v := xunji.DefaultStatus
+		xc.mutation.SetStatus(v)
+	}
+	return nil
+}
+
+// check runs all checks and user-defined validators on the builder.
+func (xc *XunjiCreate) check() error {
+	if _, ok := xc.mutation.CreatedAt(); !ok {
+		return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "Xunji.created_at"`)}
+	}
+	if _, ok := xc.mutation.UpdatedAt(); !ok {
+		return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Xunji.updated_at"`)}
+	}
+	if _, ok := xc.mutation.AppKey(); !ok {
+		return &ValidationError{Name: "app_key", err: errors.New(`ent: missing required field "Xunji.app_key"`)}
+	}
+	if _, ok := xc.mutation.AppSecret(); !ok {
+		return &ValidationError{Name: "app_secret", err: errors.New(`ent: missing required field "Xunji.app_secret"`)}
+	}
+	if _, ok := xc.mutation.Token(); !ok {
+		return &ValidationError{Name: "token", err: errors.New(`ent: missing required field "Xunji.token"`)}
+	}
+	if _, ok := xc.mutation.EncodingKey(); !ok {
+		return &ValidationError{Name: "encoding_key", err: errors.New(`ent: missing required field "Xunji.encoding_key"`)}
+	}
+	if _, ok := xc.mutation.AgentID(); !ok {
+		return &ValidationError{Name: "agent_id", err: errors.New(`ent: missing required field "Xunji.agent_id"`)}
+	}
+	if _, ok := xc.mutation.OrganizationID(); !ok {
+		return &ValidationError{Name: "organization_id", err: errors.New(`ent: missing required field "Xunji.organization_id"`)}
+	}
+	if v, ok := xc.mutation.OrganizationID(); ok {
+		if err := xunji.OrganizationIDValidator(v); err != nil {
+			return &ValidationError{Name: "organization_id", err: fmt.Errorf(`ent: validator failed for field "Xunji.organization_id": %w`, err)}
+		}
+	}
+	return nil
+}
+
+func (xc *XunjiCreate) sqlSave(ctx context.Context) (*Xunji, error) {
+	if err := xc.check(); err != nil {
+		return nil, err
+	}
+	_node, _spec := xc.createSpec()
+	if err := sqlgraph.CreateNode(ctx, xc.driver, _spec); err != nil {
+		if sqlgraph.IsConstraintError(err) {
+			err = &ConstraintError{msg: err.Error(), wrap: err}
+		}
+		return nil, err
+	}
+	if _spec.ID.Value != _node.ID {
+		id := _spec.ID.Value.(int64)
+		_node.ID = uint64(id)
+	}
+	xc.mutation.id = &_node.ID
+	xc.mutation.done = true
+	return _node, nil
+}
+
+func (xc *XunjiCreate) createSpec() (*Xunji, *sqlgraph.CreateSpec) {
+	var (
+		_node = &Xunji{config: xc.config}
+		_spec = sqlgraph.NewCreateSpec(xunji.Table, sqlgraph.NewFieldSpec(xunji.FieldID, field.TypeUint64))
+	)
+	_spec.OnConflict = xc.conflict
+	if id, ok := xc.mutation.ID(); ok {
+		_node.ID = id
+		_spec.ID.Value = id
+	}
+	if value, ok := xc.mutation.CreatedAt(); ok {
+		_spec.SetField(xunji.FieldCreatedAt, field.TypeTime, value)
+		_node.CreatedAt = value
+	}
+	if value, ok := xc.mutation.UpdatedAt(); ok {
+		_spec.SetField(xunji.FieldUpdatedAt, field.TypeTime, value)
+		_node.UpdatedAt = value
+	}
+	if value, ok := xc.mutation.Status(); ok {
+		_spec.SetField(xunji.FieldStatus, field.TypeUint8, value)
+		_node.Status = value
+	}
+	if value, ok := xc.mutation.DeletedAt(); ok {
+		_spec.SetField(xunji.FieldDeletedAt, field.TypeTime, value)
+		_node.DeletedAt = value
+	}
+	if value, ok := xc.mutation.AppKey(); ok {
+		_spec.SetField(xunji.FieldAppKey, field.TypeString, value)
+		_node.AppKey = value
+	}
+	if value, ok := xc.mutation.AppSecret(); ok {
+		_spec.SetField(xunji.FieldAppSecret, field.TypeString, value)
+		_node.AppSecret = value
+	}
+	if value, ok := xc.mutation.Token(); ok {
+		_spec.SetField(xunji.FieldToken, field.TypeString, value)
+		_node.Token = value
+	}
+	if value, ok := xc.mutation.EncodingKey(); ok {
+		_spec.SetField(xunji.FieldEncodingKey, field.TypeString, value)
+		_node.EncodingKey = value
+	}
+	if value, ok := xc.mutation.AgentID(); ok {
+		_spec.SetField(xunji.FieldAgentID, field.TypeUint64, value)
+		_node.AgentID = value
+	}
+	if value, ok := xc.mutation.OrganizationID(); ok {
+		_spec.SetField(xunji.FieldOrganizationID, field.TypeUint64, value)
+		_node.OrganizationID = value
+	}
+	return _node, _spec
+}
+
+// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
+// of the `INSERT` statement. For example:
+//
+//	client.Xunji.Create().
+//		SetCreatedAt(v).
+//		OnConflict(
+//			// Update the row with the new values
+//			// the was proposed for insertion.
+//			sql.ResolveWithNewValues(),
+//		).
+//		// Override some of the fields with custom
+//		// update values.
+//		Update(func(u *ent.XunjiUpsert) {
+//			SetCreatedAt(v+v).
+//		}).
+//		Exec(ctx)
+func (xc *XunjiCreate) OnConflict(opts ...sql.ConflictOption) *XunjiUpsertOne {
+	xc.conflict = opts
+	return &XunjiUpsertOne{
+		create: xc,
+	}
+}
+
+// OnConflictColumns calls `OnConflict` and configures the columns
+// as conflict target. Using this option is equivalent to using:
+//
+//	client.Xunji.Create().
+//		OnConflict(sql.ConflictColumns(columns...)).
+//		Exec(ctx)
+func (xc *XunjiCreate) OnConflictColumns(columns ...string) *XunjiUpsertOne {
+	xc.conflict = append(xc.conflict, sql.ConflictColumns(columns...))
+	return &XunjiUpsertOne{
+		create: xc,
+	}
+}
+
+type (
+	// XunjiUpsertOne is the builder for "upsert"-ing
+	//  one Xunji node.
+	XunjiUpsertOne struct {
+		create *XunjiCreate
+	}
+
+	// XunjiUpsert is the "OnConflict" setter.
+	XunjiUpsert struct {
+		*sql.UpdateSet
+	}
+)
+
+// SetUpdatedAt sets the "updated_at" field.
+func (u *XunjiUpsert) SetUpdatedAt(v time.Time) *XunjiUpsert {
+	u.Set(xunji.FieldUpdatedAt, v)
+	return u
+}
+
+// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
+func (u *XunjiUpsert) UpdateUpdatedAt() *XunjiUpsert {
+	u.SetExcluded(xunji.FieldUpdatedAt)
+	return u
+}
+
+// SetStatus sets the "status" field.
+func (u *XunjiUpsert) SetStatus(v uint8) *XunjiUpsert {
+	u.Set(xunji.FieldStatus, v)
+	return u
+}
+
+// UpdateStatus sets the "status" field to the value that was provided on create.
+func (u *XunjiUpsert) UpdateStatus() *XunjiUpsert {
+	u.SetExcluded(xunji.FieldStatus)
+	return u
+}
+
+// AddStatus adds v to the "status" field.
+func (u *XunjiUpsert) AddStatus(v uint8) *XunjiUpsert {
+	u.Add(xunji.FieldStatus, v)
+	return u
+}
+
+// ClearStatus clears the value of the "status" field.
+func (u *XunjiUpsert) ClearStatus() *XunjiUpsert {
+	u.SetNull(xunji.FieldStatus)
+	return u
+}
+
+// SetDeletedAt sets the "deleted_at" field.
+func (u *XunjiUpsert) SetDeletedAt(v time.Time) *XunjiUpsert {
+	u.Set(xunji.FieldDeletedAt, v)
+	return u
+}
+
+// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
+func (u *XunjiUpsert) UpdateDeletedAt() *XunjiUpsert {
+	u.SetExcluded(xunji.FieldDeletedAt)
+	return u
+}
+
+// ClearDeletedAt clears the value of the "deleted_at" field.
+func (u *XunjiUpsert) ClearDeletedAt() *XunjiUpsert {
+	u.SetNull(xunji.FieldDeletedAt)
+	return u
+}
+
+// SetAppKey sets the "app_key" field.
+func (u *XunjiUpsert) SetAppKey(v string) *XunjiUpsert {
+	u.Set(xunji.FieldAppKey, v)
+	return u
+}
+
+// UpdateAppKey sets the "app_key" field to the value that was provided on create.
+func (u *XunjiUpsert) UpdateAppKey() *XunjiUpsert {
+	u.SetExcluded(xunji.FieldAppKey)
+	return u
+}
+
+// SetAppSecret sets the "app_secret" field.
+func (u *XunjiUpsert) SetAppSecret(v string) *XunjiUpsert {
+	u.Set(xunji.FieldAppSecret, v)
+	return u
+}
+
+// UpdateAppSecret sets the "app_secret" field to the value that was provided on create.
+func (u *XunjiUpsert) UpdateAppSecret() *XunjiUpsert {
+	u.SetExcluded(xunji.FieldAppSecret)
+	return u
+}
+
+// SetToken sets the "token" field.
+func (u *XunjiUpsert) SetToken(v string) *XunjiUpsert {
+	u.Set(xunji.FieldToken, v)
+	return u
+}
+
+// UpdateToken sets the "token" field to the value that was provided on create.
+func (u *XunjiUpsert) UpdateToken() *XunjiUpsert {
+	u.SetExcluded(xunji.FieldToken)
+	return u
+}
+
+// SetEncodingKey sets the "encoding_key" field.
+func (u *XunjiUpsert) SetEncodingKey(v string) *XunjiUpsert {
+	u.Set(xunji.FieldEncodingKey, v)
+	return u
+}
+
+// UpdateEncodingKey sets the "encoding_key" field to the value that was provided on create.
+func (u *XunjiUpsert) UpdateEncodingKey() *XunjiUpsert {
+	u.SetExcluded(xunji.FieldEncodingKey)
+	return u
+}
+
+// SetAgentID sets the "agent_id" field.
+func (u *XunjiUpsert) SetAgentID(v uint64) *XunjiUpsert {
+	u.Set(xunji.FieldAgentID, v)
+	return u
+}
+
+// UpdateAgentID sets the "agent_id" field to the value that was provided on create.
+func (u *XunjiUpsert) UpdateAgentID() *XunjiUpsert {
+	u.SetExcluded(xunji.FieldAgentID)
+	return u
+}
+
+// AddAgentID adds v to the "agent_id" field.
+func (u *XunjiUpsert) AddAgentID(v uint64) *XunjiUpsert {
+	u.Add(xunji.FieldAgentID, v)
+	return u
+}
+
+// SetOrganizationID sets the "organization_id" field.
+func (u *XunjiUpsert) SetOrganizationID(v uint64) *XunjiUpsert {
+	u.Set(xunji.FieldOrganizationID, v)
+	return u
+}
+
+// UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
+func (u *XunjiUpsert) UpdateOrganizationID() *XunjiUpsert {
+	u.SetExcluded(xunji.FieldOrganizationID)
+	return u
+}
+
+// AddOrganizationID adds v to the "organization_id" field.
+func (u *XunjiUpsert) AddOrganizationID(v uint64) *XunjiUpsert {
+	u.Add(xunji.FieldOrganizationID, v)
+	return u
+}
+
+// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
+// Using this option is equivalent to using:
+//
+//	client.Xunji.Create().
+//		OnConflict(
+//			sql.ResolveWithNewValues(),
+//			sql.ResolveWith(func(u *sql.UpdateSet) {
+//				u.SetIgnore(xunji.FieldID)
+//			}),
+//		).
+//		Exec(ctx)
+func (u *XunjiUpsertOne) UpdateNewValues() *XunjiUpsertOne {
+	u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
+	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
+		if _, exists := u.create.mutation.ID(); exists {
+			s.SetIgnore(xunji.FieldID)
+		}
+		if _, exists := u.create.mutation.CreatedAt(); exists {
+			s.SetIgnore(xunji.FieldCreatedAt)
+		}
+	}))
+	return u
+}
+
+// Ignore sets each column to itself in case of conflict.
+// Using this option is equivalent to using:
+//
+//	client.Xunji.Create().
+//	    OnConflict(sql.ResolveWithIgnore()).
+//	    Exec(ctx)
+func (u *XunjiUpsertOne) Ignore() *XunjiUpsertOne {
+	u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
+	return u
+}
+
+// DoNothing configures the conflict_action to `DO NOTHING`.
+// Supported only by SQLite and PostgreSQL.
+func (u *XunjiUpsertOne) DoNothing() *XunjiUpsertOne {
+	u.create.conflict = append(u.create.conflict, sql.DoNothing())
+	return u
+}
+
+// Update allows overriding fields `UPDATE` values. See the XunjiCreate.OnConflict
+// documentation for more info.
+func (u *XunjiUpsertOne) Update(set func(*XunjiUpsert)) *XunjiUpsertOne {
+	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
+		set(&XunjiUpsert{UpdateSet: update})
+	}))
+	return u
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (u *XunjiUpsertOne) SetUpdatedAt(v time.Time) *XunjiUpsertOne {
+	return u.Update(func(s *XunjiUpsert) {
+		s.SetUpdatedAt(v)
+	})
+}
+
+// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
+func (u *XunjiUpsertOne) UpdateUpdatedAt() *XunjiUpsertOne {
+	return u.Update(func(s *XunjiUpsert) {
+		s.UpdateUpdatedAt()
+	})
+}
+
+// SetStatus sets the "status" field.
+func (u *XunjiUpsertOne) SetStatus(v uint8) *XunjiUpsertOne {
+	return u.Update(func(s *XunjiUpsert) {
+		s.SetStatus(v)
+	})
+}
+
+// AddStatus adds v to the "status" field.
+func (u *XunjiUpsertOne) AddStatus(v uint8) *XunjiUpsertOne {
+	return u.Update(func(s *XunjiUpsert) {
+		s.AddStatus(v)
+	})
+}
+
+// UpdateStatus sets the "status" field to the value that was provided on create.
+func (u *XunjiUpsertOne) UpdateStatus() *XunjiUpsertOne {
+	return u.Update(func(s *XunjiUpsert) {
+		s.UpdateStatus()
+	})
+}
+
+// ClearStatus clears the value of the "status" field.
+func (u *XunjiUpsertOne) ClearStatus() *XunjiUpsertOne {
+	return u.Update(func(s *XunjiUpsert) {
+		s.ClearStatus()
+	})
+}
+
+// SetDeletedAt sets the "deleted_at" field.
+func (u *XunjiUpsertOne) SetDeletedAt(v time.Time) *XunjiUpsertOne {
+	return u.Update(func(s *XunjiUpsert) {
+		s.SetDeletedAt(v)
+	})
+}
+
+// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
+func (u *XunjiUpsertOne) UpdateDeletedAt() *XunjiUpsertOne {
+	return u.Update(func(s *XunjiUpsert) {
+		s.UpdateDeletedAt()
+	})
+}
+
+// ClearDeletedAt clears the value of the "deleted_at" field.
+func (u *XunjiUpsertOne) ClearDeletedAt() *XunjiUpsertOne {
+	return u.Update(func(s *XunjiUpsert) {
+		s.ClearDeletedAt()
+	})
+}
+
+// SetAppKey sets the "app_key" field.
+func (u *XunjiUpsertOne) SetAppKey(v string) *XunjiUpsertOne {
+	return u.Update(func(s *XunjiUpsert) {
+		s.SetAppKey(v)
+	})
+}
+
+// UpdateAppKey sets the "app_key" field to the value that was provided on create.
+func (u *XunjiUpsertOne) UpdateAppKey() *XunjiUpsertOne {
+	return u.Update(func(s *XunjiUpsert) {
+		s.UpdateAppKey()
+	})
+}
+
+// SetAppSecret sets the "app_secret" field.
+func (u *XunjiUpsertOne) SetAppSecret(v string) *XunjiUpsertOne {
+	return u.Update(func(s *XunjiUpsert) {
+		s.SetAppSecret(v)
+	})
+}
+
+// UpdateAppSecret sets the "app_secret" field to the value that was provided on create.
+func (u *XunjiUpsertOne) UpdateAppSecret() *XunjiUpsertOne {
+	return u.Update(func(s *XunjiUpsert) {
+		s.UpdateAppSecret()
+	})
+}
+
+// SetToken sets the "token" field.
+func (u *XunjiUpsertOne) SetToken(v string) *XunjiUpsertOne {
+	return u.Update(func(s *XunjiUpsert) {
+		s.SetToken(v)
+	})
+}
+
+// UpdateToken sets the "token" field to the value that was provided on create.
+func (u *XunjiUpsertOne) UpdateToken() *XunjiUpsertOne {
+	return u.Update(func(s *XunjiUpsert) {
+		s.UpdateToken()
+	})
+}
+
+// SetEncodingKey sets the "encoding_key" field.
+func (u *XunjiUpsertOne) SetEncodingKey(v string) *XunjiUpsertOne {
+	return u.Update(func(s *XunjiUpsert) {
+		s.SetEncodingKey(v)
+	})
+}
+
+// UpdateEncodingKey sets the "encoding_key" field to the value that was provided on create.
+func (u *XunjiUpsertOne) UpdateEncodingKey() *XunjiUpsertOne {
+	return u.Update(func(s *XunjiUpsert) {
+		s.UpdateEncodingKey()
+	})
+}
+
+// SetAgentID sets the "agent_id" field.
+func (u *XunjiUpsertOne) SetAgentID(v uint64) *XunjiUpsertOne {
+	return u.Update(func(s *XunjiUpsert) {
+		s.SetAgentID(v)
+	})
+}
+
+// AddAgentID adds v to the "agent_id" field.
+func (u *XunjiUpsertOne) AddAgentID(v uint64) *XunjiUpsertOne {
+	return u.Update(func(s *XunjiUpsert) {
+		s.AddAgentID(v)
+	})
+}
+
+// UpdateAgentID sets the "agent_id" field to the value that was provided on create.
+func (u *XunjiUpsertOne) UpdateAgentID() *XunjiUpsertOne {
+	return u.Update(func(s *XunjiUpsert) {
+		s.UpdateAgentID()
+	})
+}
+
+// SetOrganizationID sets the "organization_id" field.
+func (u *XunjiUpsertOne) SetOrganizationID(v uint64) *XunjiUpsertOne {
+	return u.Update(func(s *XunjiUpsert) {
+		s.SetOrganizationID(v)
+	})
+}
+
+// AddOrganizationID adds v to the "organization_id" field.
+func (u *XunjiUpsertOne) AddOrganizationID(v uint64) *XunjiUpsertOne {
+	return u.Update(func(s *XunjiUpsert) {
+		s.AddOrganizationID(v)
+	})
+}
+
+// UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
+func (u *XunjiUpsertOne) UpdateOrganizationID() *XunjiUpsertOne {
+	return u.Update(func(s *XunjiUpsert) {
+		s.UpdateOrganizationID()
+	})
+}
+
+// Exec executes the query.
+func (u *XunjiUpsertOne) Exec(ctx context.Context) error {
+	if len(u.create.conflict) == 0 {
+		return errors.New("ent: missing options for XunjiCreate.OnConflict")
+	}
+	return u.create.Exec(ctx)
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (u *XunjiUpsertOne) ExecX(ctx context.Context) {
+	if err := u.create.Exec(ctx); err != nil {
+		panic(err)
+	}
+}
+
+// Exec executes the UPSERT query and returns the inserted/updated ID.
+func (u *XunjiUpsertOne) ID(ctx context.Context) (id uint64, err error) {
+	node, err := u.create.Save(ctx)
+	if err != nil {
+		return id, err
+	}
+	return node.ID, nil
+}
+
+// IDX is like ID, but panics if an error occurs.
+func (u *XunjiUpsertOne) IDX(ctx context.Context) uint64 {
+	id, err := u.ID(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return id
+}
+
+// XunjiCreateBulk is the builder for creating many Xunji entities in bulk.
+type XunjiCreateBulk struct {
+	config
+	err      error
+	builders []*XunjiCreate
+	conflict []sql.ConflictOption
+}
+
+// Save creates the Xunji entities in the database.
+func (xcb *XunjiCreateBulk) Save(ctx context.Context) ([]*Xunji, error) {
+	if xcb.err != nil {
+		return nil, xcb.err
+	}
+	specs := make([]*sqlgraph.CreateSpec, len(xcb.builders))
+	nodes := make([]*Xunji, len(xcb.builders))
+	mutators := make([]Mutator, len(xcb.builders))
+	for i := range xcb.builders {
+		func(i int, root context.Context) {
+			builder := xcb.builders[i]
+			builder.defaults()
+			var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
+				mutation, ok := m.(*XunjiMutation)
+				if !ok {
+					return nil, fmt.Errorf("unexpected mutation type %T", m)
+				}
+				if err := builder.check(); err != nil {
+					return nil, err
+				}
+				builder.mutation = mutation
+				var err error
+				nodes[i], specs[i] = builder.createSpec()
+				if i < len(mutators)-1 {
+					_, err = mutators[i+1].Mutate(root, xcb.builders[i+1].mutation)
+				} else {
+					spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
+					spec.OnConflict = xcb.conflict
+					// Invoke the actual operation on the latest mutation in the chain.
+					if err = sqlgraph.BatchCreate(ctx, xcb.driver, spec); err != nil {
+						if sqlgraph.IsConstraintError(err) {
+							err = &ConstraintError{msg: err.Error(), wrap: err}
+						}
+					}
+				}
+				if err != nil {
+					return nil, err
+				}
+				mutation.id = &nodes[i].ID
+				if specs[i].ID.Value != nil && nodes[i].ID == 0 {
+					id := specs[i].ID.Value.(int64)
+					nodes[i].ID = uint64(id)
+				}
+				mutation.done = true
+				return nodes[i], nil
+			})
+			for i := len(builder.hooks) - 1; i >= 0; i-- {
+				mut = builder.hooks[i](mut)
+			}
+			mutators[i] = mut
+		}(i, ctx)
+	}
+	if len(mutators) > 0 {
+		if _, err := mutators[0].Mutate(ctx, xcb.builders[0].mutation); err != nil {
+			return nil, err
+		}
+	}
+	return nodes, nil
+}
+
+// SaveX is like Save, but panics if an error occurs.
+func (xcb *XunjiCreateBulk) SaveX(ctx context.Context) []*Xunji {
+	v, err := xcb.Save(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return v
+}
+
+// Exec executes the query.
+func (xcb *XunjiCreateBulk) Exec(ctx context.Context) error {
+	_, err := xcb.Save(ctx)
+	return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (xcb *XunjiCreateBulk) ExecX(ctx context.Context) {
+	if err := xcb.Exec(ctx); err != nil {
+		panic(err)
+	}
+}
+
+// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
+// of the `INSERT` statement. For example:
+//
+//	client.Xunji.CreateBulk(builders...).
+//		OnConflict(
+//			// Update the row with the new values
+//			// the was proposed for insertion.
+//			sql.ResolveWithNewValues(),
+//		).
+//		// Override some of the fields with custom
+//		// update values.
+//		Update(func(u *ent.XunjiUpsert) {
+//			SetCreatedAt(v+v).
+//		}).
+//		Exec(ctx)
+func (xcb *XunjiCreateBulk) OnConflict(opts ...sql.ConflictOption) *XunjiUpsertBulk {
+	xcb.conflict = opts
+	return &XunjiUpsertBulk{
+		create: xcb,
+	}
+}
+
+// OnConflictColumns calls `OnConflict` and configures the columns
+// as conflict target. Using this option is equivalent to using:
+//
+//	client.Xunji.Create().
+//		OnConflict(sql.ConflictColumns(columns...)).
+//		Exec(ctx)
+func (xcb *XunjiCreateBulk) OnConflictColumns(columns ...string) *XunjiUpsertBulk {
+	xcb.conflict = append(xcb.conflict, sql.ConflictColumns(columns...))
+	return &XunjiUpsertBulk{
+		create: xcb,
+	}
+}
+
+// XunjiUpsertBulk is the builder for "upsert"-ing
+// a bulk of Xunji nodes.
+type XunjiUpsertBulk struct {
+	create *XunjiCreateBulk
+}
+
+// UpdateNewValues updates the mutable fields using the new values that
+// were set on create. Using this option is equivalent to using:
+//
+//	client.Xunji.Create().
+//		OnConflict(
+//			sql.ResolveWithNewValues(),
+//			sql.ResolveWith(func(u *sql.UpdateSet) {
+//				u.SetIgnore(xunji.FieldID)
+//			}),
+//		).
+//		Exec(ctx)
+func (u *XunjiUpsertBulk) UpdateNewValues() *XunjiUpsertBulk {
+	u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
+	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
+		for _, b := range u.create.builders {
+			if _, exists := b.mutation.ID(); exists {
+				s.SetIgnore(xunji.FieldID)
+			}
+			if _, exists := b.mutation.CreatedAt(); exists {
+				s.SetIgnore(xunji.FieldCreatedAt)
+			}
+		}
+	}))
+	return u
+}
+
+// Ignore sets each column to itself in case of conflict.
+// Using this option is equivalent to using:
+//
+//	client.Xunji.Create().
+//		OnConflict(sql.ResolveWithIgnore()).
+//		Exec(ctx)
+func (u *XunjiUpsertBulk) Ignore() *XunjiUpsertBulk {
+	u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
+	return u
+}
+
+// DoNothing configures the conflict_action to `DO NOTHING`.
+// Supported only by SQLite and PostgreSQL.
+func (u *XunjiUpsertBulk) DoNothing() *XunjiUpsertBulk {
+	u.create.conflict = append(u.create.conflict, sql.DoNothing())
+	return u
+}
+
+// Update allows overriding fields `UPDATE` values. See the XunjiCreateBulk.OnConflict
+// documentation for more info.
+func (u *XunjiUpsertBulk) Update(set func(*XunjiUpsert)) *XunjiUpsertBulk {
+	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
+		set(&XunjiUpsert{UpdateSet: update})
+	}))
+	return u
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (u *XunjiUpsertBulk) SetUpdatedAt(v time.Time) *XunjiUpsertBulk {
+	return u.Update(func(s *XunjiUpsert) {
+		s.SetUpdatedAt(v)
+	})
+}
+
+// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
+func (u *XunjiUpsertBulk) UpdateUpdatedAt() *XunjiUpsertBulk {
+	return u.Update(func(s *XunjiUpsert) {
+		s.UpdateUpdatedAt()
+	})
+}
+
+// SetStatus sets the "status" field.
+func (u *XunjiUpsertBulk) SetStatus(v uint8) *XunjiUpsertBulk {
+	return u.Update(func(s *XunjiUpsert) {
+		s.SetStatus(v)
+	})
+}
+
+// AddStatus adds v to the "status" field.
+func (u *XunjiUpsertBulk) AddStatus(v uint8) *XunjiUpsertBulk {
+	return u.Update(func(s *XunjiUpsert) {
+		s.AddStatus(v)
+	})
+}
+
+// UpdateStatus sets the "status" field to the value that was provided on create.
+func (u *XunjiUpsertBulk) UpdateStatus() *XunjiUpsertBulk {
+	return u.Update(func(s *XunjiUpsert) {
+		s.UpdateStatus()
+	})
+}
+
+// ClearStatus clears the value of the "status" field.
+func (u *XunjiUpsertBulk) ClearStatus() *XunjiUpsertBulk {
+	return u.Update(func(s *XunjiUpsert) {
+		s.ClearStatus()
+	})
+}
+
+// SetDeletedAt sets the "deleted_at" field.
+func (u *XunjiUpsertBulk) SetDeletedAt(v time.Time) *XunjiUpsertBulk {
+	return u.Update(func(s *XunjiUpsert) {
+		s.SetDeletedAt(v)
+	})
+}
+
+// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
+func (u *XunjiUpsertBulk) UpdateDeletedAt() *XunjiUpsertBulk {
+	return u.Update(func(s *XunjiUpsert) {
+		s.UpdateDeletedAt()
+	})
+}
+
+// ClearDeletedAt clears the value of the "deleted_at" field.
+func (u *XunjiUpsertBulk) ClearDeletedAt() *XunjiUpsertBulk {
+	return u.Update(func(s *XunjiUpsert) {
+		s.ClearDeletedAt()
+	})
+}
+
+// SetAppKey sets the "app_key" field.
+func (u *XunjiUpsertBulk) SetAppKey(v string) *XunjiUpsertBulk {
+	return u.Update(func(s *XunjiUpsert) {
+		s.SetAppKey(v)
+	})
+}
+
+// UpdateAppKey sets the "app_key" field to the value that was provided on create.
+func (u *XunjiUpsertBulk) UpdateAppKey() *XunjiUpsertBulk {
+	return u.Update(func(s *XunjiUpsert) {
+		s.UpdateAppKey()
+	})
+}
+
+// SetAppSecret sets the "app_secret" field.
+func (u *XunjiUpsertBulk) SetAppSecret(v string) *XunjiUpsertBulk {
+	return u.Update(func(s *XunjiUpsert) {
+		s.SetAppSecret(v)
+	})
+}
+
+// UpdateAppSecret sets the "app_secret" field to the value that was provided on create.
+func (u *XunjiUpsertBulk) UpdateAppSecret() *XunjiUpsertBulk {
+	return u.Update(func(s *XunjiUpsert) {
+		s.UpdateAppSecret()
+	})
+}
+
+// SetToken sets the "token" field.
+func (u *XunjiUpsertBulk) SetToken(v string) *XunjiUpsertBulk {
+	return u.Update(func(s *XunjiUpsert) {
+		s.SetToken(v)
+	})
+}
+
+// UpdateToken sets the "token" field to the value that was provided on create.
+func (u *XunjiUpsertBulk) UpdateToken() *XunjiUpsertBulk {
+	return u.Update(func(s *XunjiUpsert) {
+		s.UpdateToken()
+	})
+}
+
+// SetEncodingKey sets the "encoding_key" field.
+func (u *XunjiUpsertBulk) SetEncodingKey(v string) *XunjiUpsertBulk {
+	return u.Update(func(s *XunjiUpsert) {
+		s.SetEncodingKey(v)
+	})
+}
+
+// UpdateEncodingKey sets the "encoding_key" field to the value that was provided on create.
+func (u *XunjiUpsertBulk) UpdateEncodingKey() *XunjiUpsertBulk {
+	return u.Update(func(s *XunjiUpsert) {
+		s.UpdateEncodingKey()
+	})
+}
+
+// SetAgentID sets the "agent_id" field.
+func (u *XunjiUpsertBulk) SetAgentID(v uint64) *XunjiUpsertBulk {
+	return u.Update(func(s *XunjiUpsert) {
+		s.SetAgentID(v)
+	})
+}
+
+// AddAgentID adds v to the "agent_id" field.
+func (u *XunjiUpsertBulk) AddAgentID(v uint64) *XunjiUpsertBulk {
+	return u.Update(func(s *XunjiUpsert) {
+		s.AddAgentID(v)
+	})
+}
+
+// UpdateAgentID sets the "agent_id" field to the value that was provided on create.
+func (u *XunjiUpsertBulk) UpdateAgentID() *XunjiUpsertBulk {
+	return u.Update(func(s *XunjiUpsert) {
+		s.UpdateAgentID()
+	})
+}
+
+// SetOrganizationID sets the "organization_id" field.
+func (u *XunjiUpsertBulk) SetOrganizationID(v uint64) *XunjiUpsertBulk {
+	return u.Update(func(s *XunjiUpsert) {
+		s.SetOrganizationID(v)
+	})
+}
+
+// AddOrganizationID adds v to the "organization_id" field.
+func (u *XunjiUpsertBulk) AddOrganizationID(v uint64) *XunjiUpsertBulk {
+	return u.Update(func(s *XunjiUpsert) {
+		s.AddOrganizationID(v)
+	})
+}
+
+// UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
+func (u *XunjiUpsertBulk) UpdateOrganizationID() *XunjiUpsertBulk {
+	return u.Update(func(s *XunjiUpsert) {
+		s.UpdateOrganizationID()
+	})
+}
+
+// Exec executes the query.
+func (u *XunjiUpsertBulk) Exec(ctx context.Context) error {
+	if u.create.err != nil {
+		return u.create.err
+	}
+	for i, b := range u.create.builders {
+		if len(b.conflict) != 0 {
+			return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the XunjiCreateBulk instead", i)
+		}
+	}
+	if len(u.create.conflict) == 0 {
+		return errors.New("ent: missing options for XunjiCreateBulk.OnConflict")
+	}
+	return u.create.Exec(ctx)
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (u *XunjiUpsertBulk) ExecX(ctx context.Context) {
+	if err := u.create.Exec(ctx); err != nil {
+		panic(err)
+	}
+}

+ 88 - 0
ent/xunji_delete.go

@@ -0,0 +1,88 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+	"context"
+	"wechat-api/ent/predicate"
+	"wechat-api/ent/xunji"
+
+	"entgo.io/ent/dialect/sql"
+	"entgo.io/ent/dialect/sql/sqlgraph"
+	"entgo.io/ent/schema/field"
+)
+
+// XunjiDelete is the builder for deleting a Xunji entity.
+type XunjiDelete struct {
+	config
+	hooks    []Hook
+	mutation *XunjiMutation
+}
+
+// Where appends a list predicates to the XunjiDelete builder.
+func (xd *XunjiDelete) Where(ps ...predicate.Xunji) *XunjiDelete {
+	xd.mutation.Where(ps...)
+	return xd
+}
+
+// Exec executes the deletion query and returns how many vertices were deleted.
+func (xd *XunjiDelete) Exec(ctx context.Context) (int, error) {
+	return withHooks(ctx, xd.sqlExec, xd.mutation, xd.hooks)
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (xd *XunjiDelete) ExecX(ctx context.Context) int {
+	n, err := xd.Exec(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return n
+}
+
+func (xd *XunjiDelete) sqlExec(ctx context.Context) (int, error) {
+	_spec := sqlgraph.NewDeleteSpec(xunji.Table, sqlgraph.NewFieldSpec(xunji.FieldID, field.TypeUint64))
+	if ps := xd.mutation.predicates; len(ps) > 0 {
+		_spec.Predicate = func(selector *sql.Selector) {
+			for i := range ps {
+				ps[i](selector)
+			}
+		}
+	}
+	affected, err := sqlgraph.DeleteNodes(ctx, xd.driver, _spec)
+	if err != nil && sqlgraph.IsConstraintError(err) {
+		err = &ConstraintError{msg: err.Error(), wrap: err}
+	}
+	xd.mutation.done = true
+	return affected, err
+}
+
+// XunjiDeleteOne is the builder for deleting a single Xunji entity.
+type XunjiDeleteOne struct {
+	xd *XunjiDelete
+}
+
+// Where appends a list predicates to the XunjiDelete builder.
+func (xdo *XunjiDeleteOne) Where(ps ...predicate.Xunji) *XunjiDeleteOne {
+	xdo.xd.mutation.Where(ps...)
+	return xdo
+}
+
+// Exec executes the deletion query.
+func (xdo *XunjiDeleteOne) Exec(ctx context.Context) error {
+	n, err := xdo.xd.Exec(ctx)
+	switch {
+	case err != nil:
+		return err
+	case n == 0:
+		return &NotFoundError{xunji.Label}
+	default:
+		return nil
+	}
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (xdo *XunjiDeleteOne) ExecX(ctx context.Context) {
+	if err := xdo.Exec(ctx); err != nil {
+		panic(err)
+	}
+}

+ 526 - 0
ent/xunji_query.go

@@ -0,0 +1,526 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+	"context"
+	"fmt"
+	"math"
+	"wechat-api/ent/predicate"
+	"wechat-api/ent/xunji"
+
+	"entgo.io/ent/dialect/sql"
+	"entgo.io/ent/dialect/sql/sqlgraph"
+	"entgo.io/ent/schema/field"
+)
+
+// XunjiQuery is the builder for querying Xunji entities.
+type XunjiQuery struct {
+	config
+	ctx        *QueryContext
+	order      []xunji.OrderOption
+	inters     []Interceptor
+	predicates []predicate.Xunji
+	// intermediate query (i.e. traversal path).
+	sql  *sql.Selector
+	path func(context.Context) (*sql.Selector, error)
+}
+
+// Where adds a new predicate for the XunjiQuery builder.
+func (xq *XunjiQuery) Where(ps ...predicate.Xunji) *XunjiQuery {
+	xq.predicates = append(xq.predicates, ps...)
+	return xq
+}
+
+// Limit the number of records to be returned by this query.
+func (xq *XunjiQuery) Limit(limit int) *XunjiQuery {
+	xq.ctx.Limit = &limit
+	return xq
+}
+
+// Offset to start from.
+func (xq *XunjiQuery) Offset(offset int) *XunjiQuery {
+	xq.ctx.Offset = &offset
+	return xq
+}
+
+// Unique configures the query builder to filter duplicate records on query.
+// By default, unique is set to true, and can be disabled using this method.
+func (xq *XunjiQuery) Unique(unique bool) *XunjiQuery {
+	xq.ctx.Unique = &unique
+	return xq
+}
+
+// Order specifies how the records should be ordered.
+func (xq *XunjiQuery) Order(o ...xunji.OrderOption) *XunjiQuery {
+	xq.order = append(xq.order, o...)
+	return xq
+}
+
+// First returns the first Xunji entity from the query.
+// Returns a *NotFoundError when no Xunji was found.
+func (xq *XunjiQuery) First(ctx context.Context) (*Xunji, error) {
+	nodes, err := xq.Limit(1).All(setContextOp(ctx, xq.ctx, "First"))
+	if err != nil {
+		return nil, err
+	}
+	if len(nodes) == 0 {
+		return nil, &NotFoundError{xunji.Label}
+	}
+	return nodes[0], nil
+}
+
+// FirstX is like First, but panics if an error occurs.
+func (xq *XunjiQuery) FirstX(ctx context.Context) *Xunji {
+	node, err := xq.First(ctx)
+	if err != nil && !IsNotFound(err) {
+		panic(err)
+	}
+	return node
+}
+
+// FirstID returns the first Xunji ID from the query.
+// Returns a *NotFoundError when no Xunji ID was found.
+func (xq *XunjiQuery) FirstID(ctx context.Context) (id uint64, err error) {
+	var ids []uint64
+	if ids, err = xq.Limit(1).IDs(setContextOp(ctx, xq.ctx, "FirstID")); err != nil {
+		return
+	}
+	if len(ids) == 0 {
+		err = &NotFoundError{xunji.Label}
+		return
+	}
+	return ids[0], nil
+}
+
+// FirstIDX is like FirstID, but panics if an error occurs.
+func (xq *XunjiQuery) FirstIDX(ctx context.Context) uint64 {
+	id, err := xq.FirstID(ctx)
+	if err != nil && !IsNotFound(err) {
+		panic(err)
+	}
+	return id
+}
+
+// Only returns a single Xunji entity found by the query, ensuring it only returns one.
+// Returns a *NotSingularError when more than one Xunji entity is found.
+// Returns a *NotFoundError when no Xunji entities are found.
+func (xq *XunjiQuery) Only(ctx context.Context) (*Xunji, error) {
+	nodes, err := xq.Limit(2).All(setContextOp(ctx, xq.ctx, "Only"))
+	if err != nil {
+		return nil, err
+	}
+	switch len(nodes) {
+	case 1:
+		return nodes[0], nil
+	case 0:
+		return nil, &NotFoundError{xunji.Label}
+	default:
+		return nil, &NotSingularError{xunji.Label}
+	}
+}
+
+// OnlyX is like Only, but panics if an error occurs.
+func (xq *XunjiQuery) OnlyX(ctx context.Context) *Xunji {
+	node, err := xq.Only(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return node
+}
+
+// OnlyID is like Only, but returns the only Xunji ID in the query.
+// Returns a *NotSingularError when more than one Xunji ID is found.
+// Returns a *NotFoundError when no entities are found.
+func (xq *XunjiQuery) OnlyID(ctx context.Context) (id uint64, err error) {
+	var ids []uint64
+	if ids, err = xq.Limit(2).IDs(setContextOp(ctx, xq.ctx, "OnlyID")); err != nil {
+		return
+	}
+	switch len(ids) {
+	case 1:
+		id = ids[0]
+	case 0:
+		err = &NotFoundError{xunji.Label}
+	default:
+		err = &NotSingularError{xunji.Label}
+	}
+	return
+}
+
+// OnlyIDX is like OnlyID, but panics if an error occurs.
+func (xq *XunjiQuery) OnlyIDX(ctx context.Context) uint64 {
+	id, err := xq.OnlyID(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return id
+}
+
+// All executes the query and returns a list of Xunjis.
+func (xq *XunjiQuery) All(ctx context.Context) ([]*Xunji, error) {
+	ctx = setContextOp(ctx, xq.ctx, "All")
+	if err := xq.prepareQuery(ctx); err != nil {
+		return nil, err
+	}
+	qr := querierAll[[]*Xunji, *XunjiQuery]()
+	return withInterceptors[[]*Xunji](ctx, xq, qr, xq.inters)
+}
+
+// AllX is like All, but panics if an error occurs.
+func (xq *XunjiQuery) AllX(ctx context.Context) []*Xunji {
+	nodes, err := xq.All(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return nodes
+}
+
+// IDs executes the query and returns a list of Xunji IDs.
+func (xq *XunjiQuery) IDs(ctx context.Context) (ids []uint64, err error) {
+	if xq.ctx.Unique == nil && xq.path != nil {
+		xq.Unique(true)
+	}
+	ctx = setContextOp(ctx, xq.ctx, "IDs")
+	if err = xq.Select(xunji.FieldID).Scan(ctx, &ids); err != nil {
+		return nil, err
+	}
+	return ids, nil
+}
+
+// IDsX is like IDs, but panics if an error occurs.
+func (xq *XunjiQuery) IDsX(ctx context.Context) []uint64 {
+	ids, err := xq.IDs(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return ids
+}
+
+// Count returns the count of the given query.
+func (xq *XunjiQuery) Count(ctx context.Context) (int, error) {
+	ctx = setContextOp(ctx, xq.ctx, "Count")
+	if err := xq.prepareQuery(ctx); err != nil {
+		return 0, err
+	}
+	return withInterceptors[int](ctx, xq, querierCount[*XunjiQuery](), xq.inters)
+}
+
+// CountX is like Count, but panics if an error occurs.
+func (xq *XunjiQuery) CountX(ctx context.Context) int {
+	count, err := xq.Count(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return count
+}
+
+// Exist returns true if the query has elements in the graph.
+func (xq *XunjiQuery) Exist(ctx context.Context) (bool, error) {
+	ctx = setContextOp(ctx, xq.ctx, "Exist")
+	switch _, err := xq.FirstID(ctx); {
+	case IsNotFound(err):
+		return false, nil
+	case err != nil:
+		return false, fmt.Errorf("ent: check existence: %w", err)
+	default:
+		return true, nil
+	}
+}
+
+// ExistX is like Exist, but panics if an error occurs.
+func (xq *XunjiQuery) ExistX(ctx context.Context) bool {
+	exist, err := xq.Exist(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return exist
+}
+
+// Clone returns a duplicate of the XunjiQuery builder, including all associated steps. It can be
+// used to prepare common query builders and use them differently after the clone is made.
+func (xq *XunjiQuery) Clone() *XunjiQuery {
+	if xq == nil {
+		return nil
+	}
+	return &XunjiQuery{
+		config:     xq.config,
+		ctx:        xq.ctx.Clone(),
+		order:      append([]xunji.OrderOption{}, xq.order...),
+		inters:     append([]Interceptor{}, xq.inters...),
+		predicates: append([]predicate.Xunji{}, xq.predicates...),
+		// clone intermediate query.
+		sql:  xq.sql.Clone(),
+		path: xq.path,
+	}
+}
+
+// GroupBy is used to group vertices by one or more fields/columns.
+// It is often used with aggregate functions, like: count, max, mean, min, sum.
+//
+// Example:
+//
+//	var v []struct {
+//		CreatedAt time.Time `json:"created_at,omitempty"`
+//		Count int `json:"count,omitempty"`
+//	}
+//
+//	client.Xunji.Query().
+//		GroupBy(xunji.FieldCreatedAt).
+//		Aggregate(ent.Count()).
+//		Scan(ctx, &v)
+func (xq *XunjiQuery) GroupBy(field string, fields ...string) *XunjiGroupBy {
+	xq.ctx.Fields = append([]string{field}, fields...)
+	grbuild := &XunjiGroupBy{build: xq}
+	grbuild.flds = &xq.ctx.Fields
+	grbuild.label = xunji.Label
+	grbuild.scan = grbuild.Scan
+	return grbuild
+}
+
+// Select allows the selection one or more fields/columns for the given query,
+// instead of selecting all fields in the entity.
+//
+// Example:
+//
+//	var v []struct {
+//		CreatedAt time.Time `json:"created_at,omitempty"`
+//	}
+//
+//	client.Xunji.Query().
+//		Select(xunji.FieldCreatedAt).
+//		Scan(ctx, &v)
+func (xq *XunjiQuery) Select(fields ...string) *XunjiSelect {
+	xq.ctx.Fields = append(xq.ctx.Fields, fields...)
+	sbuild := &XunjiSelect{XunjiQuery: xq}
+	sbuild.label = xunji.Label
+	sbuild.flds, sbuild.scan = &xq.ctx.Fields, sbuild.Scan
+	return sbuild
+}
+
+// Aggregate returns a XunjiSelect configured with the given aggregations.
+func (xq *XunjiQuery) Aggregate(fns ...AggregateFunc) *XunjiSelect {
+	return xq.Select().Aggregate(fns...)
+}
+
+func (xq *XunjiQuery) prepareQuery(ctx context.Context) error {
+	for _, inter := range xq.inters {
+		if inter == nil {
+			return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
+		}
+		if trv, ok := inter.(Traverser); ok {
+			if err := trv.Traverse(ctx, xq); err != nil {
+				return err
+			}
+		}
+	}
+	for _, f := range xq.ctx.Fields {
+		if !xunji.ValidColumn(f) {
+			return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
+		}
+	}
+	if xq.path != nil {
+		prev, err := xq.path(ctx)
+		if err != nil {
+			return err
+		}
+		xq.sql = prev
+	}
+	return nil
+}
+
+func (xq *XunjiQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Xunji, error) {
+	var (
+		nodes = []*Xunji{}
+		_spec = xq.querySpec()
+	)
+	_spec.ScanValues = func(columns []string) ([]any, error) {
+		return (*Xunji).scanValues(nil, columns)
+	}
+	_spec.Assign = func(columns []string, values []any) error {
+		node := &Xunji{config: xq.config}
+		nodes = append(nodes, node)
+		return node.assignValues(columns, values)
+	}
+	for i := range hooks {
+		hooks[i](ctx, _spec)
+	}
+	if err := sqlgraph.QueryNodes(ctx, xq.driver, _spec); err != nil {
+		return nil, err
+	}
+	if len(nodes) == 0 {
+		return nodes, nil
+	}
+	return nodes, nil
+}
+
+func (xq *XunjiQuery) sqlCount(ctx context.Context) (int, error) {
+	_spec := xq.querySpec()
+	_spec.Node.Columns = xq.ctx.Fields
+	if len(xq.ctx.Fields) > 0 {
+		_spec.Unique = xq.ctx.Unique != nil && *xq.ctx.Unique
+	}
+	return sqlgraph.CountNodes(ctx, xq.driver, _spec)
+}
+
+func (xq *XunjiQuery) querySpec() *sqlgraph.QuerySpec {
+	_spec := sqlgraph.NewQuerySpec(xunji.Table, xunji.Columns, sqlgraph.NewFieldSpec(xunji.FieldID, field.TypeUint64))
+	_spec.From = xq.sql
+	if unique := xq.ctx.Unique; unique != nil {
+		_spec.Unique = *unique
+	} else if xq.path != nil {
+		_spec.Unique = true
+	}
+	if fields := xq.ctx.Fields; len(fields) > 0 {
+		_spec.Node.Columns = make([]string, 0, len(fields))
+		_spec.Node.Columns = append(_spec.Node.Columns, xunji.FieldID)
+		for i := range fields {
+			if fields[i] != xunji.FieldID {
+				_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
+			}
+		}
+	}
+	if ps := xq.predicates; len(ps) > 0 {
+		_spec.Predicate = func(selector *sql.Selector) {
+			for i := range ps {
+				ps[i](selector)
+			}
+		}
+	}
+	if limit := xq.ctx.Limit; limit != nil {
+		_spec.Limit = *limit
+	}
+	if offset := xq.ctx.Offset; offset != nil {
+		_spec.Offset = *offset
+	}
+	if ps := xq.order; len(ps) > 0 {
+		_spec.Order = func(selector *sql.Selector) {
+			for i := range ps {
+				ps[i](selector)
+			}
+		}
+	}
+	return _spec
+}
+
+func (xq *XunjiQuery) sqlQuery(ctx context.Context) *sql.Selector {
+	builder := sql.Dialect(xq.driver.Dialect())
+	t1 := builder.Table(xunji.Table)
+	columns := xq.ctx.Fields
+	if len(columns) == 0 {
+		columns = xunji.Columns
+	}
+	selector := builder.Select(t1.Columns(columns...)...).From(t1)
+	if xq.sql != nil {
+		selector = xq.sql
+		selector.Select(selector.Columns(columns...)...)
+	}
+	if xq.ctx.Unique != nil && *xq.ctx.Unique {
+		selector.Distinct()
+	}
+	for _, p := range xq.predicates {
+		p(selector)
+	}
+	for _, p := range xq.order {
+		p(selector)
+	}
+	if offset := xq.ctx.Offset; offset != nil {
+		// limit is mandatory for offset clause. We start
+		// with default value, and override it below if needed.
+		selector.Offset(*offset).Limit(math.MaxInt32)
+	}
+	if limit := xq.ctx.Limit; limit != nil {
+		selector.Limit(*limit)
+	}
+	return selector
+}
+
+// XunjiGroupBy is the group-by builder for Xunji entities.
+type XunjiGroupBy struct {
+	selector
+	build *XunjiQuery
+}
+
+// Aggregate adds the given aggregation functions to the group-by query.
+func (xgb *XunjiGroupBy) Aggregate(fns ...AggregateFunc) *XunjiGroupBy {
+	xgb.fns = append(xgb.fns, fns...)
+	return xgb
+}
+
+// Scan applies the selector query and scans the result into the given value.
+func (xgb *XunjiGroupBy) Scan(ctx context.Context, v any) error {
+	ctx = setContextOp(ctx, xgb.build.ctx, "GroupBy")
+	if err := xgb.build.prepareQuery(ctx); err != nil {
+		return err
+	}
+	return scanWithInterceptors[*XunjiQuery, *XunjiGroupBy](ctx, xgb.build, xgb, xgb.build.inters, v)
+}
+
+func (xgb *XunjiGroupBy) sqlScan(ctx context.Context, root *XunjiQuery, v any) error {
+	selector := root.sqlQuery(ctx).Select()
+	aggregation := make([]string, 0, len(xgb.fns))
+	for _, fn := range xgb.fns {
+		aggregation = append(aggregation, fn(selector))
+	}
+	if len(selector.SelectedColumns()) == 0 {
+		columns := make([]string, 0, len(*xgb.flds)+len(xgb.fns))
+		for _, f := range *xgb.flds {
+			columns = append(columns, selector.C(f))
+		}
+		columns = append(columns, aggregation...)
+		selector.Select(columns...)
+	}
+	selector.GroupBy(selector.Columns(*xgb.flds...)...)
+	if err := selector.Err(); err != nil {
+		return err
+	}
+	rows := &sql.Rows{}
+	query, args := selector.Query()
+	if err := xgb.build.driver.Query(ctx, query, args, rows); err != nil {
+		return err
+	}
+	defer rows.Close()
+	return sql.ScanSlice(rows, v)
+}
+
+// XunjiSelect is the builder for selecting fields of Xunji entities.
+type XunjiSelect struct {
+	*XunjiQuery
+	selector
+}
+
+// Aggregate adds the given aggregation functions to the selector query.
+func (xs *XunjiSelect) Aggregate(fns ...AggregateFunc) *XunjiSelect {
+	xs.fns = append(xs.fns, fns...)
+	return xs
+}
+
+// Scan applies the selector query and scans the result into the given value.
+func (xs *XunjiSelect) Scan(ctx context.Context, v any) error {
+	ctx = setContextOp(ctx, xs.ctx, "Select")
+	if err := xs.prepareQuery(ctx); err != nil {
+		return err
+	}
+	return scanWithInterceptors[*XunjiQuery, *XunjiSelect](ctx, xs.XunjiQuery, xs, xs.inters, v)
+}
+
+func (xs *XunjiSelect) sqlScan(ctx context.Context, root *XunjiQuery, v any) error {
+	selector := root.sqlQuery(ctx)
+	aggregation := make([]string, 0, len(xs.fns))
+	for _, fn := range xs.fns {
+		aggregation = append(aggregation, fn(selector))
+	}
+	switch n := len(*xs.selector.flds); {
+	case n == 0 && len(aggregation) > 0:
+		selector.Select(aggregation...)
+	case n != 0 && len(aggregation) > 0:
+		selector.AppendSelect(aggregation...)
+	}
+	rows := &sql.Rows{}
+	query, args := selector.Query()
+	if err := xs.driver.Query(ctx, query, args, rows); err != nil {
+		return err
+	}
+	defer rows.Close()
+	return sql.ScanSlice(rows, v)
+}

+ 618 - 0
ent/xunji_update.go

@@ -0,0 +1,618 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+	"context"
+	"errors"
+	"fmt"
+	"time"
+	"wechat-api/ent/predicate"
+	"wechat-api/ent/xunji"
+
+	"entgo.io/ent/dialect/sql"
+	"entgo.io/ent/dialect/sql/sqlgraph"
+	"entgo.io/ent/schema/field"
+)
+
+// XunjiUpdate is the builder for updating Xunji entities.
+type XunjiUpdate struct {
+	config
+	hooks    []Hook
+	mutation *XunjiMutation
+}
+
+// Where appends a list predicates to the XunjiUpdate builder.
+func (xu *XunjiUpdate) Where(ps ...predicate.Xunji) *XunjiUpdate {
+	xu.mutation.Where(ps...)
+	return xu
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (xu *XunjiUpdate) SetUpdatedAt(t time.Time) *XunjiUpdate {
+	xu.mutation.SetUpdatedAt(t)
+	return xu
+}
+
+// SetStatus sets the "status" field.
+func (xu *XunjiUpdate) SetStatus(u uint8) *XunjiUpdate {
+	xu.mutation.ResetStatus()
+	xu.mutation.SetStatus(u)
+	return xu
+}
+
+// SetNillableStatus sets the "status" field if the given value is not nil.
+func (xu *XunjiUpdate) SetNillableStatus(u *uint8) *XunjiUpdate {
+	if u != nil {
+		xu.SetStatus(*u)
+	}
+	return xu
+}
+
+// AddStatus adds u to the "status" field.
+func (xu *XunjiUpdate) AddStatus(u int8) *XunjiUpdate {
+	xu.mutation.AddStatus(u)
+	return xu
+}
+
+// ClearStatus clears the value of the "status" field.
+func (xu *XunjiUpdate) ClearStatus() *XunjiUpdate {
+	xu.mutation.ClearStatus()
+	return xu
+}
+
+// SetDeletedAt sets the "deleted_at" field.
+func (xu *XunjiUpdate) SetDeletedAt(t time.Time) *XunjiUpdate {
+	xu.mutation.SetDeletedAt(t)
+	return xu
+}
+
+// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
+func (xu *XunjiUpdate) SetNillableDeletedAt(t *time.Time) *XunjiUpdate {
+	if t != nil {
+		xu.SetDeletedAt(*t)
+	}
+	return xu
+}
+
+// ClearDeletedAt clears the value of the "deleted_at" field.
+func (xu *XunjiUpdate) ClearDeletedAt() *XunjiUpdate {
+	xu.mutation.ClearDeletedAt()
+	return xu
+}
+
+// SetAppKey sets the "app_key" field.
+func (xu *XunjiUpdate) SetAppKey(s string) *XunjiUpdate {
+	xu.mutation.SetAppKey(s)
+	return xu
+}
+
+// SetNillableAppKey sets the "app_key" field if the given value is not nil.
+func (xu *XunjiUpdate) SetNillableAppKey(s *string) *XunjiUpdate {
+	if s != nil {
+		xu.SetAppKey(*s)
+	}
+	return xu
+}
+
+// SetAppSecret sets the "app_secret" field.
+func (xu *XunjiUpdate) SetAppSecret(s string) *XunjiUpdate {
+	xu.mutation.SetAppSecret(s)
+	return xu
+}
+
+// SetNillableAppSecret sets the "app_secret" field if the given value is not nil.
+func (xu *XunjiUpdate) SetNillableAppSecret(s *string) *XunjiUpdate {
+	if s != nil {
+		xu.SetAppSecret(*s)
+	}
+	return xu
+}
+
+// SetToken sets the "token" field.
+func (xu *XunjiUpdate) SetToken(s string) *XunjiUpdate {
+	xu.mutation.SetToken(s)
+	return xu
+}
+
+// SetNillableToken sets the "token" field if the given value is not nil.
+func (xu *XunjiUpdate) SetNillableToken(s *string) *XunjiUpdate {
+	if s != nil {
+		xu.SetToken(*s)
+	}
+	return xu
+}
+
+// SetEncodingKey sets the "encoding_key" field.
+func (xu *XunjiUpdate) SetEncodingKey(s string) *XunjiUpdate {
+	xu.mutation.SetEncodingKey(s)
+	return xu
+}
+
+// SetNillableEncodingKey sets the "encoding_key" field if the given value is not nil.
+func (xu *XunjiUpdate) SetNillableEncodingKey(s *string) *XunjiUpdate {
+	if s != nil {
+		xu.SetEncodingKey(*s)
+	}
+	return xu
+}
+
+// SetAgentID sets the "agent_id" field.
+func (xu *XunjiUpdate) SetAgentID(u uint64) *XunjiUpdate {
+	xu.mutation.ResetAgentID()
+	xu.mutation.SetAgentID(u)
+	return xu
+}
+
+// SetNillableAgentID sets the "agent_id" field if the given value is not nil.
+func (xu *XunjiUpdate) SetNillableAgentID(u *uint64) *XunjiUpdate {
+	if u != nil {
+		xu.SetAgentID(*u)
+	}
+	return xu
+}
+
+// AddAgentID adds u to the "agent_id" field.
+func (xu *XunjiUpdate) AddAgentID(u int64) *XunjiUpdate {
+	xu.mutation.AddAgentID(u)
+	return xu
+}
+
+// SetOrganizationID sets the "organization_id" field.
+func (xu *XunjiUpdate) SetOrganizationID(u uint64) *XunjiUpdate {
+	xu.mutation.ResetOrganizationID()
+	xu.mutation.SetOrganizationID(u)
+	return xu
+}
+
+// SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
+func (xu *XunjiUpdate) SetNillableOrganizationID(u *uint64) *XunjiUpdate {
+	if u != nil {
+		xu.SetOrganizationID(*u)
+	}
+	return xu
+}
+
+// AddOrganizationID adds u to the "organization_id" field.
+func (xu *XunjiUpdate) AddOrganizationID(u int64) *XunjiUpdate {
+	xu.mutation.AddOrganizationID(u)
+	return xu
+}
+
+// Mutation returns the XunjiMutation object of the builder.
+func (xu *XunjiUpdate) Mutation() *XunjiMutation {
+	return xu.mutation
+}
+
+// Save executes the query and returns the number of nodes affected by the update operation.
+func (xu *XunjiUpdate) Save(ctx context.Context) (int, error) {
+	if err := xu.defaults(); err != nil {
+		return 0, err
+	}
+	return withHooks(ctx, xu.sqlSave, xu.mutation, xu.hooks)
+}
+
+// SaveX is like Save, but panics if an error occurs.
+func (xu *XunjiUpdate) SaveX(ctx context.Context) int {
+	affected, err := xu.Save(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return affected
+}
+
+// Exec executes the query.
+func (xu *XunjiUpdate) Exec(ctx context.Context) error {
+	_, err := xu.Save(ctx)
+	return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (xu *XunjiUpdate) ExecX(ctx context.Context) {
+	if err := xu.Exec(ctx); err != nil {
+		panic(err)
+	}
+}
+
+// defaults sets the default values of the builder before save.
+func (xu *XunjiUpdate) defaults() error {
+	if _, ok := xu.mutation.UpdatedAt(); !ok {
+		if xunji.UpdateDefaultUpdatedAt == nil {
+			return fmt.Errorf("ent: uninitialized xunji.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
+		}
+		v := xunji.UpdateDefaultUpdatedAt()
+		xu.mutation.SetUpdatedAt(v)
+	}
+	return nil
+}
+
+// check runs all checks and user-defined validators on the builder.
+func (xu *XunjiUpdate) check() error {
+	if v, ok := xu.mutation.OrganizationID(); ok {
+		if err := xunji.OrganizationIDValidator(v); err != nil {
+			return &ValidationError{Name: "organization_id", err: fmt.Errorf(`ent: validator failed for field "Xunji.organization_id": %w`, err)}
+		}
+	}
+	return nil
+}
+
+func (xu *XunjiUpdate) sqlSave(ctx context.Context) (n int, err error) {
+	if err := xu.check(); err != nil {
+		return n, err
+	}
+	_spec := sqlgraph.NewUpdateSpec(xunji.Table, xunji.Columns, sqlgraph.NewFieldSpec(xunji.FieldID, field.TypeUint64))
+	if ps := xu.mutation.predicates; len(ps) > 0 {
+		_spec.Predicate = func(selector *sql.Selector) {
+			for i := range ps {
+				ps[i](selector)
+			}
+		}
+	}
+	if value, ok := xu.mutation.UpdatedAt(); ok {
+		_spec.SetField(xunji.FieldUpdatedAt, field.TypeTime, value)
+	}
+	if value, ok := xu.mutation.Status(); ok {
+		_spec.SetField(xunji.FieldStatus, field.TypeUint8, value)
+	}
+	if value, ok := xu.mutation.AddedStatus(); ok {
+		_spec.AddField(xunji.FieldStatus, field.TypeUint8, value)
+	}
+	if xu.mutation.StatusCleared() {
+		_spec.ClearField(xunji.FieldStatus, field.TypeUint8)
+	}
+	if value, ok := xu.mutation.DeletedAt(); ok {
+		_spec.SetField(xunji.FieldDeletedAt, field.TypeTime, value)
+	}
+	if xu.mutation.DeletedAtCleared() {
+		_spec.ClearField(xunji.FieldDeletedAt, field.TypeTime)
+	}
+	if value, ok := xu.mutation.AppKey(); ok {
+		_spec.SetField(xunji.FieldAppKey, field.TypeString, value)
+	}
+	if value, ok := xu.mutation.AppSecret(); ok {
+		_spec.SetField(xunji.FieldAppSecret, field.TypeString, value)
+	}
+	if value, ok := xu.mutation.Token(); ok {
+		_spec.SetField(xunji.FieldToken, field.TypeString, value)
+	}
+	if value, ok := xu.mutation.EncodingKey(); ok {
+		_spec.SetField(xunji.FieldEncodingKey, field.TypeString, value)
+	}
+	if value, ok := xu.mutation.AgentID(); ok {
+		_spec.SetField(xunji.FieldAgentID, field.TypeUint64, value)
+	}
+	if value, ok := xu.mutation.AddedAgentID(); ok {
+		_spec.AddField(xunji.FieldAgentID, field.TypeUint64, value)
+	}
+	if value, ok := xu.mutation.OrganizationID(); ok {
+		_spec.SetField(xunji.FieldOrganizationID, field.TypeUint64, value)
+	}
+	if value, ok := xu.mutation.AddedOrganizationID(); ok {
+		_spec.AddField(xunji.FieldOrganizationID, field.TypeUint64, value)
+	}
+	if n, err = sqlgraph.UpdateNodes(ctx, xu.driver, _spec); err != nil {
+		if _, ok := err.(*sqlgraph.NotFoundError); ok {
+			err = &NotFoundError{xunji.Label}
+		} else if sqlgraph.IsConstraintError(err) {
+			err = &ConstraintError{msg: err.Error(), wrap: err}
+		}
+		return 0, err
+	}
+	xu.mutation.done = true
+	return n, nil
+}
+
+// XunjiUpdateOne is the builder for updating a single Xunji entity.
+type XunjiUpdateOne struct {
+	config
+	fields   []string
+	hooks    []Hook
+	mutation *XunjiMutation
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (xuo *XunjiUpdateOne) SetUpdatedAt(t time.Time) *XunjiUpdateOne {
+	xuo.mutation.SetUpdatedAt(t)
+	return xuo
+}
+
+// SetStatus sets the "status" field.
+func (xuo *XunjiUpdateOne) SetStatus(u uint8) *XunjiUpdateOne {
+	xuo.mutation.ResetStatus()
+	xuo.mutation.SetStatus(u)
+	return xuo
+}
+
+// SetNillableStatus sets the "status" field if the given value is not nil.
+func (xuo *XunjiUpdateOne) SetNillableStatus(u *uint8) *XunjiUpdateOne {
+	if u != nil {
+		xuo.SetStatus(*u)
+	}
+	return xuo
+}
+
+// AddStatus adds u to the "status" field.
+func (xuo *XunjiUpdateOne) AddStatus(u int8) *XunjiUpdateOne {
+	xuo.mutation.AddStatus(u)
+	return xuo
+}
+
+// ClearStatus clears the value of the "status" field.
+func (xuo *XunjiUpdateOne) ClearStatus() *XunjiUpdateOne {
+	xuo.mutation.ClearStatus()
+	return xuo
+}
+
+// SetDeletedAt sets the "deleted_at" field.
+func (xuo *XunjiUpdateOne) SetDeletedAt(t time.Time) *XunjiUpdateOne {
+	xuo.mutation.SetDeletedAt(t)
+	return xuo
+}
+
+// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
+func (xuo *XunjiUpdateOne) SetNillableDeletedAt(t *time.Time) *XunjiUpdateOne {
+	if t != nil {
+		xuo.SetDeletedAt(*t)
+	}
+	return xuo
+}
+
+// ClearDeletedAt clears the value of the "deleted_at" field.
+func (xuo *XunjiUpdateOne) ClearDeletedAt() *XunjiUpdateOne {
+	xuo.mutation.ClearDeletedAt()
+	return xuo
+}
+
+// SetAppKey sets the "app_key" field.
+func (xuo *XunjiUpdateOne) SetAppKey(s string) *XunjiUpdateOne {
+	xuo.mutation.SetAppKey(s)
+	return xuo
+}
+
+// SetNillableAppKey sets the "app_key" field if the given value is not nil.
+func (xuo *XunjiUpdateOne) SetNillableAppKey(s *string) *XunjiUpdateOne {
+	if s != nil {
+		xuo.SetAppKey(*s)
+	}
+	return xuo
+}
+
+// SetAppSecret sets the "app_secret" field.
+func (xuo *XunjiUpdateOne) SetAppSecret(s string) *XunjiUpdateOne {
+	xuo.mutation.SetAppSecret(s)
+	return xuo
+}
+
+// SetNillableAppSecret sets the "app_secret" field if the given value is not nil.
+func (xuo *XunjiUpdateOne) SetNillableAppSecret(s *string) *XunjiUpdateOne {
+	if s != nil {
+		xuo.SetAppSecret(*s)
+	}
+	return xuo
+}
+
+// SetToken sets the "token" field.
+func (xuo *XunjiUpdateOne) SetToken(s string) *XunjiUpdateOne {
+	xuo.mutation.SetToken(s)
+	return xuo
+}
+
+// SetNillableToken sets the "token" field if the given value is not nil.
+func (xuo *XunjiUpdateOne) SetNillableToken(s *string) *XunjiUpdateOne {
+	if s != nil {
+		xuo.SetToken(*s)
+	}
+	return xuo
+}
+
+// SetEncodingKey sets the "encoding_key" field.
+func (xuo *XunjiUpdateOne) SetEncodingKey(s string) *XunjiUpdateOne {
+	xuo.mutation.SetEncodingKey(s)
+	return xuo
+}
+
+// SetNillableEncodingKey sets the "encoding_key" field if the given value is not nil.
+func (xuo *XunjiUpdateOne) SetNillableEncodingKey(s *string) *XunjiUpdateOne {
+	if s != nil {
+		xuo.SetEncodingKey(*s)
+	}
+	return xuo
+}
+
+// SetAgentID sets the "agent_id" field.
+func (xuo *XunjiUpdateOne) SetAgentID(u uint64) *XunjiUpdateOne {
+	xuo.mutation.ResetAgentID()
+	xuo.mutation.SetAgentID(u)
+	return xuo
+}
+
+// SetNillableAgentID sets the "agent_id" field if the given value is not nil.
+func (xuo *XunjiUpdateOne) SetNillableAgentID(u *uint64) *XunjiUpdateOne {
+	if u != nil {
+		xuo.SetAgentID(*u)
+	}
+	return xuo
+}
+
+// AddAgentID adds u to the "agent_id" field.
+func (xuo *XunjiUpdateOne) AddAgentID(u int64) *XunjiUpdateOne {
+	xuo.mutation.AddAgentID(u)
+	return xuo
+}
+
+// SetOrganizationID sets the "organization_id" field.
+func (xuo *XunjiUpdateOne) SetOrganizationID(u uint64) *XunjiUpdateOne {
+	xuo.mutation.ResetOrganizationID()
+	xuo.mutation.SetOrganizationID(u)
+	return xuo
+}
+
+// SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
+func (xuo *XunjiUpdateOne) SetNillableOrganizationID(u *uint64) *XunjiUpdateOne {
+	if u != nil {
+		xuo.SetOrganizationID(*u)
+	}
+	return xuo
+}
+
+// AddOrganizationID adds u to the "organization_id" field.
+func (xuo *XunjiUpdateOne) AddOrganizationID(u int64) *XunjiUpdateOne {
+	xuo.mutation.AddOrganizationID(u)
+	return xuo
+}
+
+// Mutation returns the XunjiMutation object of the builder.
+func (xuo *XunjiUpdateOne) Mutation() *XunjiMutation {
+	return xuo.mutation
+}
+
+// Where appends a list predicates to the XunjiUpdate builder.
+func (xuo *XunjiUpdateOne) Where(ps ...predicate.Xunji) *XunjiUpdateOne {
+	xuo.mutation.Where(ps...)
+	return xuo
+}
+
+// Select allows selecting one or more fields (columns) of the returned entity.
+// The default is selecting all fields defined in the entity schema.
+func (xuo *XunjiUpdateOne) Select(field string, fields ...string) *XunjiUpdateOne {
+	xuo.fields = append([]string{field}, fields...)
+	return xuo
+}
+
+// Save executes the query and returns the updated Xunji entity.
+func (xuo *XunjiUpdateOne) Save(ctx context.Context) (*Xunji, error) {
+	if err := xuo.defaults(); err != nil {
+		return nil, err
+	}
+	return withHooks(ctx, xuo.sqlSave, xuo.mutation, xuo.hooks)
+}
+
+// SaveX is like Save, but panics if an error occurs.
+func (xuo *XunjiUpdateOne) SaveX(ctx context.Context) *Xunji {
+	node, err := xuo.Save(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return node
+}
+
+// Exec executes the query on the entity.
+func (xuo *XunjiUpdateOne) Exec(ctx context.Context) error {
+	_, err := xuo.Save(ctx)
+	return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (xuo *XunjiUpdateOne) ExecX(ctx context.Context) {
+	if err := xuo.Exec(ctx); err != nil {
+		panic(err)
+	}
+}
+
+// defaults sets the default values of the builder before save.
+func (xuo *XunjiUpdateOne) defaults() error {
+	if _, ok := xuo.mutation.UpdatedAt(); !ok {
+		if xunji.UpdateDefaultUpdatedAt == nil {
+			return fmt.Errorf("ent: uninitialized xunji.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
+		}
+		v := xunji.UpdateDefaultUpdatedAt()
+		xuo.mutation.SetUpdatedAt(v)
+	}
+	return nil
+}
+
+// check runs all checks and user-defined validators on the builder.
+func (xuo *XunjiUpdateOne) check() error {
+	if v, ok := xuo.mutation.OrganizationID(); ok {
+		if err := xunji.OrganizationIDValidator(v); err != nil {
+			return &ValidationError{Name: "organization_id", err: fmt.Errorf(`ent: validator failed for field "Xunji.organization_id": %w`, err)}
+		}
+	}
+	return nil
+}
+
+func (xuo *XunjiUpdateOne) sqlSave(ctx context.Context) (_node *Xunji, err error) {
+	if err := xuo.check(); err != nil {
+		return _node, err
+	}
+	_spec := sqlgraph.NewUpdateSpec(xunji.Table, xunji.Columns, sqlgraph.NewFieldSpec(xunji.FieldID, field.TypeUint64))
+	id, ok := xuo.mutation.ID()
+	if !ok {
+		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Xunji.id" for update`)}
+	}
+	_spec.Node.ID.Value = id
+	if fields := xuo.fields; len(fields) > 0 {
+		_spec.Node.Columns = make([]string, 0, len(fields))
+		_spec.Node.Columns = append(_spec.Node.Columns, xunji.FieldID)
+		for _, f := range fields {
+			if !xunji.ValidColumn(f) {
+				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
+			}
+			if f != xunji.FieldID {
+				_spec.Node.Columns = append(_spec.Node.Columns, f)
+			}
+		}
+	}
+	if ps := xuo.mutation.predicates; len(ps) > 0 {
+		_spec.Predicate = func(selector *sql.Selector) {
+			for i := range ps {
+				ps[i](selector)
+			}
+		}
+	}
+	if value, ok := xuo.mutation.UpdatedAt(); ok {
+		_spec.SetField(xunji.FieldUpdatedAt, field.TypeTime, value)
+	}
+	if value, ok := xuo.mutation.Status(); ok {
+		_spec.SetField(xunji.FieldStatus, field.TypeUint8, value)
+	}
+	if value, ok := xuo.mutation.AddedStatus(); ok {
+		_spec.AddField(xunji.FieldStatus, field.TypeUint8, value)
+	}
+	if xuo.mutation.StatusCleared() {
+		_spec.ClearField(xunji.FieldStatus, field.TypeUint8)
+	}
+	if value, ok := xuo.mutation.DeletedAt(); ok {
+		_spec.SetField(xunji.FieldDeletedAt, field.TypeTime, value)
+	}
+	if xuo.mutation.DeletedAtCleared() {
+		_spec.ClearField(xunji.FieldDeletedAt, field.TypeTime)
+	}
+	if value, ok := xuo.mutation.AppKey(); ok {
+		_spec.SetField(xunji.FieldAppKey, field.TypeString, value)
+	}
+	if value, ok := xuo.mutation.AppSecret(); ok {
+		_spec.SetField(xunji.FieldAppSecret, field.TypeString, value)
+	}
+	if value, ok := xuo.mutation.Token(); ok {
+		_spec.SetField(xunji.FieldToken, field.TypeString, value)
+	}
+	if value, ok := xuo.mutation.EncodingKey(); ok {
+		_spec.SetField(xunji.FieldEncodingKey, field.TypeString, value)
+	}
+	if value, ok := xuo.mutation.AgentID(); ok {
+		_spec.SetField(xunji.FieldAgentID, field.TypeUint64, value)
+	}
+	if value, ok := xuo.mutation.AddedAgentID(); ok {
+		_spec.AddField(xunji.FieldAgentID, field.TypeUint64, value)
+	}
+	if value, ok := xuo.mutation.OrganizationID(); ok {
+		_spec.SetField(xunji.FieldOrganizationID, field.TypeUint64, value)
+	}
+	if value, ok := xuo.mutation.AddedOrganizationID(); ok {
+		_spec.AddField(xunji.FieldOrganizationID, field.TypeUint64, value)
+	}
+	_node = &Xunji{config: xuo.config}
+	_spec.Assign = _node.assignValues
+	_spec.ScanValues = _node.scanValues
+	if err = sqlgraph.UpdateNode(ctx, xuo.driver, _spec); err != nil {
+		if _, ok := err.(*sqlgraph.NotFoundError); ok {
+			err = &NotFoundError{xunji.Label}
+		} else if sqlgraph.IsConstraintError(err) {
+			err = &ConstraintError{msg: err.Error(), wrap: err}
+		}
+		return nil, err
+	}
+	xuo.mutation.done = true
+	return _node, nil
+}

+ 234 - 0
ent/xunjiservice.go

@@ -0,0 +1,234 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+	"fmt"
+	"strings"
+	"time"
+	"wechat-api/ent/agent"
+	"wechat-api/ent/xunjiservice"
+
+	"entgo.io/ent"
+	"entgo.io/ent/dialect/sql"
+)
+
+// XunjiService is the model entity for the XunjiService schema.
+type XunjiService struct {
+	config `json:"-"`
+	// ID of the ent.
+	ID uint64 `json:"id,omitempty"`
+	// Create Time | 创建日期
+	CreatedAt time.Time `json:"created_at,omitempty"`
+	// Update Time | 修改日期
+	UpdatedAt time.Time `json:"updated_at,omitempty"`
+	// Status 1: normal 2: ban | 状态 1 正常 2 禁用
+	Status uint8 `json:"status,omitempty"`
+	// Delete Time | 删除日期
+	DeletedAt time.Time `json:"deleted_at,omitempty"`
+	// Xunji表ID
+	XunjiID uint64 `json:"xunji_id,omitempty"`
+	// 智能体ID
+	AgentID uint64 `json:"agent_id,omitempty"`
+	// organization_id | 租户ID
+	OrganizationID uint64 `json:"organization_id,omitempty"`
+	// 微信ID
+	Wxid string `json:"wxid,omitempty"`
+	// 大模型服务地址
+	APIBase string `json:"api_base,omitempty"`
+	// 大模型服务密钥
+	APIKey string `json:"api_key,omitempty"`
+	// Edges holds the relations/edges for other nodes in the graph.
+	// The values are being populated by the XunjiServiceQuery when eager-loading is set.
+	Edges        XunjiServiceEdges `json:"edges"`
+	selectValues sql.SelectValues
+}
+
+// XunjiServiceEdges holds the relations/edges for other nodes in the graph.
+type XunjiServiceEdges struct {
+	// Agent holds the value of the agent edge.
+	Agent *Agent `json:"agent,omitempty"`
+	// loadedTypes holds the information for reporting if a
+	// type was loaded (or requested) in eager-loading or not.
+	loadedTypes [1]bool
+}
+
+// AgentOrErr returns the Agent value or an error if the edge
+// was not loaded in eager-loading, or loaded but was not found.
+func (e XunjiServiceEdges) AgentOrErr() (*Agent, error) {
+	if e.Agent != nil {
+		return e.Agent, nil
+	} else if e.loadedTypes[0] {
+		return nil, &NotFoundError{label: agent.Label}
+	}
+	return nil, &NotLoadedError{edge: "agent"}
+}
+
+// scanValues returns the types for scanning values from sql.Rows.
+func (*XunjiService) scanValues(columns []string) ([]any, error) {
+	values := make([]any, len(columns))
+	for i := range columns {
+		switch columns[i] {
+		case xunjiservice.FieldID, xunjiservice.FieldStatus, xunjiservice.FieldXunjiID, xunjiservice.FieldAgentID, xunjiservice.FieldOrganizationID:
+			values[i] = new(sql.NullInt64)
+		case xunjiservice.FieldWxid, xunjiservice.FieldAPIBase, xunjiservice.FieldAPIKey:
+			values[i] = new(sql.NullString)
+		case xunjiservice.FieldCreatedAt, xunjiservice.FieldUpdatedAt, xunjiservice.FieldDeletedAt:
+			values[i] = new(sql.NullTime)
+		default:
+			values[i] = new(sql.UnknownType)
+		}
+	}
+	return values, nil
+}
+
+// assignValues assigns the values that were returned from sql.Rows (after scanning)
+// to the XunjiService fields.
+func (xs *XunjiService) assignValues(columns []string, values []any) error {
+	if m, n := len(values), len(columns); m < n {
+		return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
+	}
+	for i := range columns {
+		switch columns[i] {
+		case xunjiservice.FieldID:
+			value, ok := values[i].(*sql.NullInt64)
+			if !ok {
+				return fmt.Errorf("unexpected type %T for field id", value)
+			}
+			xs.ID = uint64(value.Int64)
+		case xunjiservice.FieldCreatedAt:
+			if value, ok := values[i].(*sql.NullTime); !ok {
+				return fmt.Errorf("unexpected type %T for field created_at", values[i])
+			} else if value.Valid {
+				xs.CreatedAt = value.Time
+			}
+		case xunjiservice.FieldUpdatedAt:
+			if value, ok := values[i].(*sql.NullTime); !ok {
+				return fmt.Errorf("unexpected type %T for field updated_at", values[i])
+			} else if value.Valid {
+				xs.UpdatedAt = value.Time
+			}
+		case xunjiservice.FieldStatus:
+			if value, ok := values[i].(*sql.NullInt64); !ok {
+				return fmt.Errorf("unexpected type %T for field status", values[i])
+			} else if value.Valid {
+				xs.Status = uint8(value.Int64)
+			}
+		case xunjiservice.FieldDeletedAt:
+			if value, ok := values[i].(*sql.NullTime); !ok {
+				return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
+			} else if value.Valid {
+				xs.DeletedAt = value.Time
+			}
+		case xunjiservice.FieldXunjiID:
+			if value, ok := values[i].(*sql.NullInt64); !ok {
+				return fmt.Errorf("unexpected type %T for field xunji_id", values[i])
+			} else if value.Valid {
+				xs.XunjiID = uint64(value.Int64)
+			}
+		case xunjiservice.FieldAgentID:
+			if value, ok := values[i].(*sql.NullInt64); !ok {
+				return fmt.Errorf("unexpected type %T for field agent_id", values[i])
+			} else if value.Valid {
+				xs.AgentID = uint64(value.Int64)
+			}
+		case xunjiservice.FieldOrganizationID:
+			if value, ok := values[i].(*sql.NullInt64); !ok {
+				return fmt.Errorf("unexpected type %T for field organization_id", values[i])
+			} else if value.Valid {
+				xs.OrganizationID = uint64(value.Int64)
+			}
+		case xunjiservice.FieldWxid:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field wxid", values[i])
+			} else if value.Valid {
+				xs.Wxid = value.String
+			}
+		case xunjiservice.FieldAPIBase:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field api_base", values[i])
+			} else if value.Valid {
+				xs.APIBase = value.String
+			}
+		case xunjiservice.FieldAPIKey:
+			if value, ok := values[i].(*sql.NullString); !ok {
+				return fmt.Errorf("unexpected type %T for field api_key", values[i])
+			} else if value.Valid {
+				xs.APIKey = value.String
+			}
+		default:
+			xs.selectValues.Set(columns[i], values[i])
+		}
+	}
+	return nil
+}
+
+// Value returns the ent.Value that was dynamically selected and assigned to the XunjiService.
+// This includes values selected through modifiers, order, etc.
+func (xs *XunjiService) Value(name string) (ent.Value, error) {
+	return xs.selectValues.Get(name)
+}
+
+// QueryAgent queries the "agent" edge of the XunjiService entity.
+func (xs *XunjiService) QueryAgent() *AgentQuery {
+	return NewXunjiServiceClient(xs.config).QueryAgent(xs)
+}
+
+// Update returns a builder for updating this XunjiService.
+// Note that you need to call XunjiService.Unwrap() before calling this method if this XunjiService
+// was returned from a transaction, and the transaction was committed or rolled back.
+func (xs *XunjiService) Update() *XunjiServiceUpdateOne {
+	return NewXunjiServiceClient(xs.config).UpdateOne(xs)
+}
+
+// Unwrap unwraps the XunjiService entity that was returned from a transaction after it was closed,
+// so that all future queries will be executed through the driver which created the transaction.
+func (xs *XunjiService) Unwrap() *XunjiService {
+	_tx, ok := xs.config.driver.(*txDriver)
+	if !ok {
+		panic("ent: XunjiService is not a transactional entity")
+	}
+	xs.config.driver = _tx.drv
+	return xs
+}
+
+// String implements the fmt.Stringer.
+func (xs *XunjiService) String() string {
+	var builder strings.Builder
+	builder.WriteString("XunjiService(")
+	builder.WriteString(fmt.Sprintf("id=%v, ", xs.ID))
+	builder.WriteString("created_at=")
+	builder.WriteString(xs.CreatedAt.Format(time.ANSIC))
+	builder.WriteString(", ")
+	builder.WriteString("updated_at=")
+	builder.WriteString(xs.UpdatedAt.Format(time.ANSIC))
+	builder.WriteString(", ")
+	builder.WriteString("status=")
+	builder.WriteString(fmt.Sprintf("%v", xs.Status))
+	builder.WriteString(", ")
+	builder.WriteString("deleted_at=")
+	builder.WriteString(xs.DeletedAt.Format(time.ANSIC))
+	builder.WriteString(", ")
+	builder.WriteString("xunji_id=")
+	builder.WriteString(fmt.Sprintf("%v", xs.XunjiID))
+	builder.WriteString(", ")
+	builder.WriteString("agent_id=")
+	builder.WriteString(fmt.Sprintf("%v", xs.AgentID))
+	builder.WriteString(", ")
+	builder.WriteString("organization_id=")
+	builder.WriteString(fmt.Sprintf("%v", xs.OrganizationID))
+	builder.WriteString(", ")
+	builder.WriteString("wxid=")
+	builder.WriteString(xs.Wxid)
+	builder.WriteString(", ")
+	builder.WriteString("api_base=")
+	builder.WriteString(xs.APIBase)
+	builder.WriteString(", ")
+	builder.WriteString("api_key=")
+	builder.WriteString(xs.APIKey)
+	builder.WriteByte(')')
+	return builder.String()
+}
+
+// XunjiServices is a parsable slice of XunjiService.
+type XunjiServices []*XunjiService

+ 639 - 0
ent/xunjiservice/where.go

@@ -0,0 +1,639 @@
+// Code generated by ent, DO NOT EDIT.
+
+package xunjiservice
+
+import (
+	"time"
+	"wechat-api/ent/predicate"
+
+	"entgo.io/ent/dialect/sql"
+	"entgo.io/ent/dialect/sql/sqlgraph"
+)
+
+// ID filters vertices based on their ID field.
+func ID(id uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldEQ(FieldID, id))
+}
+
+// IDEQ applies the EQ predicate on the ID field.
+func IDEQ(id uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldEQ(FieldID, id))
+}
+
+// IDNEQ applies the NEQ predicate on the ID field.
+func IDNEQ(id uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldNEQ(FieldID, id))
+}
+
+// IDIn applies the In predicate on the ID field.
+func IDIn(ids ...uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldIn(FieldID, ids...))
+}
+
+// IDNotIn applies the NotIn predicate on the ID field.
+func IDNotIn(ids ...uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldNotIn(FieldID, ids...))
+}
+
+// IDGT applies the GT predicate on the ID field.
+func IDGT(id uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldGT(FieldID, id))
+}
+
+// IDGTE applies the GTE predicate on the ID field.
+func IDGTE(id uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldGTE(FieldID, id))
+}
+
+// IDLT applies the LT predicate on the ID field.
+func IDLT(id uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldLT(FieldID, id))
+}
+
+// IDLTE applies the LTE predicate on the ID field.
+func IDLTE(id uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldLTE(FieldID, id))
+}
+
+// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
+func CreatedAt(v time.Time) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldEQ(FieldCreatedAt, v))
+}
+
+// UpdatedAt applies equality check predicate on the "updated_at" field. It's identical to UpdatedAtEQ.
+func UpdatedAt(v time.Time) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldEQ(FieldUpdatedAt, v))
+}
+
+// Status applies equality check predicate on the "status" field. It's identical to StatusEQ.
+func Status(v uint8) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldEQ(FieldStatus, v))
+}
+
+// DeletedAt applies equality check predicate on the "deleted_at" field. It's identical to DeletedAtEQ.
+func DeletedAt(v time.Time) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldEQ(FieldDeletedAt, v))
+}
+
+// XunjiID applies equality check predicate on the "xunji_id" field. It's identical to XunjiIDEQ.
+func XunjiID(v uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldEQ(FieldXunjiID, v))
+}
+
+// AgentID applies equality check predicate on the "agent_id" field. It's identical to AgentIDEQ.
+func AgentID(v uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldEQ(FieldAgentID, v))
+}
+
+// OrganizationID applies equality check predicate on the "organization_id" field. It's identical to OrganizationIDEQ.
+func OrganizationID(v uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldEQ(FieldOrganizationID, v))
+}
+
+// Wxid applies equality check predicate on the "wxid" field. It's identical to WxidEQ.
+func Wxid(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldEQ(FieldWxid, v))
+}
+
+// APIBase applies equality check predicate on the "api_base" field. It's identical to APIBaseEQ.
+func APIBase(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldEQ(FieldAPIBase, v))
+}
+
+// APIKey applies equality check predicate on the "api_key" field. It's identical to APIKeyEQ.
+func APIKey(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldEQ(FieldAPIKey, v))
+}
+
+// CreatedAtEQ applies the EQ predicate on the "created_at" field.
+func CreatedAtEQ(v time.Time) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldEQ(FieldCreatedAt, v))
+}
+
+// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
+func CreatedAtNEQ(v time.Time) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldNEQ(FieldCreatedAt, v))
+}
+
+// CreatedAtIn applies the In predicate on the "created_at" field.
+func CreatedAtIn(vs ...time.Time) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldIn(FieldCreatedAt, vs...))
+}
+
+// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
+func CreatedAtNotIn(vs ...time.Time) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldNotIn(FieldCreatedAt, vs...))
+}
+
+// CreatedAtGT applies the GT predicate on the "created_at" field.
+func CreatedAtGT(v time.Time) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldGT(FieldCreatedAt, v))
+}
+
+// CreatedAtGTE applies the GTE predicate on the "created_at" field.
+func CreatedAtGTE(v time.Time) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldGTE(FieldCreatedAt, v))
+}
+
+// CreatedAtLT applies the LT predicate on the "created_at" field.
+func CreatedAtLT(v time.Time) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldLT(FieldCreatedAt, v))
+}
+
+// CreatedAtLTE applies the LTE predicate on the "created_at" field.
+func CreatedAtLTE(v time.Time) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldLTE(FieldCreatedAt, v))
+}
+
+// UpdatedAtEQ applies the EQ predicate on the "updated_at" field.
+func UpdatedAtEQ(v time.Time) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldEQ(FieldUpdatedAt, v))
+}
+
+// UpdatedAtNEQ applies the NEQ predicate on the "updated_at" field.
+func UpdatedAtNEQ(v time.Time) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldNEQ(FieldUpdatedAt, v))
+}
+
+// UpdatedAtIn applies the In predicate on the "updated_at" field.
+func UpdatedAtIn(vs ...time.Time) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldIn(FieldUpdatedAt, vs...))
+}
+
+// UpdatedAtNotIn applies the NotIn predicate on the "updated_at" field.
+func UpdatedAtNotIn(vs ...time.Time) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldNotIn(FieldUpdatedAt, vs...))
+}
+
+// UpdatedAtGT applies the GT predicate on the "updated_at" field.
+func UpdatedAtGT(v time.Time) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldGT(FieldUpdatedAt, v))
+}
+
+// UpdatedAtGTE applies the GTE predicate on the "updated_at" field.
+func UpdatedAtGTE(v time.Time) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldGTE(FieldUpdatedAt, v))
+}
+
+// UpdatedAtLT applies the LT predicate on the "updated_at" field.
+func UpdatedAtLT(v time.Time) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldLT(FieldUpdatedAt, v))
+}
+
+// UpdatedAtLTE applies the LTE predicate on the "updated_at" field.
+func UpdatedAtLTE(v time.Time) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldLTE(FieldUpdatedAt, v))
+}
+
+// StatusEQ applies the EQ predicate on the "status" field.
+func StatusEQ(v uint8) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldEQ(FieldStatus, v))
+}
+
+// StatusNEQ applies the NEQ predicate on the "status" field.
+func StatusNEQ(v uint8) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldNEQ(FieldStatus, v))
+}
+
+// StatusIn applies the In predicate on the "status" field.
+func StatusIn(vs ...uint8) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldIn(FieldStatus, vs...))
+}
+
+// StatusNotIn applies the NotIn predicate on the "status" field.
+func StatusNotIn(vs ...uint8) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldNotIn(FieldStatus, vs...))
+}
+
+// StatusGT applies the GT predicate on the "status" field.
+func StatusGT(v uint8) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldGT(FieldStatus, v))
+}
+
+// StatusGTE applies the GTE predicate on the "status" field.
+func StatusGTE(v uint8) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldGTE(FieldStatus, v))
+}
+
+// StatusLT applies the LT predicate on the "status" field.
+func StatusLT(v uint8) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldLT(FieldStatus, v))
+}
+
+// StatusLTE applies the LTE predicate on the "status" field.
+func StatusLTE(v uint8) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldLTE(FieldStatus, v))
+}
+
+// StatusIsNil applies the IsNil predicate on the "status" field.
+func StatusIsNil() predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldIsNull(FieldStatus))
+}
+
+// StatusNotNil applies the NotNil predicate on the "status" field.
+func StatusNotNil() predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldNotNull(FieldStatus))
+}
+
+// DeletedAtEQ applies the EQ predicate on the "deleted_at" field.
+func DeletedAtEQ(v time.Time) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldEQ(FieldDeletedAt, v))
+}
+
+// DeletedAtNEQ applies the NEQ predicate on the "deleted_at" field.
+func DeletedAtNEQ(v time.Time) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldNEQ(FieldDeletedAt, v))
+}
+
+// DeletedAtIn applies the In predicate on the "deleted_at" field.
+func DeletedAtIn(vs ...time.Time) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldIn(FieldDeletedAt, vs...))
+}
+
+// DeletedAtNotIn applies the NotIn predicate on the "deleted_at" field.
+func DeletedAtNotIn(vs ...time.Time) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldNotIn(FieldDeletedAt, vs...))
+}
+
+// DeletedAtGT applies the GT predicate on the "deleted_at" field.
+func DeletedAtGT(v time.Time) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldGT(FieldDeletedAt, v))
+}
+
+// DeletedAtGTE applies the GTE predicate on the "deleted_at" field.
+func DeletedAtGTE(v time.Time) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldGTE(FieldDeletedAt, v))
+}
+
+// DeletedAtLT applies the LT predicate on the "deleted_at" field.
+func DeletedAtLT(v time.Time) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldLT(FieldDeletedAt, v))
+}
+
+// DeletedAtLTE applies the LTE predicate on the "deleted_at" field.
+func DeletedAtLTE(v time.Time) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldLTE(FieldDeletedAt, v))
+}
+
+// DeletedAtIsNil applies the IsNil predicate on the "deleted_at" field.
+func DeletedAtIsNil() predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldIsNull(FieldDeletedAt))
+}
+
+// DeletedAtNotNil applies the NotNil predicate on the "deleted_at" field.
+func DeletedAtNotNil() predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldNotNull(FieldDeletedAt))
+}
+
+// XunjiIDEQ applies the EQ predicate on the "xunji_id" field.
+func XunjiIDEQ(v uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldEQ(FieldXunjiID, v))
+}
+
+// XunjiIDNEQ applies the NEQ predicate on the "xunji_id" field.
+func XunjiIDNEQ(v uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldNEQ(FieldXunjiID, v))
+}
+
+// XunjiIDIn applies the In predicate on the "xunji_id" field.
+func XunjiIDIn(vs ...uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldIn(FieldXunjiID, vs...))
+}
+
+// XunjiIDNotIn applies the NotIn predicate on the "xunji_id" field.
+func XunjiIDNotIn(vs ...uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldNotIn(FieldXunjiID, vs...))
+}
+
+// XunjiIDGT applies the GT predicate on the "xunji_id" field.
+func XunjiIDGT(v uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldGT(FieldXunjiID, v))
+}
+
+// XunjiIDGTE applies the GTE predicate on the "xunji_id" field.
+func XunjiIDGTE(v uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldGTE(FieldXunjiID, v))
+}
+
+// XunjiIDLT applies the LT predicate on the "xunji_id" field.
+func XunjiIDLT(v uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldLT(FieldXunjiID, v))
+}
+
+// XunjiIDLTE applies the LTE predicate on the "xunji_id" field.
+func XunjiIDLTE(v uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldLTE(FieldXunjiID, v))
+}
+
+// AgentIDEQ applies the EQ predicate on the "agent_id" field.
+func AgentIDEQ(v uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldEQ(FieldAgentID, v))
+}
+
+// AgentIDNEQ applies the NEQ predicate on the "agent_id" field.
+func AgentIDNEQ(v uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldNEQ(FieldAgentID, v))
+}
+
+// AgentIDIn applies the In predicate on the "agent_id" field.
+func AgentIDIn(vs ...uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldIn(FieldAgentID, vs...))
+}
+
+// AgentIDNotIn applies the NotIn predicate on the "agent_id" field.
+func AgentIDNotIn(vs ...uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldNotIn(FieldAgentID, vs...))
+}
+
+// OrganizationIDEQ applies the EQ predicate on the "organization_id" field.
+func OrganizationIDEQ(v uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldEQ(FieldOrganizationID, v))
+}
+
+// OrganizationIDNEQ applies the NEQ predicate on the "organization_id" field.
+func OrganizationIDNEQ(v uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldNEQ(FieldOrganizationID, v))
+}
+
+// OrganizationIDIn applies the In predicate on the "organization_id" field.
+func OrganizationIDIn(vs ...uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldIn(FieldOrganizationID, vs...))
+}
+
+// OrganizationIDNotIn applies the NotIn predicate on the "organization_id" field.
+func OrganizationIDNotIn(vs ...uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldNotIn(FieldOrganizationID, vs...))
+}
+
+// OrganizationIDGT applies the GT predicate on the "organization_id" field.
+func OrganizationIDGT(v uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldGT(FieldOrganizationID, v))
+}
+
+// OrganizationIDGTE applies the GTE predicate on the "organization_id" field.
+func OrganizationIDGTE(v uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldGTE(FieldOrganizationID, v))
+}
+
+// OrganizationIDLT applies the LT predicate on the "organization_id" field.
+func OrganizationIDLT(v uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldLT(FieldOrganizationID, v))
+}
+
+// OrganizationIDLTE applies the LTE predicate on the "organization_id" field.
+func OrganizationIDLTE(v uint64) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldLTE(FieldOrganizationID, v))
+}
+
+// WxidEQ applies the EQ predicate on the "wxid" field.
+func WxidEQ(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldEQ(FieldWxid, v))
+}
+
+// WxidNEQ applies the NEQ predicate on the "wxid" field.
+func WxidNEQ(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldNEQ(FieldWxid, v))
+}
+
+// WxidIn applies the In predicate on the "wxid" field.
+func WxidIn(vs ...string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldIn(FieldWxid, vs...))
+}
+
+// WxidNotIn applies the NotIn predicate on the "wxid" field.
+func WxidNotIn(vs ...string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldNotIn(FieldWxid, vs...))
+}
+
+// WxidGT applies the GT predicate on the "wxid" field.
+func WxidGT(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldGT(FieldWxid, v))
+}
+
+// WxidGTE applies the GTE predicate on the "wxid" field.
+func WxidGTE(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldGTE(FieldWxid, v))
+}
+
+// WxidLT applies the LT predicate on the "wxid" field.
+func WxidLT(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldLT(FieldWxid, v))
+}
+
+// WxidLTE applies the LTE predicate on the "wxid" field.
+func WxidLTE(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldLTE(FieldWxid, v))
+}
+
+// WxidContains applies the Contains predicate on the "wxid" field.
+func WxidContains(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldContains(FieldWxid, v))
+}
+
+// WxidHasPrefix applies the HasPrefix predicate on the "wxid" field.
+func WxidHasPrefix(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldHasPrefix(FieldWxid, v))
+}
+
+// WxidHasSuffix applies the HasSuffix predicate on the "wxid" field.
+func WxidHasSuffix(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldHasSuffix(FieldWxid, v))
+}
+
+// WxidEqualFold applies the EqualFold predicate on the "wxid" field.
+func WxidEqualFold(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldEqualFold(FieldWxid, v))
+}
+
+// WxidContainsFold applies the ContainsFold predicate on the "wxid" field.
+func WxidContainsFold(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldContainsFold(FieldWxid, v))
+}
+
+// APIBaseEQ applies the EQ predicate on the "api_base" field.
+func APIBaseEQ(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldEQ(FieldAPIBase, v))
+}
+
+// APIBaseNEQ applies the NEQ predicate on the "api_base" field.
+func APIBaseNEQ(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldNEQ(FieldAPIBase, v))
+}
+
+// APIBaseIn applies the In predicate on the "api_base" field.
+func APIBaseIn(vs ...string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldIn(FieldAPIBase, vs...))
+}
+
+// APIBaseNotIn applies the NotIn predicate on the "api_base" field.
+func APIBaseNotIn(vs ...string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldNotIn(FieldAPIBase, vs...))
+}
+
+// APIBaseGT applies the GT predicate on the "api_base" field.
+func APIBaseGT(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldGT(FieldAPIBase, v))
+}
+
+// APIBaseGTE applies the GTE predicate on the "api_base" field.
+func APIBaseGTE(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldGTE(FieldAPIBase, v))
+}
+
+// APIBaseLT applies the LT predicate on the "api_base" field.
+func APIBaseLT(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldLT(FieldAPIBase, v))
+}
+
+// APIBaseLTE applies the LTE predicate on the "api_base" field.
+func APIBaseLTE(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldLTE(FieldAPIBase, v))
+}
+
+// APIBaseContains applies the Contains predicate on the "api_base" field.
+func APIBaseContains(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldContains(FieldAPIBase, v))
+}
+
+// APIBaseHasPrefix applies the HasPrefix predicate on the "api_base" field.
+func APIBaseHasPrefix(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldHasPrefix(FieldAPIBase, v))
+}
+
+// APIBaseHasSuffix applies the HasSuffix predicate on the "api_base" field.
+func APIBaseHasSuffix(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldHasSuffix(FieldAPIBase, v))
+}
+
+// APIBaseIsNil applies the IsNil predicate on the "api_base" field.
+func APIBaseIsNil() predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldIsNull(FieldAPIBase))
+}
+
+// APIBaseNotNil applies the NotNil predicate on the "api_base" field.
+func APIBaseNotNil() predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldNotNull(FieldAPIBase))
+}
+
+// APIBaseEqualFold applies the EqualFold predicate on the "api_base" field.
+func APIBaseEqualFold(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldEqualFold(FieldAPIBase, v))
+}
+
+// APIBaseContainsFold applies the ContainsFold predicate on the "api_base" field.
+func APIBaseContainsFold(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldContainsFold(FieldAPIBase, v))
+}
+
+// APIKeyEQ applies the EQ predicate on the "api_key" field.
+func APIKeyEQ(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldEQ(FieldAPIKey, v))
+}
+
+// APIKeyNEQ applies the NEQ predicate on the "api_key" field.
+func APIKeyNEQ(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldNEQ(FieldAPIKey, v))
+}
+
+// APIKeyIn applies the In predicate on the "api_key" field.
+func APIKeyIn(vs ...string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldIn(FieldAPIKey, vs...))
+}
+
+// APIKeyNotIn applies the NotIn predicate on the "api_key" field.
+func APIKeyNotIn(vs ...string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldNotIn(FieldAPIKey, vs...))
+}
+
+// APIKeyGT applies the GT predicate on the "api_key" field.
+func APIKeyGT(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldGT(FieldAPIKey, v))
+}
+
+// APIKeyGTE applies the GTE predicate on the "api_key" field.
+func APIKeyGTE(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldGTE(FieldAPIKey, v))
+}
+
+// APIKeyLT applies the LT predicate on the "api_key" field.
+func APIKeyLT(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldLT(FieldAPIKey, v))
+}
+
+// APIKeyLTE applies the LTE predicate on the "api_key" field.
+func APIKeyLTE(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldLTE(FieldAPIKey, v))
+}
+
+// APIKeyContains applies the Contains predicate on the "api_key" field.
+func APIKeyContains(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldContains(FieldAPIKey, v))
+}
+
+// APIKeyHasPrefix applies the HasPrefix predicate on the "api_key" field.
+func APIKeyHasPrefix(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldHasPrefix(FieldAPIKey, v))
+}
+
+// APIKeyHasSuffix applies the HasSuffix predicate on the "api_key" field.
+func APIKeyHasSuffix(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldHasSuffix(FieldAPIKey, v))
+}
+
+// APIKeyIsNil applies the IsNil predicate on the "api_key" field.
+func APIKeyIsNil() predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldIsNull(FieldAPIKey))
+}
+
+// APIKeyNotNil applies the NotNil predicate on the "api_key" field.
+func APIKeyNotNil() predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldNotNull(FieldAPIKey))
+}
+
+// APIKeyEqualFold applies the EqualFold predicate on the "api_key" field.
+func APIKeyEqualFold(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldEqualFold(FieldAPIKey, v))
+}
+
+// APIKeyContainsFold applies the ContainsFold predicate on the "api_key" field.
+func APIKeyContainsFold(v string) predicate.XunjiService {
+	return predicate.XunjiService(sql.FieldContainsFold(FieldAPIKey, v))
+}
+
+// HasAgent applies the HasEdge predicate on the "agent" edge.
+func HasAgent() predicate.XunjiService {
+	return predicate.XunjiService(func(s *sql.Selector) {
+		step := sqlgraph.NewStep(
+			sqlgraph.From(Table, FieldID),
+			sqlgraph.Edge(sqlgraph.M2O, true, AgentTable, AgentColumn),
+		)
+		sqlgraph.HasNeighbors(s, step)
+	})
+}
+
+// HasAgentWith applies the HasEdge predicate on the "agent" edge with a given conditions (other predicates).
+func HasAgentWith(preds ...predicate.Agent) predicate.XunjiService {
+	return predicate.XunjiService(func(s *sql.Selector) {
+		step := newAgentStep()
+		sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
+			for _, p := range preds {
+				p(s)
+			}
+		})
+	})
+}
+
+// And groups predicates with the AND operator between them.
+func And(predicates ...predicate.XunjiService) predicate.XunjiService {
+	return predicate.XunjiService(sql.AndPredicates(predicates...))
+}
+
+// Or groups predicates with the OR operator between them.
+func Or(predicates ...predicate.XunjiService) predicate.XunjiService {
+	return predicate.XunjiService(sql.OrPredicates(predicates...))
+}
+
+// Not applies the not operator on the given predicate.
+func Not(p predicate.XunjiService) predicate.XunjiService {
+	return predicate.XunjiService(sql.NotPredicates(p))
+}

+ 172 - 0
ent/xunjiservice/xunjiservice.go

@@ -0,0 +1,172 @@
+// Code generated by ent, DO NOT EDIT.
+
+package xunjiservice
+
+import (
+	"time"
+
+	"entgo.io/ent"
+	"entgo.io/ent/dialect/sql"
+	"entgo.io/ent/dialect/sql/sqlgraph"
+)
+
+const (
+	// Label holds the string label denoting the xunjiservice type in the database.
+	Label = "xunji_service"
+	// FieldID holds the string denoting the id field in the database.
+	FieldID = "id"
+	// FieldCreatedAt holds the string denoting the created_at field in the database.
+	FieldCreatedAt = "created_at"
+	// FieldUpdatedAt holds the string denoting the updated_at field in the database.
+	FieldUpdatedAt = "updated_at"
+	// FieldStatus holds the string denoting the status field in the database.
+	FieldStatus = "status"
+	// FieldDeletedAt holds the string denoting the deleted_at field in the database.
+	FieldDeletedAt = "deleted_at"
+	// FieldXunjiID holds the string denoting the xunji_id field in the database.
+	FieldXunjiID = "xunji_id"
+	// FieldAgentID holds the string denoting the agent_id field in the database.
+	FieldAgentID = "agent_id"
+	// FieldOrganizationID holds the string denoting the organization_id field in the database.
+	FieldOrganizationID = "organization_id"
+	// FieldWxid holds the string denoting the wxid field in the database.
+	FieldWxid = "wxid"
+	// FieldAPIBase holds the string denoting the api_base field in the database.
+	FieldAPIBase = "api_base"
+	// FieldAPIKey holds the string denoting the api_key field in the database.
+	FieldAPIKey = "api_key"
+	// EdgeAgent holds the string denoting the agent edge name in mutations.
+	EdgeAgent = "agent"
+	// Table holds the table name of the xunjiservice in the database.
+	Table = "xunji_service"
+	// AgentTable is the table that holds the agent relation/edge.
+	AgentTable = "xunji_service"
+	// AgentInverseTable is the table name for the Agent entity.
+	// It exists in this package in order to avoid circular dependency with the "agent" package.
+	AgentInverseTable = "agent"
+	// AgentColumn is the table column denoting the agent relation/edge.
+	AgentColumn = "agent_id"
+)
+
+// Columns holds all SQL columns for xunjiservice fields.
+var Columns = []string{
+	FieldID,
+	FieldCreatedAt,
+	FieldUpdatedAt,
+	FieldStatus,
+	FieldDeletedAt,
+	FieldXunjiID,
+	FieldAgentID,
+	FieldOrganizationID,
+	FieldWxid,
+	FieldAPIBase,
+	FieldAPIKey,
+}
+
+// ValidColumn reports if the column name is valid (part of the table columns).
+func ValidColumn(column string) bool {
+	for i := range Columns {
+		if column == Columns[i] {
+			return true
+		}
+	}
+	return false
+}
+
+// Note that the variables below are initialized by the runtime
+// package on the initialization of the application. Therefore,
+// it should be imported in the main as follows:
+//
+//	import _ "wechat-api/ent/runtime"
+var (
+	Hooks        [1]ent.Hook
+	Interceptors [1]ent.Interceptor
+	// DefaultCreatedAt holds the default value on creation for the "created_at" field.
+	DefaultCreatedAt func() time.Time
+	// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
+	DefaultUpdatedAt func() time.Time
+	// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
+	UpdateDefaultUpdatedAt func() time.Time
+	// DefaultStatus holds the default value on creation for the "status" field.
+	DefaultStatus uint8
+	// DefaultAgentID holds the default value on creation for the "agent_id" field.
+	DefaultAgentID uint64
+	// OrganizationIDValidator is a validator for the "organization_id" field. It is called by the builders before save.
+	OrganizationIDValidator func(uint64) error
+	// DefaultAPIBase holds the default value on creation for the "api_base" field.
+	DefaultAPIBase string
+	// DefaultAPIKey holds the default value on creation for the "api_key" field.
+	DefaultAPIKey string
+)
+
+// OrderOption defines the ordering options for the XunjiService queries.
+type OrderOption func(*sql.Selector)
+
+// ByID orders the results by the id field.
+func ByID(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldID, opts...).ToFunc()
+}
+
+// ByCreatedAt orders the results by the created_at field.
+func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
+}
+
+// ByUpdatedAt orders the results by the updated_at field.
+func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
+}
+
+// ByStatus orders the results by the status field.
+func ByStatus(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldStatus, opts...).ToFunc()
+}
+
+// ByDeletedAt orders the results by the deleted_at field.
+func ByDeletedAt(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldDeletedAt, opts...).ToFunc()
+}
+
+// ByXunjiID orders the results by the xunji_id field.
+func ByXunjiID(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldXunjiID, opts...).ToFunc()
+}
+
+// ByAgentID orders the results by the agent_id field.
+func ByAgentID(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldAgentID, opts...).ToFunc()
+}
+
+// ByOrganizationID orders the results by the organization_id field.
+func ByOrganizationID(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldOrganizationID, opts...).ToFunc()
+}
+
+// ByWxid orders the results by the wxid field.
+func ByWxid(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldWxid, opts...).ToFunc()
+}
+
+// ByAPIBase orders the results by the api_base field.
+func ByAPIBase(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldAPIBase, opts...).ToFunc()
+}
+
+// ByAPIKey orders the results by the api_key field.
+func ByAPIKey(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldAPIKey, opts...).ToFunc()
+}
+
+// ByAgentField orders the results by agent field.
+func ByAgentField(field string, opts ...sql.OrderTermOption) OrderOption {
+	return func(s *sql.Selector) {
+		sqlgraph.OrderByNeighborTerms(s, newAgentStep(), sql.OrderByField(field, opts...))
+	}
+}
+func newAgentStep() *sqlgraph.Step {
+	return sqlgraph.NewStep(
+		sqlgraph.From(Table, FieldID),
+		sqlgraph.To(AgentInverseTable, FieldID),
+		sqlgraph.Edge(sqlgraph.M2O, true, AgentTable, AgentColumn),
+	)
+}

+ 1178 - 0
ent/xunjiservice_create.go

@@ -0,0 +1,1178 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+	"context"
+	"errors"
+	"fmt"
+	"time"
+	"wechat-api/ent/agent"
+	"wechat-api/ent/xunjiservice"
+
+	"entgo.io/ent/dialect/sql"
+	"entgo.io/ent/dialect/sql/sqlgraph"
+	"entgo.io/ent/schema/field"
+)
+
+// XunjiServiceCreate is the builder for creating a XunjiService entity.
+type XunjiServiceCreate struct {
+	config
+	mutation *XunjiServiceMutation
+	hooks    []Hook
+	conflict []sql.ConflictOption
+}
+
+// SetCreatedAt sets the "created_at" field.
+func (xsc *XunjiServiceCreate) SetCreatedAt(t time.Time) *XunjiServiceCreate {
+	xsc.mutation.SetCreatedAt(t)
+	return xsc
+}
+
+// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
+func (xsc *XunjiServiceCreate) SetNillableCreatedAt(t *time.Time) *XunjiServiceCreate {
+	if t != nil {
+		xsc.SetCreatedAt(*t)
+	}
+	return xsc
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (xsc *XunjiServiceCreate) SetUpdatedAt(t time.Time) *XunjiServiceCreate {
+	xsc.mutation.SetUpdatedAt(t)
+	return xsc
+}
+
+// SetNillableUpdatedAt sets the "updated_at" field if the given value is not nil.
+func (xsc *XunjiServiceCreate) SetNillableUpdatedAt(t *time.Time) *XunjiServiceCreate {
+	if t != nil {
+		xsc.SetUpdatedAt(*t)
+	}
+	return xsc
+}
+
+// SetStatus sets the "status" field.
+func (xsc *XunjiServiceCreate) SetStatus(u uint8) *XunjiServiceCreate {
+	xsc.mutation.SetStatus(u)
+	return xsc
+}
+
+// SetNillableStatus sets the "status" field if the given value is not nil.
+func (xsc *XunjiServiceCreate) SetNillableStatus(u *uint8) *XunjiServiceCreate {
+	if u != nil {
+		xsc.SetStatus(*u)
+	}
+	return xsc
+}
+
+// SetDeletedAt sets the "deleted_at" field.
+func (xsc *XunjiServiceCreate) SetDeletedAt(t time.Time) *XunjiServiceCreate {
+	xsc.mutation.SetDeletedAt(t)
+	return xsc
+}
+
+// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
+func (xsc *XunjiServiceCreate) SetNillableDeletedAt(t *time.Time) *XunjiServiceCreate {
+	if t != nil {
+		xsc.SetDeletedAt(*t)
+	}
+	return xsc
+}
+
+// SetXunjiID sets the "xunji_id" field.
+func (xsc *XunjiServiceCreate) SetXunjiID(u uint64) *XunjiServiceCreate {
+	xsc.mutation.SetXunjiID(u)
+	return xsc
+}
+
+// SetAgentID sets the "agent_id" field.
+func (xsc *XunjiServiceCreate) SetAgentID(u uint64) *XunjiServiceCreate {
+	xsc.mutation.SetAgentID(u)
+	return xsc
+}
+
+// SetNillableAgentID sets the "agent_id" field if the given value is not nil.
+func (xsc *XunjiServiceCreate) SetNillableAgentID(u *uint64) *XunjiServiceCreate {
+	if u != nil {
+		xsc.SetAgentID(*u)
+	}
+	return xsc
+}
+
+// SetOrganizationID sets the "organization_id" field.
+func (xsc *XunjiServiceCreate) SetOrganizationID(u uint64) *XunjiServiceCreate {
+	xsc.mutation.SetOrganizationID(u)
+	return xsc
+}
+
+// SetWxid sets the "wxid" field.
+func (xsc *XunjiServiceCreate) SetWxid(s string) *XunjiServiceCreate {
+	xsc.mutation.SetWxid(s)
+	return xsc
+}
+
+// SetAPIBase sets the "api_base" field.
+func (xsc *XunjiServiceCreate) SetAPIBase(s string) *XunjiServiceCreate {
+	xsc.mutation.SetAPIBase(s)
+	return xsc
+}
+
+// SetNillableAPIBase sets the "api_base" field if the given value is not nil.
+func (xsc *XunjiServiceCreate) SetNillableAPIBase(s *string) *XunjiServiceCreate {
+	if s != nil {
+		xsc.SetAPIBase(*s)
+	}
+	return xsc
+}
+
+// SetAPIKey sets the "api_key" field.
+func (xsc *XunjiServiceCreate) SetAPIKey(s string) *XunjiServiceCreate {
+	xsc.mutation.SetAPIKey(s)
+	return xsc
+}
+
+// SetNillableAPIKey sets the "api_key" field if the given value is not nil.
+func (xsc *XunjiServiceCreate) SetNillableAPIKey(s *string) *XunjiServiceCreate {
+	if s != nil {
+		xsc.SetAPIKey(*s)
+	}
+	return xsc
+}
+
+// SetID sets the "id" field.
+func (xsc *XunjiServiceCreate) SetID(u uint64) *XunjiServiceCreate {
+	xsc.mutation.SetID(u)
+	return xsc
+}
+
+// SetAgent sets the "agent" edge to the Agent entity.
+func (xsc *XunjiServiceCreate) SetAgent(a *Agent) *XunjiServiceCreate {
+	return xsc.SetAgentID(a.ID)
+}
+
+// Mutation returns the XunjiServiceMutation object of the builder.
+func (xsc *XunjiServiceCreate) Mutation() *XunjiServiceMutation {
+	return xsc.mutation
+}
+
+// Save creates the XunjiService in the database.
+func (xsc *XunjiServiceCreate) Save(ctx context.Context) (*XunjiService, error) {
+	if err := xsc.defaults(); err != nil {
+		return nil, err
+	}
+	return withHooks(ctx, xsc.sqlSave, xsc.mutation, xsc.hooks)
+}
+
+// SaveX calls Save and panics if Save returns an error.
+func (xsc *XunjiServiceCreate) SaveX(ctx context.Context) *XunjiService {
+	v, err := xsc.Save(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return v
+}
+
+// Exec executes the query.
+func (xsc *XunjiServiceCreate) Exec(ctx context.Context) error {
+	_, err := xsc.Save(ctx)
+	return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (xsc *XunjiServiceCreate) ExecX(ctx context.Context) {
+	if err := xsc.Exec(ctx); err != nil {
+		panic(err)
+	}
+}
+
+// defaults sets the default values of the builder before save.
+func (xsc *XunjiServiceCreate) defaults() error {
+	if _, ok := xsc.mutation.CreatedAt(); !ok {
+		if xunjiservice.DefaultCreatedAt == nil {
+			return fmt.Errorf("ent: uninitialized xunjiservice.DefaultCreatedAt (forgotten import ent/runtime?)")
+		}
+		v := xunjiservice.DefaultCreatedAt()
+		xsc.mutation.SetCreatedAt(v)
+	}
+	if _, ok := xsc.mutation.UpdatedAt(); !ok {
+		if xunjiservice.DefaultUpdatedAt == nil {
+			return fmt.Errorf("ent: uninitialized xunjiservice.DefaultUpdatedAt (forgotten import ent/runtime?)")
+		}
+		v := xunjiservice.DefaultUpdatedAt()
+		xsc.mutation.SetUpdatedAt(v)
+	}
+	if _, ok := xsc.mutation.Status(); !ok {
+		v := xunjiservice.DefaultStatus
+		xsc.mutation.SetStatus(v)
+	}
+	if _, ok := xsc.mutation.AgentID(); !ok {
+		v := xunjiservice.DefaultAgentID
+		xsc.mutation.SetAgentID(v)
+	}
+	if _, ok := xsc.mutation.APIBase(); !ok {
+		v := xunjiservice.DefaultAPIBase
+		xsc.mutation.SetAPIBase(v)
+	}
+	if _, ok := xsc.mutation.APIKey(); !ok {
+		v := xunjiservice.DefaultAPIKey
+		xsc.mutation.SetAPIKey(v)
+	}
+	return nil
+}
+
+// check runs all checks and user-defined validators on the builder.
+func (xsc *XunjiServiceCreate) check() error {
+	if _, ok := xsc.mutation.CreatedAt(); !ok {
+		return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "XunjiService.created_at"`)}
+	}
+	if _, ok := xsc.mutation.UpdatedAt(); !ok {
+		return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "XunjiService.updated_at"`)}
+	}
+	if _, ok := xsc.mutation.XunjiID(); !ok {
+		return &ValidationError{Name: "xunji_id", err: errors.New(`ent: missing required field "XunjiService.xunji_id"`)}
+	}
+	if _, ok := xsc.mutation.AgentID(); !ok {
+		return &ValidationError{Name: "agent_id", err: errors.New(`ent: missing required field "XunjiService.agent_id"`)}
+	}
+	if _, ok := xsc.mutation.OrganizationID(); !ok {
+		return &ValidationError{Name: "organization_id", err: errors.New(`ent: missing required field "XunjiService.organization_id"`)}
+	}
+	if v, ok := xsc.mutation.OrganizationID(); ok {
+		if err := xunjiservice.OrganizationIDValidator(v); err != nil {
+			return &ValidationError{Name: "organization_id", err: fmt.Errorf(`ent: validator failed for field "XunjiService.organization_id": %w`, err)}
+		}
+	}
+	if _, ok := xsc.mutation.Wxid(); !ok {
+		return &ValidationError{Name: "wxid", err: errors.New(`ent: missing required field "XunjiService.wxid"`)}
+	}
+	if _, ok := xsc.mutation.AgentID(); !ok {
+		return &ValidationError{Name: "agent", err: errors.New(`ent: missing required edge "XunjiService.agent"`)}
+	}
+	return nil
+}
+
+func (xsc *XunjiServiceCreate) sqlSave(ctx context.Context) (*XunjiService, error) {
+	if err := xsc.check(); err != nil {
+		return nil, err
+	}
+	_node, _spec := xsc.createSpec()
+	if err := sqlgraph.CreateNode(ctx, xsc.driver, _spec); err != nil {
+		if sqlgraph.IsConstraintError(err) {
+			err = &ConstraintError{msg: err.Error(), wrap: err}
+		}
+		return nil, err
+	}
+	if _spec.ID.Value != _node.ID {
+		id := _spec.ID.Value.(int64)
+		_node.ID = uint64(id)
+	}
+	xsc.mutation.id = &_node.ID
+	xsc.mutation.done = true
+	return _node, nil
+}
+
+func (xsc *XunjiServiceCreate) createSpec() (*XunjiService, *sqlgraph.CreateSpec) {
+	var (
+		_node = &XunjiService{config: xsc.config}
+		_spec = sqlgraph.NewCreateSpec(xunjiservice.Table, sqlgraph.NewFieldSpec(xunjiservice.FieldID, field.TypeUint64))
+	)
+	_spec.OnConflict = xsc.conflict
+	if id, ok := xsc.mutation.ID(); ok {
+		_node.ID = id
+		_spec.ID.Value = id
+	}
+	if value, ok := xsc.mutation.CreatedAt(); ok {
+		_spec.SetField(xunjiservice.FieldCreatedAt, field.TypeTime, value)
+		_node.CreatedAt = value
+	}
+	if value, ok := xsc.mutation.UpdatedAt(); ok {
+		_spec.SetField(xunjiservice.FieldUpdatedAt, field.TypeTime, value)
+		_node.UpdatedAt = value
+	}
+	if value, ok := xsc.mutation.Status(); ok {
+		_spec.SetField(xunjiservice.FieldStatus, field.TypeUint8, value)
+		_node.Status = value
+	}
+	if value, ok := xsc.mutation.DeletedAt(); ok {
+		_spec.SetField(xunjiservice.FieldDeletedAt, field.TypeTime, value)
+		_node.DeletedAt = value
+	}
+	if value, ok := xsc.mutation.XunjiID(); ok {
+		_spec.SetField(xunjiservice.FieldXunjiID, field.TypeUint64, value)
+		_node.XunjiID = value
+	}
+	if value, ok := xsc.mutation.OrganizationID(); ok {
+		_spec.SetField(xunjiservice.FieldOrganizationID, field.TypeUint64, value)
+		_node.OrganizationID = value
+	}
+	if value, ok := xsc.mutation.Wxid(); ok {
+		_spec.SetField(xunjiservice.FieldWxid, field.TypeString, value)
+		_node.Wxid = value
+	}
+	if value, ok := xsc.mutation.APIBase(); ok {
+		_spec.SetField(xunjiservice.FieldAPIBase, field.TypeString, value)
+		_node.APIBase = value
+	}
+	if value, ok := xsc.mutation.APIKey(); ok {
+		_spec.SetField(xunjiservice.FieldAPIKey, field.TypeString, value)
+		_node.APIKey = value
+	}
+	if nodes := xsc.mutation.AgentIDs(); len(nodes) > 0 {
+		edge := &sqlgraph.EdgeSpec{
+			Rel:     sqlgraph.M2O,
+			Inverse: true,
+			Table:   xunjiservice.AgentTable,
+			Columns: []string{xunjiservice.AgentColumn},
+			Bidi:    false,
+			Target: &sqlgraph.EdgeTarget{
+				IDSpec: sqlgraph.NewFieldSpec(agent.FieldID, field.TypeUint64),
+			},
+		}
+		for _, k := range nodes {
+			edge.Target.Nodes = append(edge.Target.Nodes, k)
+		}
+		_node.AgentID = nodes[0]
+		_spec.Edges = append(_spec.Edges, edge)
+	}
+	return _node, _spec
+}
+
+// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
+// of the `INSERT` statement. For example:
+//
+//	client.XunjiService.Create().
+//		SetCreatedAt(v).
+//		OnConflict(
+//			// Update the row with the new values
+//			// the was proposed for insertion.
+//			sql.ResolveWithNewValues(),
+//		).
+//		// Override some of the fields with custom
+//		// update values.
+//		Update(func(u *ent.XunjiServiceUpsert) {
+//			SetCreatedAt(v+v).
+//		}).
+//		Exec(ctx)
+func (xsc *XunjiServiceCreate) OnConflict(opts ...sql.ConflictOption) *XunjiServiceUpsertOne {
+	xsc.conflict = opts
+	return &XunjiServiceUpsertOne{
+		create: xsc,
+	}
+}
+
+// OnConflictColumns calls `OnConflict` and configures the columns
+// as conflict target. Using this option is equivalent to using:
+//
+//	client.XunjiService.Create().
+//		OnConflict(sql.ConflictColumns(columns...)).
+//		Exec(ctx)
+func (xsc *XunjiServiceCreate) OnConflictColumns(columns ...string) *XunjiServiceUpsertOne {
+	xsc.conflict = append(xsc.conflict, sql.ConflictColumns(columns...))
+	return &XunjiServiceUpsertOne{
+		create: xsc,
+	}
+}
+
+type (
+	// XunjiServiceUpsertOne is the builder for "upsert"-ing
+	//  one XunjiService node.
+	XunjiServiceUpsertOne struct {
+		create *XunjiServiceCreate
+	}
+
+	// XunjiServiceUpsert is the "OnConflict" setter.
+	XunjiServiceUpsert struct {
+		*sql.UpdateSet
+	}
+)
+
+// SetUpdatedAt sets the "updated_at" field.
+func (u *XunjiServiceUpsert) SetUpdatedAt(v time.Time) *XunjiServiceUpsert {
+	u.Set(xunjiservice.FieldUpdatedAt, v)
+	return u
+}
+
+// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
+func (u *XunjiServiceUpsert) UpdateUpdatedAt() *XunjiServiceUpsert {
+	u.SetExcluded(xunjiservice.FieldUpdatedAt)
+	return u
+}
+
+// SetStatus sets the "status" field.
+func (u *XunjiServiceUpsert) SetStatus(v uint8) *XunjiServiceUpsert {
+	u.Set(xunjiservice.FieldStatus, v)
+	return u
+}
+
+// UpdateStatus sets the "status" field to the value that was provided on create.
+func (u *XunjiServiceUpsert) UpdateStatus() *XunjiServiceUpsert {
+	u.SetExcluded(xunjiservice.FieldStatus)
+	return u
+}
+
+// AddStatus adds v to the "status" field.
+func (u *XunjiServiceUpsert) AddStatus(v uint8) *XunjiServiceUpsert {
+	u.Add(xunjiservice.FieldStatus, v)
+	return u
+}
+
+// ClearStatus clears the value of the "status" field.
+func (u *XunjiServiceUpsert) ClearStatus() *XunjiServiceUpsert {
+	u.SetNull(xunjiservice.FieldStatus)
+	return u
+}
+
+// SetDeletedAt sets the "deleted_at" field.
+func (u *XunjiServiceUpsert) SetDeletedAt(v time.Time) *XunjiServiceUpsert {
+	u.Set(xunjiservice.FieldDeletedAt, v)
+	return u
+}
+
+// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
+func (u *XunjiServiceUpsert) UpdateDeletedAt() *XunjiServiceUpsert {
+	u.SetExcluded(xunjiservice.FieldDeletedAt)
+	return u
+}
+
+// ClearDeletedAt clears the value of the "deleted_at" field.
+func (u *XunjiServiceUpsert) ClearDeletedAt() *XunjiServiceUpsert {
+	u.SetNull(xunjiservice.FieldDeletedAt)
+	return u
+}
+
+// SetXunjiID sets the "xunji_id" field.
+func (u *XunjiServiceUpsert) SetXunjiID(v uint64) *XunjiServiceUpsert {
+	u.Set(xunjiservice.FieldXunjiID, v)
+	return u
+}
+
+// UpdateXunjiID sets the "xunji_id" field to the value that was provided on create.
+func (u *XunjiServiceUpsert) UpdateXunjiID() *XunjiServiceUpsert {
+	u.SetExcluded(xunjiservice.FieldXunjiID)
+	return u
+}
+
+// AddXunjiID adds v to the "xunji_id" field.
+func (u *XunjiServiceUpsert) AddXunjiID(v uint64) *XunjiServiceUpsert {
+	u.Add(xunjiservice.FieldXunjiID, v)
+	return u
+}
+
+// SetAgentID sets the "agent_id" field.
+func (u *XunjiServiceUpsert) SetAgentID(v uint64) *XunjiServiceUpsert {
+	u.Set(xunjiservice.FieldAgentID, v)
+	return u
+}
+
+// UpdateAgentID sets the "agent_id" field to the value that was provided on create.
+func (u *XunjiServiceUpsert) UpdateAgentID() *XunjiServiceUpsert {
+	u.SetExcluded(xunjiservice.FieldAgentID)
+	return u
+}
+
+// SetOrganizationID sets the "organization_id" field.
+func (u *XunjiServiceUpsert) SetOrganizationID(v uint64) *XunjiServiceUpsert {
+	u.Set(xunjiservice.FieldOrganizationID, v)
+	return u
+}
+
+// UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
+func (u *XunjiServiceUpsert) UpdateOrganizationID() *XunjiServiceUpsert {
+	u.SetExcluded(xunjiservice.FieldOrganizationID)
+	return u
+}
+
+// AddOrganizationID adds v to the "organization_id" field.
+func (u *XunjiServiceUpsert) AddOrganizationID(v uint64) *XunjiServiceUpsert {
+	u.Add(xunjiservice.FieldOrganizationID, v)
+	return u
+}
+
+// SetWxid sets the "wxid" field.
+func (u *XunjiServiceUpsert) SetWxid(v string) *XunjiServiceUpsert {
+	u.Set(xunjiservice.FieldWxid, v)
+	return u
+}
+
+// UpdateWxid sets the "wxid" field to the value that was provided on create.
+func (u *XunjiServiceUpsert) UpdateWxid() *XunjiServiceUpsert {
+	u.SetExcluded(xunjiservice.FieldWxid)
+	return u
+}
+
+// SetAPIBase sets the "api_base" field.
+func (u *XunjiServiceUpsert) SetAPIBase(v string) *XunjiServiceUpsert {
+	u.Set(xunjiservice.FieldAPIBase, v)
+	return u
+}
+
+// UpdateAPIBase sets the "api_base" field to the value that was provided on create.
+func (u *XunjiServiceUpsert) UpdateAPIBase() *XunjiServiceUpsert {
+	u.SetExcluded(xunjiservice.FieldAPIBase)
+	return u
+}
+
+// ClearAPIBase clears the value of the "api_base" field.
+func (u *XunjiServiceUpsert) ClearAPIBase() *XunjiServiceUpsert {
+	u.SetNull(xunjiservice.FieldAPIBase)
+	return u
+}
+
+// SetAPIKey sets the "api_key" field.
+func (u *XunjiServiceUpsert) SetAPIKey(v string) *XunjiServiceUpsert {
+	u.Set(xunjiservice.FieldAPIKey, v)
+	return u
+}
+
+// UpdateAPIKey sets the "api_key" field to the value that was provided on create.
+func (u *XunjiServiceUpsert) UpdateAPIKey() *XunjiServiceUpsert {
+	u.SetExcluded(xunjiservice.FieldAPIKey)
+	return u
+}
+
+// ClearAPIKey clears the value of the "api_key" field.
+func (u *XunjiServiceUpsert) ClearAPIKey() *XunjiServiceUpsert {
+	u.SetNull(xunjiservice.FieldAPIKey)
+	return u
+}
+
+// UpdateNewValues updates the mutable fields using the new values that were set on create except the ID field.
+// Using this option is equivalent to using:
+//
+//	client.XunjiService.Create().
+//		OnConflict(
+//			sql.ResolveWithNewValues(),
+//			sql.ResolveWith(func(u *sql.UpdateSet) {
+//				u.SetIgnore(xunjiservice.FieldID)
+//			}),
+//		).
+//		Exec(ctx)
+func (u *XunjiServiceUpsertOne) UpdateNewValues() *XunjiServiceUpsertOne {
+	u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
+	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
+		if _, exists := u.create.mutation.ID(); exists {
+			s.SetIgnore(xunjiservice.FieldID)
+		}
+		if _, exists := u.create.mutation.CreatedAt(); exists {
+			s.SetIgnore(xunjiservice.FieldCreatedAt)
+		}
+	}))
+	return u
+}
+
+// Ignore sets each column to itself in case of conflict.
+// Using this option is equivalent to using:
+//
+//	client.XunjiService.Create().
+//	    OnConflict(sql.ResolveWithIgnore()).
+//	    Exec(ctx)
+func (u *XunjiServiceUpsertOne) Ignore() *XunjiServiceUpsertOne {
+	u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
+	return u
+}
+
+// DoNothing configures the conflict_action to `DO NOTHING`.
+// Supported only by SQLite and PostgreSQL.
+func (u *XunjiServiceUpsertOne) DoNothing() *XunjiServiceUpsertOne {
+	u.create.conflict = append(u.create.conflict, sql.DoNothing())
+	return u
+}
+
+// Update allows overriding fields `UPDATE` values. See the XunjiServiceCreate.OnConflict
+// documentation for more info.
+func (u *XunjiServiceUpsertOne) Update(set func(*XunjiServiceUpsert)) *XunjiServiceUpsertOne {
+	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
+		set(&XunjiServiceUpsert{UpdateSet: update})
+	}))
+	return u
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (u *XunjiServiceUpsertOne) SetUpdatedAt(v time.Time) *XunjiServiceUpsertOne {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.SetUpdatedAt(v)
+	})
+}
+
+// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
+func (u *XunjiServiceUpsertOne) UpdateUpdatedAt() *XunjiServiceUpsertOne {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.UpdateUpdatedAt()
+	})
+}
+
+// SetStatus sets the "status" field.
+func (u *XunjiServiceUpsertOne) SetStatus(v uint8) *XunjiServiceUpsertOne {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.SetStatus(v)
+	})
+}
+
+// AddStatus adds v to the "status" field.
+func (u *XunjiServiceUpsertOne) AddStatus(v uint8) *XunjiServiceUpsertOne {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.AddStatus(v)
+	})
+}
+
+// UpdateStatus sets the "status" field to the value that was provided on create.
+func (u *XunjiServiceUpsertOne) UpdateStatus() *XunjiServiceUpsertOne {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.UpdateStatus()
+	})
+}
+
+// ClearStatus clears the value of the "status" field.
+func (u *XunjiServiceUpsertOne) ClearStatus() *XunjiServiceUpsertOne {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.ClearStatus()
+	})
+}
+
+// SetDeletedAt sets the "deleted_at" field.
+func (u *XunjiServiceUpsertOne) SetDeletedAt(v time.Time) *XunjiServiceUpsertOne {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.SetDeletedAt(v)
+	})
+}
+
+// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
+func (u *XunjiServiceUpsertOne) UpdateDeletedAt() *XunjiServiceUpsertOne {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.UpdateDeletedAt()
+	})
+}
+
+// ClearDeletedAt clears the value of the "deleted_at" field.
+func (u *XunjiServiceUpsertOne) ClearDeletedAt() *XunjiServiceUpsertOne {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.ClearDeletedAt()
+	})
+}
+
+// SetXunjiID sets the "xunji_id" field.
+func (u *XunjiServiceUpsertOne) SetXunjiID(v uint64) *XunjiServiceUpsertOne {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.SetXunjiID(v)
+	})
+}
+
+// AddXunjiID adds v to the "xunji_id" field.
+func (u *XunjiServiceUpsertOne) AddXunjiID(v uint64) *XunjiServiceUpsertOne {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.AddXunjiID(v)
+	})
+}
+
+// UpdateXunjiID sets the "xunji_id" field to the value that was provided on create.
+func (u *XunjiServiceUpsertOne) UpdateXunjiID() *XunjiServiceUpsertOne {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.UpdateXunjiID()
+	})
+}
+
+// SetAgentID sets the "agent_id" field.
+func (u *XunjiServiceUpsertOne) SetAgentID(v uint64) *XunjiServiceUpsertOne {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.SetAgentID(v)
+	})
+}
+
+// UpdateAgentID sets the "agent_id" field to the value that was provided on create.
+func (u *XunjiServiceUpsertOne) UpdateAgentID() *XunjiServiceUpsertOne {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.UpdateAgentID()
+	})
+}
+
+// SetOrganizationID sets the "organization_id" field.
+func (u *XunjiServiceUpsertOne) SetOrganizationID(v uint64) *XunjiServiceUpsertOne {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.SetOrganizationID(v)
+	})
+}
+
+// AddOrganizationID adds v to the "organization_id" field.
+func (u *XunjiServiceUpsertOne) AddOrganizationID(v uint64) *XunjiServiceUpsertOne {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.AddOrganizationID(v)
+	})
+}
+
+// UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
+func (u *XunjiServiceUpsertOne) UpdateOrganizationID() *XunjiServiceUpsertOne {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.UpdateOrganizationID()
+	})
+}
+
+// SetWxid sets the "wxid" field.
+func (u *XunjiServiceUpsertOne) SetWxid(v string) *XunjiServiceUpsertOne {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.SetWxid(v)
+	})
+}
+
+// UpdateWxid sets the "wxid" field to the value that was provided on create.
+func (u *XunjiServiceUpsertOne) UpdateWxid() *XunjiServiceUpsertOne {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.UpdateWxid()
+	})
+}
+
+// SetAPIBase sets the "api_base" field.
+func (u *XunjiServiceUpsertOne) SetAPIBase(v string) *XunjiServiceUpsertOne {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.SetAPIBase(v)
+	})
+}
+
+// UpdateAPIBase sets the "api_base" field to the value that was provided on create.
+func (u *XunjiServiceUpsertOne) UpdateAPIBase() *XunjiServiceUpsertOne {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.UpdateAPIBase()
+	})
+}
+
+// ClearAPIBase clears the value of the "api_base" field.
+func (u *XunjiServiceUpsertOne) ClearAPIBase() *XunjiServiceUpsertOne {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.ClearAPIBase()
+	})
+}
+
+// SetAPIKey sets the "api_key" field.
+func (u *XunjiServiceUpsertOne) SetAPIKey(v string) *XunjiServiceUpsertOne {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.SetAPIKey(v)
+	})
+}
+
+// UpdateAPIKey sets the "api_key" field to the value that was provided on create.
+func (u *XunjiServiceUpsertOne) UpdateAPIKey() *XunjiServiceUpsertOne {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.UpdateAPIKey()
+	})
+}
+
+// ClearAPIKey clears the value of the "api_key" field.
+func (u *XunjiServiceUpsertOne) ClearAPIKey() *XunjiServiceUpsertOne {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.ClearAPIKey()
+	})
+}
+
+// Exec executes the query.
+func (u *XunjiServiceUpsertOne) Exec(ctx context.Context) error {
+	if len(u.create.conflict) == 0 {
+		return errors.New("ent: missing options for XunjiServiceCreate.OnConflict")
+	}
+	return u.create.Exec(ctx)
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (u *XunjiServiceUpsertOne) ExecX(ctx context.Context) {
+	if err := u.create.Exec(ctx); err != nil {
+		panic(err)
+	}
+}
+
+// Exec executes the UPSERT query and returns the inserted/updated ID.
+func (u *XunjiServiceUpsertOne) ID(ctx context.Context) (id uint64, err error) {
+	node, err := u.create.Save(ctx)
+	if err != nil {
+		return id, err
+	}
+	return node.ID, nil
+}
+
+// IDX is like ID, but panics if an error occurs.
+func (u *XunjiServiceUpsertOne) IDX(ctx context.Context) uint64 {
+	id, err := u.ID(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return id
+}
+
+// XunjiServiceCreateBulk is the builder for creating many XunjiService entities in bulk.
+type XunjiServiceCreateBulk struct {
+	config
+	err      error
+	builders []*XunjiServiceCreate
+	conflict []sql.ConflictOption
+}
+
+// Save creates the XunjiService entities in the database.
+func (xscb *XunjiServiceCreateBulk) Save(ctx context.Context) ([]*XunjiService, error) {
+	if xscb.err != nil {
+		return nil, xscb.err
+	}
+	specs := make([]*sqlgraph.CreateSpec, len(xscb.builders))
+	nodes := make([]*XunjiService, len(xscb.builders))
+	mutators := make([]Mutator, len(xscb.builders))
+	for i := range xscb.builders {
+		func(i int, root context.Context) {
+			builder := xscb.builders[i]
+			builder.defaults()
+			var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
+				mutation, ok := m.(*XunjiServiceMutation)
+				if !ok {
+					return nil, fmt.Errorf("unexpected mutation type %T", m)
+				}
+				if err := builder.check(); err != nil {
+					return nil, err
+				}
+				builder.mutation = mutation
+				var err error
+				nodes[i], specs[i] = builder.createSpec()
+				if i < len(mutators)-1 {
+					_, err = mutators[i+1].Mutate(root, xscb.builders[i+1].mutation)
+				} else {
+					spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
+					spec.OnConflict = xscb.conflict
+					// Invoke the actual operation on the latest mutation in the chain.
+					if err = sqlgraph.BatchCreate(ctx, xscb.driver, spec); err != nil {
+						if sqlgraph.IsConstraintError(err) {
+							err = &ConstraintError{msg: err.Error(), wrap: err}
+						}
+					}
+				}
+				if err != nil {
+					return nil, err
+				}
+				mutation.id = &nodes[i].ID
+				if specs[i].ID.Value != nil && nodes[i].ID == 0 {
+					id := specs[i].ID.Value.(int64)
+					nodes[i].ID = uint64(id)
+				}
+				mutation.done = true
+				return nodes[i], nil
+			})
+			for i := len(builder.hooks) - 1; i >= 0; i-- {
+				mut = builder.hooks[i](mut)
+			}
+			mutators[i] = mut
+		}(i, ctx)
+	}
+	if len(mutators) > 0 {
+		if _, err := mutators[0].Mutate(ctx, xscb.builders[0].mutation); err != nil {
+			return nil, err
+		}
+	}
+	return nodes, nil
+}
+
+// SaveX is like Save, but panics if an error occurs.
+func (xscb *XunjiServiceCreateBulk) SaveX(ctx context.Context) []*XunjiService {
+	v, err := xscb.Save(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return v
+}
+
+// Exec executes the query.
+func (xscb *XunjiServiceCreateBulk) Exec(ctx context.Context) error {
+	_, err := xscb.Save(ctx)
+	return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (xscb *XunjiServiceCreateBulk) ExecX(ctx context.Context) {
+	if err := xscb.Exec(ctx); err != nil {
+		panic(err)
+	}
+}
+
+// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
+// of the `INSERT` statement. For example:
+//
+//	client.XunjiService.CreateBulk(builders...).
+//		OnConflict(
+//			// Update the row with the new values
+//			// the was proposed for insertion.
+//			sql.ResolveWithNewValues(),
+//		).
+//		// Override some of the fields with custom
+//		// update values.
+//		Update(func(u *ent.XunjiServiceUpsert) {
+//			SetCreatedAt(v+v).
+//		}).
+//		Exec(ctx)
+func (xscb *XunjiServiceCreateBulk) OnConflict(opts ...sql.ConflictOption) *XunjiServiceUpsertBulk {
+	xscb.conflict = opts
+	return &XunjiServiceUpsertBulk{
+		create: xscb,
+	}
+}
+
+// OnConflictColumns calls `OnConflict` and configures the columns
+// as conflict target. Using this option is equivalent to using:
+//
+//	client.XunjiService.Create().
+//		OnConflict(sql.ConflictColumns(columns...)).
+//		Exec(ctx)
+func (xscb *XunjiServiceCreateBulk) OnConflictColumns(columns ...string) *XunjiServiceUpsertBulk {
+	xscb.conflict = append(xscb.conflict, sql.ConflictColumns(columns...))
+	return &XunjiServiceUpsertBulk{
+		create: xscb,
+	}
+}
+
+// XunjiServiceUpsertBulk is the builder for "upsert"-ing
+// a bulk of XunjiService nodes.
+type XunjiServiceUpsertBulk struct {
+	create *XunjiServiceCreateBulk
+}
+
+// UpdateNewValues updates the mutable fields using the new values that
+// were set on create. Using this option is equivalent to using:
+//
+//	client.XunjiService.Create().
+//		OnConflict(
+//			sql.ResolveWithNewValues(),
+//			sql.ResolveWith(func(u *sql.UpdateSet) {
+//				u.SetIgnore(xunjiservice.FieldID)
+//			}),
+//		).
+//		Exec(ctx)
+func (u *XunjiServiceUpsertBulk) UpdateNewValues() *XunjiServiceUpsertBulk {
+	u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
+	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
+		for _, b := range u.create.builders {
+			if _, exists := b.mutation.ID(); exists {
+				s.SetIgnore(xunjiservice.FieldID)
+			}
+			if _, exists := b.mutation.CreatedAt(); exists {
+				s.SetIgnore(xunjiservice.FieldCreatedAt)
+			}
+		}
+	}))
+	return u
+}
+
+// Ignore sets each column to itself in case of conflict.
+// Using this option is equivalent to using:
+//
+//	client.XunjiService.Create().
+//		OnConflict(sql.ResolveWithIgnore()).
+//		Exec(ctx)
+func (u *XunjiServiceUpsertBulk) Ignore() *XunjiServiceUpsertBulk {
+	u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
+	return u
+}
+
+// DoNothing configures the conflict_action to `DO NOTHING`.
+// Supported only by SQLite and PostgreSQL.
+func (u *XunjiServiceUpsertBulk) DoNothing() *XunjiServiceUpsertBulk {
+	u.create.conflict = append(u.create.conflict, sql.DoNothing())
+	return u
+}
+
+// Update allows overriding fields `UPDATE` values. See the XunjiServiceCreateBulk.OnConflict
+// documentation for more info.
+func (u *XunjiServiceUpsertBulk) Update(set func(*XunjiServiceUpsert)) *XunjiServiceUpsertBulk {
+	u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
+		set(&XunjiServiceUpsert{UpdateSet: update})
+	}))
+	return u
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (u *XunjiServiceUpsertBulk) SetUpdatedAt(v time.Time) *XunjiServiceUpsertBulk {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.SetUpdatedAt(v)
+	})
+}
+
+// UpdateUpdatedAt sets the "updated_at" field to the value that was provided on create.
+func (u *XunjiServiceUpsertBulk) UpdateUpdatedAt() *XunjiServiceUpsertBulk {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.UpdateUpdatedAt()
+	})
+}
+
+// SetStatus sets the "status" field.
+func (u *XunjiServiceUpsertBulk) SetStatus(v uint8) *XunjiServiceUpsertBulk {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.SetStatus(v)
+	})
+}
+
+// AddStatus adds v to the "status" field.
+func (u *XunjiServiceUpsertBulk) AddStatus(v uint8) *XunjiServiceUpsertBulk {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.AddStatus(v)
+	})
+}
+
+// UpdateStatus sets the "status" field to the value that was provided on create.
+func (u *XunjiServiceUpsertBulk) UpdateStatus() *XunjiServiceUpsertBulk {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.UpdateStatus()
+	})
+}
+
+// ClearStatus clears the value of the "status" field.
+func (u *XunjiServiceUpsertBulk) ClearStatus() *XunjiServiceUpsertBulk {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.ClearStatus()
+	})
+}
+
+// SetDeletedAt sets the "deleted_at" field.
+func (u *XunjiServiceUpsertBulk) SetDeletedAt(v time.Time) *XunjiServiceUpsertBulk {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.SetDeletedAt(v)
+	})
+}
+
+// UpdateDeletedAt sets the "deleted_at" field to the value that was provided on create.
+func (u *XunjiServiceUpsertBulk) UpdateDeletedAt() *XunjiServiceUpsertBulk {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.UpdateDeletedAt()
+	})
+}
+
+// ClearDeletedAt clears the value of the "deleted_at" field.
+func (u *XunjiServiceUpsertBulk) ClearDeletedAt() *XunjiServiceUpsertBulk {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.ClearDeletedAt()
+	})
+}
+
+// SetXunjiID sets the "xunji_id" field.
+func (u *XunjiServiceUpsertBulk) SetXunjiID(v uint64) *XunjiServiceUpsertBulk {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.SetXunjiID(v)
+	})
+}
+
+// AddXunjiID adds v to the "xunji_id" field.
+func (u *XunjiServiceUpsertBulk) AddXunjiID(v uint64) *XunjiServiceUpsertBulk {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.AddXunjiID(v)
+	})
+}
+
+// UpdateXunjiID sets the "xunji_id" field to the value that was provided on create.
+func (u *XunjiServiceUpsertBulk) UpdateXunjiID() *XunjiServiceUpsertBulk {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.UpdateXunjiID()
+	})
+}
+
+// SetAgentID sets the "agent_id" field.
+func (u *XunjiServiceUpsertBulk) SetAgentID(v uint64) *XunjiServiceUpsertBulk {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.SetAgentID(v)
+	})
+}
+
+// UpdateAgentID sets the "agent_id" field to the value that was provided on create.
+func (u *XunjiServiceUpsertBulk) UpdateAgentID() *XunjiServiceUpsertBulk {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.UpdateAgentID()
+	})
+}
+
+// SetOrganizationID sets the "organization_id" field.
+func (u *XunjiServiceUpsertBulk) SetOrganizationID(v uint64) *XunjiServiceUpsertBulk {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.SetOrganizationID(v)
+	})
+}
+
+// AddOrganizationID adds v to the "organization_id" field.
+func (u *XunjiServiceUpsertBulk) AddOrganizationID(v uint64) *XunjiServiceUpsertBulk {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.AddOrganizationID(v)
+	})
+}
+
+// UpdateOrganizationID sets the "organization_id" field to the value that was provided on create.
+func (u *XunjiServiceUpsertBulk) UpdateOrganizationID() *XunjiServiceUpsertBulk {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.UpdateOrganizationID()
+	})
+}
+
+// SetWxid sets the "wxid" field.
+func (u *XunjiServiceUpsertBulk) SetWxid(v string) *XunjiServiceUpsertBulk {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.SetWxid(v)
+	})
+}
+
+// UpdateWxid sets the "wxid" field to the value that was provided on create.
+func (u *XunjiServiceUpsertBulk) UpdateWxid() *XunjiServiceUpsertBulk {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.UpdateWxid()
+	})
+}
+
+// SetAPIBase sets the "api_base" field.
+func (u *XunjiServiceUpsertBulk) SetAPIBase(v string) *XunjiServiceUpsertBulk {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.SetAPIBase(v)
+	})
+}
+
+// UpdateAPIBase sets the "api_base" field to the value that was provided on create.
+func (u *XunjiServiceUpsertBulk) UpdateAPIBase() *XunjiServiceUpsertBulk {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.UpdateAPIBase()
+	})
+}
+
+// ClearAPIBase clears the value of the "api_base" field.
+func (u *XunjiServiceUpsertBulk) ClearAPIBase() *XunjiServiceUpsertBulk {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.ClearAPIBase()
+	})
+}
+
+// SetAPIKey sets the "api_key" field.
+func (u *XunjiServiceUpsertBulk) SetAPIKey(v string) *XunjiServiceUpsertBulk {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.SetAPIKey(v)
+	})
+}
+
+// UpdateAPIKey sets the "api_key" field to the value that was provided on create.
+func (u *XunjiServiceUpsertBulk) UpdateAPIKey() *XunjiServiceUpsertBulk {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.UpdateAPIKey()
+	})
+}
+
+// ClearAPIKey clears the value of the "api_key" field.
+func (u *XunjiServiceUpsertBulk) ClearAPIKey() *XunjiServiceUpsertBulk {
+	return u.Update(func(s *XunjiServiceUpsert) {
+		s.ClearAPIKey()
+	})
+}
+
+// Exec executes the query.
+func (u *XunjiServiceUpsertBulk) Exec(ctx context.Context) error {
+	if u.create.err != nil {
+		return u.create.err
+	}
+	for i, b := range u.create.builders {
+		if len(b.conflict) != 0 {
+			return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the XunjiServiceCreateBulk instead", i)
+		}
+	}
+	if len(u.create.conflict) == 0 {
+		return errors.New("ent: missing options for XunjiServiceCreateBulk.OnConflict")
+	}
+	return u.create.Exec(ctx)
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (u *XunjiServiceUpsertBulk) ExecX(ctx context.Context) {
+	if err := u.create.Exec(ctx); err != nil {
+		panic(err)
+	}
+}

+ 88 - 0
ent/xunjiservice_delete.go

@@ -0,0 +1,88 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+	"context"
+	"wechat-api/ent/predicate"
+	"wechat-api/ent/xunjiservice"
+
+	"entgo.io/ent/dialect/sql"
+	"entgo.io/ent/dialect/sql/sqlgraph"
+	"entgo.io/ent/schema/field"
+)
+
+// XunjiServiceDelete is the builder for deleting a XunjiService entity.
+type XunjiServiceDelete struct {
+	config
+	hooks    []Hook
+	mutation *XunjiServiceMutation
+}
+
+// Where appends a list predicates to the XunjiServiceDelete builder.
+func (xsd *XunjiServiceDelete) Where(ps ...predicate.XunjiService) *XunjiServiceDelete {
+	xsd.mutation.Where(ps...)
+	return xsd
+}
+
+// Exec executes the deletion query and returns how many vertices were deleted.
+func (xsd *XunjiServiceDelete) Exec(ctx context.Context) (int, error) {
+	return withHooks(ctx, xsd.sqlExec, xsd.mutation, xsd.hooks)
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (xsd *XunjiServiceDelete) ExecX(ctx context.Context) int {
+	n, err := xsd.Exec(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return n
+}
+
+func (xsd *XunjiServiceDelete) sqlExec(ctx context.Context) (int, error) {
+	_spec := sqlgraph.NewDeleteSpec(xunjiservice.Table, sqlgraph.NewFieldSpec(xunjiservice.FieldID, field.TypeUint64))
+	if ps := xsd.mutation.predicates; len(ps) > 0 {
+		_spec.Predicate = func(selector *sql.Selector) {
+			for i := range ps {
+				ps[i](selector)
+			}
+		}
+	}
+	affected, err := sqlgraph.DeleteNodes(ctx, xsd.driver, _spec)
+	if err != nil && sqlgraph.IsConstraintError(err) {
+		err = &ConstraintError{msg: err.Error(), wrap: err}
+	}
+	xsd.mutation.done = true
+	return affected, err
+}
+
+// XunjiServiceDeleteOne is the builder for deleting a single XunjiService entity.
+type XunjiServiceDeleteOne struct {
+	xsd *XunjiServiceDelete
+}
+
+// Where appends a list predicates to the XunjiServiceDelete builder.
+func (xsdo *XunjiServiceDeleteOne) Where(ps ...predicate.XunjiService) *XunjiServiceDeleteOne {
+	xsdo.xsd.mutation.Where(ps...)
+	return xsdo
+}
+
+// Exec executes the deletion query.
+func (xsdo *XunjiServiceDeleteOne) Exec(ctx context.Context) error {
+	n, err := xsdo.xsd.Exec(ctx)
+	switch {
+	case err != nil:
+		return err
+	case n == 0:
+		return &NotFoundError{xunjiservice.Label}
+	default:
+		return nil
+	}
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (xsdo *XunjiServiceDeleteOne) ExecX(ctx context.Context) {
+	if err := xsdo.Exec(ctx); err != nil {
+		panic(err)
+	}
+}

+ 605 - 0
ent/xunjiservice_query.go

@@ -0,0 +1,605 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+	"context"
+	"fmt"
+	"math"
+	"wechat-api/ent/agent"
+	"wechat-api/ent/predicate"
+	"wechat-api/ent/xunjiservice"
+
+	"entgo.io/ent/dialect/sql"
+	"entgo.io/ent/dialect/sql/sqlgraph"
+	"entgo.io/ent/schema/field"
+)
+
+// XunjiServiceQuery is the builder for querying XunjiService entities.
+type XunjiServiceQuery struct {
+	config
+	ctx        *QueryContext
+	order      []xunjiservice.OrderOption
+	inters     []Interceptor
+	predicates []predicate.XunjiService
+	withAgent  *AgentQuery
+	// intermediate query (i.e. traversal path).
+	sql  *sql.Selector
+	path func(context.Context) (*sql.Selector, error)
+}
+
+// Where adds a new predicate for the XunjiServiceQuery builder.
+func (xsq *XunjiServiceQuery) Where(ps ...predicate.XunjiService) *XunjiServiceQuery {
+	xsq.predicates = append(xsq.predicates, ps...)
+	return xsq
+}
+
+// Limit the number of records to be returned by this query.
+func (xsq *XunjiServiceQuery) Limit(limit int) *XunjiServiceQuery {
+	xsq.ctx.Limit = &limit
+	return xsq
+}
+
+// Offset to start from.
+func (xsq *XunjiServiceQuery) Offset(offset int) *XunjiServiceQuery {
+	xsq.ctx.Offset = &offset
+	return xsq
+}
+
+// Unique configures the query builder to filter duplicate records on query.
+// By default, unique is set to true, and can be disabled using this method.
+func (xsq *XunjiServiceQuery) Unique(unique bool) *XunjiServiceQuery {
+	xsq.ctx.Unique = &unique
+	return xsq
+}
+
+// Order specifies how the records should be ordered.
+func (xsq *XunjiServiceQuery) Order(o ...xunjiservice.OrderOption) *XunjiServiceQuery {
+	xsq.order = append(xsq.order, o...)
+	return xsq
+}
+
+// QueryAgent chains the current query on the "agent" edge.
+func (xsq *XunjiServiceQuery) QueryAgent() *AgentQuery {
+	query := (&AgentClient{config: xsq.config}).Query()
+	query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
+		if err := xsq.prepareQuery(ctx); err != nil {
+			return nil, err
+		}
+		selector := xsq.sqlQuery(ctx)
+		if err := selector.Err(); err != nil {
+			return nil, err
+		}
+		step := sqlgraph.NewStep(
+			sqlgraph.From(xunjiservice.Table, xunjiservice.FieldID, selector),
+			sqlgraph.To(agent.Table, agent.FieldID),
+			sqlgraph.Edge(sqlgraph.M2O, true, xunjiservice.AgentTable, xunjiservice.AgentColumn),
+		)
+		fromU = sqlgraph.SetNeighbors(xsq.driver.Dialect(), step)
+		return fromU, nil
+	}
+	return query
+}
+
+// First returns the first XunjiService entity from the query.
+// Returns a *NotFoundError when no XunjiService was found.
+func (xsq *XunjiServiceQuery) First(ctx context.Context) (*XunjiService, error) {
+	nodes, err := xsq.Limit(1).All(setContextOp(ctx, xsq.ctx, "First"))
+	if err != nil {
+		return nil, err
+	}
+	if len(nodes) == 0 {
+		return nil, &NotFoundError{xunjiservice.Label}
+	}
+	return nodes[0], nil
+}
+
+// FirstX is like First, but panics if an error occurs.
+func (xsq *XunjiServiceQuery) FirstX(ctx context.Context) *XunjiService {
+	node, err := xsq.First(ctx)
+	if err != nil && !IsNotFound(err) {
+		panic(err)
+	}
+	return node
+}
+
+// FirstID returns the first XunjiService ID from the query.
+// Returns a *NotFoundError when no XunjiService ID was found.
+func (xsq *XunjiServiceQuery) FirstID(ctx context.Context) (id uint64, err error) {
+	var ids []uint64
+	if ids, err = xsq.Limit(1).IDs(setContextOp(ctx, xsq.ctx, "FirstID")); err != nil {
+		return
+	}
+	if len(ids) == 0 {
+		err = &NotFoundError{xunjiservice.Label}
+		return
+	}
+	return ids[0], nil
+}
+
+// FirstIDX is like FirstID, but panics if an error occurs.
+func (xsq *XunjiServiceQuery) FirstIDX(ctx context.Context) uint64 {
+	id, err := xsq.FirstID(ctx)
+	if err != nil && !IsNotFound(err) {
+		panic(err)
+	}
+	return id
+}
+
+// Only returns a single XunjiService entity found by the query, ensuring it only returns one.
+// Returns a *NotSingularError when more than one XunjiService entity is found.
+// Returns a *NotFoundError when no XunjiService entities are found.
+func (xsq *XunjiServiceQuery) Only(ctx context.Context) (*XunjiService, error) {
+	nodes, err := xsq.Limit(2).All(setContextOp(ctx, xsq.ctx, "Only"))
+	if err != nil {
+		return nil, err
+	}
+	switch len(nodes) {
+	case 1:
+		return nodes[0], nil
+	case 0:
+		return nil, &NotFoundError{xunjiservice.Label}
+	default:
+		return nil, &NotSingularError{xunjiservice.Label}
+	}
+}
+
+// OnlyX is like Only, but panics if an error occurs.
+func (xsq *XunjiServiceQuery) OnlyX(ctx context.Context) *XunjiService {
+	node, err := xsq.Only(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return node
+}
+
+// OnlyID is like Only, but returns the only XunjiService ID in the query.
+// Returns a *NotSingularError when more than one XunjiService ID is found.
+// Returns a *NotFoundError when no entities are found.
+func (xsq *XunjiServiceQuery) OnlyID(ctx context.Context) (id uint64, err error) {
+	var ids []uint64
+	if ids, err = xsq.Limit(2).IDs(setContextOp(ctx, xsq.ctx, "OnlyID")); err != nil {
+		return
+	}
+	switch len(ids) {
+	case 1:
+		id = ids[0]
+	case 0:
+		err = &NotFoundError{xunjiservice.Label}
+	default:
+		err = &NotSingularError{xunjiservice.Label}
+	}
+	return
+}
+
+// OnlyIDX is like OnlyID, but panics if an error occurs.
+func (xsq *XunjiServiceQuery) OnlyIDX(ctx context.Context) uint64 {
+	id, err := xsq.OnlyID(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return id
+}
+
+// All executes the query and returns a list of XunjiServices.
+func (xsq *XunjiServiceQuery) All(ctx context.Context) ([]*XunjiService, error) {
+	ctx = setContextOp(ctx, xsq.ctx, "All")
+	if err := xsq.prepareQuery(ctx); err != nil {
+		return nil, err
+	}
+	qr := querierAll[[]*XunjiService, *XunjiServiceQuery]()
+	return withInterceptors[[]*XunjiService](ctx, xsq, qr, xsq.inters)
+}
+
+// AllX is like All, but panics if an error occurs.
+func (xsq *XunjiServiceQuery) AllX(ctx context.Context) []*XunjiService {
+	nodes, err := xsq.All(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return nodes
+}
+
+// IDs executes the query and returns a list of XunjiService IDs.
+func (xsq *XunjiServiceQuery) IDs(ctx context.Context) (ids []uint64, err error) {
+	if xsq.ctx.Unique == nil && xsq.path != nil {
+		xsq.Unique(true)
+	}
+	ctx = setContextOp(ctx, xsq.ctx, "IDs")
+	if err = xsq.Select(xunjiservice.FieldID).Scan(ctx, &ids); err != nil {
+		return nil, err
+	}
+	return ids, nil
+}
+
+// IDsX is like IDs, but panics if an error occurs.
+func (xsq *XunjiServiceQuery) IDsX(ctx context.Context) []uint64 {
+	ids, err := xsq.IDs(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return ids
+}
+
+// Count returns the count of the given query.
+func (xsq *XunjiServiceQuery) Count(ctx context.Context) (int, error) {
+	ctx = setContextOp(ctx, xsq.ctx, "Count")
+	if err := xsq.prepareQuery(ctx); err != nil {
+		return 0, err
+	}
+	return withInterceptors[int](ctx, xsq, querierCount[*XunjiServiceQuery](), xsq.inters)
+}
+
+// CountX is like Count, but panics if an error occurs.
+func (xsq *XunjiServiceQuery) CountX(ctx context.Context) int {
+	count, err := xsq.Count(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return count
+}
+
+// Exist returns true if the query has elements in the graph.
+func (xsq *XunjiServiceQuery) Exist(ctx context.Context) (bool, error) {
+	ctx = setContextOp(ctx, xsq.ctx, "Exist")
+	switch _, err := xsq.FirstID(ctx); {
+	case IsNotFound(err):
+		return false, nil
+	case err != nil:
+		return false, fmt.Errorf("ent: check existence: %w", err)
+	default:
+		return true, nil
+	}
+}
+
+// ExistX is like Exist, but panics if an error occurs.
+func (xsq *XunjiServiceQuery) ExistX(ctx context.Context) bool {
+	exist, err := xsq.Exist(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return exist
+}
+
+// Clone returns a duplicate of the XunjiServiceQuery builder, including all associated steps. It can be
+// used to prepare common query builders and use them differently after the clone is made.
+func (xsq *XunjiServiceQuery) Clone() *XunjiServiceQuery {
+	if xsq == nil {
+		return nil
+	}
+	return &XunjiServiceQuery{
+		config:     xsq.config,
+		ctx:        xsq.ctx.Clone(),
+		order:      append([]xunjiservice.OrderOption{}, xsq.order...),
+		inters:     append([]Interceptor{}, xsq.inters...),
+		predicates: append([]predicate.XunjiService{}, xsq.predicates...),
+		withAgent:  xsq.withAgent.Clone(),
+		// clone intermediate query.
+		sql:  xsq.sql.Clone(),
+		path: xsq.path,
+	}
+}
+
+// WithAgent tells the query-builder to eager-load the nodes that are connected to
+// the "agent" edge. The optional arguments are used to configure the query builder of the edge.
+func (xsq *XunjiServiceQuery) WithAgent(opts ...func(*AgentQuery)) *XunjiServiceQuery {
+	query := (&AgentClient{config: xsq.config}).Query()
+	for _, opt := range opts {
+		opt(query)
+	}
+	xsq.withAgent = query
+	return xsq
+}
+
+// GroupBy is used to group vertices by one or more fields/columns.
+// It is often used with aggregate functions, like: count, max, mean, min, sum.
+//
+// Example:
+//
+//	var v []struct {
+//		CreatedAt time.Time `json:"created_at,omitempty"`
+//		Count int `json:"count,omitempty"`
+//	}
+//
+//	client.XunjiService.Query().
+//		GroupBy(xunjiservice.FieldCreatedAt).
+//		Aggregate(ent.Count()).
+//		Scan(ctx, &v)
+func (xsq *XunjiServiceQuery) GroupBy(field string, fields ...string) *XunjiServiceGroupBy {
+	xsq.ctx.Fields = append([]string{field}, fields...)
+	grbuild := &XunjiServiceGroupBy{build: xsq}
+	grbuild.flds = &xsq.ctx.Fields
+	grbuild.label = xunjiservice.Label
+	grbuild.scan = grbuild.Scan
+	return grbuild
+}
+
+// Select allows the selection one or more fields/columns for the given query,
+// instead of selecting all fields in the entity.
+//
+// Example:
+//
+//	var v []struct {
+//		CreatedAt time.Time `json:"created_at,omitempty"`
+//	}
+//
+//	client.XunjiService.Query().
+//		Select(xunjiservice.FieldCreatedAt).
+//		Scan(ctx, &v)
+func (xsq *XunjiServiceQuery) Select(fields ...string) *XunjiServiceSelect {
+	xsq.ctx.Fields = append(xsq.ctx.Fields, fields...)
+	sbuild := &XunjiServiceSelect{XunjiServiceQuery: xsq}
+	sbuild.label = xunjiservice.Label
+	sbuild.flds, sbuild.scan = &xsq.ctx.Fields, sbuild.Scan
+	return sbuild
+}
+
+// Aggregate returns a XunjiServiceSelect configured with the given aggregations.
+func (xsq *XunjiServiceQuery) Aggregate(fns ...AggregateFunc) *XunjiServiceSelect {
+	return xsq.Select().Aggregate(fns...)
+}
+
+func (xsq *XunjiServiceQuery) prepareQuery(ctx context.Context) error {
+	for _, inter := range xsq.inters {
+		if inter == nil {
+			return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
+		}
+		if trv, ok := inter.(Traverser); ok {
+			if err := trv.Traverse(ctx, xsq); err != nil {
+				return err
+			}
+		}
+	}
+	for _, f := range xsq.ctx.Fields {
+		if !xunjiservice.ValidColumn(f) {
+			return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
+		}
+	}
+	if xsq.path != nil {
+		prev, err := xsq.path(ctx)
+		if err != nil {
+			return err
+		}
+		xsq.sql = prev
+	}
+	return nil
+}
+
+func (xsq *XunjiServiceQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*XunjiService, error) {
+	var (
+		nodes       = []*XunjiService{}
+		_spec       = xsq.querySpec()
+		loadedTypes = [1]bool{
+			xsq.withAgent != nil,
+		}
+	)
+	_spec.ScanValues = func(columns []string) ([]any, error) {
+		return (*XunjiService).scanValues(nil, columns)
+	}
+	_spec.Assign = func(columns []string, values []any) error {
+		node := &XunjiService{config: xsq.config}
+		nodes = append(nodes, node)
+		node.Edges.loadedTypes = loadedTypes
+		return node.assignValues(columns, values)
+	}
+	for i := range hooks {
+		hooks[i](ctx, _spec)
+	}
+	if err := sqlgraph.QueryNodes(ctx, xsq.driver, _spec); err != nil {
+		return nil, err
+	}
+	if len(nodes) == 0 {
+		return nodes, nil
+	}
+	if query := xsq.withAgent; query != nil {
+		if err := xsq.loadAgent(ctx, query, nodes, nil,
+			func(n *XunjiService, e *Agent) { n.Edges.Agent = e }); err != nil {
+			return nil, err
+		}
+	}
+	return nodes, nil
+}
+
+func (xsq *XunjiServiceQuery) loadAgent(ctx context.Context, query *AgentQuery, nodes []*XunjiService, init func(*XunjiService), assign func(*XunjiService, *Agent)) error {
+	ids := make([]uint64, 0, len(nodes))
+	nodeids := make(map[uint64][]*XunjiService)
+	for i := range nodes {
+		fk := nodes[i].AgentID
+		if _, ok := nodeids[fk]; !ok {
+			ids = append(ids, fk)
+		}
+		nodeids[fk] = append(nodeids[fk], nodes[i])
+	}
+	if len(ids) == 0 {
+		return nil
+	}
+	query.Where(agent.IDIn(ids...))
+	neighbors, err := query.All(ctx)
+	if err != nil {
+		return err
+	}
+	for _, n := range neighbors {
+		nodes, ok := nodeids[n.ID]
+		if !ok {
+			return fmt.Errorf(`unexpected foreign-key "agent_id" returned %v`, n.ID)
+		}
+		for i := range nodes {
+			assign(nodes[i], n)
+		}
+	}
+	return nil
+}
+
+func (xsq *XunjiServiceQuery) sqlCount(ctx context.Context) (int, error) {
+	_spec := xsq.querySpec()
+	_spec.Node.Columns = xsq.ctx.Fields
+	if len(xsq.ctx.Fields) > 0 {
+		_spec.Unique = xsq.ctx.Unique != nil && *xsq.ctx.Unique
+	}
+	return sqlgraph.CountNodes(ctx, xsq.driver, _spec)
+}
+
+func (xsq *XunjiServiceQuery) querySpec() *sqlgraph.QuerySpec {
+	_spec := sqlgraph.NewQuerySpec(xunjiservice.Table, xunjiservice.Columns, sqlgraph.NewFieldSpec(xunjiservice.FieldID, field.TypeUint64))
+	_spec.From = xsq.sql
+	if unique := xsq.ctx.Unique; unique != nil {
+		_spec.Unique = *unique
+	} else if xsq.path != nil {
+		_spec.Unique = true
+	}
+	if fields := xsq.ctx.Fields; len(fields) > 0 {
+		_spec.Node.Columns = make([]string, 0, len(fields))
+		_spec.Node.Columns = append(_spec.Node.Columns, xunjiservice.FieldID)
+		for i := range fields {
+			if fields[i] != xunjiservice.FieldID {
+				_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
+			}
+		}
+		if xsq.withAgent != nil {
+			_spec.Node.AddColumnOnce(xunjiservice.FieldAgentID)
+		}
+	}
+	if ps := xsq.predicates; len(ps) > 0 {
+		_spec.Predicate = func(selector *sql.Selector) {
+			for i := range ps {
+				ps[i](selector)
+			}
+		}
+	}
+	if limit := xsq.ctx.Limit; limit != nil {
+		_spec.Limit = *limit
+	}
+	if offset := xsq.ctx.Offset; offset != nil {
+		_spec.Offset = *offset
+	}
+	if ps := xsq.order; len(ps) > 0 {
+		_spec.Order = func(selector *sql.Selector) {
+			for i := range ps {
+				ps[i](selector)
+			}
+		}
+	}
+	return _spec
+}
+
+func (xsq *XunjiServiceQuery) sqlQuery(ctx context.Context) *sql.Selector {
+	builder := sql.Dialect(xsq.driver.Dialect())
+	t1 := builder.Table(xunjiservice.Table)
+	columns := xsq.ctx.Fields
+	if len(columns) == 0 {
+		columns = xunjiservice.Columns
+	}
+	selector := builder.Select(t1.Columns(columns...)...).From(t1)
+	if xsq.sql != nil {
+		selector = xsq.sql
+		selector.Select(selector.Columns(columns...)...)
+	}
+	if xsq.ctx.Unique != nil && *xsq.ctx.Unique {
+		selector.Distinct()
+	}
+	for _, p := range xsq.predicates {
+		p(selector)
+	}
+	for _, p := range xsq.order {
+		p(selector)
+	}
+	if offset := xsq.ctx.Offset; offset != nil {
+		// limit is mandatory for offset clause. We start
+		// with default value, and override it below if needed.
+		selector.Offset(*offset).Limit(math.MaxInt32)
+	}
+	if limit := xsq.ctx.Limit; limit != nil {
+		selector.Limit(*limit)
+	}
+	return selector
+}
+
+// XunjiServiceGroupBy is the group-by builder for XunjiService entities.
+type XunjiServiceGroupBy struct {
+	selector
+	build *XunjiServiceQuery
+}
+
+// Aggregate adds the given aggregation functions to the group-by query.
+func (xsgb *XunjiServiceGroupBy) Aggregate(fns ...AggregateFunc) *XunjiServiceGroupBy {
+	xsgb.fns = append(xsgb.fns, fns...)
+	return xsgb
+}
+
+// Scan applies the selector query and scans the result into the given value.
+func (xsgb *XunjiServiceGroupBy) Scan(ctx context.Context, v any) error {
+	ctx = setContextOp(ctx, xsgb.build.ctx, "GroupBy")
+	if err := xsgb.build.prepareQuery(ctx); err != nil {
+		return err
+	}
+	return scanWithInterceptors[*XunjiServiceQuery, *XunjiServiceGroupBy](ctx, xsgb.build, xsgb, xsgb.build.inters, v)
+}
+
+func (xsgb *XunjiServiceGroupBy) sqlScan(ctx context.Context, root *XunjiServiceQuery, v any) error {
+	selector := root.sqlQuery(ctx).Select()
+	aggregation := make([]string, 0, len(xsgb.fns))
+	for _, fn := range xsgb.fns {
+		aggregation = append(aggregation, fn(selector))
+	}
+	if len(selector.SelectedColumns()) == 0 {
+		columns := make([]string, 0, len(*xsgb.flds)+len(xsgb.fns))
+		for _, f := range *xsgb.flds {
+			columns = append(columns, selector.C(f))
+		}
+		columns = append(columns, aggregation...)
+		selector.Select(columns...)
+	}
+	selector.GroupBy(selector.Columns(*xsgb.flds...)...)
+	if err := selector.Err(); err != nil {
+		return err
+	}
+	rows := &sql.Rows{}
+	query, args := selector.Query()
+	if err := xsgb.build.driver.Query(ctx, query, args, rows); err != nil {
+		return err
+	}
+	defer rows.Close()
+	return sql.ScanSlice(rows, v)
+}
+
+// XunjiServiceSelect is the builder for selecting fields of XunjiService entities.
+type XunjiServiceSelect struct {
+	*XunjiServiceQuery
+	selector
+}
+
+// Aggregate adds the given aggregation functions to the selector query.
+func (xss *XunjiServiceSelect) Aggregate(fns ...AggregateFunc) *XunjiServiceSelect {
+	xss.fns = append(xss.fns, fns...)
+	return xss
+}
+
+// Scan applies the selector query and scans the result into the given value.
+func (xss *XunjiServiceSelect) Scan(ctx context.Context, v any) error {
+	ctx = setContextOp(ctx, xss.ctx, "Select")
+	if err := xss.prepareQuery(ctx); err != nil {
+		return err
+	}
+	return scanWithInterceptors[*XunjiServiceQuery, *XunjiServiceSelect](ctx, xss.XunjiServiceQuery, xss, xss.inters, v)
+}
+
+func (xss *XunjiServiceSelect) sqlScan(ctx context.Context, root *XunjiServiceQuery, v any) error {
+	selector := root.sqlQuery(ctx)
+	aggregation := make([]string, 0, len(xss.fns))
+	for _, fn := range xss.fns {
+		aggregation = append(aggregation, fn(selector))
+	}
+	switch n := len(*xss.selector.flds); {
+	case n == 0 && len(aggregation) > 0:
+		selector.Select(aggregation...)
+	case n != 0 && len(aggregation) > 0:
+		selector.AppendSelect(aggregation...)
+	}
+	rows := &sql.Rows{}
+	query, args := selector.Query()
+	if err := xss.driver.Query(ctx, query, args, rows); err != nil {
+		return err
+	}
+	defer rows.Close()
+	return sql.ScanSlice(rows, v)
+}

+ 735 - 0
ent/xunjiservice_update.go

@@ -0,0 +1,735 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+	"context"
+	"errors"
+	"fmt"
+	"time"
+	"wechat-api/ent/agent"
+	"wechat-api/ent/predicate"
+	"wechat-api/ent/xunjiservice"
+
+	"entgo.io/ent/dialect/sql"
+	"entgo.io/ent/dialect/sql/sqlgraph"
+	"entgo.io/ent/schema/field"
+)
+
+// XunjiServiceUpdate is the builder for updating XunjiService entities.
+type XunjiServiceUpdate struct {
+	config
+	hooks    []Hook
+	mutation *XunjiServiceMutation
+}
+
+// Where appends a list predicates to the XunjiServiceUpdate builder.
+func (xsu *XunjiServiceUpdate) Where(ps ...predicate.XunjiService) *XunjiServiceUpdate {
+	xsu.mutation.Where(ps...)
+	return xsu
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (xsu *XunjiServiceUpdate) SetUpdatedAt(t time.Time) *XunjiServiceUpdate {
+	xsu.mutation.SetUpdatedAt(t)
+	return xsu
+}
+
+// SetStatus sets the "status" field.
+func (xsu *XunjiServiceUpdate) SetStatus(u uint8) *XunjiServiceUpdate {
+	xsu.mutation.ResetStatus()
+	xsu.mutation.SetStatus(u)
+	return xsu
+}
+
+// SetNillableStatus sets the "status" field if the given value is not nil.
+func (xsu *XunjiServiceUpdate) SetNillableStatus(u *uint8) *XunjiServiceUpdate {
+	if u != nil {
+		xsu.SetStatus(*u)
+	}
+	return xsu
+}
+
+// AddStatus adds u to the "status" field.
+func (xsu *XunjiServiceUpdate) AddStatus(u int8) *XunjiServiceUpdate {
+	xsu.mutation.AddStatus(u)
+	return xsu
+}
+
+// ClearStatus clears the value of the "status" field.
+func (xsu *XunjiServiceUpdate) ClearStatus() *XunjiServiceUpdate {
+	xsu.mutation.ClearStatus()
+	return xsu
+}
+
+// SetDeletedAt sets the "deleted_at" field.
+func (xsu *XunjiServiceUpdate) SetDeletedAt(t time.Time) *XunjiServiceUpdate {
+	xsu.mutation.SetDeletedAt(t)
+	return xsu
+}
+
+// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
+func (xsu *XunjiServiceUpdate) SetNillableDeletedAt(t *time.Time) *XunjiServiceUpdate {
+	if t != nil {
+		xsu.SetDeletedAt(*t)
+	}
+	return xsu
+}
+
+// ClearDeletedAt clears the value of the "deleted_at" field.
+func (xsu *XunjiServiceUpdate) ClearDeletedAt() *XunjiServiceUpdate {
+	xsu.mutation.ClearDeletedAt()
+	return xsu
+}
+
+// SetXunjiID sets the "xunji_id" field.
+func (xsu *XunjiServiceUpdate) SetXunjiID(u uint64) *XunjiServiceUpdate {
+	xsu.mutation.ResetXunjiID()
+	xsu.mutation.SetXunjiID(u)
+	return xsu
+}
+
+// SetNillableXunjiID sets the "xunji_id" field if the given value is not nil.
+func (xsu *XunjiServiceUpdate) SetNillableXunjiID(u *uint64) *XunjiServiceUpdate {
+	if u != nil {
+		xsu.SetXunjiID(*u)
+	}
+	return xsu
+}
+
+// AddXunjiID adds u to the "xunji_id" field.
+func (xsu *XunjiServiceUpdate) AddXunjiID(u int64) *XunjiServiceUpdate {
+	xsu.mutation.AddXunjiID(u)
+	return xsu
+}
+
+// SetAgentID sets the "agent_id" field.
+func (xsu *XunjiServiceUpdate) SetAgentID(u uint64) *XunjiServiceUpdate {
+	xsu.mutation.SetAgentID(u)
+	return xsu
+}
+
+// SetNillableAgentID sets the "agent_id" field if the given value is not nil.
+func (xsu *XunjiServiceUpdate) SetNillableAgentID(u *uint64) *XunjiServiceUpdate {
+	if u != nil {
+		xsu.SetAgentID(*u)
+	}
+	return xsu
+}
+
+// SetOrganizationID sets the "organization_id" field.
+func (xsu *XunjiServiceUpdate) SetOrganizationID(u uint64) *XunjiServiceUpdate {
+	xsu.mutation.ResetOrganizationID()
+	xsu.mutation.SetOrganizationID(u)
+	return xsu
+}
+
+// SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
+func (xsu *XunjiServiceUpdate) SetNillableOrganizationID(u *uint64) *XunjiServiceUpdate {
+	if u != nil {
+		xsu.SetOrganizationID(*u)
+	}
+	return xsu
+}
+
+// AddOrganizationID adds u to the "organization_id" field.
+func (xsu *XunjiServiceUpdate) AddOrganizationID(u int64) *XunjiServiceUpdate {
+	xsu.mutation.AddOrganizationID(u)
+	return xsu
+}
+
+// SetWxid sets the "wxid" field.
+func (xsu *XunjiServiceUpdate) SetWxid(s string) *XunjiServiceUpdate {
+	xsu.mutation.SetWxid(s)
+	return xsu
+}
+
+// SetNillableWxid sets the "wxid" field if the given value is not nil.
+func (xsu *XunjiServiceUpdate) SetNillableWxid(s *string) *XunjiServiceUpdate {
+	if s != nil {
+		xsu.SetWxid(*s)
+	}
+	return xsu
+}
+
+// SetAPIBase sets the "api_base" field.
+func (xsu *XunjiServiceUpdate) SetAPIBase(s string) *XunjiServiceUpdate {
+	xsu.mutation.SetAPIBase(s)
+	return xsu
+}
+
+// SetNillableAPIBase sets the "api_base" field if the given value is not nil.
+func (xsu *XunjiServiceUpdate) SetNillableAPIBase(s *string) *XunjiServiceUpdate {
+	if s != nil {
+		xsu.SetAPIBase(*s)
+	}
+	return xsu
+}
+
+// ClearAPIBase clears the value of the "api_base" field.
+func (xsu *XunjiServiceUpdate) ClearAPIBase() *XunjiServiceUpdate {
+	xsu.mutation.ClearAPIBase()
+	return xsu
+}
+
+// SetAPIKey sets the "api_key" field.
+func (xsu *XunjiServiceUpdate) SetAPIKey(s string) *XunjiServiceUpdate {
+	xsu.mutation.SetAPIKey(s)
+	return xsu
+}
+
+// SetNillableAPIKey sets the "api_key" field if the given value is not nil.
+func (xsu *XunjiServiceUpdate) SetNillableAPIKey(s *string) *XunjiServiceUpdate {
+	if s != nil {
+		xsu.SetAPIKey(*s)
+	}
+	return xsu
+}
+
+// ClearAPIKey clears the value of the "api_key" field.
+func (xsu *XunjiServiceUpdate) ClearAPIKey() *XunjiServiceUpdate {
+	xsu.mutation.ClearAPIKey()
+	return xsu
+}
+
+// SetAgent sets the "agent" edge to the Agent entity.
+func (xsu *XunjiServiceUpdate) SetAgent(a *Agent) *XunjiServiceUpdate {
+	return xsu.SetAgentID(a.ID)
+}
+
+// Mutation returns the XunjiServiceMutation object of the builder.
+func (xsu *XunjiServiceUpdate) Mutation() *XunjiServiceMutation {
+	return xsu.mutation
+}
+
+// ClearAgent clears the "agent" edge to the Agent entity.
+func (xsu *XunjiServiceUpdate) ClearAgent() *XunjiServiceUpdate {
+	xsu.mutation.ClearAgent()
+	return xsu
+}
+
+// Save executes the query and returns the number of nodes affected by the update operation.
+func (xsu *XunjiServiceUpdate) Save(ctx context.Context) (int, error) {
+	if err := xsu.defaults(); err != nil {
+		return 0, err
+	}
+	return withHooks(ctx, xsu.sqlSave, xsu.mutation, xsu.hooks)
+}
+
+// SaveX is like Save, but panics if an error occurs.
+func (xsu *XunjiServiceUpdate) SaveX(ctx context.Context) int {
+	affected, err := xsu.Save(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return affected
+}
+
+// Exec executes the query.
+func (xsu *XunjiServiceUpdate) Exec(ctx context.Context) error {
+	_, err := xsu.Save(ctx)
+	return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (xsu *XunjiServiceUpdate) ExecX(ctx context.Context) {
+	if err := xsu.Exec(ctx); err != nil {
+		panic(err)
+	}
+}
+
+// defaults sets the default values of the builder before save.
+func (xsu *XunjiServiceUpdate) defaults() error {
+	if _, ok := xsu.mutation.UpdatedAt(); !ok {
+		if xunjiservice.UpdateDefaultUpdatedAt == nil {
+			return fmt.Errorf("ent: uninitialized xunjiservice.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
+		}
+		v := xunjiservice.UpdateDefaultUpdatedAt()
+		xsu.mutation.SetUpdatedAt(v)
+	}
+	return nil
+}
+
+// check runs all checks and user-defined validators on the builder.
+func (xsu *XunjiServiceUpdate) check() error {
+	if v, ok := xsu.mutation.OrganizationID(); ok {
+		if err := xunjiservice.OrganizationIDValidator(v); err != nil {
+			return &ValidationError{Name: "organization_id", err: fmt.Errorf(`ent: validator failed for field "XunjiService.organization_id": %w`, err)}
+		}
+	}
+	if _, ok := xsu.mutation.AgentID(); xsu.mutation.AgentCleared() && !ok {
+		return errors.New(`ent: clearing a required unique edge "XunjiService.agent"`)
+	}
+	return nil
+}
+
+func (xsu *XunjiServiceUpdate) sqlSave(ctx context.Context) (n int, err error) {
+	if err := xsu.check(); err != nil {
+		return n, err
+	}
+	_spec := sqlgraph.NewUpdateSpec(xunjiservice.Table, xunjiservice.Columns, sqlgraph.NewFieldSpec(xunjiservice.FieldID, field.TypeUint64))
+	if ps := xsu.mutation.predicates; len(ps) > 0 {
+		_spec.Predicate = func(selector *sql.Selector) {
+			for i := range ps {
+				ps[i](selector)
+			}
+		}
+	}
+	if value, ok := xsu.mutation.UpdatedAt(); ok {
+		_spec.SetField(xunjiservice.FieldUpdatedAt, field.TypeTime, value)
+	}
+	if value, ok := xsu.mutation.Status(); ok {
+		_spec.SetField(xunjiservice.FieldStatus, field.TypeUint8, value)
+	}
+	if value, ok := xsu.mutation.AddedStatus(); ok {
+		_spec.AddField(xunjiservice.FieldStatus, field.TypeUint8, value)
+	}
+	if xsu.mutation.StatusCleared() {
+		_spec.ClearField(xunjiservice.FieldStatus, field.TypeUint8)
+	}
+	if value, ok := xsu.mutation.DeletedAt(); ok {
+		_spec.SetField(xunjiservice.FieldDeletedAt, field.TypeTime, value)
+	}
+	if xsu.mutation.DeletedAtCleared() {
+		_spec.ClearField(xunjiservice.FieldDeletedAt, field.TypeTime)
+	}
+	if value, ok := xsu.mutation.XunjiID(); ok {
+		_spec.SetField(xunjiservice.FieldXunjiID, field.TypeUint64, value)
+	}
+	if value, ok := xsu.mutation.AddedXunjiID(); ok {
+		_spec.AddField(xunjiservice.FieldXunjiID, field.TypeUint64, value)
+	}
+	if value, ok := xsu.mutation.OrganizationID(); ok {
+		_spec.SetField(xunjiservice.FieldOrganizationID, field.TypeUint64, value)
+	}
+	if value, ok := xsu.mutation.AddedOrganizationID(); ok {
+		_spec.AddField(xunjiservice.FieldOrganizationID, field.TypeUint64, value)
+	}
+	if value, ok := xsu.mutation.Wxid(); ok {
+		_spec.SetField(xunjiservice.FieldWxid, field.TypeString, value)
+	}
+	if value, ok := xsu.mutation.APIBase(); ok {
+		_spec.SetField(xunjiservice.FieldAPIBase, field.TypeString, value)
+	}
+	if xsu.mutation.APIBaseCleared() {
+		_spec.ClearField(xunjiservice.FieldAPIBase, field.TypeString)
+	}
+	if value, ok := xsu.mutation.APIKey(); ok {
+		_spec.SetField(xunjiservice.FieldAPIKey, field.TypeString, value)
+	}
+	if xsu.mutation.APIKeyCleared() {
+		_spec.ClearField(xunjiservice.FieldAPIKey, field.TypeString)
+	}
+	if xsu.mutation.AgentCleared() {
+		edge := &sqlgraph.EdgeSpec{
+			Rel:     sqlgraph.M2O,
+			Inverse: true,
+			Table:   xunjiservice.AgentTable,
+			Columns: []string{xunjiservice.AgentColumn},
+			Bidi:    false,
+			Target: &sqlgraph.EdgeTarget{
+				IDSpec: sqlgraph.NewFieldSpec(agent.FieldID, field.TypeUint64),
+			},
+		}
+		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
+	}
+	if nodes := xsu.mutation.AgentIDs(); len(nodes) > 0 {
+		edge := &sqlgraph.EdgeSpec{
+			Rel:     sqlgraph.M2O,
+			Inverse: true,
+			Table:   xunjiservice.AgentTable,
+			Columns: []string{xunjiservice.AgentColumn},
+			Bidi:    false,
+			Target: &sqlgraph.EdgeTarget{
+				IDSpec: sqlgraph.NewFieldSpec(agent.FieldID, field.TypeUint64),
+			},
+		}
+		for _, k := range nodes {
+			edge.Target.Nodes = append(edge.Target.Nodes, k)
+		}
+		_spec.Edges.Add = append(_spec.Edges.Add, edge)
+	}
+	if n, err = sqlgraph.UpdateNodes(ctx, xsu.driver, _spec); err != nil {
+		if _, ok := err.(*sqlgraph.NotFoundError); ok {
+			err = &NotFoundError{xunjiservice.Label}
+		} else if sqlgraph.IsConstraintError(err) {
+			err = &ConstraintError{msg: err.Error(), wrap: err}
+		}
+		return 0, err
+	}
+	xsu.mutation.done = true
+	return n, nil
+}
+
+// XunjiServiceUpdateOne is the builder for updating a single XunjiService entity.
+type XunjiServiceUpdateOne struct {
+	config
+	fields   []string
+	hooks    []Hook
+	mutation *XunjiServiceMutation
+}
+
+// SetUpdatedAt sets the "updated_at" field.
+func (xsuo *XunjiServiceUpdateOne) SetUpdatedAt(t time.Time) *XunjiServiceUpdateOne {
+	xsuo.mutation.SetUpdatedAt(t)
+	return xsuo
+}
+
+// SetStatus sets the "status" field.
+func (xsuo *XunjiServiceUpdateOne) SetStatus(u uint8) *XunjiServiceUpdateOne {
+	xsuo.mutation.ResetStatus()
+	xsuo.mutation.SetStatus(u)
+	return xsuo
+}
+
+// SetNillableStatus sets the "status" field if the given value is not nil.
+func (xsuo *XunjiServiceUpdateOne) SetNillableStatus(u *uint8) *XunjiServiceUpdateOne {
+	if u != nil {
+		xsuo.SetStatus(*u)
+	}
+	return xsuo
+}
+
+// AddStatus adds u to the "status" field.
+func (xsuo *XunjiServiceUpdateOne) AddStatus(u int8) *XunjiServiceUpdateOne {
+	xsuo.mutation.AddStatus(u)
+	return xsuo
+}
+
+// ClearStatus clears the value of the "status" field.
+func (xsuo *XunjiServiceUpdateOne) ClearStatus() *XunjiServiceUpdateOne {
+	xsuo.mutation.ClearStatus()
+	return xsuo
+}
+
+// SetDeletedAt sets the "deleted_at" field.
+func (xsuo *XunjiServiceUpdateOne) SetDeletedAt(t time.Time) *XunjiServiceUpdateOne {
+	xsuo.mutation.SetDeletedAt(t)
+	return xsuo
+}
+
+// SetNillableDeletedAt sets the "deleted_at" field if the given value is not nil.
+func (xsuo *XunjiServiceUpdateOne) SetNillableDeletedAt(t *time.Time) *XunjiServiceUpdateOne {
+	if t != nil {
+		xsuo.SetDeletedAt(*t)
+	}
+	return xsuo
+}
+
+// ClearDeletedAt clears the value of the "deleted_at" field.
+func (xsuo *XunjiServiceUpdateOne) ClearDeletedAt() *XunjiServiceUpdateOne {
+	xsuo.mutation.ClearDeletedAt()
+	return xsuo
+}
+
+// SetXunjiID sets the "xunji_id" field.
+func (xsuo *XunjiServiceUpdateOne) SetXunjiID(u uint64) *XunjiServiceUpdateOne {
+	xsuo.mutation.ResetXunjiID()
+	xsuo.mutation.SetXunjiID(u)
+	return xsuo
+}
+
+// SetNillableXunjiID sets the "xunji_id" field if the given value is not nil.
+func (xsuo *XunjiServiceUpdateOne) SetNillableXunjiID(u *uint64) *XunjiServiceUpdateOne {
+	if u != nil {
+		xsuo.SetXunjiID(*u)
+	}
+	return xsuo
+}
+
+// AddXunjiID adds u to the "xunji_id" field.
+func (xsuo *XunjiServiceUpdateOne) AddXunjiID(u int64) *XunjiServiceUpdateOne {
+	xsuo.mutation.AddXunjiID(u)
+	return xsuo
+}
+
+// SetAgentID sets the "agent_id" field.
+func (xsuo *XunjiServiceUpdateOne) SetAgentID(u uint64) *XunjiServiceUpdateOne {
+	xsuo.mutation.SetAgentID(u)
+	return xsuo
+}
+
+// SetNillableAgentID sets the "agent_id" field if the given value is not nil.
+func (xsuo *XunjiServiceUpdateOne) SetNillableAgentID(u *uint64) *XunjiServiceUpdateOne {
+	if u != nil {
+		xsuo.SetAgentID(*u)
+	}
+	return xsuo
+}
+
+// SetOrganizationID sets the "organization_id" field.
+func (xsuo *XunjiServiceUpdateOne) SetOrganizationID(u uint64) *XunjiServiceUpdateOne {
+	xsuo.mutation.ResetOrganizationID()
+	xsuo.mutation.SetOrganizationID(u)
+	return xsuo
+}
+
+// SetNillableOrganizationID sets the "organization_id" field if the given value is not nil.
+func (xsuo *XunjiServiceUpdateOne) SetNillableOrganizationID(u *uint64) *XunjiServiceUpdateOne {
+	if u != nil {
+		xsuo.SetOrganizationID(*u)
+	}
+	return xsuo
+}
+
+// AddOrganizationID adds u to the "organization_id" field.
+func (xsuo *XunjiServiceUpdateOne) AddOrganizationID(u int64) *XunjiServiceUpdateOne {
+	xsuo.mutation.AddOrganizationID(u)
+	return xsuo
+}
+
+// SetWxid sets the "wxid" field.
+func (xsuo *XunjiServiceUpdateOne) SetWxid(s string) *XunjiServiceUpdateOne {
+	xsuo.mutation.SetWxid(s)
+	return xsuo
+}
+
+// SetNillableWxid sets the "wxid" field if the given value is not nil.
+func (xsuo *XunjiServiceUpdateOne) SetNillableWxid(s *string) *XunjiServiceUpdateOne {
+	if s != nil {
+		xsuo.SetWxid(*s)
+	}
+	return xsuo
+}
+
+// SetAPIBase sets the "api_base" field.
+func (xsuo *XunjiServiceUpdateOne) SetAPIBase(s string) *XunjiServiceUpdateOne {
+	xsuo.mutation.SetAPIBase(s)
+	return xsuo
+}
+
+// SetNillableAPIBase sets the "api_base" field if the given value is not nil.
+func (xsuo *XunjiServiceUpdateOne) SetNillableAPIBase(s *string) *XunjiServiceUpdateOne {
+	if s != nil {
+		xsuo.SetAPIBase(*s)
+	}
+	return xsuo
+}
+
+// ClearAPIBase clears the value of the "api_base" field.
+func (xsuo *XunjiServiceUpdateOne) ClearAPIBase() *XunjiServiceUpdateOne {
+	xsuo.mutation.ClearAPIBase()
+	return xsuo
+}
+
+// SetAPIKey sets the "api_key" field.
+func (xsuo *XunjiServiceUpdateOne) SetAPIKey(s string) *XunjiServiceUpdateOne {
+	xsuo.mutation.SetAPIKey(s)
+	return xsuo
+}
+
+// SetNillableAPIKey sets the "api_key" field if the given value is not nil.
+func (xsuo *XunjiServiceUpdateOne) SetNillableAPIKey(s *string) *XunjiServiceUpdateOne {
+	if s != nil {
+		xsuo.SetAPIKey(*s)
+	}
+	return xsuo
+}
+
+// ClearAPIKey clears the value of the "api_key" field.
+func (xsuo *XunjiServiceUpdateOne) ClearAPIKey() *XunjiServiceUpdateOne {
+	xsuo.mutation.ClearAPIKey()
+	return xsuo
+}
+
+// SetAgent sets the "agent" edge to the Agent entity.
+func (xsuo *XunjiServiceUpdateOne) SetAgent(a *Agent) *XunjiServiceUpdateOne {
+	return xsuo.SetAgentID(a.ID)
+}
+
+// Mutation returns the XunjiServiceMutation object of the builder.
+func (xsuo *XunjiServiceUpdateOne) Mutation() *XunjiServiceMutation {
+	return xsuo.mutation
+}
+
+// ClearAgent clears the "agent" edge to the Agent entity.
+func (xsuo *XunjiServiceUpdateOne) ClearAgent() *XunjiServiceUpdateOne {
+	xsuo.mutation.ClearAgent()
+	return xsuo
+}
+
+// Where appends a list predicates to the XunjiServiceUpdate builder.
+func (xsuo *XunjiServiceUpdateOne) Where(ps ...predicate.XunjiService) *XunjiServiceUpdateOne {
+	xsuo.mutation.Where(ps...)
+	return xsuo
+}
+
+// Select allows selecting one or more fields (columns) of the returned entity.
+// The default is selecting all fields defined in the entity schema.
+func (xsuo *XunjiServiceUpdateOne) Select(field string, fields ...string) *XunjiServiceUpdateOne {
+	xsuo.fields = append([]string{field}, fields...)
+	return xsuo
+}
+
+// Save executes the query and returns the updated XunjiService entity.
+func (xsuo *XunjiServiceUpdateOne) Save(ctx context.Context) (*XunjiService, error) {
+	if err := xsuo.defaults(); err != nil {
+		return nil, err
+	}
+	return withHooks(ctx, xsuo.sqlSave, xsuo.mutation, xsuo.hooks)
+}
+
+// SaveX is like Save, but panics if an error occurs.
+func (xsuo *XunjiServiceUpdateOne) SaveX(ctx context.Context) *XunjiService {
+	node, err := xsuo.Save(ctx)
+	if err != nil {
+		panic(err)
+	}
+	return node
+}
+
+// Exec executes the query on the entity.
+func (xsuo *XunjiServiceUpdateOne) Exec(ctx context.Context) error {
+	_, err := xsuo.Save(ctx)
+	return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (xsuo *XunjiServiceUpdateOne) ExecX(ctx context.Context) {
+	if err := xsuo.Exec(ctx); err != nil {
+		panic(err)
+	}
+}
+
+// defaults sets the default values of the builder before save.
+func (xsuo *XunjiServiceUpdateOne) defaults() error {
+	if _, ok := xsuo.mutation.UpdatedAt(); !ok {
+		if xunjiservice.UpdateDefaultUpdatedAt == nil {
+			return fmt.Errorf("ent: uninitialized xunjiservice.UpdateDefaultUpdatedAt (forgotten import ent/runtime?)")
+		}
+		v := xunjiservice.UpdateDefaultUpdatedAt()
+		xsuo.mutation.SetUpdatedAt(v)
+	}
+	return nil
+}
+
+// check runs all checks and user-defined validators on the builder.
+func (xsuo *XunjiServiceUpdateOne) check() error {
+	if v, ok := xsuo.mutation.OrganizationID(); ok {
+		if err := xunjiservice.OrganizationIDValidator(v); err != nil {
+			return &ValidationError{Name: "organization_id", err: fmt.Errorf(`ent: validator failed for field "XunjiService.organization_id": %w`, err)}
+		}
+	}
+	if _, ok := xsuo.mutation.AgentID(); xsuo.mutation.AgentCleared() && !ok {
+		return errors.New(`ent: clearing a required unique edge "XunjiService.agent"`)
+	}
+	return nil
+}
+
+func (xsuo *XunjiServiceUpdateOne) sqlSave(ctx context.Context) (_node *XunjiService, err error) {
+	if err := xsuo.check(); err != nil {
+		return _node, err
+	}
+	_spec := sqlgraph.NewUpdateSpec(xunjiservice.Table, xunjiservice.Columns, sqlgraph.NewFieldSpec(xunjiservice.FieldID, field.TypeUint64))
+	id, ok := xsuo.mutation.ID()
+	if !ok {
+		return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "XunjiService.id" for update`)}
+	}
+	_spec.Node.ID.Value = id
+	if fields := xsuo.fields; len(fields) > 0 {
+		_spec.Node.Columns = make([]string, 0, len(fields))
+		_spec.Node.Columns = append(_spec.Node.Columns, xunjiservice.FieldID)
+		for _, f := range fields {
+			if !xunjiservice.ValidColumn(f) {
+				return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
+			}
+			if f != xunjiservice.FieldID {
+				_spec.Node.Columns = append(_spec.Node.Columns, f)
+			}
+		}
+	}
+	if ps := xsuo.mutation.predicates; len(ps) > 0 {
+		_spec.Predicate = func(selector *sql.Selector) {
+			for i := range ps {
+				ps[i](selector)
+			}
+		}
+	}
+	if value, ok := xsuo.mutation.UpdatedAt(); ok {
+		_spec.SetField(xunjiservice.FieldUpdatedAt, field.TypeTime, value)
+	}
+	if value, ok := xsuo.mutation.Status(); ok {
+		_spec.SetField(xunjiservice.FieldStatus, field.TypeUint8, value)
+	}
+	if value, ok := xsuo.mutation.AddedStatus(); ok {
+		_spec.AddField(xunjiservice.FieldStatus, field.TypeUint8, value)
+	}
+	if xsuo.mutation.StatusCleared() {
+		_spec.ClearField(xunjiservice.FieldStatus, field.TypeUint8)
+	}
+	if value, ok := xsuo.mutation.DeletedAt(); ok {
+		_spec.SetField(xunjiservice.FieldDeletedAt, field.TypeTime, value)
+	}
+	if xsuo.mutation.DeletedAtCleared() {
+		_spec.ClearField(xunjiservice.FieldDeletedAt, field.TypeTime)
+	}
+	if value, ok := xsuo.mutation.XunjiID(); ok {
+		_spec.SetField(xunjiservice.FieldXunjiID, field.TypeUint64, value)
+	}
+	if value, ok := xsuo.mutation.AddedXunjiID(); ok {
+		_spec.AddField(xunjiservice.FieldXunjiID, field.TypeUint64, value)
+	}
+	if value, ok := xsuo.mutation.OrganizationID(); ok {
+		_spec.SetField(xunjiservice.FieldOrganizationID, field.TypeUint64, value)
+	}
+	if value, ok := xsuo.mutation.AddedOrganizationID(); ok {
+		_spec.AddField(xunjiservice.FieldOrganizationID, field.TypeUint64, value)
+	}
+	if value, ok := xsuo.mutation.Wxid(); ok {
+		_spec.SetField(xunjiservice.FieldWxid, field.TypeString, value)
+	}
+	if value, ok := xsuo.mutation.APIBase(); ok {
+		_spec.SetField(xunjiservice.FieldAPIBase, field.TypeString, value)
+	}
+	if xsuo.mutation.APIBaseCleared() {
+		_spec.ClearField(xunjiservice.FieldAPIBase, field.TypeString)
+	}
+	if value, ok := xsuo.mutation.APIKey(); ok {
+		_spec.SetField(xunjiservice.FieldAPIKey, field.TypeString, value)
+	}
+	if xsuo.mutation.APIKeyCleared() {
+		_spec.ClearField(xunjiservice.FieldAPIKey, field.TypeString)
+	}
+	if xsuo.mutation.AgentCleared() {
+		edge := &sqlgraph.EdgeSpec{
+			Rel:     sqlgraph.M2O,
+			Inverse: true,
+			Table:   xunjiservice.AgentTable,
+			Columns: []string{xunjiservice.AgentColumn},
+			Bidi:    false,
+			Target: &sqlgraph.EdgeTarget{
+				IDSpec: sqlgraph.NewFieldSpec(agent.FieldID, field.TypeUint64),
+			},
+		}
+		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
+	}
+	if nodes := xsuo.mutation.AgentIDs(); len(nodes) > 0 {
+		edge := &sqlgraph.EdgeSpec{
+			Rel:     sqlgraph.M2O,
+			Inverse: true,
+			Table:   xunjiservice.AgentTable,
+			Columns: []string{xunjiservice.AgentColumn},
+			Bidi:    false,
+			Target: &sqlgraph.EdgeTarget{
+				IDSpec: sqlgraph.NewFieldSpec(agent.FieldID, field.TypeUint64),
+			},
+		}
+		for _, k := range nodes {
+			edge.Target.Nodes = append(edge.Target.Nodes, k)
+		}
+		_spec.Edges.Add = append(_spec.Edges.Add, edge)
+	}
+	_node = &XunjiService{config: xsuo.config}
+	_spec.Assign = _node.assignValues
+	_spec.ScanValues = _node.scanValues
+	if err = sqlgraph.UpdateNode(ctx, xsuo.driver, _spec); err != nil {
+		if _, ok := err.(*sqlgraph.NotFoundError); ok {
+			err = &NotFoundError{xunjiservice.Label}
+		} else if sqlgraph.IsConstraintError(err) {
+			err = &ConstraintError{msg: err.Error(), wrap: err}
+		}
+		return nil, err
+	}
+	xsuo.mutation.done = true
+	return _node, nil
+}

+ 4 - 0
go.sum

@@ -472,6 +472,7 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky
 github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
 github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
 github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
+github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
 github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
 github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
 github.com/mattn/go-sqlite3 v1.14.8/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
@@ -510,6 +511,7 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLA
 github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
 github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
 github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
+github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
 github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
 github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
 github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
@@ -611,6 +613,8 @@ github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkU
 github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
 github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
 github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo=
+github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
+github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
 github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
 github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
 github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=