فهرست منبع

fix:添加圈量客服接口

jimmyyem 1 ماه پیش
والد
کامیت
fd5e50406a
54فایلهای تغییر یافته به همراه6537 افزوده شده و 956 حذف شده
  1. 2 1
      desc/all.api
  2. 95 0
      desc/wechat/xunji_service.api
  3. 17 1
      ent/agent.go
  4. 30 0
      ent/agent/agent.go
  5. 23 0
      ent/agent/where.go
  6. 32 0
      ent/agent_create.go
  7. 75 1
      ent/agent_query.go
  8. 163 0
      ent/agent_update.go
  9. 179 4
      ent/client.go
  10. 2 0
      ent/ent.go
  11. 12 0
      ent/hook/hook.go
  12. 30 0
      ent/intercept/intercept.go
  13. 42 5
      ent/migrate/schema.go
  14. 1143 204
      ent/mutation.go
  15. 82 0
      ent/pagination.go
  16. 3 0
      ent/predicate/predicate.go
  17. 42 8
      ent/runtime/runtime.go
  18. 1 0
      ent/schema/agent.go
  19. 0 4
      ent/schema/xunji.go
  20. 60 0
      ent/schema/xunji_service.go
  21. 171 27
      ent/set_not_nil.go
  22. 3 0
      ent/tx.go
  23. 2 35
      ent/xunji.go
  24. 0 230
      ent/xunji/where.go
  25. 0 28
      ent/xunji/xunji.go
  26. 0 217
      ent/xunji_create.go
  27. 0 138
      ent/xunji_update.go
  28. 234 0
      ent/xunjiservice.go
  29. 639 0
      ent/xunjiservice/where.go
  30. 172 0
      ent/xunjiservice/xunjiservice.go
  31. 1178 0
      ent/xunjiservice_create.go
  32. 88 0
      ent/xunjiservice_delete.go
  33. 605 0
      ent/xunjiservice_query.go
  34. 735 0
      ent/xunjiservice_update.go
  35. 5 5
      etc/wechat.yaml
  36. 1 0
      go.mod
  37. 6 0
      go.sum
  38. 35 0
      internal/handler/routes.go
  39. 44 0
      internal/handler/xunji_service/create_xunji_service_handler.go
  40. 44 0
      internal/handler/xunji_service/delete_xunji_service_handler.go
  41. 44 0
      internal/handler/xunji_service/get_xunji_service_by_id_handler.go
  42. 44 0
      internal/handler/xunji_service/get_xunji_service_list_handler.go
  43. 44 0
      internal/handler/xunji_service/update_xunji_service_handler.go
  44. 62 0
      internal/logic/base/init_api_data.go
  45. 0 3
      internal/logic/xunji/create_xunji_logic.go
  46. 19 23
      internal/logic/xunji/get_xunji_by_id_logic.go
  47. 16 19
      internal/logic/xunji/get_xunji_list_logic.go
  48. 1 3
      internal/logic/xunji/update_xunji_logic.go
  49. 45 0
      internal/logic/xunji_service/create_xunji_service_logic.go
  50. 37 0
      internal/logic/xunji_service/delete_xunji_service_logic.go
  51. 57 0
      internal/logic/xunji_service/get_xunji_service_by_id_logic.go
  52. 72 0
      internal/logic/xunji_service/get_xunji_service_list_logic.go
  53. 45 0
      internal/logic/xunji_service/update_xunji_service_logic.go
  54. 56 0
      internal/types/types.go

+ 2 - 1
desc/all.api

@@ -42,4 +42,5 @@ import "./wechat/credit_usage.api"
 import "./wechat/pay_recharge.api"
 import "./wechat/whatsapp.api"
 import "./wechat/whatsapp_channel.api"
-import "./wechat/xunji.api"
+import "./wechat/xunji.api"
+import "./wechat/xunji_service.api"

+ 95 - 0
desc/wechat/xunji_service.api

@@ -0,0 +1,95 @@
+import "../base.api"
+
+type (
+    // The data of xunji service information | XunjiService信息
+    XunjiServiceInfo {
+        BaseIDInfo
+
+        // Status 1: normal 2: ban | 状态 1 正常 2 禁用 
+        Status  *uint8 `json:"status,optional"`
+
+        // Xunji表ID 
+        XunjiId  *uint64 `json:"xunjiId,optional"`
+
+        // 智能体ID 
+        AgentId  *uint64 `json:"agentId,optional"`
+
+        // organization_id | 租户ID 
+        OrganizationId  *uint64 `json:"organizationId,optional"`
+
+        // 微信ID 
+        Wxid  *string `json:"wxid,optional"`
+
+        // 大模型服务地址 
+        ApiBase  *string `json:"apiBase,optional"`
+
+        // 大模型服务密钥 
+        ApiKey  *string `json:"apiKey,optional"`
+    }
+
+    // The response data of xunji service list | XunjiService列表数据
+    XunjiServiceListResp {
+        BaseDataInfo
+
+        // XunjiService list data | XunjiService列表数据
+        Data XunjiServiceListInfo `json:"data"`
+    }
+
+    // XunjiService list data | XunjiService列表数据
+    XunjiServiceListInfo {
+        BaseListInfo
+
+        // The API list data | XunjiService列表数据
+        Data  []XunjiServiceInfo  `json:"data"`
+    }
+
+    // Get xunji service list request params | XunjiService列表请求参数
+    XunjiServiceListReq {
+        PageInfo
+
+        // 微信ID 
+        Wxid  *string `json:"wxid,optional"`
+
+        // 大模型服务地址 
+        ApiBase  *string `json:"apiBase,optional"`
+
+        // 大模型服务密钥 
+        ApiKey  *string `json:"apiKey,optional"`
+    }
+
+    // XunjiService information response | XunjiService信息返回体
+    XunjiServiceInfoResp {
+        BaseDataInfo
+
+        // XunjiService information | XunjiService数据
+        Data XunjiServiceInfo `json:"data"`
+    }
+)
+
+@server(
+    jwt: Auth
+    group: xunji_service
+    middleware: Authority
+)
+
+service Wechat {
+    // Create xunji service information | 创建XunjiService
+    @handler createXunjiService
+    post /xunji_service/create (XunjiServiceInfo) returns (BaseMsgResp)
+
+    // Update xunji service information | 更新XunjiService
+    @handler updateXunjiService
+    post /xunji_service/update (XunjiServiceInfo) returns (BaseMsgResp)
+
+    // Delete xunji service information | 删除XunjiService信息
+    @handler deleteXunjiService
+    post /xunji_service/delete (IDsReq) returns (BaseMsgResp)
+
+    // Get xunji service list | 获取XunjiService列表
+    @handler getXunjiServiceList
+    post /xunji_service/list (XunjiServiceListReq) returns (XunjiServiceListResp)
+
+    // Get xunji service by ID | 通过ID获取XunjiService
+    @handler getXunjiServiceById
+    post /xunji_service (IDReq) returns (XunjiServiceInfoResp)
+}

+ 17 - 1
ent/agent.go

@@ -53,9 +53,11 @@ type AgentEdges struct {
 	TokenAgent []*Token `json:"token_agent,omitempty"`
 	// WaAgent holds the value of the wa_agent edge.
 	WaAgent []*Whatsapp `json:"wa_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 [3]bool
+	loadedTypes [4]bool
 }
 
 // WxAgentOrErr returns the WxAgent value or an error if the edge
@@ -85,6 +87,15 @@ func (e AgentEdges) WaAgentOrErr() ([]*Whatsapp, error) {
 	return nil, &NotLoadedError{edge: "wa_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[3] {
+		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))
@@ -211,6 +222,11 @@ func (a *Agent) QueryWaAgent() *WhatsappQuery {
 	return NewAgentClient(a.config).QueryWaAgent(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

@@ -43,6 +43,8 @@ const (
 	EdgeTokenAgent = "token_agent"
 	// EdgeWaAgent holds the string denoting the wa_agent edge name in mutations.
 	EdgeWaAgent = "wa_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.
@@ -66,6 +68,13 @@ const (
 	WaAgentInverseTable = "whatsapp"
 	// WaAgentColumn is the table column denoting the wa_agent relation/edge.
 	WaAgentColumn = "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.
@@ -234,6 +243,20 @@ func ByWaAgent(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
 		sqlgraph.OrderByNeighborTerms(s, newWaAgentStep(), 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),
@@ -255,3 +278,10 @@ func newWaAgentStep() *sqlgraph.Step {
 		sqlgraph.Edge(sqlgraph.O2M, false, WaAgentTable, WaAgentColumn),
 	)
 }
+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

@@ -809,6 +809,29 @@ func HasWaAgentWith(preds ...predicate.Whatsapp) 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

@@ -11,6 +11,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"
@@ -206,6 +207,21 @@ func (ac *AgentCreate) AddWaAgent(w ...*Whatsapp) *AgentCreate {
 	return ac.AddWaAgentIDs(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
@@ -453,6 +469,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

@@ -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"
@@ -28,6 +29,7 @@ type AgentQuery struct {
 	withWxAgent    *WxQuery
 	withTokenAgent *TokenQuery
 	withWaAgent    *WhatsappQuery
+	withXjsAgent   *XunjiServiceQuery
 	// intermediate query (i.e. traversal path).
 	sql  *sql.Selector
 	path func(context.Context) (*sql.Selector, error)
@@ -130,6 +132,28 @@ func (aq *AgentQuery) QueryWaAgent() *WhatsappQuery {
 	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) {
@@ -325,6 +349,7 @@ func (aq *AgentQuery) Clone() *AgentQuery {
 		withWxAgent:    aq.withWxAgent.Clone(),
 		withTokenAgent: aq.withTokenAgent.Clone(),
 		withWaAgent:    aq.withWaAgent.Clone(),
+		withXjsAgent:   aq.withXjsAgent.Clone(),
 		// clone intermediate query.
 		sql:  aq.sql.Clone(),
 		path: aq.path,
@@ -364,6 +389,17 @@ func (aq *AgentQuery) WithWaAgent(opts ...func(*WhatsappQuery)) *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.
 //
@@ -442,10 +478,11 @@ func (aq *AgentQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Agent,
 	var (
 		nodes       = []*Agent{}
 		_spec       = aq.querySpec()
-		loadedTypes = [3]bool{
+		loadedTypes = [4]bool{
 			aq.withWxAgent != nil,
 			aq.withTokenAgent != nil,
 			aq.withWaAgent != nil,
+			aq.withXjsAgent != nil,
 		}
 	)
 	_spec.ScanValues = func(columns []string) ([]any, error) {
@@ -487,6 +524,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
 }
 
@@ -581,6 +625,36 @@ func (aq *AgentQuery) loadWaAgent(ctx context.Context, query *WhatsappQuery, nod
 	}
 	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

@@ -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"
@@ -246,6 +247,21 @@ func (au *AgentUpdate) AddWaAgent(w ...*Whatsapp) *AgentUpdate {
 	return au.AddWaAgentIDs(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
@@ -314,6 +330,27 @@ func (au *AgentUpdate) RemoveWaAgent(w ...*Whatsapp) *AgentUpdate {
 	return au.RemoveWaAgentIDs(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 {
@@ -581,6 +618,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}
@@ -816,6 +898,21 @@ func (auo *AgentUpdateOne) AddWaAgent(w ...*Whatsapp) *AgentUpdateOne {
 	return auo.AddWaAgentIDs(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
@@ -884,6 +981,27 @@ func (auo *AgentUpdateOne) RemoveWaAgent(w ...*Whatsapp) *AgentUpdateOne {
 	return auo.RemoveWaAgentIDs(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...)
@@ -1181,6 +1299,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

+ 179 - 4
ent/client.go

@@ -52,6 +52,7 @@ import (
 	"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 +149,8 @@ type Client struct {
 	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 +203,7 @@ func (c *Client) init() {
 	c.WxCardUser = NewWxCardUserClient(c.config)
 	c.WxCardVisit = NewWxCardVisitClient(c.config)
 	c.Xunji = NewXunjiClient(c.config)
+	c.XunjiService = NewXunjiServiceClient(c.config)
 }
 
 type (
@@ -333,6 +337,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
 		WxCardUser:          NewWxCardUserClient(cfg),
 		WxCardVisit:         NewWxCardVisitClient(cfg),
 		Xunji:               NewXunjiClient(cfg),
+		XunjiService:        NewXunjiServiceClient(cfg),
 	}, nil
 }
 
@@ -393,6 +398,7 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
 		WxCardUser:          NewWxCardUserClient(cfg),
 		WxCardVisit:         NewWxCardVisitClient(cfg),
 		Xunji:               NewXunjiClient(cfg),
+		XunjiService:        NewXunjiServiceClient(cfg),
 	}, nil
 }
 
@@ -429,7 +435,7 @@ func (c *Client) Use(hooks ...Hook) {
 		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.Xunji,
+		c.WxCard, c.WxCardUser, c.WxCardVisit, c.Xunji, c.XunjiService,
 	} {
 		n.Use(hooks...)
 	}
@@ -446,7 +452,7 @@ func (c *Client) Intercept(interceptors ...Interceptor) {
 		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.Xunji,
+		c.WxCard, c.WxCardUser, c.WxCardVisit, c.Xunji, c.XunjiService,
 	} {
 		n.Intercept(interceptors...)
 	}
@@ -537,6 +543,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
 		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)
 	}
@@ -698,6 +706,22 @@ func (c *AgentClient) QueryWaAgent(a *Agent) *WhatsappQuery {
 	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
@@ -6491,6 +6515,157 @@ func (c *XunjiClient) mutate(ctx context.Context, m *XunjiMutation) (Value, erro
 	}
 }
 
+// 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 {
@@ -6500,7 +6675,7 @@ type (
 		PayRecharge, Server, SopNode, SopStage, SopTask, Token, Tutorial, UsageDetail,
 		UsageStatisticDay, UsageStatisticHour, UsageStatisticMonth, UsageTotal,
 		Whatsapp, WhatsappChannel, WorkExperience, WpChatroom, WpChatroomMember, Wx,
-		WxCard, WxCardUser, WxCardVisit, Xunji []ent.Hook
+		WxCard, WxCardUser, WxCardVisit, Xunji, XunjiService []ent.Hook
 	}
 	inters struct {
 		Agent, AgentBase, AliyunAvatar, AllocAgent, BatchMsg, Category, ChatRecords,
@@ -6509,7 +6684,7 @@ type (
 		PayRecharge, Server, SopNode, SopStage, SopTask, Token, Tutorial, UsageDetail,
 		UsageStatisticDay, UsageStatisticHour, UsageStatisticMonth, UsageTotal,
 		Whatsapp, WhatsappChannel, WorkExperience, WpChatroom, WpChatroomMember, Wx,
-		WxCard, WxCardUser, WxCardVisit, Xunji []ent.Interceptor
+		WxCard, WxCardUser, WxCardVisit, Xunji, XunjiService []ent.Interceptor
 	}
 )
 

+ 2 - 0
ent/ent.go

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

+ 12 - 0
ent/hook/hook.go

@@ -500,6 +500,18 @@ func (f XunjiFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error
 	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
 

+ 30 - 0
ent/intercept/intercept.go

@@ -48,6 +48,7 @@ import (
 	"wechat-api/ent/wxcarduser"
 	"wechat-api/ent/wxcardvisit"
 	"wechat-api/ent/xunji"
+	"wechat-api/ent/xunjiservice"
 
 	"entgo.io/ent/dialect/sql"
 )
@@ -1215,6 +1216,33 @@ func (f TraverseXunji) Traverse(ctx context.Context, q ent.Query) error {
 	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 +1328,8 @@ func NewQuery(q ent.Query) (Query, error) {
 		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)
 	}

+ 42 - 5
ent/migrate/schema.go

@@ -1389,9 +1389,6 @@ var (
 		{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"},
-		{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: ""},
 	}
 	// XunjiTable holds the schema information for the "xunji" table.
 	XunjiTable = &schema.Table{
@@ -1404,10 +1401,45 @@ var (
 				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{
 			{
-				Name:    "xunji_wxid",
+				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{XunjiColumns[11]},
+				Columns: []*schema.Column{XunjiServiceColumns[7]},
 			},
 		},
 	}
@@ -1454,6 +1486,7 @@ var (
 		WxCardUserTable,
 		WxCardVisitTable,
 		XunjiTable,
+		XunjiServiceTable,
 	}
 )
 
@@ -1595,4 +1628,8 @@ func init() {
 	XunjiTable.Annotation = &entsql.Annotation{
 		Table: "xunji",
 	}
+	XunjiServiceTable.ForeignKeys[0].RefTable = AgentTable
+	XunjiServiceTable.Annotation = &entsql.Annotation{
+		Table: "xunji_service",
+	}
 }

+ 1143 - 204
ent/mutation.go

@@ -51,6 +51,7 @@ import (
 	"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 +107,7 @@ const (
 	TypeWxCardUser          = "WxCardUser"
 	TypeWxCardVisit         = "WxCardVisit"
 	TypeXunji               = "Xunji"
+	TypeXunjiService        = "XunjiService"
 )
 
 // AgentMutation represents an operation that mutates the Agent nodes in the graph.
@@ -137,6 +139,9 @@ type AgentMutation struct {
 	wa_agent           map[uint64]struct{}
 	removedwa_agent    map[uint64]struct{}
 	clearedwa_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
@@ -897,6 +902,60 @@ func (m *AgentMutation) ResetWaAgent() {
 	m.removedwa_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...)
@@ -1254,7 +1313,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, 3)
+	edges := make([]string, 0, 4)
 	if m.wx_agent != nil {
 		edges = append(edges, agent.EdgeWxAgent)
 	}
@@ -1264,6 +1323,9 @@ func (m *AgentMutation) AddedEdges() []string {
 	if m.wa_agent != nil {
 		edges = append(edges, agent.EdgeWaAgent)
 	}
+	if m.xjs_agent != nil {
+		edges = append(edges, agent.EdgeXjsAgent)
+	}
 	return edges
 }
 
@@ -1289,13 +1351,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, 3)
+	edges := make([]string, 0, 4)
 	if m.removedwx_agent != nil {
 		edges = append(edges, agent.EdgeWxAgent)
 	}
@@ -1305,6 +1373,9 @@ func (m *AgentMutation) RemovedEdges() []string {
 	if m.removedwa_agent != nil {
 		edges = append(edges, agent.EdgeWaAgent)
 	}
+	if m.removedxjs_agent != nil {
+		edges = append(edges, agent.EdgeXjsAgent)
+	}
 	return edges
 }
 
@@ -1330,13 +1401,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, 3)
+	edges := make([]string, 0, 4)
 	if m.clearedwx_agent {
 		edges = append(edges, agent.EdgeWxAgent)
 	}
@@ -1346,6 +1423,9 @@ func (m *AgentMutation) ClearedEdges() []string {
 	if m.clearedwa_agent {
 		edges = append(edges, agent.EdgeWaAgent)
 	}
+	if m.clearedxjs_agent {
+		edges = append(edges, agent.EdgeXjsAgent)
+	}
 	return edges
 }
 
@@ -1359,6 +1439,8 @@ func (m *AgentMutation) EdgeCleared(name string) bool {
 		return m.clearedtoken_agent
 	case agent.EdgeWaAgent:
 		return m.clearedwa_agent
+	case agent.EdgeXjsAgent:
+		return m.clearedxjs_agent
 	}
 	return false
 }
@@ -1384,6 +1466,9 @@ func (m *AgentMutation) ResetEdge(name string) error {
 	case agent.EdgeWaAgent:
 		m.ResetWaAgent()
 		return nil
+	case agent.EdgeXjsAgent:
+		m.ResetXjsAgent()
+		return nil
 	}
 	return fmt.Errorf("unknown Agent edge %s", name)
 }
@@ -48783,9 +48868,6 @@ type XunjiMutation struct {
 	addagent_id        *int64
 	organization_id    *uint64
 	addorganization_id *int64
-	wxid               *string
-	api_base           *string
-	api_key            *string
 	clearedFields      map[string]struct{}
 	done               bool
 	oldValue           func(context.Context) (*Xunji, error)
@@ -49343,140 +49425,6 @@ func (m *XunjiMutation) ResetOrganizationID() {
 	m.addorganization_id = nil
 }
 
-// SetWxid sets the "wxid" field.
-func (m *XunjiMutation) SetWxid(s string) {
-	m.wxid = &s
-}
-
-// Wxid returns the value of the "wxid" field in the mutation.
-func (m *XunjiMutation) 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 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) 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 *XunjiMutation) ResetWxid() {
-	m.wxid = nil
-}
-
-// SetAPIBase sets the "api_base" field.
-func (m *XunjiMutation) SetAPIBase(s string) {
-	m.api_base = &s
-}
-
-// APIBase returns the value of the "api_base" field in the mutation.
-func (m *XunjiMutation) 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 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) 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 *XunjiMutation) ClearAPIBase() {
-	m.api_base = nil
-	m.clearedFields[xunji.FieldAPIBase] = struct{}{}
-}
-
-// APIBaseCleared returns if the "api_base" field was cleared in this mutation.
-func (m *XunjiMutation) APIBaseCleared() bool {
-	_, ok := m.clearedFields[xunji.FieldAPIBase]
-	return ok
-}
-
-// ResetAPIBase resets all changes to the "api_base" field.
-func (m *XunjiMutation) ResetAPIBase() {
-	m.api_base = nil
-	delete(m.clearedFields, xunji.FieldAPIBase)
-}
-
-// SetAPIKey sets the "api_key" field.
-func (m *XunjiMutation) SetAPIKey(s string) {
-	m.api_key = &s
-}
-
-// APIKey returns the value of the "api_key" field in the mutation.
-func (m *XunjiMutation) 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 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) 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 *XunjiMutation) ClearAPIKey() {
-	m.api_key = nil
-	m.clearedFields[xunji.FieldAPIKey] = struct{}{}
-}
-
-// APIKeyCleared returns if the "api_key" field was cleared in this mutation.
-func (m *XunjiMutation) APIKeyCleared() bool {
-	_, ok := m.clearedFields[xunji.FieldAPIKey]
-	return ok
-}
-
-// ResetAPIKey resets all changes to the "api_key" field.
-func (m *XunjiMutation) ResetAPIKey() {
-	m.api_key = nil
-	delete(m.clearedFields, xunji.FieldAPIKey)
-}
-
 // Where appends a list predicates to the XunjiMutation builder.
 func (m *XunjiMutation) Where(ps ...predicate.Xunji) {
 	m.predicates = append(m.predicates, ps...)
@@ -49511,7 +49459,7 @@ func (m *XunjiMutation) Type() string {
 // order to get all numeric fields that were incremented/decremented, call
 // AddedFields().
 func (m *XunjiMutation) Fields() []string {
-	fields := make([]string, 0, 13)
+	fields := make([]string, 0, 10)
 	if m.created_at != nil {
 		fields = append(fields, xunji.FieldCreatedAt)
 	}
@@ -49542,15 +49490,6 @@ func (m *XunjiMutation) Fields() []string {
 	if m.organization_id != nil {
 		fields = append(fields, xunji.FieldOrganizationID)
 	}
-	if m.wxid != nil {
-		fields = append(fields, xunji.FieldWxid)
-	}
-	if m.api_base != nil {
-		fields = append(fields, xunji.FieldAPIBase)
-	}
-	if m.api_key != nil {
-		fields = append(fields, xunji.FieldAPIKey)
-	}
 	return fields
 }
 
@@ -49579,12 +49518,6 @@ func (m *XunjiMutation) Field(name string) (ent.Value, bool) {
 		return m.AgentID()
 	case xunji.FieldOrganizationID:
 		return m.OrganizationID()
-	case xunji.FieldWxid:
-		return m.Wxid()
-	case xunji.FieldAPIBase:
-		return m.APIBase()
-	case xunji.FieldAPIKey:
-		return m.APIKey()
 	}
 	return nil, false
 }
@@ -49614,12 +49547,6 @@ func (m *XunjiMutation) OldField(ctx context.Context, name string) (ent.Value, e
 		return m.OldAgentID(ctx)
 	case xunji.FieldOrganizationID:
 		return m.OldOrganizationID(ctx)
-	case xunji.FieldWxid:
-		return m.OldWxid(ctx)
-	case xunji.FieldAPIBase:
-		return m.OldAPIBase(ctx)
-	case xunji.FieldAPIKey:
-		return m.OldAPIKey(ctx)
 	}
 	return nil, fmt.Errorf("unknown Xunji field %s", name)
 }
@@ -49699,27 +49626,6 @@ func (m *XunjiMutation) SetField(name string, value ent.Value) error {
 		}
 		m.SetOrganizationID(v)
 		return nil
-	case xunji.FieldWxid:
-		v, ok := value.(string)
-		if !ok {
-			return fmt.Errorf("unexpected type %T for field %s", value, name)
-		}
-		m.SetWxid(v)
-		return nil
-	case xunji.FieldAPIBase:
-		v, ok := value.(string)
-		if !ok {
-			return fmt.Errorf("unexpected type %T for field %s", value, name)
-		}
-		m.SetAPIBase(v)
-		return nil
-	case xunji.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 Xunji field %s", name)
 }
@@ -49795,12 +49701,6 @@ func (m *XunjiMutation) ClearedFields() []string {
 	if m.FieldCleared(xunji.FieldDeletedAt) {
 		fields = append(fields, xunji.FieldDeletedAt)
 	}
-	if m.FieldCleared(xunji.FieldAPIBase) {
-		fields = append(fields, xunji.FieldAPIBase)
-	}
-	if m.FieldCleared(xunji.FieldAPIKey) {
-		fields = append(fields, xunji.FieldAPIKey)
-	}
 	return fields
 }
 
@@ -49821,12 +49721,6 @@ func (m *XunjiMutation) ClearField(name string) error {
 	case xunji.FieldDeletedAt:
 		m.ClearDeletedAt()
 		return nil
-	case xunji.FieldAPIBase:
-		m.ClearAPIBase()
-		return nil
-	case xunji.FieldAPIKey:
-		m.ClearAPIKey()
-		return nil
 	}
 	return fmt.Errorf("unknown Xunji nullable field %s", name)
 }
@@ -49865,15 +49759,6 @@ func (m *XunjiMutation) ResetField(name string) error {
 	case xunji.FieldOrganizationID:
 		m.ResetOrganizationID()
 		return nil
-	case xunji.FieldWxid:
-		m.ResetWxid()
-		return nil
-	case xunji.FieldAPIBase:
-		m.ResetAPIBase()
-		return nil
-	case xunji.FieldAPIKey:
-		m.ResetAPIKey()
-		return nil
 	}
 	return fmt.Errorf("unknown Xunji field %s", name)
 }
@@ -49925,3 +49810,1057 @@ func (m *XunjiMutation) ClearEdge(name string) error {
 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)
+}

+ 82 - 0
ent/pagination.go

@@ -46,6 +46,7 @@ import (
 	"wechat-api/ent/wxcarduser"
 	"wechat-api/ent/wxcardvisit"
 	"wechat-api/ent/xunji"
+	"wechat-api/ent/xunjiservice"
 )
 
 const errInvalidPage = "INVALID_PAGE"
@@ -3414,3 +3415,84 @@ func (x *XunjiQuery) Page(
 
 	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
+}

+ 3 - 0
ent/predicate/predicate.go

@@ -128,3 +128,6 @@ 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)

+ 42 - 8
ent/runtime/runtime.go

@@ -46,6 +46,7 @@ import (
 	"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
@@ -1823,14 +1824,47 @@ func init() {
 	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)
-	// xunjiDescAPIBase is the schema descriptor for api_base field.
-	xunjiDescAPIBase := xunjiFields[7].Descriptor()
-	// xunji.DefaultAPIBase holds the default value on creation for the api_base field.
-	xunji.DefaultAPIBase = xunjiDescAPIBase.Default.(string)
-	// xunjiDescAPIKey is the schema descriptor for api_key field.
-	xunjiDescAPIKey := xunjiFields[8].Descriptor()
-	// xunji.DefaultAPIKey holds the default value on creation for the api_key field.
-	xunji.DefaultAPIKey = xunjiDescAPIKey.Default.(string)
+	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

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

+ 0 - 4
ent/schema/xunji.go

@@ -23,9 +23,6 @@ func (Xunji) Fields() []ent.Field {
 		field.String("encoding_key").Comment("加密key"),
 		field.Uint64("agent_id").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("大模型服务密钥"),
 	}
 }
 
@@ -40,7 +37,6 @@ func (Xunji) Mixin() []ent.Mixin {
 func (Xunji) Indexes() []ent.Index {
 	return []ent.Index{
 		index.Fields("app_key", "token"),
-		index.Fields("wxid"),
 	}
 }
 

+ 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"},
+	}
+}

+ 171 - 27
ent/set_not_nil.go

@@ -11000,73 +11000,217 @@ func (x *XunjiCreate) SetNotNilOrganizationID(value *uint64) *XunjiCreate {
 }
 
 // set field if value's pointer is not nil.
-func (x *XunjiUpdate) SetNotNilWxid(value *string) *XunjiUpdate {
+func (xs *XunjiServiceUpdate) SetNotNilUpdatedAt(value *time.Time) *XunjiServiceUpdate {
 	if value != nil {
-		return x.SetWxid(*value)
+		return xs.SetUpdatedAt(*value)
 	}
-	return x
+	return xs
 }
 
 // set field if value's pointer is not nil.
-func (x *XunjiUpdateOne) SetNotNilWxid(value *string) *XunjiUpdateOne {
+func (xs *XunjiServiceUpdateOne) SetNotNilUpdatedAt(value *time.Time) *XunjiServiceUpdateOne {
 	if value != nil {
-		return x.SetWxid(*value)
+		return xs.SetUpdatedAt(*value)
 	}
-	return x
+	return xs
 }
 
 // set field if value's pointer is not nil.
-func (x *XunjiCreate) SetNotNilWxid(value *string) *XunjiCreate {
+func (xs *XunjiServiceCreate) SetNotNilUpdatedAt(value *time.Time) *XunjiServiceCreate {
 	if value != nil {
-		return x.SetWxid(*value)
+		return xs.SetUpdatedAt(*value)
 	}
-	return x
+	return xs
 }
 
 // set field if value's pointer is not nil.
-func (x *XunjiUpdate) SetNotNilAPIBase(value *string) *XunjiUpdate {
+func (xs *XunjiServiceUpdate) SetNotNilStatus(value *uint8) *XunjiServiceUpdate {
 	if value != nil {
-		return x.SetAPIBase(*value)
+		return xs.SetStatus(*value)
 	}
-	return x
+	return xs
 }
 
 // set field if value's pointer is not nil.
-func (x *XunjiUpdateOne) SetNotNilAPIBase(value *string) *XunjiUpdateOne {
+func (xs *XunjiServiceUpdateOne) SetNotNilStatus(value *uint8) *XunjiServiceUpdateOne {
 	if value != nil {
-		return x.SetAPIBase(*value)
+		return xs.SetStatus(*value)
 	}
-	return x
+	return xs
 }
 
 // set field if value's pointer is not nil.
-func (x *XunjiCreate) SetNotNilAPIBase(value *string) *XunjiCreate {
+func (xs *XunjiServiceCreate) SetNotNilStatus(value *uint8) *XunjiServiceCreate {
 	if value != nil {
-		return x.SetAPIBase(*value)
+		return xs.SetStatus(*value)
 	}
-	return x
+	return xs
 }
 
 // set field if value's pointer is not nil.
-func (x *XunjiUpdate) SetNotNilAPIKey(value *string) *XunjiUpdate {
+func (xs *XunjiServiceUpdate) SetNotNilDeletedAt(value *time.Time) *XunjiServiceUpdate {
 	if value != nil {
-		return x.SetAPIKey(*value)
+		return xs.SetDeletedAt(*value)
 	}
-	return x
+	return xs
 }
 
 // set field if value's pointer is not nil.
-func (x *XunjiUpdateOne) SetNotNilAPIKey(value *string) *XunjiUpdateOne {
+func (xs *XunjiServiceUpdateOne) SetNotNilDeletedAt(value *time.Time) *XunjiServiceUpdateOne {
 	if value != nil {
-		return x.SetAPIKey(*value)
+		return xs.SetDeletedAt(*value)
 	}
-	return x
+	return xs
 }
 
 // set field if value's pointer is not nil.
-func (x *XunjiCreate) SetNotNilAPIKey(value *string) *XunjiCreate {
+func (xs *XunjiServiceCreate) SetNotNilDeletedAt(value *time.Time) *XunjiServiceCreate {
 	if value != nil {
-		return x.SetAPIKey(*value)
+		return xs.SetDeletedAt(*value)
 	}
-	return x
+	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
 }

+ 3 - 0
ent/tx.go

@@ -96,6 +96,8 @@ type Tx struct {
 	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 +270,7 @@ func (tx *Tx) init() {
 	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.

+ 2 - 35
ent/xunji.go

@@ -37,13 +37,7 @@ type Xunji struct {
 	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"`
-	selectValues sql.SelectValues
+	selectValues   sql.SelectValues
 }
 
 // scanValues returns the types for scanning values from sql.Rows.
@@ -53,7 +47,7 @@ func (*Xunji) scanValues(columns []string) ([]any, error) {
 		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, xunji.FieldWxid, xunji.FieldAPIBase, xunji.FieldAPIKey:
+		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)
@@ -138,24 +132,6 @@ func (x *Xunji) assignValues(columns []string, values []any) error {
 			} else if value.Valid {
 				x.OrganizationID = uint64(value.Int64)
 			}
-		case xunji.FieldWxid:
-			if value, ok := values[i].(*sql.NullString); !ok {
-				return fmt.Errorf("unexpected type %T for field wxid", values[i])
-			} else if value.Valid {
-				x.Wxid = value.String
-			}
-		case xunji.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 {
-				x.APIBase = value.String
-			}
-		case xunji.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 {
-				x.APIKey = value.String
-			}
 		default:
 			x.selectValues.Set(columns[i], values[i])
 		}
@@ -221,15 +197,6 @@ func (x *Xunji) String() string {
 	builder.WriteString(", ")
 	builder.WriteString("organization_id=")
 	builder.WriteString(fmt.Sprintf("%v", x.OrganizationID))
-	builder.WriteString(", ")
-	builder.WriteString("wxid=")
-	builder.WriteString(x.Wxid)
-	builder.WriteString(", ")
-	builder.WriteString("api_base=")
-	builder.WriteString(x.APIBase)
-	builder.WriteString(", ")
-	builder.WriteString("api_key=")
-	builder.WriteString(x.APIKey)
 	builder.WriteByte(')')
 	return builder.String()
 }

+ 0 - 230
ent/xunji/where.go

@@ -104,21 +104,6 @@ func OrganizationID(v uint64) predicate.Xunji {
 	return predicate.Xunji(sql.FieldEQ(FieldOrganizationID, v))
 }
 
-// Wxid applies equality check predicate on the "wxid" field. It's identical to WxidEQ.
-func Wxid(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldEQ(FieldWxid, v))
-}
-
-// APIBase applies equality check predicate on the "api_base" field. It's identical to APIBaseEQ.
-func APIBase(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldEQ(FieldAPIBase, v))
-}
-
-// APIKey applies equality check predicate on the "api_key" field. It's identical to APIKeyEQ.
-func APIKey(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldEQ(FieldAPIKey, 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))
@@ -639,221 +624,6 @@ func OrganizationIDLTE(v uint64) predicate.Xunji {
 	return predicate.Xunji(sql.FieldLTE(FieldOrganizationID, v))
 }
 
-// WxidEQ applies the EQ predicate on the "wxid" field.
-func WxidEQ(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldEQ(FieldWxid, v))
-}
-
-// WxidNEQ applies the NEQ predicate on the "wxid" field.
-func WxidNEQ(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldNEQ(FieldWxid, v))
-}
-
-// WxidIn applies the In predicate on the "wxid" field.
-func WxidIn(vs ...string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldIn(FieldWxid, vs...))
-}
-
-// WxidNotIn applies the NotIn predicate on the "wxid" field.
-func WxidNotIn(vs ...string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldNotIn(FieldWxid, vs...))
-}
-
-// WxidGT applies the GT predicate on the "wxid" field.
-func WxidGT(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldGT(FieldWxid, v))
-}
-
-// WxidGTE applies the GTE predicate on the "wxid" field.
-func WxidGTE(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldGTE(FieldWxid, v))
-}
-
-// WxidLT applies the LT predicate on the "wxid" field.
-func WxidLT(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldLT(FieldWxid, v))
-}
-
-// WxidLTE applies the LTE predicate on the "wxid" field.
-func WxidLTE(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldLTE(FieldWxid, v))
-}
-
-// WxidContains applies the Contains predicate on the "wxid" field.
-func WxidContains(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldContains(FieldWxid, v))
-}
-
-// WxidHasPrefix applies the HasPrefix predicate on the "wxid" field.
-func WxidHasPrefix(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldHasPrefix(FieldWxid, v))
-}
-
-// WxidHasSuffix applies the HasSuffix predicate on the "wxid" field.
-func WxidHasSuffix(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldHasSuffix(FieldWxid, v))
-}
-
-// WxidEqualFold applies the EqualFold predicate on the "wxid" field.
-func WxidEqualFold(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldEqualFold(FieldWxid, v))
-}
-
-// WxidContainsFold applies the ContainsFold predicate on the "wxid" field.
-func WxidContainsFold(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldContainsFold(FieldWxid, v))
-}
-
-// APIBaseEQ applies the EQ predicate on the "api_base" field.
-func APIBaseEQ(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldEQ(FieldAPIBase, v))
-}
-
-// APIBaseNEQ applies the NEQ predicate on the "api_base" field.
-func APIBaseNEQ(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldNEQ(FieldAPIBase, v))
-}
-
-// APIBaseIn applies the In predicate on the "api_base" field.
-func APIBaseIn(vs ...string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldIn(FieldAPIBase, vs...))
-}
-
-// APIBaseNotIn applies the NotIn predicate on the "api_base" field.
-func APIBaseNotIn(vs ...string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldNotIn(FieldAPIBase, vs...))
-}
-
-// APIBaseGT applies the GT predicate on the "api_base" field.
-func APIBaseGT(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldGT(FieldAPIBase, v))
-}
-
-// APIBaseGTE applies the GTE predicate on the "api_base" field.
-func APIBaseGTE(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldGTE(FieldAPIBase, v))
-}
-
-// APIBaseLT applies the LT predicate on the "api_base" field.
-func APIBaseLT(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldLT(FieldAPIBase, v))
-}
-
-// APIBaseLTE applies the LTE predicate on the "api_base" field.
-func APIBaseLTE(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldLTE(FieldAPIBase, v))
-}
-
-// APIBaseContains applies the Contains predicate on the "api_base" field.
-func APIBaseContains(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldContains(FieldAPIBase, v))
-}
-
-// APIBaseHasPrefix applies the HasPrefix predicate on the "api_base" field.
-func APIBaseHasPrefix(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldHasPrefix(FieldAPIBase, v))
-}
-
-// APIBaseHasSuffix applies the HasSuffix predicate on the "api_base" field.
-func APIBaseHasSuffix(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldHasSuffix(FieldAPIBase, v))
-}
-
-// APIBaseIsNil applies the IsNil predicate on the "api_base" field.
-func APIBaseIsNil() predicate.Xunji {
-	return predicate.Xunji(sql.FieldIsNull(FieldAPIBase))
-}
-
-// APIBaseNotNil applies the NotNil predicate on the "api_base" field.
-func APIBaseNotNil() predicate.Xunji {
-	return predicate.Xunji(sql.FieldNotNull(FieldAPIBase))
-}
-
-// APIBaseEqualFold applies the EqualFold predicate on the "api_base" field.
-func APIBaseEqualFold(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldEqualFold(FieldAPIBase, v))
-}
-
-// APIBaseContainsFold applies the ContainsFold predicate on the "api_base" field.
-func APIBaseContainsFold(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldContainsFold(FieldAPIBase, v))
-}
-
-// APIKeyEQ applies the EQ predicate on the "api_key" field.
-func APIKeyEQ(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldEQ(FieldAPIKey, v))
-}
-
-// APIKeyNEQ applies the NEQ predicate on the "api_key" field.
-func APIKeyNEQ(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldNEQ(FieldAPIKey, v))
-}
-
-// APIKeyIn applies the In predicate on the "api_key" field.
-func APIKeyIn(vs ...string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldIn(FieldAPIKey, vs...))
-}
-
-// APIKeyNotIn applies the NotIn predicate on the "api_key" field.
-func APIKeyNotIn(vs ...string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldNotIn(FieldAPIKey, vs...))
-}
-
-// APIKeyGT applies the GT predicate on the "api_key" field.
-func APIKeyGT(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldGT(FieldAPIKey, v))
-}
-
-// APIKeyGTE applies the GTE predicate on the "api_key" field.
-func APIKeyGTE(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldGTE(FieldAPIKey, v))
-}
-
-// APIKeyLT applies the LT predicate on the "api_key" field.
-func APIKeyLT(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldLT(FieldAPIKey, v))
-}
-
-// APIKeyLTE applies the LTE predicate on the "api_key" field.
-func APIKeyLTE(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldLTE(FieldAPIKey, v))
-}
-
-// APIKeyContains applies the Contains predicate on the "api_key" field.
-func APIKeyContains(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldContains(FieldAPIKey, v))
-}
-
-// APIKeyHasPrefix applies the HasPrefix predicate on the "api_key" field.
-func APIKeyHasPrefix(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldHasPrefix(FieldAPIKey, v))
-}
-
-// APIKeyHasSuffix applies the HasSuffix predicate on the "api_key" field.
-func APIKeyHasSuffix(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldHasSuffix(FieldAPIKey, v))
-}
-
-// APIKeyIsNil applies the IsNil predicate on the "api_key" field.
-func APIKeyIsNil() predicate.Xunji {
-	return predicate.Xunji(sql.FieldIsNull(FieldAPIKey))
-}
-
-// APIKeyNotNil applies the NotNil predicate on the "api_key" field.
-func APIKeyNotNil() predicate.Xunji {
-	return predicate.Xunji(sql.FieldNotNull(FieldAPIKey))
-}
-
-// APIKeyEqualFold applies the EqualFold predicate on the "api_key" field.
-func APIKeyEqualFold(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldEqualFold(FieldAPIKey, v))
-}
-
-// APIKeyContainsFold applies the ContainsFold predicate on the "api_key" field.
-func APIKeyContainsFold(v string) predicate.Xunji {
-	return predicate.Xunji(sql.FieldContainsFold(FieldAPIKey, v))
-}
-
 // And groups predicates with the AND operator between them.
 func And(predicates ...predicate.Xunji) predicate.Xunji {
 	return predicate.Xunji(sql.AndPredicates(predicates...))

+ 0 - 28
ent/xunji/xunji.go

@@ -34,12 +34,6 @@ const (
 	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"
 	// Table holds the table name of the xunji in the database.
 	Table = "xunji"
 )
@@ -57,9 +51,6 @@ var Columns = []string{
 	FieldEncodingKey,
 	FieldAgentID,
 	FieldOrganizationID,
-	FieldWxid,
-	FieldAPIBase,
-	FieldAPIKey,
 }
 
 // ValidColumn reports if the column name is valid (part of the table columns).
@@ -90,10 +81,6 @@ var (
 	DefaultStatus uint8
 	// 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 Xunji queries.
@@ -153,18 +140,3 @@ func ByAgentID(opts ...sql.OrderTermOption) OrderOption {
 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()
-}

+ 0 - 217
ent/xunji_create.go

@@ -114,40 +114,6 @@ func (xc *XunjiCreate) SetOrganizationID(u uint64) *XunjiCreate {
 	return xc
 }
 
-// SetWxid sets the "wxid" field.
-func (xc *XunjiCreate) SetWxid(s string) *XunjiCreate {
-	xc.mutation.SetWxid(s)
-	return xc
-}
-
-// SetAPIBase sets the "api_base" field.
-func (xc *XunjiCreate) SetAPIBase(s string) *XunjiCreate {
-	xc.mutation.SetAPIBase(s)
-	return xc
-}
-
-// SetNillableAPIBase sets the "api_base" field if the given value is not nil.
-func (xc *XunjiCreate) SetNillableAPIBase(s *string) *XunjiCreate {
-	if s != nil {
-		xc.SetAPIBase(*s)
-	}
-	return xc
-}
-
-// SetAPIKey sets the "api_key" field.
-func (xc *XunjiCreate) SetAPIKey(s string) *XunjiCreate {
-	xc.mutation.SetAPIKey(s)
-	return xc
-}
-
-// SetNillableAPIKey sets the "api_key" field if the given value is not nil.
-func (xc *XunjiCreate) SetNillableAPIKey(s *string) *XunjiCreate {
-	if s != nil {
-		xc.SetAPIKey(*s)
-	}
-	return xc
-}
-
 // SetID sets the "id" field.
 func (xc *XunjiCreate) SetID(u uint64) *XunjiCreate {
 	xc.mutation.SetID(u)
@@ -209,14 +175,6 @@ func (xc *XunjiCreate) defaults() error {
 		v := xunji.DefaultStatus
 		xc.mutation.SetStatus(v)
 	}
-	if _, ok := xc.mutation.APIBase(); !ok {
-		v := xunji.DefaultAPIBase
-		xc.mutation.SetAPIBase(v)
-	}
-	if _, ok := xc.mutation.APIKey(); !ok {
-		v := xunji.DefaultAPIKey
-		xc.mutation.SetAPIKey(v)
-	}
 	return nil
 }
 
@@ -251,9 +209,6 @@ func (xc *XunjiCreate) check() error {
 			return &ValidationError{Name: "organization_id", err: fmt.Errorf(`ent: validator failed for field "Xunji.organization_id": %w`, err)}
 		}
 	}
-	if _, ok := xc.mutation.Wxid(); !ok {
-		return &ValidationError{Name: "wxid", err: errors.New(`ent: missing required field "Xunji.wxid"`)}
-	}
 	return nil
 }
 
@@ -327,18 +282,6 @@ func (xc *XunjiCreate) createSpec() (*Xunji, *sqlgraph.CreateSpec) {
 		_spec.SetField(xunji.FieldOrganizationID, field.TypeUint64, value)
 		_node.OrganizationID = value
 	}
-	if value, ok := xc.mutation.Wxid(); ok {
-		_spec.SetField(xunji.FieldWxid, field.TypeString, value)
-		_node.Wxid = value
-	}
-	if value, ok := xc.mutation.APIBase(); ok {
-		_spec.SetField(xunji.FieldAPIBase, field.TypeString, value)
-		_node.APIBase = value
-	}
-	if value, ok := xc.mutation.APIKey(); ok {
-		_spec.SetField(xunji.FieldAPIKey, field.TypeString, value)
-		_node.APIKey = value
-	}
 	return _node, _spec
 }
 
@@ -529,54 +472,6 @@ func (u *XunjiUpsert) AddOrganizationID(v uint64) *XunjiUpsert {
 	return u
 }
 
-// SetWxid sets the "wxid" field.
-func (u *XunjiUpsert) SetWxid(v string) *XunjiUpsert {
-	u.Set(xunji.FieldWxid, v)
-	return u
-}
-
-// UpdateWxid sets the "wxid" field to the value that was provided on create.
-func (u *XunjiUpsert) UpdateWxid() *XunjiUpsert {
-	u.SetExcluded(xunji.FieldWxid)
-	return u
-}
-
-// SetAPIBase sets the "api_base" field.
-func (u *XunjiUpsert) SetAPIBase(v string) *XunjiUpsert {
-	u.Set(xunji.FieldAPIBase, v)
-	return u
-}
-
-// UpdateAPIBase sets the "api_base" field to the value that was provided on create.
-func (u *XunjiUpsert) UpdateAPIBase() *XunjiUpsert {
-	u.SetExcluded(xunji.FieldAPIBase)
-	return u
-}
-
-// ClearAPIBase clears the value of the "api_base" field.
-func (u *XunjiUpsert) ClearAPIBase() *XunjiUpsert {
-	u.SetNull(xunji.FieldAPIBase)
-	return u
-}
-
-// SetAPIKey sets the "api_key" field.
-func (u *XunjiUpsert) SetAPIKey(v string) *XunjiUpsert {
-	u.Set(xunji.FieldAPIKey, v)
-	return u
-}
-
-// UpdateAPIKey sets the "api_key" field to the value that was provided on create.
-func (u *XunjiUpsert) UpdateAPIKey() *XunjiUpsert {
-	u.SetExcluded(xunji.FieldAPIKey)
-	return u
-}
-
-// ClearAPIKey clears the value of the "api_key" field.
-func (u *XunjiUpsert) ClearAPIKey() *XunjiUpsert {
-	u.SetNull(xunji.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:
 //
@@ -789,62 +684,6 @@ func (u *XunjiUpsertOne) UpdateOrganizationID() *XunjiUpsertOne {
 	})
 }
 
-// SetWxid sets the "wxid" field.
-func (u *XunjiUpsertOne) SetWxid(v string) *XunjiUpsertOne {
-	return u.Update(func(s *XunjiUpsert) {
-		s.SetWxid(v)
-	})
-}
-
-// UpdateWxid sets the "wxid" field to the value that was provided on create.
-func (u *XunjiUpsertOne) UpdateWxid() *XunjiUpsertOne {
-	return u.Update(func(s *XunjiUpsert) {
-		s.UpdateWxid()
-	})
-}
-
-// SetAPIBase sets the "api_base" field.
-func (u *XunjiUpsertOne) SetAPIBase(v string) *XunjiUpsertOne {
-	return u.Update(func(s *XunjiUpsert) {
-		s.SetAPIBase(v)
-	})
-}
-
-// UpdateAPIBase sets the "api_base" field to the value that was provided on create.
-func (u *XunjiUpsertOne) UpdateAPIBase() *XunjiUpsertOne {
-	return u.Update(func(s *XunjiUpsert) {
-		s.UpdateAPIBase()
-	})
-}
-
-// ClearAPIBase clears the value of the "api_base" field.
-func (u *XunjiUpsertOne) ClearAPIBase() *XunjiUpsertOne {
-	return u.Update(func(s *XunjiUpsert) {
-		s.ClearAPIBase()
-	})
-}
-
-// SetAPIKey sets the "api_key" field.
-func (u *XunjiUpsertOne) SetAPIKey(v string) *XunjiUpsertOne {
-	return u.Update(func(s *XunjiUpsert) {
-		s.SetAPIKey(v)
-	})
-}
-
-// UpdateAPIKey sets the "api_key" field to the value that was provided on create.
-func (u *XunjiUpsertOne) UpdateAPIKey() *XunjiUpsertOne {
-	return u.Update(func(s *XunjiUpsert) {
-		s.UpdateAPIKey()
-	})
-}
-
-// ClearAPIKey clears the value of the "api_key" field.
-func (u *XunjiUpsertOne) ClearAPIKey() *XunjiUpsertOne {
-	return u.Update(func(s *XunjiUpsert) {
-		s.ClearAPIKey()
-	})
-}
-
 // Exec executes the query.
 func (u *XunjiUpsertOne) Exec(ctx context.Context) error {
 	if len(u.create.conflict) == 0 {
@@ -1223,62 +1062,6 @@ func (u *XunjiUpsertBulk) UpdateOrganizationID() *XunjiUpsertBulk {
 	})
 }
 
-// SetWxid sets the "wxid" field.
-func (u *XunjiUpsertBulk) SetWxid(v string) *XunjiUpsertBulk {
-	return u.Update(func(s *XunjiUpsert) {
-		s.SetWxid(v)
-	})
-}
-
-// UpdateWxid sets the "wxid" field to the value that was provided on create.
-func (u *XunjiUpsertBulk) UpdateWxid() *XunjiUpsertBulk {
-	return u.Update(func(s *XunjiUpsert) {
-		s.UpdateWxid()
-	})
-}
-
-// SetAPIBase sets the "api_base" field.
-func (u *XunjiUpsertBulk) SetAPIBase(v string) *XunjiUpsertBulk {
-	return u.Update(func(s *XunjiUpsert) {
-		s.SetAPIBase(v)
-	})
-}
-
-// UpdateAPIBase sets the "api_base" field to the value that was provided on create.
-func (u *XunjiUpsertBulk) UpdateAPIBase() *XunjiUpsertBulk {
-	return u.Update(func(s *XunjiUpsert) {
-		s.UpdateAPIBase()
-	})
-}
-
-// ClearAPIBase clears the value of the "api_base" field.
-func (u *XunjiUpsertBulk) ClearAPIBase() *XunjiUpsertBulk {
-	return u.Update(func(s *XunjiUpsert) {
-		s.ClearAPIBase()
-	})
-}
-
-// SetAPIKey sets the "api_key" field.
-func (u *XunjiUpsertBulk) SetAPIKey(v string) *XunjiUpsertBulk {
-	return u.Update(func(s *XunjiUpsert) {
-		s.SetAPIKey(v)
-	})
-}
-
-// UpdateAPIKey sets the "api_key" field to the value that was provided on create.
-func (u *XunjiUpsertBulk) UpdateAPIKey() *XunjiUpsertBulk {
-	return u.Update(func(s *XunjiUpsert) {
-		s.UpdateAPIKey()
-	})
-}
-
-// ClearAPIKey clears the value of the "api_key" field.
-func (u *XunjiUpsertBulk) ClearAPIKey() *XunjiUpsertBulk {
-	return u.Update(func(s *XunjiUpsert) {
-		s.ClearAPIKey()
-	})
-}
-
 // Exec executes the query.
 func (u *XunjiUpsertBulk) Exec(ctx context.Context) error {
 	if u.create.err != nil {

+ 0 - 138
ent/xunji_update.go

@@ -179,60 +179,6 @@ func (xu *XunjiUpdate) AddOrganizationID(u int64) *XunjiUpdate {
 	return xu
 }
 
-// SetWxid sets the "wxid" field.
-func (xu *XunjiUpdate) SetWxid(s string) *XunjiUpdate {
-	xu.mutation.SetWxid(s)
-	return xu
-}
-
-// SetNillableWxid sets the "wxid" field if the given value is not nil.
-func (xu *XunjiUpdate) SetNillableWxid(s *string) *XunjiUpdate {
-	if s != nil {
-		xu.SetWxid(*s)
-	}
-	return xu
-}
-
-// SetAPIBase sets the "api_base" field.
-func (xu *XunjiUpdate) SetAPIBase(s string) *XunjiUpdate {
-	xu.mutation.SetAPIBase(s)
-	return xu
-}
-
-// SetNillableAPIBase sets the "api_base" field if the given value is not nil.
-func (xu *XunjiUpdate) SetNillableAPIBase(s *string) *XunjiUpdate {
-	if s != nil {
-		xu.SetAPIBase(*s)
-	}
-	return xu
-}
-
-// ClearAPIBase clears the value of the "api_base" field.
-func (xu *XunjiUpdate) ClearAPIBase() *XunjiUpdate {
-	xu.mutation.ClearAPIBase()
-	return xu
-}
-
-// SetAPIKey sets the "api_key" field.
-func (xu *XunjiUpdate) SetAPIKey(s string) *XunjiUpdate {
-	xu.mutation.SetAPIKey(s)
-	return xu
-}
-
-// SetNillableAPIKey sets the "api_key" field if the given value is not nil.
-func (xu *XunjiUpdate) SetNillableAPIKey(s *string) *XunjiUpdate {
-	if s != nil {
-		xu.SetAPIKey(*s)
-	}
-	return xu
-}
-
-// ClearAPIKey clears the value of the "api_key" field.
-func (xu *XunjiUpdate) ClearAPIKey() *XunjiUpdate {
-	xu.mutation.ClearAPIKey()
-	return xu
-}
-
 // Mutation returns the XunjiMutation object of the builder.
 func (xu *XunjiUpdate) Mutation() *XunjiMutation {
 	return xu.mutation
@@ -344,21 +290,6 @@ func (xu *XunjiUpdate) sqlSave(ctx context.Context) (n int, err error) {
 	if value, ok := xu.mutation.AddedOrganizationID(); ok {
 		_spec.AddField(xunji.FieldOrganizationID, field.TypeUint64, value)
 	}
-	if value, ok := xu.mutation.Wxid(); ok {
-		_spec.SetField(xunji.FieldWxid, field.TypeString, value)
-	}
-	if value, ok := xu.mutation.APIBase(); ok {
-		_spec.SetField(xunji.FieldAPIBase, field.TypeString, value)
-	}
-	if xu.mutation.APIBaseCleared() {
-		_spec.ClearField(xunji.FieldAPIBase, field.TypeString)
-	}
-	if value, ok := xu.mutation.APIKey(); ok {
-		_spec.SetField(xunji.FieldAPIKey, field.TypeString, value)
-	}
-	if xu.mutation.APIKeyCleared() {
-		_spec.ClearField(xunji.FieldAPIKey, field.TypeString)
-	}
 	if n, err = sqlgraph.UpdateNodes(ctx, xu.driver, _spec); err != nil {
 		if _, ok := err.(*sqlgraph.NotFoundError); ok {
 			err = &NotFoundError{xunji.Label}
@@ -530,60 +461,6 @@ func (xuo *XunjiUpdateOne) AddOrganizationID(u int64) *XunjiUpdateOne {
 	return xuo
 }
 
-// SetWxid sets the "wxid" field.
-func (xuo *XunjiUpdateOne) SetWxid(s string) *XunjiUpdateOne {
-	xuo.mutation.SetWxid(s)
-	return xuo
-}
-
-// SetNillableWxid sets the "wxid" field if the given value is not nil.
-func (xuo *XunjiUpdateOne) SetNillableWxid(s *string) *XunjiUpdateOne {
-	if s != nil {
-		xuo.SetWxid(*s)
-	}
-	return xuo
-}
-
-// SetAPIBase sets the "api_base" field.
-func (xuo *XunjiUpdateOne) SetAPIBase(s string) *XunjiUpdateOne {
-	xuo.mutation.SetAPIBase(s)
-	return xuo
-}
-
-// SetNillableAPIBase sets the "api_base" field if the given value is not nil.
-func (xuo *XunjiUpdateOne) SetNillableAPIBase(s *string) *XunjiUpdateOne {
-	if s != nil {
-		xuo.SetAPIBase(*s)
-	}
-	return xuo
-}
-
-// ClearAPIBase clears the value of the "api_base" field.
-func (xuo *XunjiUpdateOne) ClearAPIBase() *XunjiUpdateOne {
-	xuo.mutation.ClearAPIBase()
-	return xuo
-}
-
-// SetAPIKey sets the "api_key" field.
-func (xuo *XunjiUpdateOne) SetAPIKey(s string) *XunjiUpdateOne {
-	xuo.mutation.SetAPIKey(s)
-	return xuo
-}
-
-// SetNillableAPIKey sets the "api_key" field if the given value is not nil.
-func (xuo *XunjiUpdateOne) SetNillableAPIKey(s *string) *XunjiUpdateOne {
-	if s != nil {
-		xuo.SetAPIKey(*s)
-	}
-	return xuo
-}
-
-// ClearAPIKey clears the value of the "api_key" field.
-func (xuo *XunjiUpdateOne) ClearAPIKey() *XunjiUpdateOne {
-	xuo.mutation.ClearAPIKey()
-	return xuo
-}
-
 // Mutation returns the XunjiMutation object of the builder.
 func (xuo *XunjiUpdateOne) Mutation() *XunjiMutation {
 	return xuo.mutation
@@ -725,21 +602,6 @@ func (xuo *XunjiUpdateOne) sqlSave(ctx context.Context) (_node *Xunji, err error
 	if value, ok := xuo.mutation.AddedOrganizationID(); ok {
 		_spec.AddField(xunji.FieldOrganizationID, field.TypeUint64, value)
 	}
-	if value, ok := xuo.mutation.Wxid(); ok {
-		_spec.SetField(xunji.FieldWxid, field.TypeString, value)
-	}
-	if value, ok := xuo.mutation.APIBase(); ok {
-		_spec.SetField(xunji.FieldAPIBase, field.TypeString, value)
-	}
-	if xuo.mutation.APIBaseCleared() {
-		_spec.ClearField(xunji.FieldAPIBase, field.TypeString)
-	}
-	if value, ok := xuo.mutation.APIKey(); ok {
-		_spec.SetField(xunji.FieldAPIKey, field.TypeString, value)
-	}
-	if xuo.mutation.APIKeyCleared() {
-		_spec.ClearField(xunji.FieldAPIKey, field.TypeString)
-	}
 	_node = &Xunji{config: xuo.config}
 	_spec.Assign = _node.assignValues
 	_spec.ScanValues = _node.scanValues

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

+ 5 - 5
etc/wechat.yaml

@@ -28,8 +28,8 @@ DatabaseConf:
   Host: mysql-server
   Port: 3306
   DBName: wechat
-  Username: wallet
-  Password: wallet
+  Username: root
+  Password: simple-admin.
   MaxOpenConn: 100
   SSLMode: disable
   CacheTime: 5
@@ -47,9 +47,9 @@ CasbinDatabaseConf:
   Type: mysql
   Host: mysql-server
   Port: 3306
-  DBName: wechat-admin
-  Username: wallet
-  Password: wallet
+  DBName: wechat_admin
+  Username: root
+  Password: simple-admin.
   MaxOpenConn: 100
   SSLMode: disable
   CacheTime: 5

+ 1 - 0
go.mod

@@ -13,6 +13,7 @@ require (
 	github.com/alibabacloud-go/tea-utils/v2 v2.0.7
 	github.com/bwmarrin/snowflake v0.3.0
 	github.com/casbin/casbin/v2 v2.85.0
+	github.com/deckarep/golang-set/v2 v2.8.0
 	github.com/go-resty/resty/v2 v2.14.0
 	github.com/gofrs/uuid/v5 v5.0.0
 	github.com/golang-jwt/jwt/v5 v5.2.1

+ 6 - 0
go.sum

@@ -163,6 +163,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/deckarep/golang-set/v2 v2.8.0 h1:swm0rlPCmdWn9mESxKOjWk8hXSqoxOp+ZlfuyaAdFlQ=
+github.com/deckarep/golang-set/v2 v2.8.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4=
 github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
 github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
 github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
@@ -466,6 +468,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=
@@ -502,6 +505,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=
@@ -603,6 +607,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=

+ 35 - 0
internal/handler/routes.go

@@ -49,6 +49,7 @@ import (
 	wxcardvisit "wechat-api/internal/handler/wxcardvisit"
 	xiaoice "wechat-api/internal/handler/xiaoice"
 	xunji "wechat-api/internal/handler/xunji"
+	xunji_service "wechat-api/internal/handler/xunji_service"
 	"wechat-api/internal/svc"
 
 	"github.com/zeromicro/go-zero/rest"
@@ -2072,4 +2073,38 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 		),
 		rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
 	)
+
+	server.AddRoutes(
+		rest.WithMiddlewares(
+			[]rest.Middleware{serverCtx.Authority},
+			[]rest.Route{
+				{
+					Method:  http.MethodPost,
+					Path:    "/xunji_service/create",
+					Handler: xunji_service.CreateXunjiServiceHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/xunji_service/update",
+					Handler: xunji_service.UpdateXunjiServiceHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/xunji_service/delete",
+					Handler: xunji_service.DeleteXunjiServiceHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/xunji_service/list",
+					Handler: xunji_service.GetXunjiServiceListHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/xunji_service",
+					Handler: xunji_service.GetXunjiServiceByIdHandler(serverCtx),
+				},
+			}...,
+		),
+		rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
+	)
 }

+ 44 - 0
internal/handler/xunji_service/create_xunji_service_handler.go

@@ -0,0 +1,44 @@
+package xunji_service
+
+import (
+	"net/http"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
+
+	"wechat-api/internal/logic/xunji_service"
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+)
+
+// swagger:route post /xunji_service/create xunji_service CreateXunjiService
+//
+// Create xunji service information | 创建XunjiService
+//
+// Create xunji service information | 创建XunjiService
+//
+// Parameters:
+//  + name: body
+//    require: true
+//    in: body
+//    type: XunjiServiceInfo
+//
+// Responses:
+//  200: BaseMsgResp
+
+func CreateXunjiServiceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.XunjiServiceInfo
+		if err := httpx.Parse(r, &req, true); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := xunji_service.NewCreateXunjiServiceLogic(r.Context(), svcCtx)
+		resp, err := l.CreateXunjiService(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 44 - 0
internal/handler/xunji_service/delete_xunji_service_handler.go

@@ -0,0 +1,44 @@
+package xunji_service
+
+import (
+	"net/http"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
+
+	"wechat-api/internal/logic/xunji_service"
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+)
+
+// swagger:route post /xunji_service/delete xunji_service DeleteXunjiService
+//
+// Delete xunji service information | 删除XunjiService信息
+//
+// Delete xunji service information | 删除XunjiService信息
+//
+// Parameters:
+//  + name: body
+//    require: true
+//    in: body
+//    type: IDsReq
+//
+// Responses:
+//  200: BaseMsgResp
+
+func DeleteXunjiServiceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.IDsReq
+		if err := httpx.Parse(r, &req, true); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := xunji_service.NewDeleteXunjiServiceLogic(r.Context(), svcCtx)
+		resp, err := l.DeleteXunjiService(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 44 - 0
internal/handler/xunji_service/get_xunji_service_by_id_handler.go

@@ -0,0 +1,44 @@
+package xunji_service
+
+import (
+	"net/http"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
+
+	"wechat-api/internal/logic/xunji_service"
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+)
+
+// swagger:route post /xunji_service xunji_service GetXunjiServiceById
+//
+// Get xunji service by ID | 通过ID获取XunjiService
+//
+// Get xunji service by ID | 通过ID获取XunjiService
+//
+// Parameters:
+//  + name: body
+//    require: true
+//    in: body
+//    type: IDReq
+//
+// Responses:
+//  200: XunjiServiceInfoResp
+
+func GetXunjiServiceByIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.IDReq
+		if err := httpx.Parse(r, &req, true); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := xunji_service.NewGetXunjiServiceByIdLogic(r.Context(), svcCtx)
+		resp, err := l.GetXunjiServiceById(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 44 - 0
internal/handler/xunji_service/get_xunji_service_list_handler.go

@@ -0,0 +1,44 @@
+package xunji_service
+
+import (
+	"net/http"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
+
+	"wechat-api/internal/logic/xunji_service"
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+)
+
+// swagger:route post /xunji_service/list xunji_service GetXunjiServiceList
+//
+// Get xunji service list | 获取XunjiService列表
+//
+// Get xunji service list | 获取XunjiService列表
+//
+// Parameters:
+//  + name: body
+//    require: true
+//    in: body
+//    type: XunjiServiceListReq
+//
+// Responses:
+//  200: XunjiServiceListResp
+
+func GetXunjiServiceListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.XunjiServiceListReq
+		if err := httpx.Parse(r, &req, true); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := xunji_service.NewGetXunjiServiceListLogic(r.Context(), svcCtx)
+		resp, err := l.GetXunjiServiceList(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 44 - 0
internal/handler/xunji_service/update_xunji_service_handler.go

@@ -0,0 +1,44 @@
+package xunji_service
+
+import (
+	"net/http"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
+
+	"wechat-api/internal/logic/xunji_service"
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+)
+
+// swagger:route post /xunji_service/update xunji_service UpdateXunjiService
+//
+// Update xunji service information | 更新XunjiService
+//
+// Update xunji service information | 更新XunjiService
+//
+// Parameters:
+//  + name: body
+//    require: true
+//    in: body
+//    type: XunjiServiceInfo
+//
+// Responses:
+//  200: BaseMsgResp
+
+func UpdateXunjiServiceHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.XunjiServiceInfo
+		if err := httpx.Parse(r, &req, true); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := xunji_service.NewUpdateXunjiServiceLogic(r.Context(), svcCtx)
+		resp, err := l.UpdateXunjiService(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 62 - 0
internal/logic/base/init_api_data.go

@@ -6,6 +6,68 @@ import (
 )
 
 func (l *InitDatabaseLogic) insertApiData() (err error) {
+	// XunjiService
+
+	_, err = l.svcCtx.CoreRpc.CreateApi(l.ctx, &core.ApiInfo{
+		ServiceName: pointy.GetPointer("Wechat"),
+		Path:        pointy.GetPointer("/xunji_service/create"),
+		Description: pointy.GetPointer("apiDesc.createXunjiService"),
+		ApiGroup:    pointy.GetPointer("xunji_service"),
+		Method:      pointy.GetPointer("POST"),
+	})
+
+	if err != nil {
+		return err
+	}
+
+	_, err = l.svcCtx.CoreRpc.CreateApi(l.ctx, &core.ApiInfo{
+		ServiceName: pointy.GetPointer("Wechat"),
+		Path:        pointy.GetPointer("/xunji_service/update"),
+		Description: pointy.GetPointer("apiDesc.updateXunjiService"),
+		ApiGroup:    pointy.GetPointer("xunji_service"),
+		Method:      pointy.GetPointer("POST"),
+	})
+
+	if err != nil {
+		return err
+	}
+
+	_, err = l.svcCtx.CoreRpc.CreateApi(l.ctx, &core.ApiInfo{
+		ServiceName: pointy.GetPointer("Wechat"),
+		Path:        pointy.GetPointer("/xunji_service/delete"),
+		Description: pointy.GetPointer("apiDesc.deleteXunjiService"),
+		ApiGroup:    pointy.GetPointer("xunji_service"),
+		Method:      pointy.GetPointer("POST"),
+	})
+
+	if err != nil {
+		return err
+	}
+
+	_, err = l.svcCtx.CoreRpc.CreateApi(l.ctx, &core.ApiInfo{
+		ServiceName: pointy.GetPointer("Wechat"),
+		Path:        pointy.GetPointer("/xunji_service/list"),
+		Description: pointy.GetPointer("apiDesc.getXunjiServiceList"),
+		ApiGroup:    pointy.GetPointer("xunji_service"),
+		Method:      pointy.GetPointer("POST"),
+	})
+
+	if err != nil {
+		return err
+	}
+
+	_, err = l.svcCtx.CoreRpc.CreateApi(l.ctx, &core.ApiInfo{
+		ServiceName: pointy.GetPointer("Wechat"),
+		Path:        pointy.GetPointer("/xunji_service"),
+		Description: pointy.GetPointer("apiDesc.getXunjiServiceById"),
+		ApiGroup:    pointy.GetPointer("xunji_service"),
+		Method:      pointy.GetPointer("POST"),
+	})
+
+	if err != nil {
+		return err
+	}
+
 	// Xunji
 
 	_, err = l.svcCtx.CoreRpc.CreateApi(l.ctx, &core.ApiInfo{

+ 0 - 3
internal/logic/xunji/create_xunji_logic.go

@@ -37,9 +37,6 @@ func (l *CreateXunjiLogic) CreateXunji(req *types.XunjiInfo) (*types.BaseMsgResp
 		SetNotNilEncodingKey(req.EncodingKey).
 		SetNotNilAgentID(req.AgentId).
 		SetOrganizationID(organizationId).
-		SetNotNilWxid(req.Wxid).
-		SetNotNilAPIBase(req.ApiBase).
-		SetNotNilAPIKey(req.ApiKey).
 		Save(l.ctx)
 
 	if err != nil {

+ 19 - 23
internal/logic/xunji/get_xunji_by_id_logic.go

@@ -7,7 +7,7 @@ import (
 	"wechat-api/internal/types"
 	"wechat-api/internal/utils/dberrorhandler"
 
-    "github.com/suyuan32/simple-admin-common/msg/errormsg"
+	"github.com/suyuan32/simple-admin-common/msg/errormsg"
 
 	"github.com/suyuan32/simple-admin-common/utils/pointy"
 	"github.com/zeromicro/go-zero/core/logx"
@@ -34,27 +34,23 @@ func (l *GetXunjiByIdLogic) GetXunjiById(req *types.IDReq) (*types.XunjiInfoResp
 	}
 
 	return &types.XunjiInfoResp{
-	    BaseDataInfo: types.BaseDataInfo{
-            Code: 0,
-            Msg:  errormsg.Success,
-        },
-        Data: types.XunjiInfo{
-            BaseIDInfo:    types.BaseIDInfo{
-				Id:          &data.ID,
-				CreatedAt:    pointy.GetPointer(data.CreatedAt.UnixMilli()),
-				UpdatedAt:    pointy.GetPointer(data.UpdatedAt.UnixMilli()),
-            },
-			Status:	&data.Status,
-			AppKey:	&data.AppKey,
-			AppSecret:	&data.AppSecret,
-			Token:	&data.Token,
-			EncodingKey:	&data.EncodingKey,
-			AgentId:	&data.AgentID,
-			OrganizationId:	&data.OrganizationID,
-			Wxid:	&data.Wxid,
-			ApiBase:	&data.APIBase,
-			ApiKey:	&data.APIKey,
-        },
+		BaseDataInfo: types.BaseDataInfo{
+			Code: 0,
+			Msg:  errormsg.Success,
+		},
+		Data: types.XunjiInfo{
+			BaseIDInfo: types.BaseIDInfo{
+				Id:        &data.ID,
+				CreatedAt: pointy.GetPointer(data.CreatedAt.UnixMilli()),
+				UpdatedAt: pointy.GetPointer(data.UpdatedAt.UnixMilli()),
+			},
+			Status:         &data.Status,
+			AppKey:         &data.AppKey,
+			AppSecret:      &data.AppSecret,
+			Token:          &data.Token,
+			EncodingKey:    &data.EncodingKey,
+			AgentId:        &data.AgentID,
+			OrganizationId: &data.OrganizationID,
+		},
 	}, nil
 }
-

+ 16 - 19
internal/logic/xunji/get_xunji_list_logic.go

@@ -3,13 +3,13 @@ package xunji
 import (
 	"context"
 
-	"wechat-api/ent/xunji"
 	"wechat-api/ent/predicate"
+	"wechat-api/ent/xunji"
 	"wechat-api/internal/svc"
 	"wechat-api/internal/types"
 	"wechat-api/internal/utils/dberrorhandler"
 
-    "github.com/suyuan32/simple-admin-common/msg/errormsg"
+	"github.com/suyuan32/simple-admin-common/msg/errormsg"
 
 	"github.com/suyuan32/simple-admin-common/utils/pointy"
 	"github.com/zeromicro/go-zero/core/logx"
@@ -52,23 +52,20 @@ func (l *GetXunjiListLogic) GetXunjiList(req *types.XunjiListReq) (*types.XunjiL
 
 	for _, v := range data.List {
 		resp.Data.Data = append(resp.Data.Data,
-		types.XunjiInfo{
-			BaseIDInfo:    types.BaseIDInfo{
-				Id:          &v.ID,
-				CreatedAt:    pointy.GetPointer(v.CreatedAt.UnixMilli()),
-				UpdatedAt:    pointy.GetPointer(v.UpdatedAt.UnixMilli()),
-            },
-			Status:	&v.Status,
-			AppKey:	&v.AppKey,
-			AppSecret:	&v.AppSecret,
-			Token:	&v.Token,
-			EncodingKey:	&v.EncodingKey,
-			AgentId:	&v.AgentID,
-			OrganizationId:	&v.OrganizationID,
-			Wxid:	&v.Wxid,
-			ApiBase:	&v.APIBase,
-			ApiKey:	&v.APIKey,
-		})
+			types.XunjiInfo{
+				BaseIDInfo: types.BaseIDInfo{
+					Id:        &v.ID,
+					CreatedAt: pointy.GetPointer(v.CreatedAt.UnixMilli()),
+					UpdatedAt: pointy.GetPointer(v.UpdatedAt.UnixMilli()),
+				},
+				Status:         &v.Status,
+				AppKey:         &v.AppKey,
+				AppSecret:      &v.AppSecret,
+				Token:          &v.Token,
+				EncodingKey:    &v.EncodingKey,
+				AgentId:        &v.AgentID,
+				OrganizationId: &v.OrganizationID,
+			})
 	}
 
 	return resp, nil

+ 1 - 3
internal/logic/xunji/update_xunji_logic.go

@@ -33,9 +33,7 @@ func (l *UpdateXunjiLogic) UpdateXunji(req *types.XunjiInfo) (*types.BaseMsgResp
 		SetNotNilToken(req.Token).
 		SetNotNilEncodingKey(req.EncodingKey).
 		SetNotNilAgentID(req.AgentId).
-		//SetNotNilOrganizationID(req.OrganizationId).
-		SetNotNilAPIBase(req.ApiBase).
-		SetNotNilAPIKey(req.ApiKey).
+		SetNotNilOrganizationID(req.OrganizationId).
 		Exec(l.ctx)
 
 	if err != nil {

+ 45 - 0
internal/logic/xunji_service/create_xunji_service_logic.go

@@ -0,0 +1,45 @@
+package xunji_service
+
+import (
+	"context"
+
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+	"wechat-api/internal/utils/dberrorhandler"
+
+    "github.com/suyuan32/simple-admin-common/msg/errormsg"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type CreateXunjiServiceLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewCreateXunjiServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateXunjiServiceLogic {
+	return &CreateXunjiServiceLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *CreateXunjiServiceLogic) CreateXunjiService(req *types.XunjiServiceInfo) (*types.BaseMsgResp, error) {
+    _, err := l.svcCtx.DB.XunjiService.Create().
+			SetNotNilStatus(req.Status).
+			SetNotNilXunjiID(req.XunjiId).
+			SetNotNilAgentID(req.AgentId).
+			SetNotNilOrganizationID(req.OrganizationId).
+			SetNotNilWxid(req.Wxid).
+			SetNotNilAPIBase(req.ApiBase).
+			SetNotNilAPIKey(req.ApiKey).
+			Save(l.ctx)
+
+    if err != nil {
+		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
+	}
+
+    return &types.BaseMsgResp{Msg: errormsg.CreateSuccess}, nil
+}

+ 37 - 0
internal/logic/xunji_service/delete_xunji_service_logic.go

@@ -0,0 +1,37 @@
+package xunji_service
+
+import (
+	"context"
+
+    "wechat-api/ent/xunjiservice"
+    "wechat-api/internal/svc"
+    "wechat-api/internal/types"
+    "wechat-api/internal/utils/dberrorhandler"
+
+    "github.com/suyuan32/simple-admin-common/msg/errormsg"
+    "github.com/zeromicro/go-zero/core/logx"
+)
+
+type DeleteXunjiServiceLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewDeleteXunjiServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteXunjiServiceLogic {
+	return &DeleteXunjiServiceLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *DeleteXunjiServiceLogic) DeleteXunjiService(req *types.IDsReq) (*types.BaseMsgResp, error) {
+	_, err := l.svcCtx.DB.XunjiService.Delete().Where(xunjiservice.IDIn(req.Ids...)).Exec(l.ctx)
+
+    if err != nil {
+		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
+	}
+
+    return &types.BaseMsgResp{Msg: errormsg.DeleteSuccess}, nil
+}

+ 57 - 0
internal/logic/xunji_service/get_xunji_service_by_id_logic.go

@@ -0,0 +1,57 @@
+package xunji_service
+
+import (
+	"context"
+
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+	"wechat-api/internal/utils/dberrorhandler"
+
+    "github.com/suyuan32/simple-admin-common/msg/errormsg"
+
+	"github.com/suyuan32/simple-admin-common/utils/pointy"
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type GetXunjiServiceByIdLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewGetXunjiServiceByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetXunjiServiceByIdLogic {
+	return &GetXunjiServiceByIdLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *GetXunjiServiceByIdLogic) GetXunjiServiceById(req *types.IDReq) (*types.XunjiServiceInfoResp, error) {
+	data, err := l.svcCtx.DB.XunjiService.Get(l.ctx, req.Id)
+	if err != nil {
+		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
+	}
+
+	return &types.XunjiServiceInfoResp{
+	    BaseDataInfo: types.BaseDataInfo{
+            Code: 0,
+            Msg:  errormsg.Success,
+        },
+        Data: types.XunjiServiceInfo{
+            BaseIDInfo:    types.BaseIDInfo{
+				Id:          &data.ID,
+				CreatedAt:    pointy.GetPointer(data.CreatedAt.UnixMilli()),
+				UpdatedAt:    pointy.GetPointer(data.UpdatedAt.UnixMilli()),
+            },
+			Status:	&data.Status,
+			XunjiId:	&data.XunjiID,
+			AgentId:	&data.AgentID,
+			OrganizationId:	&data.OrganizationID,
+			Wxid:	&data.Wxid,
+			ApiBase:	&data.APIBase,
+			ApiKey:	&data.APIKey,
+        },
+	}, nil
+}
+

+ 72 - 0
internal/logic/xunji_service/get_xunji_service_list_logic.go

@@ -0,0 +1,72 @@
+package xunji_service
+
+import (
+	"context"
+
+	"wechat-api/ent/xunjiservice"
+	"wechat-api/ent/predicate"
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+	"wechat-api/internal/utils/dberrorhandler"
+
+    "github.com/suyuan32/simple-admin-common/msg/errormsg"
+
+	"github.com/suyuan32/simple-admin-common/utils/pointy"
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type GetXunjiServiceListLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewGetXunjiServiceListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetXunjiServiceListLogic {
+	return &GetXunjiServiceListLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *GetXunjiServiceListLogic) GetXunjiServiceList(req *types.XunjiServiceListReq) (*types.XunjiServiceListResp, error) {
+	var predicates []predicate.XunjiService
+	if req.Wxid != nil {
+		predicates = append(predicates, xunjiservice.WxidContains(*req.Wxid))
+	}
+	if req.ApiBase != nil {
+		predicates = append(predicates, xunjiservice.APIBaseContains(*req.ApiBase))
+	}
+	if req.ApiKey != nil {
+		predicates = append(predicates, xunjiservice.APIKeyContains(*req.ApiKey))
+	}
+	data, err := l.svcCtx.DB.XunjiService.Query().Where(predicates...).Page(l.ctx, req.Page, req.PageSize)
+
+	if err != nil {
+		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
+	}
+
+	resp := &types.XunjiServiceListResp{}
+	resp.Msg = errormsg.Success
+	resp.Data.Total = data.PageDetails.Total
+
+	for _, v := range data.List {
+		resp.Data.Data = append(resp.Data.Data,
+		types.XunjiServiceInfo{
+			BaseIDInfo:    types.BaseIDInfo{
+				Id:          &v.ID,
+				CreatedAt:    pointy.GetPointer(v.CreatedAt.UnixMilli()),
+				UpdatedAt:    pointy.GetPointer(v.UpdatedAt.UnixMilli()),
+            },
+			Status:	&v.Status,
+			XunjiId:	&v.XunjiID,
+			AgentId:	&v.AgentID,
+			OrganizationId:	&v.OrganizationID,
+			Wxid:	&v.Wxid,
+			ApiBase:	&v.APIBase,
+			ApiKey:	&v.APIKey,
+		})
+	}
+
+	return resp, nil
+}

+ 45 - 0
internal/logic/xunji_service/update_xunji_service_logic.go

@@ -0,0 +1,45 @@
+package xunji_service
+
+import (
+	"context"
+
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+	"wechat-api/internal/utils/dberrorhandler"
+
+
+	"github.com/suyuan32/simple-admin-common/msg/errormsg"
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type UpdateXunjiServiceLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewUpdateXunjiServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateXunjiServiceLogic {
+	return &UpdateXunjiServiceLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *UpdateXunjiServiceLogic) UpdateXunjiService(req *types.XunjiServiceInfo) (*types.BaseMsgResp, error) {
+    err := l.svcCtx.DB.XunjiService.UpdateOneID(*req.Id).
+			SetNotNilStatus(req.Status).
+			SetNotNilXunjiID(req.XunjiId).
+			SetNotNilAgentID(req.AgentId).
+			SetNotNilOrganizationID(req.OrganizationId).
+			SetNotNilWxid(req.Wxid).
+			SetNotNilAPIBase(req.ApiBase).
+			SetNotNilAPIKey(req.ApiKey).
+			Exec(l.ctx)
+
+    if err != nil {
+		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
+	}
+
+    return &types.BaseMsgResp{Msg: errormsg.UpdateSuccess}, nil
+}

+ 56 - 0
internal/types/types.go

@@ -4079,3 +4079,59 @@ type XunjiInfoResp struct {
 	// Xunji information | Xunji数据
 	Data XunjiInfo `json:"data"`
 }
+
+// The data of xunji service information | XunjiService信息
+// swagger:model XunjiServiceInfo
+type XunjiServiceInfo struct {
+	BaseIDInfo
+	// Status 1: normal 2: ban | 状态 1 正常 2 禁用
+	Status *uint8 `json:"status,optional"`
+	// Xunji表ID
+	XunjiId *uint64 `json:"xunjiId,optional"`
+	// 智能体ID
+	AgentId *uint64 `json:"agentId,optional"`
+	// organization_id | 租户ID
+	OrganizationId *uint64 `json:"organizationId,optional"`
+	// 微信ID
+	Wxid *string `json:"wxid,optional"`
+	// 大模型服务地址
+	ApiBase *string `json:"apiBase,optional"`
+	// 大模型服务密钥
+	ApiKey *string `json:"apiKey,optional"`
+}
+
+// The response data of xunji service list | XunjiService列表数据
+// swagger:model XunjiServiceListResp
+type XunjiServiceListResp struct {
+	BaseDataInfo
+	// XunjiService list data | XunjiService列表数据
+	Data XunjiServiceListInfo `json:"data"`
+}
+
+// XunjiService list data | XunjiService列表数据
+// swagger:model XunjiServiceListInfo
+type XunjiServiceListInfo struct {
+	BaseListInfo
+	// The API list data | XunjiService列表数据
+	Data []XunjiServiceInfo `json:"data"`
+}
+
+// Get xunji service list request params | XunjiService列表请求参数
+// swagger:model XunjiServiceListReq
+type XunjiServiceListReq struct {
+	PageInfo
+	// 微信ID
+	Wxid *string `json:"wxid,optional"`
+	// 大模型服务地址
+	ApiBase *string `json:"apiBase,optional"`
+	// 大模型服务密钥
+	ApiKey *string `json:"apiKey,optional"`
+}
+
+// XunjiService information response | XunjiService信息返回体
+// swagger:model XunjiServiceInfoResp
+type XunjiServiceInfoResp struct {
+	BaseDataInfo
+	// XunjiService information | XunjiService数据
+	Data XunjiServiceInfo `json:"data"`
+}