jimmyyem 1 сар өмнө
parent
commit
6efa487981

+ 0 - 12
desc/wechat/xunji.api

@@ -20,20 +20,8 @@ type (
         // 加密key 
         EncodingKey  *string `json:"encodingKey,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 list | Xunji列表数据

+ 0 - 1
ent/migrate/schema.go

@@ -1423,7 +1423,6 @@ var (
 		{Name: "app_secret", Type: field.TypeString, Comment: "AppSecret"},
 		{Name: "token", Type: field.TypeString, Comment: "Token"},
 		{Name: "encoding_key", Type: field.TypeString, Comment: "加密key"},
-		{Name: "agent_id", Type: field.TypeUint64, Comment: "角色ID"},
 		{Name: "organization_id", Type: field.TypeUint64, Comment: "organization_id | 租户ID"},
 	}
 	// XunjiTable holds the schema information for the "xunji" table.

+ 1 - 88
ent/mutation.go

@@ -50047,8 +50047,6 @@ type XunjiMutation struct {
 	app_secret         *string
 	token              *string
 	encoding_key       *string
-	agent_id           *uint64
-	addagent_id        *int64
 	organization_id    *uint64
 	addorganization_id *int64
 	clearedFields      map[string]struct{}
@@ -50496,62 +50494,6 @@ func (m *XunjiMutation) ResetEncodingKey() {
 	m.encoding_key = nil
 }
 
-// SetAgentID sets the "agent_id" field.
-func (m *XunjiMutation) SetAgentID(u uint64) {
-	m.agent_id = &u
-	m.addagent_id = nil
-}
-
-// AgentID returns the value of the "agent_id" field in the mutation.
-func (m *XunjiMutation) AgentID() (r uint64, exists bool) {
-	v := m.agent_id
-	if v == nil {
-		return
-	}
-	return *v, true
-}
-
-// OldAgentID returns the old "agent_id" field's value of the Xunji entity.
-// If the Xunji object wasn't provided to the builder, the object is fetched from the database.
-// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *XunjiMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
-	if !m.op.Is(OpUpdateOne) {
-		return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
-	}
-	if m.id == nil || m.oldValue == nil {
-		return v, errors.New("OldAgentID requires an ID field in the mutation")
-	}
-	oldValue, err := m.oldValue(ctx)
-	if err != nil {
-		return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
-	}
-	return oldValue.AgentID, nil
-}
-
-// AddAgentID adds u to the "agent_id" field.
-func (m *XunjiMutation) AddAgentID(u int64) {
-	if m.addagent_id != nil {
-		*m.addagent_id += u
-	} else {
-		m.addagent_id = &u
-	}
-}
-
-// AddedAgentID returns the value that was added to the "agent_id" field in this mutation.
-func (m *XunjiMutation) AddedAgentID() (r int64, exists bool) {
-	v := m.addagent_id
-	if v == nil {
-		return
-	}
-	return *v, true
-}
-
-// ResetAgentID resets all changes to the "agent_id" field.
-func (m *XunjiMutation) ResetAgentID() {
-	m.agent_id = nil
-	m.addagent_id = nil
-}
-
 // SetOrganizationID sets the "organization_id" field.
 func (m *XunjiMutation) SetOrganizationID(u uint64) {
 	m.organization_id = &u
@@ -50642,7 +50584,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, 10)
+	fields := make([]string, 0, 9)
 	if m.created_at != nil {
 		fields = append(fields, xunji.FieldCreatedAt)
 	}
@@ -50667,9 +50609,6 @@ func (m *XunjiMutation) Fields() []string {
 	if m.encoding_key != nil {
 		fields = append(fields, xunji.FieldEncodingKey)
 	}
-	if m.agent_id != nil {
-		fields = append(fields, xunji.FieldAgentID)
-	}
 	if m.organization_id != nil {
 		fields = append(fields, xunji.FieldOrganizationID)
 	}
@@ -50697,8 +50636,6 @@ func (m *XunjiMutation) Field(name string) (ent.Value, bool) {
 		return m.Token()
 	case xunji.FieldEncodingKey:
 		return m.EncodingKey()
-	case xunji.FieldAgentID:
-		return m.AgentID()
 	case xunji.FieldOrganizationID:
 		return m.OrganizationID()
 	}
@@ -50726,8 +50663,6 @@ func (m *XunjiMutation) OldField(ctx context.Context, name string) (ent.Value, e
 		return m.OldToken(ctx)
 	case xunji.FieldEncodingKey:
 		return m.OldEncodingKey(ctx)
-	case xunji.FieldAgentID:
-		return m.OldAgentID(ctx)
 	case xunji.FieldOrganizationID:
 		return m.OldOrganizationID(ctx)
 	}
@@ -50795,13 +50730,6 @@ func (m *XunjiMutation) SetField(name string, value ent.Value) error {
 		}
 		m.SetEncodingKey(v)
 		return nil
-	case xunji.FieldAgentID:
-		v, ok := value.(uint64)
-		if !ok {
-			return fmt.Errorf("unexpected type %T for field %s", value, name)
-		}
-		m.SetAgentID(v)
-		return nil
 	case xunji.FieldOrganizationID:
 		v, ok := value.(uint64)
 		if !ok {
@@ -50820,9 +50748,6 @@ func (m *XunjiMutation) AddedFields() []string {
 	if m.addstatus != nil {
 		fields = append(fields, xunji.FieldStatus)
 	}
-	if m.addagent_id != nil {
-		fields = append(fields, xunji.FieldAgentID)
-	}
 	if m.addorganization_id != nil {
 		fields = append(fields, xunji.FieldOrganizationID)
 	}
@@ -50836,8 +50761,6 @@ func (m *XunjiMutation) AddedField(name string) (ent.Value, bool) {
 	switch name {
 	case xunji.FieldStatus:
 		return m.AddedStatus()
-	case xunji.FieldAgentID:
-		return m.AddedAgentID()
 	case xunji.FieldOrganizationID:
 		return m.AddedOrganizationID()
 	}
@@ -50856,13 +50779,6 @@ func (m *XunjiMutation) AddField(name string, value ent.Value) error {
 		}
 		m.AddStatus(v)
 		return nil
-	case xunji.FieldAgentID:
-		v, ok := value.(int64)
-		if !ok {
-			return fmt.Errorf("unexpected type %T for field %s", value, name)
-		}
-		m.AddAgentID(v)
-		return nil
 	case xunji.FieldOrganizationID:
 		v, ok := value.(int64)
 		if !ok {
@@ -50936,9 +50852,6 @@ func (m *XunjiMutation) ResetField(name string) error {
 	case xunji.FieldEncodingKey:
 		m.ResetEncodingKey()
 		return nil
-	case xunji.FieldAgentID:
-		m.ResetAgentID()
-		return nil
 	case xunji.FieldOrganizationID:
 		m.ResetOrganizationID()
 		return nil

+ 1 - 1
ent/runtime/runtime.go

@@ -1873,7 +1873,7 @@ func init() {
 	// xunji.DefaultStatus holds the default value on creation for the status field.
 	xunji.DefaultStatus = xunjiDescStatus.Default.(uint8)
 	// xunjiDescOrganizationID is the schema descriptor for organization_id field.
-	xunjiDescOrganizationID := xunjiFields[5].Descriptor()
+	xunjiDescOrganizationID := xunjiFields[4].Descriptor()
 	// xunji.OrganizationIDValidator is a validator for the "organization_id" field. It is called by the builders before save.
 	xunji.OrganizationIDValidator = xunjiDescOrganizationID.Validators[0].(func(uint64) error)
 	xunjiserviceMixin := schema.XunjiService{}.Mixin()

+ 0 - 1
ent/schema/xunji.go

@@ -21,7 +21,6 @@ func (Xunji) Fields() []ent.Field {
 		field.String("app_secret").Comment("AppSecret"),
 		field.String("token").Comment("Token"),
 		field.String("encoding_key").Comment("加密key"),
-		field.Uint64("agent_id").Comment("角色ID"),
 		field.Uint64("organization_id").Positive().Comment("organization_id | 租户ID"),
 	}
 }

+ 0 - 24
ent/set_not_nil.go

@@ -11192,30 +11192,6 @@ func (x *XunjiCreate) SetNotNilEncodingKey(value *string) *XunjiCreate {
 }
 
 // set field if value's pointer is not nil.
-func (x *XunjiUpdate) SetNotNilAgentID(value *uint64) *XunjiUpdate {
-	if value != nil {
-		return x.SetAgentID(*value)
-	}
-	return x
-}
-
-// set field if value's pointer is not nil.
-func (x *XunjiUpdateOne) SetNotNilAgentID(value *uint64) *XunjiUpdateOne {
-	if value != nil {
-		return x.SetAgentID(*value)
-	}
-	return x
-}
-
-// set field if value's pointer is not nil.
-func (x *XunjiCreate) SetNotNilAgentID(value *uint64) *XunjiCreate {
-	if value != nil {
-		return x.SetAgentID(*value)
-	}
-	return x
-}
-
-// set field if value's pointer is not nil.
 func (x *XunjiUpdate) SetNotNilOrganizationID(value *uint64) *XunjiUpdate {
 	if value != nil {
 		return x.SetOrganizationID(*value)

+ 1 - 12
ent/xunji.go

@@ -33,8 +33,6 @@ type Xunji struct {
 	Token string `json:"token,omitempty"`
 	// 加密key
 	EncodingKey string `json:"encoding_key,omitempty"`
-	// 角色ID
-	AgentID uint64 `json:"agent_id,omitempty"`
 	// organization_id | 租户ID
 	OrganizationID uint64 `json:"organization_id,omitempty"`
 	selectValues   sql.SelectValues
@@ -45,7 +43,7 @@ func (*Xunji) scanValues(columns []string) ([]any, error) {
 	values := make([]any, len(columns))
 	for i := range columns {
 		switch columns[i] {
-		case xunji.FieldID, xunji.FieldStatus, xunji.FieldAgentID, xunji.FieldOrganizationID:
+		case xunji.FieldID, xunji.FieldStatus, xunji.FieldOrganizationID:
 			values[i] = new(sql.NullInt64)
 		case xunji.FieldAppKey, xunji.FieldAppSecret, xunji.FieldToken, xunji.FieldEncodingKey:
 			values[i] = new(sql.NullString)
@@ -120,12 +118,6 @@ func (x *Xunji) assignValues(columns []string, values []any) error {
 			} else if value.Valid {
 				x.EncodingKey = value.String
 			}
-		case xunji.FieldAgentID:
-			if value, ok := values[i].(*sql.NullInt64); !ok {
-				return fmt.Errorf("unexpected type %T for field agent_id", values[i])
-			} else if value.Valid {
-				x.AgentID = uint64(value.Int64)
-			}
 		case xunji.FieldOrganizationID:
 			if value, ok := values[i].(*sql.NullInt64); !ok {
 				return fmt.Errorf("unexpected type %T for field organization_id", values[i])
@@ -192,9 +184,6 @@ func (x *Xunji) String() string {
 	builder.WriteString("encoding_key=")
 	builder.WriteString(x.EncodingKey)
 	builder.WriteString(", ")
-	builder.WriteString("agent_id=")
-	builder.WriteString(fmt.Sprintf("%v", x.AgentID))
-	builder.WriteString(", ")
 	builder.WriteString("organization_id=")
 	builder.WriteString(fmt.Sprintf("%v", x.OrganizationID))
 	builder.WriteByte(')')

+ 0 - 45
ent/xunji/where.go

@@ -94,11 +94,6 @@ func EncodingKey(v string) predicate.Xunji {
 	return predicate.Xunji(sql.FieldEQ(FieldEncodingKey, v))
 }
 
-// AgentID applies equality check predicate on the "agent_id" field. It's identical to AgentIDEQ.
-func AgentID(v uint64) predicate.Xunji {
-	return predicate.Xunji(sql.FieldEQ(FieldAgentID, v))
-}
-
 // OrganizationID applies equality check predicate on the "organization_id" field. It's identical to OrganizationIDEQ.
 func OrganizationID(v uint64) predicate.Xunji {
 	return predicate.Xunji(sql.FieldEQ(FieldOrganizationID, v))
@@ -544,46 +539,6 @@ func EncodingKeyContainsFold(v string) predicate.Xunji {
 	return predicate.Xunji(sql.FieldContainsFold(FieldEncodingKey, v))
 }
 
-// AgentIDEQ applies the EQ predicate on the "agent_id" field.
-func AgentIDEQ(v uint64) predicate.Xunji {
-	return predicate.Xunji(sql.FieldEQ(FieldAgentID, v))
-}
-
-// AgentIDNEQ applies the NEQ predicate on the "agent_id" field.
-func AgentIDNEQ(v uint64) predicate.Xunji {
-	return predicate.Xunji(sql.FieldNEQ(FieldAgentID, v))
-}
-
-// AgentIDIn applies the In predicate on the "agent_id" field.
-func AgentIDIn(vs ...uint64) predicate.Xunji {
-	return predicate.Xunji(sql.FieldIn(FieldAgentID, vs...))
-}
-
-// AgentIDNotIn applies the NotIn predicate on the "agent_id" field.
-func AgentIDNotIn(vs ...uint64) predicate.Xunji {
-	return predicate.Xunji(sql.FieldNotIn(FieldAgentID, vs...))
-}
-
-// AgentIDGT applies the GT predicate on the "agent_id" field.
-func AgentIDGT(v uint64) predicate.Xunji {
-	return predicate.Xunji(sql.FieldGT(FieldAgentID, v))
-}
-
-// AgentIDGTE applies the GTE predicate on the "agent_id" field.
-func AgentIDGTE(v uint64) predicate.Xunji {
-	return predicate.Xunji(sql.FieldGTE(FieldAgentID, v))
-}
-
-// AgentIDLT applies the LT predicate on the "agent_id" field.
-func AgentIDLT(v uint64) predicate.Xunji {
-	return predicate.Xunji(sql.FieldLT(FieldAgentID, v))
-}
-
-// AgentIDLTE applies the LTE predicate on the "agent_id" field.
-func AgentIDLTE(v uint64) predicate.Xunji {
-	return predicate.Xunji(sql.FieldLTE(FieldAgentID, v))
-}
-
 // OrganizationIDEQ applies the EQ predicate on the "organization_id" field.
 func OrganizationIDEQ(v uint64) predicate.Xunji {
 	return predicate.Xunji(sql.FieldEQ(FieldOrganizationID, v))

+ 0 - 8
ent/xunji/xunji.go

@@ -30,8 +30,6 @@ const (
 	FieldToken = "token"
 	// FieldEncodingKey holds the string denoting the encoding_key field in the database.
 	FieldEncodingKey = "encoding_key"
-	// FieldAgentID holds the string denoting the agent_id field in the database.
-	FieldAgentID = "agent_id"
 	// FieldOrganizationID holds the string denoting the organization_id field in the database.
 	FieldOrganizationID = "organization_id"
 	// Table holds the table name of the xunji in the database.
@@ -49,7 +47,6 @@ var Columns = []string{
 	FieldAppSecret,
 	FieldToken,
 	FieldEncodingKey,
-	FieldAgentID,
 	FieldOrganizationID,
 }
 
@@ -131,11 +128,6 @@ func ByEncodingKey(opts ...sql.OrderTermOption) OrderOption {
 	return sql.OrderByField(FieldEncodingKey, opts...).ToFunc()
 }
 
-// ByAgentID orders the results by the agent_id field.
-func ByAgentID(opts ...sql.OrderTermOption) OrderOption {
-	return sql.OrderByField(FieldAgentID, opts...).ToFunc()
-}
-
 // ByOrganizationID orders the results by the organization_id field.
 func ByOrganizationID(opts ...sql.OrderTermOption) OrderOption {
 	return sql.OrderByField(FieldOrganizationID, opts...).ToFunc()

+ 0 - 73
ent/xunji_create.go

@@ -102,12 +102,6 @@ func (xc *XunjiCreate) SetEncodingKey(s string) *XunjiCreate {
 	return xc
 }
 
-// SetAgentID sets the "agent_id" field.
-func (xc *XunjiCreate) SetAgentID(u uint64) *XunjiCreate {
-	xc.mutation.SetAgentID(u)
-	return xc
-}
-
 // SetOrganizationID sets the "organization_id" field.
 func (xc *XunjiCreate) SetOrganizationID(u uint64) *XunjiCreate {
 	xc.mutation.SetOrganizationID(u)
@@ -198,9 +192,6 @@ func (xc *XunjiCreate) check() error {
 	if _, ok := xc.mutation.EncodingKey(); !ok {
 		return &ValidationError{Name: "encoding_key", err: errors.New(`ent: missing required field "Xunji.encoding_key"`)}
 	}
-	if _, ok := xc.mutation.AgentID(); !ok {
-		return &ValidationError{Name: "agent_id", err: errors.New(`ent: missing required field "Xunji.agent_id"`)}
-	}
 	if _, ok := xc.mutation.OrganizationID(); !ok {
 		return &ValidationError{Name: "organization_id", err: errors.New(`ent: missing required field "Xunji.organization_id"`)}
 	}
@@ -274,10 +265,6 @@ func (xc *XunjiCreate) createSpec() (*Xunji, *sqlgraph.CreateSpec) {
 		_spec.SetField(xunji.FieldEncodingKey, field.TypeString, value)
 		_node.EncodingKey = value
 	}
-	if value, ok := xc.mutation.AgentID(); ok {
-		_spec.SetField(xunji.FieldAgentID, field.TypeUint64, value)
-		_node.AgentID = value
-	}
 	if value, ok := xc.mutation.OrganizationID(); ok {
 		_spec.SetField(xunji.FieldOrganizationID, field.TypeUint64, value)
 		_node.OrganizationID = value
@@ -436,24 +423,6 @@ func (u *XunjiUpsert) UpdateEncodingKey() *XunjiUpsert {
 	return u
 }
 
-// SetAgentID sets the "agent_id" field.
-func (u *XunjiUpsert) SetAgentID(v uint64) *XunjiUpsert {
-	u.Set(xunji.FieldAgentID, v)
-	return u
-}
-
-// UpdateAgentID sets the "agent_id" field to the value that was provided on create.
-func (u *XunjiUpsert) UpdateAgentID() *XunjiUpsert {
-	u.SetExcluded(xunji.FieldAgentID)
-	return u
-}
-
-// AddAgentID adds v to the "agent_id" field.
-func (u *XunjiUpsert) AddAgentID(v uint64) *XunjiUpsert {
-	u.Add(xunji.FieldAgentID, v)
-	return u
-}
-
 // SetOrganizationID sets the "organization_id" field.
 func (u *XunjiUpsert) SetOrganizationID(v uint64) *XunjiUpsert {
 	u.Set(xunji.FieldOrganizationID, v)
@@ -642,27 +611,6 @@ func (u *XunjiUpsertOne) UpdateEncodingKey() *XunjiUpsertOne {
 	})
 }
 
-// SetAgentID sets the "agent_id" field.
-func (u *XunjiUpsertOne) SetAgentID(v uint64) *XunjiUpsertOne {
-	return u.Update(func(s *XunjiUpsert) {
-		s.SetAgentID(v)
-	})
-}
-
-// AddAgentID adds v to the "agent_id" field.
-func (u *XunjiUpsertOne) AddAgentID(v uint64) *XunjiUpsertOne {
-	return u.Update(func(s *XunjiUpsert) {
-		s.AddAgentID(v)
-	})
-}
-
-// UpdateAgentID sets the "agent_id" field to the value that was provided on create.
-func (u *XunjiUpsertOne) UpdateAgentID() *XunjiUpsertOne {
-	return u.Update(func(s *XunjiUpsert) {
-		s.UpdateAgentID()
-	})
-}
-
 // SetOrganizationID sets the "organization_id" field.
 func (u *XunjiUpsertOne) SetOrganizationID(v uint64) *XunjiUpsertOne {
 	return u.Update(func(s *XunjiUpsert) {
@@ -1020,27 +968,6 @@ func (u *XunjiUpsertBulk) UpdateEncodingKey() *XunjiUpsertBulk {
 	})
 }
 
-// SetAgentID sets the "agent_id" field.
-func (u *XunjiUpsertBulk) SetAgentID(v uint64) *XunjiUpsertBulk {
-	return u.Update(func(s *XunjiUpsert) {
-		s.SetAgentID(v)
-	})
-}
-
-// AddAgentID adds v to the "agent_id" field.
-func (u *XunjiUpsertBulk) AddAgentID(v uint64) *XunjiUpsertBulk {
-	return u.Update(func(s *XunjiUpsert) {
-		s.AddAgentID(v)
-	})
-}
-
-// UpdateAgentID sets the "agent_id" field to the value that was provided on create.
-func (u *XunjiUpsertBulk) UpdateAgentID() *XunjiUpsertBulk {
-	return u.Update(func(s *XunjiUpsert) {
-		s.UpdateAgentID()
-	})
-}
-
 // SetOrganizationID sets the "organization_id" field.
 func (u *XunjiUpsertBulk) SetOrganizationID(v uint64) *XunjiUpsertBulk {
 	return u.Update(func(s *XunjiUpsert) {

+ 0 - 54
ent/xunji_update.go

@@ -137,27 +137,6 @@ func (xu *XunjiUpdate) SetNillableEncodingKey(s *string) *XunjiUpdate {
 	return xu
 }
 
-// SetAgentID sets the "agent_id" field.
-func (xu *XunjiUpdate) SetAgentID(u uint64) *XunjiUpdate {
-	xu.mutation.ResetAgentID()
-	xu.mutation.SetAgentID(u)
-	return xu
-}
-
-// SetNillableAgentID sets the "agent_id" field if the given value is not nil.
-func (xu *XunjiUpdate) SetNillableAgentID(u *uint64) *XunjiUpdate {
-	if u != nil {
-		xu.SetAgentID(*u)
-	}
-	return xu
-}
-
-// AddAgentID adds u to the "agent_id" field.
-func (xu *XunjiUpdate) AddAgentID(u int64) *XunjiUpdate {
-	xu.mutation.AddAgentID(u)
-	return xu
-}
-
 // SetOrganizationID sets the "organization_id" field.
 func (xu *XunjiUpdate) SetOrganizationID(u uint64) *XunjiUpdate {
 	xu.mutation.ResetOrganizationID()
@@ -278,12 +257,6 @@ func (xu *XunjiUpdate) sqlSave(ctx context.Context) (n int, err error) {
 	if value, ok := xu.mutation.EncodingKey(); ok {
 		_spec.SetField(xunji.FieldEncodingKey, field.TypeString, value)
 	}
-	if value, ok := xu.mutation.AgentID(); ok {
-		_spec.SetField(xunji.FieldAgentID, field.TypeUint64, value)
-	}
-	if value, ok := xu.mutation.AddedAgentID(); ok {
-		_spec.AddField(xunji.FieldAgentID, field.TypeUint64, value)
-	}
 	if value, ok := xu.mutation.OrganizationID(); ok {
 		_spec.SetField(xunji.FieldOrganizationID, field.TypeUint64, value)
 	}
@@ -419,27 +392,6 @@ func (xuo *XunjiUpdateOne) SetNillableEncodingKey(s *string) *XunjiUpdateOne {
 	return xuo
 }
 
-// SetAgentID sets the "agent_id" field.
-func (xuo *XunjiUpdateOne) SetAgentID(u uint64) *XunjiUpdateOne {
-	xuo.mutation.ResetAgentID()
-	xuo.mutation.SetAgentID(u)
-	return xuo
-}
-
-// SetNillableAgentID sets the "agent_id" field if the given value is not nil.
-func (xuo *XunjiUpdateOne) SetNillableAgentID(u *uint64) *XunjiUpdateOne {
-	if u != nil {
-		xuo.SetAgentID(*u)
-	}
-	return xuo
-}
-
-// AddAgentID adds u to the "agent_id" field.
-func (xuo *XunjiUpdateOne) AddAgentID(u int64) *XunjiUpdateOne {
-	xuo.mutation.AddAgentID(u)
-	return xuo
-}
-
 // SetOrganizationID sets the "organization_id" field.
 func (xuo *XunjiUpdateOne) SetOrganizationID(u uint64) *XunjiUpdateOne {
 	xuo.mutation.ResetOrganizationID()
@@ -590,12 +542,6 @@ func (xuo *XunjiUpdateOne) sqlSave(ctx context.Context) (_node *Xunji, err error
 	if value, ok := xuo.mutation.EncodingKey(); ok {
 		_spec.SetField(xunji.FieldEncodingKey, field.TypeString, value)
 	}
-	if value, ok := xuo.mutation.AgentID(); ok {
-		_spec.SetField(xunji.FieldAgentID, field.TypeUint64, value)
-	}
-	if value, ok := xuo.mutation.AddedAgentID(); ok {
-		_spec.AddField(xunji.FieldAgentID, field.TypeUint64, value)
-	}
 	if value, ok := xuo.mutation.OrganizationID(); ok {
 		_spec.SetField(xunji.FieldOrganizationID, field.TypeUint64, value)
 	}

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

@@ -2,6 +2,8 @@ package xunji
 
 import (
 	"context"
+	"github.com/suyuan32/simple-admin-common/msg/errormsg"
+	"wechat-api/internal/utils/dberrorhandler"
 
 	"wechat-api/internal/svc"
 	"wechat-api/internal/types"
@@ -22,8 +24,21 @@ func NewCreateXunjiLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Creat
 		svcCtx: svcCtx}
 }
 
-func (l *CreateXunjiLogic) CreateXunji(req *types.XunjiInfo) (resp *types.BaseMsgResp, err error) {
-	// todo: add your logic here and delete this line
+func (l *CreateXunjiLogic) CreateXunji(req *types.XunjiInfo) (*types.BaseMsgResp, error) {
+	organizationId := l.ctx.Value("organizationId").(uint64)
 
-	return
+	_, err := l.svcCtx.DB.Xunji.Create().
+		SetStatus(1).
+		SetNotNilAppKey(req.AppKey).
+		SetNotNilAppSecret(req.AppSecret).
+		SetNotNilToken(req.Token).
+		SetNotNilEncodingKey(req.EncodingKey).
+		SetOrganizationID(organizationId).
+		Save(l.ctx)
+
+	if err != nil {
+		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
+	}
+
+	return &types.BaseMsgResp{Msg: errormsg.CreateSuccess}, nil
 }

+ 10 - 3
internal/logic/xunji/delete_xunji_logic.go

@@ -2,6 +2,9 @@ package xunji
 
 import (
 	"context"
+	"github.com/suyuan32/simple-admin-common/msg/errormsg"
+	"wechat-api/ent/xunji"
+	"wechat-api/internal/utils/dberrorhandler"
 
 	"wechat-api/internal/svc"
 	"wechat-api/internal/types"
@@ -22,8 +25,12 @@ func NewDeleteXunjiLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Delet
 		svcCtx: svcCtx}
 }
 
-func (l *DeleteXunjiLogic) DeleteXunji(req *types.IDsReq) (resp *types.BaseMsgResp, err error) {
-	// todo: add your logic here and delete this line
+func (l *DeleteXunjiLogic) DeleteXunji(req *types.IDsReq) (*types.BaseMsgResp, error) {
+	_, err := l.svcCtx.DB.Xunji.Delete().Where(xunji.IDIn(req.Ids...)).Exec(l.ctx)
 
-	return
+	if err != nil {
+		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
+	}
+
+	return &types.BaseMsgResp{Msg: errormsg.DeleteSuccess}, nil
 }

+ 27 - 3
internal/logic/xunji/get_xunji_by_id_logic.go

@@ -2,6 +2,9 @@ package xunji
 
 import (
 	"context"
+	"github.com/suyuan32/simple-admin-common/msg/errormsg"
+	"github.com/suyuan32/simple-admin-common/utils/pointy"
+	"wechat-api/internal/utils/dberrorhandler"
 
 	"wechat-api/internal/svc"
 	"wechat-api/internal/types"
@@ -22,8 +25,29 @@ func NewGetXunjiByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetX
 		svcCtx: svcCtx}
 }
 
-func (l *GetXunjiByIdLogic) GetXunjiById(req *types.IDReq) (resp *types.XunjiInfoResp, err error) {
-	// todo: add your logic here and delete this line
+func (l *GetXunjiByIdLogic) GetXunjiById(req *types.IDReq) (*types.XunjiInfoResp, error) {
+	data, err := l.svcCtx.DB.Xunji.Get(l.ctx, req.Id)
+	if err != nil {
+		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
+	}
 
-	return
+	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,
+			OrganizationId: &data.OrganizationID,
+		},
+	}, nil
 }

+ 43 - 3
internal/logic/xunji/get_xunji_list_logic.go

@@ -2,6 +2,11 @@ package xunji
 
 import (
 	"context"
+	"github.com/suyuan32/simple-admin-common/msg/errormsg"
+	"github.com/suyuan32/simple-admin-common/utils/pointy"
+	"wechat-api/ent/predicate"
+	"wechat-api/ent/xunji"
+	"wechat-api/internal/utils/dberrorhandler"
 
 	"wechat-api/internal/svc"
 	"wechat-api/internal/types"
@@ -22,8 +27,43 @@ func NewGetXunjiListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetX
 		svcCtx: svcCtx}
 }
 
-func (l *GetXunjiListLogic) GetXunjiList(req *types.XunjiListReq) (resp *types.XunjiListResp, err error) {
-	// todo: add your logic here and delete this line
+func (l *GetXunjiListLogic) GetXunjiList(req *types.XunjiListReq) (*types.XunjiListResp, error) {
+	var predicates []predicate.Xunji
+	if req.AppKey != nil {
+		predicates = append(predicates, xunji.AppKeyContains(*req.AppKey))
+	}
+	if req.AppSecret != nil {
+		predicates = append(predicates, xunji.AppSecretContains(*req.AppSecret))
+	}
+	if req.Token != nil {
+		predicates = append(predicates, xunji.TokenContains(*req.Token))
+	}
+	data, err := l.svcCtx.DB.Xunji.Query().Where(predicates...).Page(l.ctx, req.Page, req.PageSize)
 
-	return
+	if err != nil {
+		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
+	}
+
+	resp := &types.XunjiListResp{}
+	resp.Msg = errormsg.Success
+	resp.Data.Total = data.PageDetails.Total
+
+	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,
+				OrganizationId: &v.OrganizationID,
+			})
+	}
+
+	return resp, nil
 }

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

@@ -2,6 +2,8 @@ package xunji
 
 import (
 	"context"
+	"github.com/suyuan32/simple-admin-common/msg/errormsg"
+	"wechat-api/internal/utils/dberrorhandler"
 
 	"wechat-api/internal/svc"
 	"wechat-api/internal/types"
@@ -22,8 +24,18 @@ func NewUpdateXunjiLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Updat
 		svcCtx: svcCtx}
 }
 
-func (l *UpdateXunjiLogic) UpdateXunji(req *types.XunjiInfo) (resp *types.BaseMsgResp, err error) {
-	// todo: add your logic here and delete this line
+func (l *UpdateXunjiLogic) UpdateXunji(req *types.XunjiInfo) (*types.BaseMsgResp, error) {
+	err := l.svcCtx.DB.Xunji.UpdateOneID(*req.Id).
+		SetNotNilStatus(req.Status).
+		SetNotNilAppKey(req.AppKey).
+		SetNotNilAppSecret(req.AppSecret).
+		SetNotNilToken(req.Token).
+		SetNotNilEncodingKey(req.EncodingKey).
+		Exec(l.ctx)
 
-	return
+	if err != nil {
+		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
+	}
+
+	return &types.BaseMsgResp{Msg: errormsg.UpdateSuccess}, nil
 }

+ 17 - 3
internal/logic/xunji_service/create_xunji_service_logic.go

@@ -2,6 +2,8 @@ package xunji_service
 
 import (
 	"context"
+	"github.com/suyuan32/simple-admin-common/msg/errormsg"
+	"wechat-api/internal/utils/dberrorhandler"
 
 	"wechat-api/internal/svc"
 	"wechat-api/internal/types"
@@ -22,8 +24,20 @@ func NewCreateXunjiServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext)
 		svcCtx: svcCtx}
 }
 
-func (l *CreateXunjiServiceLogic) CreateXunjiService(req *types.XunjiServiceInfo) (resp *types.BaseMsgResp, err error) {
-	// todo: add your logic here and delete this line
+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)
 
-	return
+	if err != nil {
+		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
+	}
+
+	return &types.BaseMsgResp{Msg: errormsg.CreateSuccess}, nil
 }

+ 10 - 3
internal/logic/xunji_service/delete_xunji_service_logic.go

@@ -2,6 +2,9 @@ package xunji_service
 
 import (
 	"context"
+	"github.com/suyuan32/simple-admin-common/msg/errormsg"
+	"wechat-api/ent/xunjiservice"
+	"wechat-api/internal/utils/dberrorhandler"
 
 	"wechat-api/internal/svc"
 	"wechat-api/internal/types"
@@ -22,8 +25,12 @@ func NewDeleteXunjiServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext)
 		svcCtx: svcCtx}
 }
 
-func (l *DeleteXunjiServiceLogic) DeleteXunjiService(req *types.IDsReq) (resp *types.BaseMsgResp, err error) {
-	// todo: add your logic here and delete this line
+func (l *DeleteXunjiServiceLogic) DeleteXunjiService(req *types.IDsReq) (*types.BaseMsgResp, error) {
+	_, err := l.svcCtx.DB.XunjiService.Delete().Where(xunjiservice.IDIn(req.Ids...)).Exec(l.ctx)
 
-	return
+	if err != nil {
+		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
+	}
+
+	return &types.BaseMsgResp{Msg: errormsg.DeleteSuccess}, nil
 }

+ 46 - 3
internal/logic/xunji_service/get_xunji_service_by_id_logic.go

@@ -2,6 +2,10 @@ package xunji_service
 
 import (
 	"context"
+	"github.com/suyuan32/simple-admin-common/msg/errormsg"
+	"github.com/suyuan32/simple-admin-common/utils/pointy"
+	"wechat-api/ent/xunjiservice"
+	"wechat-api/internal/utils/dberrorhandler"
 
 	"wechat-api/internal/svc"
 	"wechat-api/internal/types"
@@ -22,8 +26,47 @@ func NewGetXunjiServiceByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext
 		svcCtx: svcCtx}
 }
 
-func (l *GetXunjiServiceByIdLogic) GetXunjiServiceById(req *types.IDReq) (resp *types.XunjiServiceInfoResp, err error) {
-	// todo: add your logic here and delete this line
+func (l *GetXunjiServiceByIdLogic) GetXunjiServiceById(req *types.IDReq) (*types.XunjiServiceInfoResp, error) {
+	data, err := l.svcCtx.DB.XunjiService.Query().Where(xunjiservice.ID(req.Id)).WithAgent().Only(l.ctx)
+	if err != nil {
+		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
+	}
 
-	return
+	var agent types.AgentInfo
+	if data.Edges.Agent != nil {
+		agent = types.AgentInfo{
+			BaseIDInfo: types.BaseIDInfo{
+				Id:        &data.AgentID,
+				CreatedAt: pointy.GetPointer(data.Edges.Agent.CreatedAt.UnixMilli()),
+				UpdatedAt: pointy.GetPointer(data.Edges.Agent.UpdatedAt.UnixMilli()),
+			},
+			Name:       &data.Edges.Agent.Name,
+			Role:       &data.Edges.Agent.Role,
+			Status:     &data.Edges.Agent.Status,
+			Background: &data.Edges.Agent.Background,
+			Examples:   &data.Edges.Agent.Examples,
+		}
+	}
+
+	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,
+			AgentInfo:      &agent,
+			OrganizationId: &data.OrganizationID,
+			Wxid:           &data.Wxid,
+			ApiBase:        &data.APIBase,
+			ApiKey:         &data.APIKey,
+		},
+	}, nil
 }

+ 66 - 3
internal/logic/xunji_service/get_xunji_service_list_logic.go

@@ -2,6 +2,12 @@ package xunji_service
 
 import (
 	"context"
+	"github.com/suyuan32/simple-admin-common/msg/errormsg"
+	"github.com/suyuan32/simple-admin-common/utils/pointy"
+	"github.com/zeromicro/go-zero/core/errorx"
+	"wechat-api/ent/predicate"
+	"wechat-api/ent/xunjiservice"
+	"wechat-api/internal/utils/dberrorhandler"
 
 	"wechat-api/internal/svc"
 	"wechat-api/internal/types"
@@ -22,8 +28,65 @@ func NewGetXunjiServiceListLogic(ctx context.Context, svcCtx *svc.ServiceContext
 		svcCtx: svcCtx}
 }
 
-func (l *GetXunjiServiceListLogic) GetXunjiServiceList(req *types.XunjiServiceListReq) (resp *types.XunjiServiceListResp, err error) {
-	// todo: add your logic here and delete this line
+func (l *GetXunjiServiceListLogic) GetXunjiServiceList(req *types.XunjiServiceListReq) (*types.XunjiServiceListResp, error) {
+	isAdmin := l.ctx.Value("isAdmin").(bool)
 
-	return
+	var predicates []predicate.XunjiService
+
+	if isAdmin {
+		if req.XunjiID != nil && *req.XunjiID > 0 {
+			predicates = append(predicates, xunjiservice.XunjiID(*req.XunjiID))
+		}
+	} else {
+		if req.XunjiID == nil || *req.XunjiID <= 0 {
+			return nil, errorx.NewInvalidArgumentError("父ID不能为空")
+		}
+		predicates = append(predicates, xunjiservice.XunjiID(*req.XunjiID))
+	}
+	data, err := l.svcCtx.DB.XunjiService.Query().Where(predicates...).WithAgent().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 {
+		var agent types.AgentInfo
+		if v.Edges.Agent != nil {
+			agent = types.AgentInfo{
+				BaseIDInfo: types.BaseIDInfo{
+					Id:        &v.AgentID,
+					CreatedAt: pointy.GetPointer(v.Edges.Agent.CreatedAt.UnixMilli()),
+					UpdatedAt: pointy.GetPointer(v.Edges.Agent.UpdatedAt.UnixMilli()),
+				},
+				Name:       &v.Edges.Agent.Name,
+				Role:       &v.Edges.Agent.Role,
+				Status:     &v.Edges.Agent.Status,
+				Background: &v.Edges.Agent.Background,
+				Examples:   &v.Edges.Agent.Examples,
+			}
+		}
+
+		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,
+				AgentInfo:      &agent,
+				OrganizationId: &v.OrganizationID,
+				Wxid:           &v.Wxid,
+				ApiBase:        &v.APIBase,
+				ApiKey:         &v.APIKey,
+			})
+	}
+
+	return resp, nil
 }

+ 16 - 3
internal/logic/xunji_service/update_xunji_service_logic.go

@@ -2,6 +2,8 @@ package xunji_service
 
 import (
 	"context"
+	"github.com/suyuan32/simple-admin-common/msg/errormsg"
+	"wechat-api/internal/utils/dberrorhandler"
 
 	"wechat-api/internal/svc"
 	"wechat-api/internal/types"
@@ -22,8 +24,19 @@ func NewUpdateXunjiServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext)
 		svcCtx: svcCtx}
 }
 
-func (l *UpdateXunjiServiceLogic) UpdateXunjiService(req *types.XunjiServiceInfo) (resp *types.BaseMsgResp, err error) {
-	// todo: add your logic here and delete this line
+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).
+		SetNotNilWxid(req.Wxid).
+		SetNotNilAPIBase(req.ApiBase).
+		SetNotNilAPIKey(req.ApiKey).
+		Exec(l.ctx)
 
-	return
+	if err != nil {
+		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
+	}
+
+	return &types.BaseMsgResp{Msg: errormsg.UpdateSuccess}, nil
 }

+ 0 - 8
internal/types/types.go

@@ -4386,16 +4386,8 @@ type XunjiInfo struct {
 	Token *string `json:"token,optional"`
 	// 加密key
 	EncodingKey *string `json:"encodingKey,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 list | Xunji列表数据