Selaa lähdekoodia

fix:合并代码

jimmyyem 1 kuukausi sitten
vanhempi
commit
71098fc717
11 muutettua tiedostoa jossa 188 lisäystä ja 169 poistoa
  1. 1 2
      desc/all.api
  2. 4 4
      ent/agent.go
  3. 1 1
      ent/agent/agent.go
  4. 12 11
      ent/agent/where.go
  5. 6 4
      ent/agent_create.go
  6. 3 8
      ent/agent_query.go
  7. 48 36
      ent/agent_update.go
  8. 35 32
      ent/client.go
  9. 21 26
      ent/mutation.go
  10. 44 33
      internal/handler/routes.go
  11. 13 12
      internal/types/types.go

+ 1 - 2
desc/all.api

@@ -45,7 +45,6 @@ import "./wechat/whatsapp_channel.api"
 import "./wechat/xunji.api"
 import "./wechat/xunji_service.api"
 import "./wp_wecom/send_msg.api"
-import "./wechat/xunji.api"
 import "./wechat/fastgpt.api"
 import "./wechat/department.api"
-import "./wechat/api_key.api"
+import "./wechat/api_key.api"

+ 4 - 4
ent/agent.go

@@ -59,7 +59,7 @@ type AgentEdges struct {
 	KeyAgent []*ApiKey `json:"key_agent,omitempty"`
 	// loadedTypes holds the information for reporting if a
 	// type was loaded (or requested) in eager-loading or not.
-	loadedTypes [4]bool
+	loadedTypes [5]bool
 }
 
 // WxAgentOrErr returns the WxAgent value or an error if the edge
@@ -89,7 +89,6 @@ 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) {
@@ -98,10 +97,11 @@ func (e AgentEdges) XjsAgentOrErr() ([]*XunjiService, error) {
 	}
 	return nil, &NotLoadedError{edge: "xjs_agent"}
 }
+
 // KeyAgentOrErr returns the KeyAgent value or an error if the edge
 // was not loaded in eager-loading.
 func (e AgentEdges) KeyAgentOrErr() ([]*ApiKey, error) {
-	if e.loadedTypes[3] {
+	if e.loadedTypes[4] {
 		return e.KeyAgent, nil
 	}
 	return nil, &NotLoadedError{edge: "key_agent"}
@@ -233,11 +233,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)
 }
+
 // QueryKeyAgent queries the "key_agent" edge of the Agent entity.
 func (a *Agent) QueryKeyAgent() *ApiKeyQuery {
 	return NewAgentClient(a.config).QueryKeyAgent(a)

+ 1 - 1
ent/agent/agent.go

@@ -253,7 +253,6 @@ func ByWaAgent(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
 	}
 }
 
-
 // ByXjsAgentCount orders the results by xjs_agent count.
 func ByXjsAgentCount(opts ...sql.OrderTermOption) OrderOption {
 	return func(s *sql.Selector) {
@@ -267,6 +266,7 @@ func ByXjsAgent(term sql.OrderTerm, terms ...sql.OrderTerm) OrderOption {
 		sqlgraph.OrderByNeighborTerms(s, newXjsAgentStep(), append([]sql.OrderTerm{term}, terms...)...)
 	}
 }
+
 // ByKeyAgentCount orders the results by key_agent count.
 func ByKeyAgentCount(opts ...sql.OrderTermOption) OrderOption {
 	return func(s *sql.Selector) {

+ 12 - 11
ent/agent/where.go

@@ -819,17 +819,6 @@ func HasXjsAgent() predicate.Agent {
 		sqlgraph.HasNeighbors(s, step)
 	})
 }
-// HasKeyAgent applies the HasEdge predicate on the "key_agent" edge.
-func HasKeyAgent() predicate.Agent {
-	return predicate.Agent(func(s *sql.Selector) {
-		step := sqlgraph.NewStep(
-			sqlgraph.From(Table, FieldID),
-			sqlgraph.Edge(sqlgraph.O2M, false, KeyAgentTable, KeyAgentColumn),
-		)
-		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 {
@@ -842,6 +831,18 @@ func HasXjsAgentWith(preds ...predicate.XunjiService) predicate.Agent {
 		})
 	})
 }
+
+// HasKeyAgent applies the HasEdge predicate on the "key_agent" edge.
+func HasKeyAgent() predicate.Agent {
+	return predicate.Agent(func(s *sql.Selector) {
+		step := sqlgraph.NewStep(
+			sqlgraph.From(Table, FieldID),
+			sqlgraph.Edge(sqlgraph.O2M, false, KeyAgentTable, KeyAgentColumn),
+		)
+		sqlgraph.HasNeighbors(s, step)
+	})
+}
+
 // HasKeyAgentWith applies the HasEdge predicate on the "key_agent" edge with a given conditions (other predicates).
 func HasKeyAgentWith(preds ...predicate.ApiKey) predicate.Agent {
 	return predicate.Agent(func(s *sql.Selector) {

+ 6 - 4
ent/agent_create.go

@@ -208,7 +208,6 @@ 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...)
@@ -223,6 +222,7 @@ func (ac *AgentCreate) AddXjsAgent(x ...*XunjiService) *AgentCreate {
 	}
 	return ac.AddXjsAgentIDs(ids...)
 }
+
 // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by IDs.
 func (ac *AgentCreate) AddKeyAgentIDs(ids ...uint64) *AgentCreate {
 	ac.mutation.AddKeyAgentIDs(ids...)
@@ -485,7 +485,6 @@ 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,
@@ -496,9 +495,12 @@ func (ac *AgentCreate) createSpec() (*Agent, *sqlgraph.CreateSpec) {
 			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)
 	}
-
 	if nodes := ac.mutation.KeyAgentIDs(); len(nodes) > 0 {
 		edge := &sqlgraph.EdgeSpec{
 			Rel:     sqlgraph.O2M,

+ 3 - 8
ent/agent_query.go

@@ -155,10 +155,10 @@ func (aq *AgentQuery) QueryXjsAgent() *XunjiServiceQuery {
 	}
 	return query
 }
+
 // QueryKeyAgent chains the current query on the "key_agent" edge.
 func (aq *AgentQuery) QueryKeyAgent() *ApiKeyQuery {
 	query := (&ApiKeyClient{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
@@ -414,7 +414,6 @@ 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 {
@@ -515,7 +514,7 @@ func (aq *AgentQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Agent,
 	var (
 		nodes       = []*Agent{}
 		_spec       = aq.querySpec()
-		loadedTypes = [4]bool{
+		loadedTypes = [5]bool{
 			aq.withWxAgent != nil,
 			aq.withTokenAgent != nil,
 			aq.withWaAgent != nil,
@@ -569,7 +568,6 @@ func (aq *AgentQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Agent,
 			return nil, err
 		}
 	}
-
 	if query := aq.withKeyAgent; query != nil {
 		if err := aq.loadKeyAgent(ctx, query, nodes,
 			func(n *Agent) { n.Edges.KeyAgent = []*ApiKey{} },
@@ -671,7 +669,6 @@ 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)
@@ -687,8 +684,7 @@ func (aq *AgentQuery) loadXjsAgent(ctx context.Context, query *XunjiServiceQuery
 	}
 	query.Where(predicate.XunjiService(func(s *sql.Selector) {
 		s.Where(sql.InValues(s.C(agent.XjsAgentColumn), fks...))
-		query.ctx.AppendFieldOnce(apikey.FieldAgentID)
-	}
+	}))
 	neighbors, err := query.All(ctx)
 	if err != nil {
 		return err
@@ -703,7 +699,6 @@ func (aq *AgentQuery) loadXjsAgent(ctx context.Context, query *XunjiServiceQuery
 	}
 	return nil
 }
-
 func (aq *AgentQuery) loadKeyAgent(ctx context.Context, query *ApiKeyQuery, nodes []*Agent, init func(*Agent), assign func(*Agent, *ApiKey)) error {
 	fks := make([]driver.Value, 0, len(nodes))
 	nodeids := make(map[uint64]*Agent)

+ 48 - 36
ent/agent_update.go

@@ -248,7 +248,6 @@ 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...)
@@ -263,6 +262,7 @@ func (au *AgentUpdate) AddXjsAgent(x ...*XunjiService) *AgentUpdate {
 	}
 	return au.AddXjsAgentIDs(ids...)
 }
+
 // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by IDs.
 func (au *AgentUpdate) AddKeyAgentIDs(ids ...uint64) *AgentUpdate {
 	au.mutation.AddKeyAgentIDs(ids...)
@@ -346,7 +346,6 @@ 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()
@@ -656,7 +655,6 @@ 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,
@@ -667,23 +665,26 @@ func (au *AgentUpdate) sqlSave(ctx context.Context) (n int, err error) {
 			Target: &sqlgraph.EdgeTarget{
 				IDSpec: sqlgraph.NewFieldSpec(xunjiservice.FieldID, field.TypeUint64),
 			},
-		},
+		}
+		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
 	}
-	if au.mutation.KeyAgentCleared() {
+	if nodes := au.mutation.RemovedXjsAgentIDs(); len(nodes) > 0 && !au.mutation.XjsAgentCleared() {
 		edge := &sqlgraph.EdgeSpec{
 			Rel:     sqlgraph.O2M,
 			Inverse: false,
-			Table:   agent.KeyAgentTable,
-			Columns: []string{agent.KeyAgentColumn},
+			Table:   agent.XjsAgentTable,
+			Columns: []string{agent.XjsAgentColumn},
 			Bidi:    false,
 			Target: &sqlgraph.EdgeTarget{
-				IDSpec: sqlgraph.NewFieldSpec(apikey.FieldID, field.TypeUint64),
+				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.RemovedXjsAgentIDs(); len(nodes) > 0 && !au.mutation.XjsAgentCleared() {
+	if nodes := au.mutation.XjsAgentIDs(); len(nodes) > 0 {
 		edge := &sqlgraph.EdgeSpec{
 			Rel:     sqlgraph.O2M,
 			Inverse: false,
@@ -694,8 +695,12 @@ func (au *AgentUpdate) sqlSave(ctx context.Context) (n int, err error) {
 				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 nodes := au.mutation.RemovedKeyAgentIDs(); len(nodes) > 0 && !au.mutation.KeyAgentCleared() {
+	if au.mutation.KeyAgentCleared() {
 		edge := &sqlgraph.EdgeSpec{
 			Rel:     sqlgraph.O2M,
 			Inverse: false,
@@ -706,23 +711,23 @@ func (au *AgentUpdate) sqlSave(ctx context.Context) (n int, err error) {
 				IDSpec: sqlgraph.NewFieldSpec(apikey.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 {
+	if nodes := au.mutation.RemovedKeyAgentIDs(); len(nodes) > 0 && !au.mutation.KeyAgentCleared() {
 		edge := &sqlgraph.EdgeSpec{
 			Rel:     sqlgraph.O2M,
 			Inverse: false,
-			Table:   agent.XjsAgentTable,
-			Columns: []string{agent.XjsAgentColumn},
+			Table:   agent.KeyAgentTable,
+			Columns: []string{agent.KeyAgentColumn},
 			Bidi:    false,
 			Target: &sqlgraph.EdgeTarget{
-				IDSpec: sqlgraph.NewFieldSpec(xunjiservice.FieldID, field.TypeUint64),
+				IDSpec: sqlgraph.NewFieldSpec(apikey.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.KeyAgentIDs(); len(nodes) > 0 {
 		edge := &sqlgraph.EdgeSpec{
@@ -989,6 +994,7 @@ func (auo *AgentUpdateOne) AddXjsAgent(x ...*XunjiService) *AgentUpdateOne {
 	}
 	return auo.AddXjsAgentIDs(ids...)
 }
+
 // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by IDs.
 func (auo *AgentUpdateOne) AddKeyAgentIDs(ids ...uint64) *AgentUpdateOne {
 	auo.mutation.AddKeyAgentIDs(ids...)
@@ -1072,7 +1078,6 @@ 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()
@@ -1093,6 +1098,7 @@ func (auo *AgentUpdateOne) RemoveXjsAgent(x ...*XunjiService) *AgentUpdateOne {
 	}
 	return auo.RemoveXjsAgentIDs(ids...)
 }
+
 // ClearKeyAgent clears all "key_agent" edges to the ApiKey entity.
 func (auo *AgentUpdateOne) ClearKeyAgent() *AgentUpdateOne {
 	auo.mutation.ClearKeyAgent()
@@ -1411,7 +1417,6 @@ 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,
@@ -1423,22 +1428,25 @@ func (auo *AgentUpdateOne) sqlSave(ctx context.Context) (_node *Agent, err error
 				IDSpec: sqlgraph.NewFieldSpec(xunjiservice.FieldID, field.TypeUint64),
 			},
 		}
+		_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
 	}
-	if auo.mutation.KeyAgentCleared() {
+	if nodes := auo.mutation.RemovedXjsAgentIDs(); len(nodes) > 0 && !auo.mutation.XjsAgentCleared() {
 		edge := &sqlgraph.EdgeSpec{
 			Rel:     sqlgraph.O2M,
 			Inverse: false,
-			Table:   agent.KeyAgentTable,
-			Columns: []string{agent.KeyAgentColumn},
+			Table:   agent.XjsAgentTable,
+			Columns: []string{agent.XjsAgentColumn},
 			Bidi:    false,
 			Target: &sqlgraph.EdgeTarget{
-				IDSpec: sqlgraph.NewFieldSpec(apikey.FieldID, field.TypeUint64),
+				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.RemovedXjsAgentIDs(); len(nodes) > 0 && !auo.mutation.XjsAgentCleared() {
+	if nodes := auo.mutation.XjsAgentIDs(); len(nodes) > 0 {
 		edge := &sqlgraph.EdgeSpec{
 			Rel:     sqlgraph.O2M,
 			Inverse: false,
@@ -1449,8 +1457,12 @@ func (auo *AgentUpdateOne) sqlSave(ctx context.Context) (_node *Agent, err error
 				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 nodes := auo.mutation.RemovedKeyAgentIDs(); len(nodes) > 0 && !auo.mutation.KeyAgentCleared() {
+	if auo.mutation.KeyAgentCleared() {
 		edge := &sqlgraph.EdgeSpec{
 			Rel:     sqlgraph.O2M,
 			Inverse: false,
@@ -1461,23 +1473,23 @@ func (auo *AgentUpdateOne) sqlSave(ctx context.Context) (_node *Agent, err error
 				IDSpec: sqlgraph.NewFieldSpec(apikey.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 {
+	if nodes := auo.mutation.RemovedKeyAgentIDs(); len(nodes) > 0 && !auo.mutation.KeyAgentCleared() {
 		edge := &sqlgraph.EdgeSpec{
 			Rel:     sqlgraph.O2M,
 			Inverse: false,
-			Table:   agent.XjsAgentTable,
-			Columns: []string{agent.XjsAgentColumn},
+			Table:   agent.KeyAgentTable,
+			Columns: []string{agent.KeyAgentColumn},
 			Bidi:    false,
 			Target: &sqlgraph.EdgeTarget{
-				IDSpec: sqlgraph.NewFieldSpec(xunjiservice.FieldID, field.TypeUint64),
+				IDSpec: sqlgraph.NewFieldSpec(apikey.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.KeyAgentIDs(); len(nodes) > 0 {
 		edge := &sqlgraph.EdgeSpec{

+ 35 - 32
ent/client.go

@@ -434,14 +434,15 @@ func (c *Client) Close() error {
 // In order to add hooks to a specific client, call: `client.Node.Use(...)`.
 func (c *Client) Use(hooks ...Hook) {
 	for _, n := range []interface{ Use(...Hook) }{
-		c.Agent, c.AgentBase, c.AliyunAvatar, c.AllocAgent, c.ApiKey, c.BatchMsg, c.Category,
-		c.ChatRecords, c.ChatSession, c.Contact, c.CreditBalance, c.CreditUsage,
-		c.Employee, c.EmployeeConfig, c.Label, c.LabelRelationship, c.LabelTagging,
-		c.Message, c.MessageRecords, c.Msg, c.PayRecharge, c.Server, c.SopNode,
-		c.SopStage, c.SopTask, c.Token, c.Tutorial, c.UsageDetail, c.UsageStatisticDay,
-		c.UsageStatisticHour, c.UsageStatisticMonth, c.UsageTotal, c.Whatsapp,
-		c.WhatsappChannel, c.WorkExperience, c.WpChatroom, c.WpChatroomMember, c.Wx,
-		c.WxCard, c.WxCardUser, c.WxCardVisit, c.Xunji, c.XunjiService,
+		c.Agent, c.AgentBase, c.AliyunAvatar, c.AllocAgent, c.ApiKey, c.BatchMsg,
+		c.Category, c.ChatRecords, c.ChatSession, c.Contact, c.CreditBalance,
+		c.CreditUsage, c.Employee, c.EmployeeConfig, c.Label, c.LabelRelationship,
+		c.LabelTagging, c.Message, c.MessageRecords, c.Msg, c.PayRecharge, c.Server,
+		c.SopNode, c.SopStage, c.SopTask, c.Token, c.Tutorial, c.UsageDetail,
+		c.UsageStatisticDay, c.UsageStatisticHour, c.UsageStatisticMonth, c.UsageTotal,
+		c.Whatsapp, c.WhatsappChannel, c.WorkExperience, c.WpChatroom,
+		c.WpChatroomMember, c.Wx, c.WxCard, c.WxCardUser, c.WxCardVisit, c.Xunji,
+		c.XunjiService,
 	} {
 		n.Use(hooks...)
 	}
@@ -451,14 +452,15 @@ func (c *Client) Use(hooks ...Hook) {
 // In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`.
 func (c *Client) Intercept(interceptors ...Interceptor) {
 	for _, n := range []interface{ Intercept(...Interceptor) }{
-		c.Agent, c.AgentBase, c.AliyunAvatar, c.AllocAgent, c.ApiKey, c.BatchMsg, c.Category,
-		c.ChatRecords, c.ChatSession, c.Contact, c.CreditBalance, c.CreditUsage,
-		c.Employee, c.EmployeeConfig, c.Label, c.LabelRelationship, c.LabelTagging,
-		c.Message, c.MessageRecords, c.Msg, c.PayRecharge, c.Server, c.SopNode,
-		c.SopStage, c.SopTask, c.Token, c.Tutorial, c.UsageDetail, c.UsageStatisticDay,
-		c.UsageStatisticHour, c.UsageStatisticMonth, c.UsageTotal, c.Whatsapp,
-		c.WhatsappChannel, c.WorkExperience, c.WpChatroom, c.WpChatroomMember, c.Wx,
-		c.WxCard, c.WxCardUser, c.WxCardVisit, c.Xunji, c.XunjiService,
+		c.Agent, c.AgentBase, c.AliyunAvatar, c.AllocAgent, c.ApiKey, c.BatchMsg,
+		c.Category, c.ChatRecords, c.ChatSession, c.Contact, c.CreditBalance,
+		c.CreditUsage, c.Employee, c.EmployeeConfig, c.Label, c.LabelRelationship,
+		c.LabelTagging, c.Message, c.MessageRecords, c.Msg, c.PayRecharge, c.Server,
+		c.SopNode, c.SopStage, c.SopTask, c.Token, c.Tutorial, c.UsageDetail,
+		c.UsageStatisticDay, c.UsageStatisticHour, c.UsageStatisticMonth, c.UsageTotal,
+		c.Whatsapp, c.WhatsappChannel, c.WorkExperience, c.WpChatroom,
+		c.WpChatroomMember, c.Wx, c.WxCard, c.WxCardUser, c.WxCardVisit, c.Xunji,
+		c.XunjiService,
 	} {
 		n.Intercept(interceptors...)
 	}
@@ -714,7 +716,6 @@ 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()
@@ -730,10 +731,10 @@ func (c *AgentClient) QueryXjsAgent(a *Agent) *XunjiServiceQuery {
 	}
 	return query
 }
+
 // QueryKeyAgent queries the key_agent edge of a Agent.
 func (c *AgentClient) QueryKeyAgent(a *Agent) *ApiKeyQuery {
 	query := (&ApiKeyClient{config: c.config}).Query()
-
 	query.path = func(context.Context) (fromV *sql.Selector, _ error) {
 		id := a.ID
 		step := sqlgraph.NewStep(
@@ -6845,22 +6846,24 @@ func (c *XunjiServiceClient) mutate(ctx context.Context, m *XunjiServiceMutation
 // hooks and interceptors per client, for fast access.
 type (
 	hooks struct {
-		Agent, AgentBase, AliyunAvatar, AllocAgent, ApiKey, BatchMsg, Category, ChatRecords,
-		ChatSession, Contact, CreditBalance, CreditUsage, Employee, EmployeeConfig,
-		Label, LabelRelationship, LabelTagging, Message, MessageRecords, Msg,
-		PayRecharge, Server, SopNode, SopStage, SopTask, Token, Tutorial, UsageDetail,
-		UsageStatisticDay, UsageStatisticHour, UsageStatisticMonth, UsageTotal,
-		Whatsapp, WhatsappChannel, WorkExperience, WpChatroom, WpChatroomMember, Wx,
-		WxCard, WxCardUser, WxCardVisit, Xunji, XunjiService []ent.Hook
+		Agent, AgentBase, AliyunAvatar, AllocAgent, ApiKey, BatchMsg, Category,
+		ChatRecords, ChatSession, Contact, CreditBalance, CreditUsage, Employee,
+		EmployeeConfig, Label, LabelRelationship, LabelTagging, Message,
+		MessageRecords, Msg, PayRecharge, Server, SopNode, SopStage, SopTask, Token,
+		Tutorial, UsageDetail, UsageStatisticDay, UsageStatisticHour,
+		UsageStatisticMonth, UsageTotal, Whatsapp, WhatsappChannel, WorkExperience,
+		WpChatroom, WpChatroomMember, Wx, WxCard, WxCardUser, WxCardVisit, Xunji,
+		XunjiService []ent.Hook
 	}
 	inters struct {
-		Agent, AgentBase, AliyunAvatar, AllocAgent, ApiKey, BatchMsg, Category, ChatRecords,
-		ChatSession, Contact, CreditBalance, CreditUsage, Employee, EmployeeConfig,
-		Label, LabelRelationship, LabelTagging, Message, MessageRecords, Msg,
-		PayRecharge, Server, SopNode, SopStage, SopTask, Token, Tutorial, UsageDetail,
-		UsageStatisticDay, UsageStatisticHour, UsageStatisticMonth, UsageTotal,
-		Whatsapp, WhatsappChannel, WorkExperience, WpChatroom, WpChatroomMember, Wx,
-		WxCard, WxCardUser, WxCardVisit, Xunji, XunjiService []ent.Interceptor
+		Agent, AgentBase, AliyunAvatar, AllocAgent, ApiKey, BatchMsg, Category,
+		ChatRecords, ChatSession, Contact, CreditBalance, CreditUsage, Employee,
+		EmployeeConfig, Label, LabelRelationship, LabelTagging, Message,
+		MessageRecords, Msg, PayRecharge, Server, SopNode, SopStage, SopTask, Token,
+		Tutorial, UsageDetail, UsageStatisticDay, UsageStatisticHour,
+		UsageStatisticMonth, UsageTotal, Whatsapp, WhatsappChannel, WorkExperience,
+		WpChatroom, WpChatroomMember, Wx, WxCard, WxCardUser, WxCardVisit, Xunji,
+		XunjiService []ent.Interceptor
 	}
 )
 

+ 21 - 26
ent/mutation.go

@@ -141,15 +141,12 @@ 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
-
 	key_agent          map[uint64]struct{}
 	removedkey_agent   map[uint64]struct{}
 	clearedkey_agent   bool
-
 	done               bool
 	oldValue           func(context.Context) (*Agent, error)
 	predicates         []predicate.Agent
@@ -910,7 +907,6 @@ 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 {
@@ -947,7 +943,24 @@ 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
+}
+
 // AddKeyAgentIDs adds the "key_agent" edge to the ApiKey entity by ids.
 func (m *AgentMutation) AddKeyAgentIDs(ids ...uint64) {
 	if m.key_agent == nil {
@@ -987,14 +1000,6 @@ func (m *AgentMutation) RemovedKeyAgentIDs() (ids []uint64) {
 	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
-}
 // KeyAgentIDs returns the "key_agent" edge IDs in the mutation.
 func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
 	for id := range m.key_agent {
@@ -1003,13 +1008,6 @@ func (m *AgentMutation) KeyAgentIDs() (ids []uint64) {
 	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
-}
 // ResetKeyAgent resets all changes to the "key_agent" edge.
 func (m *AgentMutation) ResetKeyAgent() {
 	m.key_agent = nil
@@ -1374,7 +1372,7 @@ func (m *AgentMutation) ResetField(name string) error {
 
 // AddedEdges returns all edge names that were set/added in this mutation.
 func (m *AgentMutation) AddedEdges() []string {
-	edges := make([]string, 0, 4)
+	edges := make([]string, 0, 5)
 	if m.wx_agent != nil {
 		edges = append(edges, agent.EdgeWxAgent)
 	}
@@ -1384,7 +1382,6 @@ 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)
 	}
@@ -1434,7 +1431,7 @@ func (m *AgentMutation) AddedIDs(name string) []ent.Value {
 
 // RemovedEdges returns all edge names that were removed in this mutation.
 func (m *AgentMutation) RemovedEdges() []string {
-	edges := make([]string, 0, 4)
+	edges := make([]string, 0, 5)
 	if m.removedwx_agent != nil {
 		edges = append(edges, agent.EdgeWxAgent)
 	}
@@ -1444,7 +1441,6 @@ 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)
 	}
@@ -1476,7 +1472,6 @@ 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 {
@@ -1495,7 +1490,7 @@ func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
 
 // ClearedEdges returns all edge names that were cleared in this mutation.
 func (m *AgentMutation) ClearedEdges() []string {
-	edges := make([]string, 0, 4)
+	edges := make([]string, 0, 5)
 	if m.clearedwx_agent {
 		edges = append(edges, agent.EdgeWxAgent)
 	}
@@ -1505,7 +1500,6 @@ func (m *AgentMutation) ClearedEdges() []string {
 	if m.clearedwa_agent {
 		edges = append(edges, agent.EdgeWaAgent)
 	}
-
 	if m.clearedxjs_agent {
 		edges = append(edges, agent.EdgeXjsAgent)
 	}
@@ -1556,6 +1550,7 @@ func (m *AgentMutation) ResetEdge(name string) error {
 		return nil
 	case agent.EdgeXjsAgent:
 		m.ResetXjsAgent()
+		return nil
 	case agent.EdgeKeyAgent:
 		m.ResetKeyAgent()
 		return nil

+ 44 - 33
internal/handler/routes.go

@@ -1,6 +1,4 @@
 // Code generated by goctl. DO NOT EDIT.
-// goctls v1.10.1
-
 package handler
 
 import (
@@ -2047,21 +2045,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 	)
 
 	server.AddRoutes(
-		[]rest.Route{
-			{
-				Method:  http.MethodPost,
-				Path:    "/wp/wecom/send_msg",
-				Handler: wp_wecom.SendMsgHandler(serverCtx),
-			},
-			{
-				Method:  http.MethodPost,
-				Path:    "/wp/wecom/send_msg_by_chan",
-				Handler: wp_wecom.SendMsgByChanHandler(serverCtx),
-			},
-		},
-	)
-
-	server.AddRoutes(
 		rest.WithMiddlewares(
 			[]rest.Middleware{serverCtx.Authority},
 			[]rest.Route{
@@ -2096,22 +2079,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 	)
 
 	server.AddRoutes(
-		[]rest.Route{
-			{
-				Method:  http.MethodGet,
-				Path:    "/api/fastgpt/set_token",
-				Handler: fastgpt.SetTokenHandler(serverCtx),
-			},
-			{
-				Method:  http.MethodPost,
-				Path:    "/api/fastgpt/create",
-				Handler: fastgpt.CreateFastgptHandler(serverCtx),
-			},
-		},
-	)
-
-	server.AddRoutes(
-
 		rest.WithMiddlewares(
 			[]rest.Middleware{serverCtx.Authority},
 			[]rest.Route{
@@ -2140,6 +2107,50 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 					Path:    "/xunji_service",
 					Handler: xunji_service.GetXunjiServiceByIdHandler(serverCtx),
 				},
+			}...,
+		),
+		rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
+	)
+
+	server.AddRoutes(
+		[]rest.Route{
+			{
+				Method:  http.MethodPost,
+				Path:    "/wp/wecom/send_msg",
+				Handler: wp_wecom.SendMsgHandler(serverCtx),
+			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/wp/wecom/send_msg_by_chan",
+				Handler: wp_wecom.SendMsgByChanHandler(serverCtx),
+			},
+		},
+	)
+
+	server.AddRoutes(
+		[]rest.Route{
+			{
+				Method:  http.MethodGet,
+				Path:    "/api/fastgpt/set_token",
+				Handler: fastgpt.SetTokenHandler(serverCtx),
+			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/api/fastgpt/create",
+				Handler: fastgpt.CreateFastgptHandler(serverCtx),
+			},
+		},
+	)
+
+	server.AddRoutes(
+		rest.WithMiddlewares(
+			[]rest.Middleware{serverCtx.Authority},
+			[]rest.Route{
+				{
+					Method:  http.MethodPost,
+					Path:    "/department/create",
+					Handler: department.CreateDepartmentHandler(serverCtx),
+				},
 				{
 					Method:  http.MethodPost,
 					Path:    "/department/update",

+ 13 - 12
internal/types/types.go

@@ -4018,18 +4018,6 @@ type WhatsappChannelInfoResp struct {
 	Data WhatsappChannelInfo `json:"data"`
 }
 
-// swagger:model WpWecomMsgReq
-type WpWecomMsgReq struct {
-	// 机器人微信id
-	WxId *string `json:"wx_id"`
-	// 接收方微信 id
-	ConvId *string `json:"conv_id"`
-	// 消息类型
-	ContentType *string `json:"content_type"`
-	// 消息内容
-	Content *string `json:"content"`
-}
-
 // The data of xunji information | Xunji信息
 // swagger:model XunjiInfo
 type XunjiInfo struct {
@@ -4144,6 +4132,19 @@ type XunjiServiceInfoResp struct {
 	// XunjiService information | XunjiService数据
 	Data XunjiServiceInfo `json:"data"`
 }
+
+// swagger:model WpWecomMsgReq
+type WpWecomMsgReq struct {
+	// 机器人微信id
+	WxId *string `json:"wx_id"`
+	// 接收方微信 id
+	ConvId *string `json:"conv_id"`
+	// 消息类型
+	ContentType *string `json:"content_type"`
+	// 消息内容
+	Content *string `json:"content"`
+}
+
 // swagger:model CreateInfo
 type CreateInfo struct {
 	// Translated Name | 展示名称