浏览代码

增加黑白名单功能

boweniac 9 月之前
父节点
当前提交
7a9b7dc0ae

+ 69 - 0
desc/wechat/wx.api

@@ -1,5 +1,6 @@
 import "../base.api"
 import "./agent.api"
+import "./label_relationship.api"
 
 type (
     // The response data of wx information | Wx信息
@@ -56,8 +57,36 @@ type (
 
         // 大模型服务密钥
         ApiKey *string `json:"apiKey,optional"`
+
+        // 白名单
+        AllowList []ContactInfo `json:"allowList,optional"`
+
+        // 群白名单
+        GroupAllowList []ContactInfo `json:"groupAllowList,optional"`
+
+        // 黑名单
+        BlockList []ContactInfo `json:"blockList,optional"`
+
+        // 群黑名单
+        GroupBlockList []ContactInfo `json:"groupBlockList,optional"`
     }
 
+    UpdateBlockAndAllowListReq {
+            BaseIDInfo
+
+            // 白名单
+            AllowList []string `json:"allowList,optional"`
+
+            // 群白名单
+            GroupAllowList []string `json:"groupAllowList,optional"`
+
+            // 黑名单
+            BlockList []string `json:"blockList,optional"`
+
+            // 群黑名单
+            GroupBlockList []string `json:"groupBlockList,optional"`
+        }
+
     // The response data of wx list | Wx列表数据
     WxListResp {
         BaseDataInfo
@@ -104,6 +133,38 @@ type (
         // Wx information | Wx数据
         Data WxInfo `json:"data"`
     }
+
+    // 获取黑白名单列表返回体
+    AllowBlockListResp {
+        BaseDataInfo
+
+        // Wx information | Wx数据
+        Data AllowBlockListRespData `json:"data"`
+    }
+
+    // AllowBlockListRespData
+    AllowBlockListRespData {
+        // 白名单
+        AllowList []*AllowBlockData `json:"allowList,optional"`
+
+        // 群白名单
+        GroupAllowList []*AllowBlockData `json:"groupAllowList,optional"`
+
+        // 黑名单
+        BlockList []*AllowBlockData `json:"blockList,optional"`
+
+        // 群黑名单
+        GroupBlockList []*AllowBlockData `json:"groupBlockList,optional"`
+    }
+
+    // AllowBlockData
+    AllowBlockData {
+        // 微信id 公众号微信ID
+        Wxid  *string `json:"wxid,optional"`
+
+        // 微信昵称 群备注名称
+        Nickname  *string `json:"nickname,optional"`
+    }
 )
 
 @server(
@@ -125,6 +186,10 @@ service Wechat {
     @handler updateWx
     post /wx/update (WxInfo) returns (BaseMsgResp)
 
+    // Update wx information | 更新黑白名单
+    @handler updateBlockAndAllowList
+    post /wx/updateBlockAndAllowList (UpdateBlockAndAllowListReq) returns (BaseMsgResp)
+
     // Delete wx information | 删除Wx信息
     @handler deleteWx
     post /wx/delete (IDReq) returns (BaseMsgResp)
@@ -133,6 +198,10 @@ service Wechat {
     @handler getWxList
     post /wx/list (WxListReq) returns (WxListResp)
 
+    // Get wx allow and block list | 获取黑白名单列表
+    @handler getWxAllowBlockList
+    post /wx/getWxAllowBlockList (IDReq) returns (AllowBlockListResp)
+
     // Get wx by ID | 通过ID获取Wx
     @handler getWxById
     post /wx (IDReq) returns (WxInfoResp)

+ 7 - 3
ent/migrate/schema.go

@@ -625,6 +625,10 @@ var (
 		{Name: "organization_id", Type: field.TypeUint64, Nullable: true, Comment: "机构 ID", Default: 1},
 		{Name: "api_base", Type: field.TypeString, Nullable: true, Comment: "大模型服务地址", Default: ""},
 		{Name: "api_key", Type: field.TypeString, Nullable: true, Comment: "大模型服务密钥", Default: ""},
+		{Name: "allow_list", Type: field.TypeJSON, Comment: "白名单"},
+		{Name: "group_allow_list", Type: field.TypeJSON, Comment: "群白名单"},
+		{Name: "block_list", Type: field.TypeJSON, Comment: "黑名单"},
+		{Name: "group_block_list", Type: field.TypeJSON, Comment: "群黑名单"},
 		{Name: "agent_id", Type: field.TypeUint64, Comment: "模式ID", Default: 0},
 		{Name: "server_id", Type: field.TypeUint64, Nullable: true, Comment: "服务器id", Default: 0},
 	}
@@ -636,13 +640,13 @@ var (
 		ForeignKeys: []*schema.ForeignKey{
 			{
 				Symbol:     "wx_agent_wx_agent",
-				Columns:    []*schema.Column{WxColumns[16]},
+				Columns:    []*schema.Column{WxColumns[20]},
 				RefColumns: []*schema.Column{AgentColumns[0]},
 				OnDelete:   schema.NoAction,
 			},
 			{
 				Symbol:     "wx_server_wxs",
-				Columns:    []*schema.Column{WxColumns[17]},
+				Columns:    []*schema.Column{WxColumns[21]},
 				RefColumns: []*schema.Column{ServerColumns[0]},
 				OnDelete:   schema.SetNull,
 			},
@@ -651,7 +655,7 @@ var (
 			{
 				Name:    "wx_server_id_port",
 				Unique:  true,
-				Columns: []*schema.Column{WxColumns[17], WxColumns[5]},
+				Columns: []*schema.Column{WxColumns[21], WxColumns[5]},
 			},
 			{
 				Name:    "wx_wxid",

+ 309 - 29
ent/mutation.go

@@ -20009,34 +20009,42 @@ func (m *WorkExperienceMutation) ResetEdge(name string) error {
 // WxMutation represents an operation that mutates the Wx nodes in the graph.
 type WxMutation struct {
 	config
-	op                 Op
-	typ                string
-	id                 *uint64
-	created_at         *time.Time
-	updated_at         *time.Time
-	status             *uint8
-	addstatus          *int8
-	deleted_at         *time.Time
-	port               *string
-	process_id         *string
-	callback           *string
-	wxid               *string
-	account            *string
-	nickname           *string
-	tel                *string
-	head_big           *string
-	organization_id    *uint64
-	addorganization_id *int64
-	api_base           *string
-	api_key            *string
-	clearedFields      map[string]struct{}
-	server             *uint64
-	clearedserver      bool
-	agent              *uint64
-	clearedagent       bool
-	done               bool
-	oldValue           func(context.Context) (*Wx, error)
-	predicates         []predicate.Wx
+	op                     Op
+	typ                    string
+	id                     *uint64
+	created_at             *time.Time
+	updated_at             *time.Time
+	status                 *uint8
+	addstatus              *int8
+	deleted_at             *time.Time
+	port                   *string
+	process_id             *string
+	callback               *string
+	wxid                   *string
+	account                *string
+	nickname               *string
+	tel                    *string
+	head_big               *string
+	organization_id        *uint64
+	addorganization_id     *int64
+	api_base               *string
+	api_key                *string
+	allow_list             *[]string
+	appendallow_list       []string
+	group_allow_list       *[]string
+	appendgroup_allow_list []string
+	block_list             *[]string
+	appendblock_list       []string
+	group_block_list       *[]string
+	appendgroup_block_list []string
+	clearedFields          map[string]struct{}
+	server                 *uint64
+	clearedserver          bool
+	agent                  *uint64
+	clearedagent           bool
+	done                   bool
+	oldValue               func(context.Context) (*Wx, error)
+	predicates             []predicate.Wx
 }
 
 var _ ent.Mutation = (*WxMutation)(nil)
@@ -20875,6 +20883,210 @@ func (m *WxMutation) ResetAPIKey() {
 	delete(m.clearedFields, wx.FieldAPIKey)
 }
 
+// SetAllowList sets the "allow_list" field.
+func (m *WxMutation) SetAllowList(s []string) {
+	m.allow_list = &s
+	m.appendallow_list = nil
+}
+
+// AllowList returns the value of the "allow_list" field in the mutation.
+func (m *WxMutation) AllowList() (r []string, exists bool) {
+	v := m.allow_list
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldAllowList returns the old "allow_list" field's value of the Wx entity.
+// If the Wx 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 *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldAllowList requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
+	}
+	return oldValue.AllowList, nil
+}
+
+// AppendAllowList adds s to the "allow_list" field.
+func (m *WxMutation) AppendAllowList(s []string) {
+	m.appendallow_list = append(m.appendallow_list, s...)
+}
+
+// AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
+func (m *WxMutation) AppendedAllowList() ([]string, bool) {
+	if len(m.appendallow_list) == 0 {
+		return nil, false
+	}
+	return m.appendallow_list, true
+}
+
+// ResetAllowList resets all changes to the "allow_list" field.
+func (m *WxMutation) ResetAllowList() {
+	m.allow_list = nil
+	m.appendallow_list = nil
+}
+
+// SetGroupAllowList sets the "group_allow_list" field.
+func (m *WxMutation) SetGroupAllowList(s []string) {
+	m.group_allow_list = &s
+	m.appendgroup_allow_list = nil
+}
+
+// GroupAllowList returns the value of the "group_allow_list" field in the mutation.
+func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
+	v := m.group_allow_list
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
+// If the Wx 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 *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
+	}
+	return oldValue.GroupAllowList, nil
+}
+
+// AppendGroupAllowList adds s to the "group_allow_list" field.
+func (m *WxMutation) AppendGroupAllowList(s []string) {
+	m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
+}
+
+// AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
+func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
+	if len(m.appendgroup_allow_list) == 0 {
+		return nil, false
+	}
+	return m.appendgroup_allow_list, true
+}
+
+// ResetGroupAllowList resets all changes to the "group_allow_list" field.
+func (m *WxMutation) ResetGroupAllowList() {
+	m.group_allow_list = nil
+	m.appendgroup_allow_list = nil
+}
+
+// SetBlockList sets the "block_list" field.
+func (m *WxMutation) SetBlockList(s []string) {
+	m.block_list = &s
+	m.appendblock_list = nil
+}
+
+// BlockList returns the value of the "block_list" field in the mutation.
+func (m *WxMutation) BlockList() (r []string, exists bool) {
+	v := m.block_list
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldBlockList returns the old "block_list" field's value of the Wx entity.
+// If the Wx 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 *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldBlockList requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
+	}
+	return oldValue.BlockList, nil
+}
+
+// AppendBlockList adds s to the "block_list" field.
+func (m *WxMutation) AppendBlockList(s []string) {
+	m.appendblock_list = append(m.appendblock_list, s...)
+}
+
+// AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
+func (m *WxMutation) AppendedBlockList() ([]string, bool) {
+	if len(m.appendblock_list) == 0 {
+		return nil, false
+	}
+	return m.appendblock_list, true
+}
+
+// ResetBlockList resets all changes to the "block_list" field.
+func (m *WxMutation) ResetBlockList() {
+	m.block_list = nil
+	m.appendblock_list = nil
+}
+
+// SetGroupBlockList sets the "group_block_list" field.
+func (m *WxMutation) SetGroupBlockList(s []string) {
+	m.group_block_list = &s
+	m.appendgroup_block_list = nil
+}
+
+// GroupBlockList returns the value of the "group_block_list" field in the mutation.
+func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
+	v := m.group_block_list
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
+// If the Wx 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 *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
+	}
+	return oldValue.GroupBlockList, nil
+}
+
+// AppendGroupBlockList adds s to the "group_block_list" field.
+func (m *WxMutation) AppendGroupBlockList(s []string) {
+	m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
+}
+
+// AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
+func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
+	if len(m.appendgroup_block_list) == 0 {
+		return nil, false
+	}
+	return m.appendgroup_block_list, true
+}
+
+// ResetGroupBlockList resets all changes to the "group_block_list" field.
+func (m *WxMutation) ResetGroupBlockList() {
+	m.group_block_list = nil
+	m.appendgroup_block_list = nil
+}
+
 // ClearServer clears the "server" edge to the Server entity.
 func (m *WxMutation) ClearServer() {
 	m.clearedserver = true
@@ -20963,7 +21175,7 @@ func (m *WxMutation) Type() string {
 // order to get all numeric fields that were incremented/decremented, call
 // AddedFields().
 func (m *WxMutation) Fields() []string {
-	fields := make([]string, 0, 17)
+	fields := make([]string, 0, 21)
 	if m.created_at != nil {
 		fields = append(fields, wx.FieldCreatedAt)
 	}
@@ -21015,6 +21227,18 @@ func (m *WxMutation) Fields() []string {
 	if m.api_key != nil {
 		fields = append(fields, wx.FieldAPIKey)
 	}
+	if m.allow_list != nil {
+		fields = append(fields, wx.FieldAllowList)
+	}
+	if m.group_allow_list != nil {
+		fields = append(fields, wx.FieldGroupAllowList)
+	}
+	if m.block_list != nil {
+		fields = append(fields, wx.FieldBlockList)
+	}
+	if m.group_block_list != nil {
+		fields = append(fields, wx.FieldGroupBlockList)
+	}
 	return fields
 }
 
@@ -21057,6 +21281,14 @@ func (m *WxMutation) Field(name string) (ent.Value, bool) {
 		return m.APIBase()
 	case wx.FieldAPIKey:
 		return m.APIKey()
+	case wx.FieldAllowList:
+		return m.AllowList()
+	case wx.FieldGroupAllowList:
+		return m.GroupAllowList()
+	case wx.FieldBlockList:
+		return m.BlockList()
+	case wx.FieldGroupBlockList:
+		return m.GroupBlockList()
 	}
 	return nil, false
 }
@@ -21100,6 +21332,14 @@ func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, erro
 		return m.OldAPIBase(ctx)
 	case wx.FieldAPIKey:
 		return m.OldAPIKey(ctx)
+	case wx.FieldAllowList:
+		return m.OldAllowList(ctx)
+	case wx.FieldGroupAllowList:
+		return m.OldGroupAllowList(ctx)
+	case wx.FieldBlockList:
+		return m.OldBlockList(ctx)
+	case wx.FieldGroupBlockList:
+		return m.OldGroupBlockList(ctx)
 	}
 	return nil, fmt.Errorf("unknown Wx field %s", name)
 }
@@ -21228,6 +21468,34 @@ func (m *WxMutation) SetField(name string, value ent.Value) error {
 		}
 		m.SetAPIKey(v)
 		return nil
+	case wx.FieldAllowList:
+		v, ok := value.([]string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetAllowList(v)
+		return nil
+	case wx.FieldGroupAllowList:
+		v, ok := value.([]string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetGroupAllowList(v)
+		return nil
+	case wx.FieldBlockList:
+		v, ok := value.([]string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetBlockList(v)
+		return nil
+	case wx.FieldGroupBlockList:
+		v, ok := value.([]string)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetGroupBlockList(v)
+		return nil
 	}
 	return fmt.Errorf("unknown Wx field %s", name)
 }
@@ -21394,6 +21662,18 @@ func (m *WxMutation) ResetField(name string) error {
 	case wx.FieldAPIKey:
 		m.ResetAPIKey()
 		return nil
+	case wx.FieldAllowList:
+		m.ResetAllowList()
+		return nil
+	case wx.FieldGroupAllowList:
+		m.ResetGroupAllowList()
+		return nil
+	case wx.FieldBlockList:
+		m.ResetBlockList()
+		return nil
+	case wx.FieldGroupBlockList:
+		m.ResetGroupBlockList()
+		return nil
 	}
 	return fmt.Errorf("unknown Wx field %s", name)
 }

+ 12 - 0
ent/schema/wx.go

@@ -58,6 +58,18 @@ func (Wx) Fields() []ent.Field {
 		field.String("api_key").Optional().Default("").
 			Annotations(entsql.WithComments(true)).
 			Comment("大模型服务密钥"),
+		field.JSON("allow_list", []string{}).
+			Annotations(entsql.WithComments(true)).
+			Comment("白名单"),
+		field.JSON("group_allow_list", []string{}).
+			Annotations(entsql.WithComments(true)).
+			Comment("群白名单"),
+		field.JSON("block_list", []string{}).
+			Annotations(entsql.WithComments(true)).
+			Comment("黑名单"),
+		field.JSON("group_block_list", []string{}).
+			Annotations(entsql.WithComments(true)).
+			Comment("群黑名单"),
 	}
 }
 

+ 96 - 0
ent/set_not_nil.go

@@ -4494,3 +4494,99 @@ func (w *WxCreate) SetNotNilAPIKey(value *string) *WxCreate {
 	}
 	return w
 }
+
+// set field if value's pointer is not nil.
+func (w *WxUpdate) SetNotNilAllowList(value []string) *WxUpdate {
+	if value != nil {
+		return w.SetAllowList(value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WxUpdateOne) SetNotNilAllowList(value []string) *WxUpdateOne {
+	if value != nil {
+		return w.SetAllowList(value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WxCreate) SetNotNilAllowList(value []string) *WxCreate {
+	if value != nil {
+		return w.SetAllowList(value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WxUpdate) SetNotNilGroupAllowList(value []string) *WxUpdate {
+	if value != nil {
+		return w.SetGroupAllowList(value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WxUpdateOne) SetNotNilGroupAllowList(value []string) *WxUpdateOne {
+	if value != nil {
+		return w.SetGroupAllowList(value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WxCreate) SetNotNilGroupAllowList(value []string) *WxCreate {
+	if value != nil {
+		return w.SetGroupAllowList(value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WxUpdate) SetNotNilBlockList(value []string) *WxUpdate {
+	if value != nil {
+		return w.SetBlockList(value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WxUpdateOne) SetNotNilBlockList(value []string) *WxUpdateOne {
+	if value != nil {
+		return w.SetBlockList(value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WxCreate) SetNotNilBlockList(value []string) *WxCreate {
+	if value != nil {
+		return w.SetBlockList(value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WxUpdate) SetNotNilGroupBlockList(value []string) *WxUpdate {
+	if value != nil {
+		return w.SetGroupBlockList(value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WxUpdateOne) SetNotNilGroupBlockList(value []string) *WxUpdateOne {
+	if value != nil {
+		return w.SetGroupBlockList(value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WxCreate) SetNotNilGroupBlockList(value []string) *WxCreate {
+	if value != nil {
+		return w.SetGroupBlockList(value)
+	}
+	return w
+}

+ 55 - 0
ent/wx.go

@@ -3,6 +3,7 @@
 package ent
 
 import (
+	"encoding/json"
 	"fmt"
 	"strings"
 	"time"
@@ -53,6 +54,14 @@ type Wx struct {
 	APIBase string `json:"api_base,omitempty"`
 	// 大模型服务密钥
 	APIKey string `json:"api_key,omitempty"`
+	// 白名单
+	AllowList []string `json:"allow_list,omitempty"`
+	// 群白名单
+	GroupAllowList []string `json:"group_allow_list,omitempty"`
+	// 黑名单
+	BlockList []string `json:"block_list,omitempty"`
+	// 群黑名单
+	GroupBlockList []string `json:"group_block_list,omitempty"`
 	// Edges holds the relations/edges for other nodes in the graph.
 	// The values are being populated by the WxQuery when eager-loading is set.
 	Edges        WxEdges `json:"edges"`
@@ -97,6 +106,8 @@ func (*Wx) scanValues(columns []string) ([]any, error) {
 	values := make([]any, len(columns))
 	for i := range columns {
 		switch columns[i] {
+		case wx.FieldAllowList, wx.FieldGroupAllowList, wx.FieldBlockList, wx.FieldGroupBlockList:
+			values[i] = new([]byte)
 		case wx.FieldID, wx.FieldStatus, wx.FieldServerID, wx.FieldOrganizationID, wx.FieldAgentID:
 			values[i] = new(sql.NullInt64)
 		case wx.FieldPort, wx.FieldProcessID, wx.FieldCallback, wx.FieldWxid, wx.FieldAccount, wx.FieldNickname, wx.FieldTel, wx.FieldHeadBig, wx.FieldAPIBase, wx.FieldAPIKey:
@@ -226,6 +237,38 @@ func (w *Wx) assignValues(columns []string, values []any) error {
 			} else if value.Valid {
 				w.APIKey = value.String
 			}
+		case wx.FieldAllowList:
+			if value, ok := values[i].(*[]byte); !ok {
+				return fmt.Errorf("unexpected type %T for field allow_list", values[i])
+			} else if value != nil && len(*value) > 0 {
+				if err := json.Unmarshal(*value, &w.AllowList); err != nil {
+					return fmt.Errorf("unmarshal field allow_list: %w", err)
+				}
+			}
+		case wx.FieldGroupAllowList:
+			if value, ok := values[i].(*[]byte); !ok {
+				return fmt.Errorf("unexpected type %T for field group_allow_list", values[i])
+			} else if value != nil && len(*value) > 0 {
+				if err := json.Unmarshal(*value, &w.GroupAllowList); err != nil {
+					return fmt.Errorf("unmarshal field group_allow_list: %w", err)
+				}
+			}
+		case wx.FieldBlockList:
+			if value, ok := values[i].(*[]byte); !ok {
+				return fmt.Errorf("unexpected type %T for field block_list", values[i])
+			} else if value != nil && len(*value) > 0 {
+				if err := json.Unmarshal(*value, &w.BlockList); err != nil {
+					return fmt.Errorf("unmarshal field block_list: %w", err)
+				}
+			}
+		case wx.FieldGroupBlockList:
+			if value, ok := values[i].(*[]byte); !ok {
+				return fmt.Errorf("unexpected type %T for field group_block_list", values[i])
+			} else if value != nil && len(*value) > 0 {
+				if err := json.Unmarshal(*value, &w.GroupBlockList); err != nil {
+					return fmt.Errorf("unmarshal field group_block_list: %w", err)
+				}
+			}
 		default:
 			w.selectValues.Set(columns[i], values[i])
 		}
@@ -322,6 +365,18 @@ func (w *Wx) String() string {
 	builder.WriteString(", ")
 	builder.WriteString("api_key=")
 	builder.WriteString(w.APIKey)
+	builder.WriteString(", ")
+	builder.WriteString("allow_list=")
+	builder.WriteString(fmt.Sprintf("%v", w.AllowList))
+	builder.WriteString(", ")
+	builder.WriteString("group_allow_list=")
+	builder.WriteString(fmt.Sprintf("%v", w.GroupAllowList))
+	builder.WriteString(", ")
+	builder.WriteString("block_list=")
+	builder.WriteString(fmt.Sprintf("%v", w.BlockList))
+	builder.WriteString(", ")
+	builder.WriteString("group_block_list=")
+	builder.WriteString(fmt.Sprintf("%v", w.GroupBlockList))
 	builder.WriteByte(')')
 	return builder.String()
 }

+ 12 - 0
ent/wx/wx.go

@@ -49,6 +49,14 @@ const (
 	FieldAPIBase = "api_base"
 	// FieldAPIKey holds the string denoting the api_key field in the database.
 	FieldAPIKey = "api_key"
+	// FieldAllowList holds the string denoting the allow_list field in the database.
+	FieldAllowList = "allow_list"
+	// FieldGroupAllowList holds the string denoting the group_allow_list field in the database.
+	FieldGroupAllowList = "group_allow_list"
+	// FieldBlockList holds the string denoting the block_list field in the database.
+	FieldBlockList = "block_list"
+	// FieldGroupBlockList holds the string denoting the group_block_list field in the database.
+	FieldGroupBlockList = "group_block_list"
 	// EdgeServer holds the string denoting the server edge name in mutations.
 	EdgeServer = "server"
 	// EdgeAgent holds the string denoting the agent edge name in mutations.
@@ -91,6 +99,10 @@ var Columns = []string{
 	FieldAgentID,
 	FieldAPIBase,
 	FieldAPIKey,
+	FieldAllowList,
+	FieldGroupAllowList,
+	FieldBlockList,
+	FieldGroupBlockList,
 }
 
 // ValidColumn reports if the column name is valid (part of the table columns).

+ 212 - 0
ent/wx_create.go

@@ -262,6 +262,30 @@ func (wc *WxCreate) SetNillableAPIKey(s *string) *WxCreate {
 	return wc
 }
 
+// SetAllowList sets the "allow_list" field.
+func (wc *WxCreate) SetAllowList(s []string) *WxCreate {
+	wc.mutation.SetAllowList(s)
+	return wc
+}
+
+// SetGroupAllowList sets the "group_allow_list" field.
+func (wc *WxCreate) SetGroupAllowList(s []string) *WxCreate {
+	wc.mutation.SetGroupAllowList(s)
+	return wc
+}
+
+// SetBlockList sets the "block_list" field.
+func (wc *WxCreate) SetBlockList(s []string) *WxCreate {
+	wc.mutation.SetBlockList(s)
+	return wc
+}
+
+// SetGroupBlockList sets the "group_block_list" field.
+func (wc *WxCreate) SetGroupBlockList(s []string) *WxCreate {
+	wc.mutation.SetGroupBlockList(s)
+	return wc
+}
+
 // SetID sets the "id" field.
 func (wc *WxCreate) SetID(u uint64) *WxCreate {
 	wc.mutation.SetID(u)
@@ -423,6 +447,18 @@ func (wc *WxCreate) check() error {
 	if _, ok := wc.mutation.AgentID(); !ok {
 		return &ValidationError{Name: "agent_id", err: errors.New(`ent: missing required field "Wx.agent_id"`)}
 	}
+	if _, ok := wc.mutation.AllowList(); !ok {
+		return &ValidationError{Name: "allow_list", err: errors.New(`ent: missing required field "Wx.allow_list"`)}
+	}
+	if _, ok := wc.mutation.GroupAllowList(); !ok {
+		return &ValidationError{Name: "group_allow_list", err: errors.New(`ent: missing required field "Wx.group_allow_list"`)}
+	}
+	if _, ok := wc.mutation.BlockList(); !ok {
+		return &ValidationError{Name: "block_list", err: errors.New(`ent: missing required field "Wx.block_list"`)}
+	}
+	if _, ok := wc.mutation.GroupBlockList(); !ok {
+		return &ValidationError{Name: "group_block_list", err: errors.New(`ent: missing required field "Wx.group_block_list"`)}
+	}
 	if _, ok := wc.mutation.AgentID(); !ok {
 		return &ValidationError{Name: "agent", err: errors.New(`ent: missing required edge "Wx.agent"`)}
 	}
@@ -519,6 +555,22 @@ func (wc *WxCreate) createSpec() (*Wx, *sqlgraph.CreateSpec) {
 		_spec.SetField(wx.FieldAPIKey, field.TypeString, value)
 		_node.APIKey = value
 	}
+	if value, ok := wc.mutation.AllowList(); ok {
+		_spec.SetField(wx.FieldAllowList, field.TypeJSON, value)
+		_node.AllowList = value
+	}
+	if value, ok := wc.mutation.GroupAllowList(); ok {
+		_spec.SetField(wx.FieldGroupAllowList, field.TypeJSON, value)
+		_node.GroupAllowList = value
+	}
+	if value, ok := wc.mutation.BlockList(); ok {
+		_spec.SetField(wx.FieldBlockList, field.TypeJSON, value)
+		_node.BlockList = value
+	}
+	if value, ok := wc.mutation.GroupBlockList(); ok {
+		_spec.SetField(wx.FieldGroupBlockList, field.TypeJSON, value)
+		_node.GroupBlockList = value
+	}
 	if nodes := wc.mutation.ServerIDs(); len(nodes) > 0 {
 		edge := &sqlgraph.EdgeSpec{
 			Rel:     sqlgraph.M2O,
@@ -845,6 +897,54 @@ func (u *WxUpsert) ClearAPIKey() *WxUpsert {
 	return u
 }
 
+// SetAllowList sets the "allow_list" field.
+func (u *WxUpsert) SetAllowList(v []string) *WxUpsert {
+	u.Set(wx.FieldAllowList, v)
+	return u
+}
+
+// UpdateAllowList sets the "allow_list" field to the value that was provided on create.
+func (u *WxUpsert) UpdateAllowList() *WxUpsert {
+	u.SetExcluded(wx.FieldAllowList)
+	return u
+}
+
+// SetGroupAllowList sets the "group_allow_list" field.
+func (u *WxUpsert) SetGroupAllowList(v []string) *WxUpsert {
+	u.Set(wx.FieldGroupAllowList, v)
+	return u
+}
+
+// UpdateGroupAllowList sets the "group_allow_list" field to the value that was provided on create.
+func (u *WxUpsert) UpdateGroupAllowList() *WxUpsert {
+	u.SetExcluded(wx.FieldGroupAllowList)
+	return u
+}
+
+// SetBlockList sets the "block_list" field.
+func (u *WxUpsert) SetBlockList(v []string) *WxUpsert {
+	u.Set(wx.FieldBlockList, v)
+	return u
+}
+
+// UpdateBlockList sets the "block_list" field to the value that was provided on create.
+func (u *WxUpsert) UpdateBlockList() *WxUpsert {
+	u.SetExcluded(wx.FieldBlockList)
+	return u
+}
+
+// SetGroupBlockList sets the "group_block_list" field.
+func (u *WxUpsert) SetGroupBlockList(v []string) *WxUpsert {
+	u.Set(wx.FieldGroupBlockList, v)
+	return u
+}
+
+// UpdateGroupBlockList sets the "group_block_list" field to the value that was provided on create.
+func (u *WxUpsert) UpdateGroupBlockList() *WxUpsert {
+	u.SetExcluded(wx.FieldGroupBlockList)
+	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:
 //
@@ -1176,6 +1276,62 @@ func (u *WxUpsertOne) ClearAPIKey() *WxUpsertOne {
 	})
 }
 
+// SetAllowList sets the "allow_list" field.
+func (u *WxUpsertOne) SetAllowList(v []string) *WxUpsertOne {
+	return u.Update(func(s *WxUpsert) {
+		s.SetAllowList(v)
+	})
+}
+
+// UpdateAllowList sets the "allow_list" field to the value that was provided on create.
+func (u *WxUpsertOne) UpdateAllowList() *WxUpsertOne {
+	return u.Update(func(s *WxUpsert) {
+		s.UpdateAllowList()
+	})
+}
+
+// SetGroupAllowList sets the "group_allow_list" field.
+func (u *WxUpsertOne) SetGroupAllowList(v []string) *WxUpsertOne {
+	return u.Update(func(s *WxUpsert) {
+		s.SetGroupAllowList(v)
+	})
+}
+
+// UpdateGroupAllowList sets the "group_allow_list" field to the value that was provided on create.
+func (u *WxUpsertOne) UpdateGroupAllowList() *WxUpsertOne {
+	return u.Update(func(s *WxUpsert) {
+		s.UpdateGroupAllowList()
+	})
+}
+
+// SetBlockList sets the "block_list" field.
+func (u *WxUpsertOne) SetBlockList(v []string) *WxUpsertOne {
+	return u.Update(func(s *WxUpsert) {
+		s.SetBlockList(v)
+	})
+}
+
+// UpdateBlockList sets the "block_list" field to the value that was provided on create.
+func (u *WxUpsertOne) UpdateBlockList() *WxUpsertOne {
+	return u.Update(func(s *WxUpsert) {
+		s.UpdateBlockList()
+	})
+}
+
+// SetGroupBlockList sets the "group_block_list" field.
+func (u *WxUpsertOne) SetGroupBlockList(v []string) *WxUpsertOne {
+	return u.Update(func(s *WxUpsert) {
+		s.SetGroupBlockList(v)
+	})
+}
+
+// UpdateGroupBlockList sets the "group_block_list" field to the value that was provided on create.
+func (u *WxUpsertOne) UpdateGroupBlockList() *WxUpsertOne {
+	return u.Update(func(s *WxUpsert) {
+		s.UpdateGroupBlockList()
+	})
+}
+
 // Exec executes the query.
 func (u *WxUpsertOne) Exec(ctx context.Context) error {
 	if len(u.create.conflict) == 0 {
@@ -1673,6 +1829,62 @@ func (u *WxUpsertBulk) ClearAPIKey() *WxUpsertBulk {
 	})
 }
 
+// SetAllowList sets the "allow_list" field.
+func (u *WxUpsertBulk) SetAllowList(v []string) *WxUpsertBulk {
+	return u.Update(func(s *WxUpsert) {
+		s.SetAllowList(v)
+	})
+}
+
+// UpdateAllowList sets the "allow_list" field to the value that was provided on create.
+func (u *WxUpsertBulk) UpdateAllowList() *WxUpsertBulk {
+	return u.Update(func(s *WxUpsert) {
+		s.UpdateAllowList()
+	})
+}
+
+// SetGroupAllowList sets the "group_allow_list" field.
+func (u *WxUpsertBulk) SetGroupAllowList(v []string) *WxUpsertBulk {
+	return u.Update(func(s *WxUpsert) {
+		s.SetGroupAllowList(v)
+	})
+}
+
+// UpdateGroupAllowList sets the "group_allow_list" field to the value that was provided on create.
+func (u *WxUpsertBulk) UpdateGroupAllowList() *WxUpsertBulk {
+	return u.Update(func(s *WxUpsert) {
+		s.UpdateGroupAllowList()
+	})
+}
+
+// SetBlockList sets the "block_list" field.
+func (u *WxUpsertBulk) SetBlockList(v []string) *WxUpsertBulk {
+	return u.Update(func(s *WxUpsert) {
+		s.SetBlockList(v)
+	})
+}
+
+// UpdateBlockList sets the "block_list" field to the value that was provided on create.
+func (u *WxUpsertBulk) UpdateBlockList() *WxUpsertBulk {
+	return u.Update(func(s *WxUpsert) {
+		s.UpdateBlockList()
+	})
+}
+
+// SetGroupBlockList sets the "group_block_list" field.
+func (u *WxUpsertBulk) SetGroupBlockList(v []string) *WxUpsertBulk {
+	return u.Update(func(s *WxUpsert) {
+		s.SetGroupBlockList(v)
+	})
+}
+
+// UpdateGroupBlockList sets the "group_block_list" field to the value that was provided on create.
+func (u *WxUpsertBulk) UpdateGroupBlockList() *WxUpsertBulk {
+	return u.Update(func(s *WxUpsert) {
+		s.UpdateGroupBlockList()
+	})
+}
+
 // Exec executes the query.
 func (u *WxUpsertBulk) Exec(ctx context.Context) error {
 	if u.create.err != nil {

+ 161 - 0
ent/wx_update.go

@@ -14,6 +14,7 @@ import (
 
 	"entgo.io/ent/dialect/sql"
 	"entgo.io/ent/dialect/sql/sqlgraph"
+	"entgo.io/ent/dialect/sql/sqljson"
 	"entgo.io/ent/schema/field"
 )
 
@@ -296,6 +297,54 @@ func (wu *WxUpdate) ClearAPIKey() *WxUpdate {
 	return wu
 }
 
+// SetAllowList sets the "allow_list" field.
+func (wu *WxUpdate) SetAllowList(s []string) *WxUpdate {
+	wu.mutation.SetAllowList(s)
+	return wu
+}
+
+// AppendAllowList appends s to the "allow_list" field.
+func (wu *WxUpdate) AppendAllowList(s []string) *WxUpdate {
+	wu.mutation.AppendAllowList(s)
+	return wu
+}
+
+// SetGroupAllowList sets the "group_allow_list" field.
+func (wu *WxUpdate) SetGroupAllowList(s []string) *WxUpdate {
+	wu.mutation.SetGroupAllowList(s)
+	return wu
+}
+
+// AppendGroupAllowList appends s to the "group_allow_list" field.
+func (wu *WxUpdate) AppendGroupAllowList(s []string) *WxUpdate {
+	wu.mutation.AppendGroupAllowList(s)
+	return wu
+}
+
+// SetBlockList sets the "block_list" field.
+func (wu *WxUpdate) SetBlockList(s []string) *WxUpdate {
+	wu.mutation.SetBlockList(s)
+	return wu
+}
+
+// AppendBlockList appends s to the "block_list" field.
+func (wu *WxUpdate) AppendBlockList(s []string) *WxUpdate {
+	wu.mutation.AppendBlockList(s)
+	return wu
+}
+
+// SetGroupBlockList sets the "group_block_list" field.
+func (wu *WxUpdate) SetGroupBlockList(s []string) *WxUpdate {
+	wu.mutation.SetGroupBlockList(s)
+	return wu
+}
+
+// AppendGroupBlockList appends s to the "group_block_list" field.
+func (wu *WxUpdate) AppendGroupBlockList(s []string) *WxUpdate {
+	wu.mutation.AppendGroupBlockList(s)
+	return wu
+}
+
 // SetServer sets the "server" edge to the Server entity.
 func (wu *WxUpdate) SetServer(s *Server) *WxUpdate {
 	return wu.SetServerID(s.ID)
@@ -448,6 +497,38 @@ func (wu *WxUpdate) sqlSave(ctx context.Context) (n int, err error) {
 	if wu.mutation.APIKeyCleared() {
 		_spec.ClearField(wx.FieldAPIKey, field.TypeString)
 	}
+	if value, ok := wu.mutation.AllowList(); ok {
+		_spec.SetField(wx.FieldAllowList, field.TypeJSON, value)
+	}
+	if value, ok := wu.mutation.AppendedAllowList(); ok {
+		_spec.AddModifier(func(u *sql.UpdateBuilder) {
+			sqljson.Append(u, wx.FieldAllowList, value)
+		})
+	}
+	if value, ok := wu.mutation.GroupAllowList(); ok {
+		_spec.SetField(wx.FieldGroupAllowList, field.TypeJSON, value)
+	}
+	if value, ok := wu.mutation.AppendedGroupAllowList(); ok {
+		_spec.AddModifier(func(u *sql.UpdateBuilder) {
+			sqljson.Append(u, wx.FieldGroupAllowList, value)
+		})
+	}
+	if value, ok := wu.mutation.BlockList(); ok {
+		_spec.SetField(wx.FieldBlockList, field.TypeJSON, value)
+	}
+	if value, ok := wu.mutation.AppendedBlockList(); ok {
+		_spec.AddModifier(func(u *sql.UpdateBuilder) {
+			sqljson.Append(u, wx.FieldBlockList, value)
+		})
+	}
+	if value, ok := wu.mutation.GroupBlockList(); ok {
+		_spec.SetField(wx.FieldGroupBlockList, field.TypeJSON, value)
+	}
+	if value, ok := wu.mutation.AppendedGroupBlockList(); ok {
+		_spec.AddModifier(func(u *sql.UpdateBuilder) {
+			sqljson.Append(u, wx.FieldGroupBlockList, value)
+		})
+	}
 	if wu.mutation.ServerCleared() {
 		edge := &sqlgraph.EdgeSpec{
 			Rel:     sqlgraph.M2O,
@@ -792,6 +873,54 @@ func (wuo *WxUpdateOne) ClearAPIKey() *WxUpdateOne {
 	return wuo
 }
 
+// SetAllowList sets the "allow_list" field.
+func (wuo *WxUpdateOne) SetAllowList(s []string) *WxUpdateOne {
+	wuo.mutation.SetAllowList(s)
+	return wuo
+}
+
+// AppendAllowList appends s to the "allow_list" field.
+func (wuo *WxUpdateOne) AppendAllowList(s []string) *WxUpdateOne {
+	wuo.mutation.AppendAllowList(s)
+	return wuo
+}
+
+// SetGroupAllowList sets the "group_allow_list" field.
+func (wuo *WxUpdateOne) SetGroupAllowList(s []string) *WxUpdateOne {
+	wuo.mutation.SetGroupAllowList(s)
+	return wuo
+}
+
+// AppendGroupAllowList appends s to the "group_allow_list" field.
+func (wuo *WxUpdateOne) AppendGroupAllowList(s []string) *WxUpdateOne {
+	wuo.mutation.AppendGroupAllowList(s)
+	return wuo
+}
+
+// SetBlockList sets the "block_list" field.
+func (wuo *WxUpdateOne) SetBlockList(s []string) *WxUpdateOne {
+	wuo.mutation.SetBlockList(s)
+	return wuo
+}
+
+// AppendBlockList appends s to the "block_list" field.
+func (wuo *WxUpdateOne) AppendBlockList(s []string) *WxUpdateOne {
+	wuo.mutation.AppendBlockList(s)
+	return wuo
+}
+
+// SetGroupBlockList sets the "group_block_list" field.
+func (wuo *WxUpdateOne) SetGroupBlockList(s []string) *WxUpdateOne {
+	wuo.mutation.SetGroupBlockList(s)
+	return wuo
+}
+
+// AppendGroupBlockList appends s to the "group_block_list" field.
+func (wuo *WxUpdateOne) AppendGroupBlockList(s []string) *WxUpdateOne {
+	wuo.mutation.AppendGroupBlockList(s)
+	return wuo
+}
+
 // SetServer sets the "server" edge to the Server entity.
 func (wuo *WxUpdateOne) SetServer(s *Server) *WxUpdateOne {
 	return wuo.SetServerID(s.ID)
@@ -974,6 +1103,38 @@ func (wuo *WxUpdateOne) sqlSave(ctx context.Context) (_node *Wx, err error) {
 	if wuo.mutation.APIKeyCleared() {
 		_spec.ClearField(wx.FieldAPIKey, field.TypeString)
 	}
+	if value, ok := wuo.mutation.AllowList(); ok {
+		_spec.SetField(wx.FieldAllowList, field.TypeJSON, value)
+	}
+	if value, ok := wuo.mutation.AppendedAllowList(); ok {
+		_spec.AddModifier(func(u *sql.UpdateBuilder) {
+			sqljson.Append(u, wx.FieldAllowList, value)
+		})
+	}
+	if value, ok := wuo.mutation.GroupAllowList(); ok {
+		_spec.SetField(wx.FieldGroupAllowList, field.TypeJSON, value)
+	}
+	if value, ok := wuo.mutation.AppendedGroupAllowList(); ok {
+		_spec.AddModifier(func(u *sql.UpdateBuilder) {
+			sqljson.Append(u, wx.FieldGroupAllowList, value)
+		})
+	}
+	if value, ok := wuo.mutation.BlockList(); ok {
+		_spec.SetField(wx.FieldBlockList, field.TypeJSON, value)
+	}
+	if value, ok := wuo.mutation.AppendedBlockList(); ok {
+		_spec.AddModifier(func(u *sql.UpdateBuilder) {
+			sqljson.Append(u, wx.FieldBlockList, value)
+		})
+	}
+	if value, ok := wuo.mutation.GroupBlockList(); ok {
+		_spec.SetField(wx.FieldGroupBlockList, field.TypeJSON, value)
+	}
+	if value, ok := wuo.mutation.AppendedGroupBlockList(); ok {
+		_spec.AddModifier(func(u *sql.UpdateBuilder) {
+			sqljson.Append(u, wx.FieldGroupBlockList, value)
+		})
+	}
 	if wuo.mutation.ServerCleared() {
 		edge := &sqlgraph.EdgeSpec{
 			Rel:     sqlgraph.M2O,

+ 44 - 0
internal/handler/Wx/get_wx_allow_block_list_handler.go

@@ -0,0 +1,44 @@
+package Wx
+
+import (
+	"net/http"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
+
+	"wechat-api/internal/logic/Wx"
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+)
+
+// swagger:route post /wx/getWxAllowBlockList Wx GetWxAllowBlockList
+//
+// Get wx allow and block list | 获取黑白名单列表
+//
+// Get wx allow and block list | 获取黑白名单列表
+//
+// Parameters:
+//  + name: body
+//    require: true
+//    in: body
+//    type: AllowBlockListReq
+//
+// Responses:
+//  200: AllowBlockListResp
+
+func GetWxAllowBlockListHandler(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 := Wx.NewGetWxAllowBlockListLogic(r.Context(), svcCtx)
+		resp, err := l.GetWxAllowBlockList(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 44 - 0
internal/handler/Wx/update_block_and_allow_list_handler.go

@@ -0,0 +1,44 @@
+package Wx
+
+import (
+	"net/http"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
+
+	"wechat-api/internal/logic/Wx"
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+)
+
+// swagger:route post /wx/updateBlockAndAllowList Wx UpdateBlockAndAllowList
+//
+// Update wx information | 更新黑白名单
+//
+// Update wx information | 更新黑白名单
+//
+// Parameters:
+//  + name: body
+//    require: true
+//    in: body
+//    type: WxInfo
+//
+// Responses:
+//  200: BaseMsgResp
+
+func UpdateBlockAndAllowListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.UpdateBlockAndAllowListReq
+		if err := httpx.Parse(r, &req, true); err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+			return
+		}
+
+		l := Wx.NewUpdateBlockAndAllowListLogic(r.Context(), svcCtx)
+		resp, err := l.UpdateBlockAndAllowList(&req)
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 54 - 44
internal/handler/routes.go

@@ -99,6 +99,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 				},
 				{
 					Method:  http.MethodPost,
+					Path:    "/wx/updateBlockAndAllowList",
+					Handler: Wx.UpdateBlockAndAllowListHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
 					Path:    "/wx/delete",
 					Handler: Wx.DeleteWxHandler(serverCtx),
 				},
@@ -109,6 +114,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 				},
 				{
 					Method:  http.MethodPost,
+					Path:    "/wx/getWxAllowBlockList",
+					Handler: Wx.GetWxAllowBlockListHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
 					Path:    "/wx",
 					Handler: Wx.GetWxByIdHandler(serverCtx),
 				},
@@ -187,6 +197,50 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 	)
 
 	server.AddRoutes(
+		rest.WithMiddlewares(
+			[]rest.Middleware{serverCtx.Authority},
+			[]rest.Route{
+				{
+					Method:  http.MethodPost,
+					Path:    "/label_relationship/create",
+					Handler: label_relationship.CreateLabelRelationshipHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/label_relationship/update",
+					Handler: label_relationship.UpdateLabelRelationshipHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/label_relationship/update_contact_labels",
+					Handler: label_relationship.UpdateLabelRelationshipsHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/label_relationship/batch_update_contact_labels",
+					Handler: label_relationship.BatchUpdateLabelRelationshipsHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/label_relationship/delete",
+					Handler: label_relationship.DeleteLabelRelationshipHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/label_relationship/list",
+					Handler: label_relationship.GetLabelRelationshipListHandler(serverCtx),
+				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/label_relationship",
+					Handler: label_relationship.GetLabelRelationshipByIdHandler(serverCtx),
+				},
+			}...,
+		),
+		rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
+	)
+
+	server.AddRoutes(
 		[]rest.Route{
 			{
 				Method:  http.MethodPost,
@@ -280,50 +334,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 			[]rest.Route{
 				{
 					Method:  http.MethodPost,
-					Path:    "/label_relationship/create",
-					Handler: label_relationship.CreateLabelRelationshipHandler(serverCtx),
-				},
-				{
-					Method:  http.MethodPost,
-					Path:    "/label_relationship/update",
-					Handler: label_relationship.UpdateLabelRelationshipHandler(serverCtx),
-				},
-				{
-					Method:  http.MethodPost,
-					Path:    "/label_relationship/update_contact_labels",
-					Handler: label_relationship.UpdateLabelRelationshipsHandler(serverCtx),
-				},
-				{
-					Method:  http.MethodPost,
-					Path:    "/label_relationship/batch_update_contact_labels",
-					Handler: label_relationship.BatchUpdateLabelRelationshipsHandler(serverCtx),
-				},
-				{
-					Method:  http.MethodPost,
-					Path:    "/label_relationship/delete",
-					Handler: label_relationship.DeleteLabelRelationshipHandler(serverCtx),
-				},
-				{
-					Method:  http.MethodPost,
-					Path:    "/label_relationship/list",
-					Handler: label_relationship.GetLabelRelationshipListHandler(serverCtx),
-				},
-				{
-					Method:  http.MethodPost,
-					Path:    "/label_relationship",
-					Handler: label_relationship.GetLabelRelationshipByIdHandler(serverCtx),
-				},
-			}...,
-		),
-		rest.WithJwt(serverCtx.Config.Auth.AccessSecret),
-	)
-
-	server.AddRoutes(
-		rest.WithMiddlewares(
-			[]rest.Middleware{serverCtx.Authority},
-			[]rest.Route{
-				{
-					Method:  http.MethodPost,
 					Path:    "/message/create",
 					Handler: Message.CreateMessageHandler(serverCtx),
 				},

+ 1 - 1
internal/logic/WechatServer/update_server_logic.go

@@ -41,6 +41,6 @@ func (l *UpdateServerLogic) UpdateServer(req *types.ServerInfo) (*types.BaseMsgR
 		"private_ip": req.PrivateIp,
 		"admin_port": req.AdminPort,
 	}
-	l.svcCtx.Rds.HSet(l.ctx, "server_info", *req.Id, data)
+	l.svcCtx.Rds.HSet(l.ctx, "server_info", req.Id, data)
 	return &types.BaseMsgResp{Msg: errormsg.UpdateSuccess}, nil
 }

+ 10 - 6
internal/logic/Wx/check_wx_logic.go

@@ -104,12 +104,16 @@ func (l *CheckWxLogic) CheckWx(req *types.WxInfo) (resp *types.BaseMsgResp, err
 				Save(l.ctx)
 
 			data := map[string]interface{}{
-				"nickname":  selfInfo.Nickname,
-				"server_id": wxInfo.ServerID,
-				"port":      wxInfo.Port,
-				"api_base":  wxInfo.APIBase,
-				"api_key":   wxInfo.APIKey,
-				"agent_id":  wxInfo.AgentID,
+				"nickname":         selfInfo.Nickname,
+				"server_id":        wxInfo.ServerID,
+				"port":             wxInfo.Port,
+				"api_base":         wxInfo.APIBase,
+				"api_key":          wxInfo.APIKey,
+				"agent_id":         wxInfo.AgentID,
+				"allow_list":       wxInfo.AllowList,
+				"group_allow_list": wxInfo.GroupAllowList,
+				"block_list":       wxInfo.BlockList,
+				"group_block_list": wxInfo.GroupBlockList,
 			}
 			l.svcCtx.Rds.HSet(l.ctx, "wx_info", selfInfo.Wxid, data)
 		}

+ 125 - 0
internal/logic/Wx/get_wx_allow_block_list_logic.go

@@ -0,0 +1,125 @@
+package Wx
+
+import (
+	"context"
+	"wechat-api/ent"
+	"wechat-api/ent/contact"
+	"wechat-api/ent/wx"
+	"wechat-api/internal/utils/dberrorhandler"
+
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type GetWxAllowBlockListLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewGetWxAllowBlockListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWxAllowBlockListLogic {
+	return &GetWxAllowBlockListLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx}
+}
+
+func (l *GetWxAllowBlockListLogic) GetWxAllowBlockList(req *types.IDReq) (resp *types.AllowBlockListResp, err error) {
+	isAdmin := l.ctx.Value("isAdmin").(bool)
+	var data *ent.Wx
+	if isAdmin {
+		data, err = l.svcCtx.DB.Wx.Query().
+			Where(
+				wx.IDEQ(req.Id),
+			).
+			Only(l.ctx)
+	} else {
+		organizationId := l.ctx.Value("organizationId").(uint64)
+		data, err = l.svcCtx.DB.Wx.Query().
+			Where(
+				wx.IDEQ(req.Id),                   // Filter by ID
+				wx.OrganizationID(organizationId), // Additional filter by organizationId
+			).
+			Only(l.ctx)
+	}
+	if err != nil {
+		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
+	}
+	wxid := data.Wxid
+	resp = &types.AllowBlockListResp{}
+	resp.Data = types.AllowBlockListRespData{}
+
+	if data.AllowList != nil {
+		allowList, err := l.svcCtx.DB.Contact.Query().Where(contact.WxWxidEQ(wxid), contact.WxidIn(data.AllowList...)).All(l.ctx)
+		if err != nil {
+			return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
+		}
+		// 将 allowList 转换为[]*ContactInfo
+		allowListData := make([]*types.AllowBlockData, 0)
+		for _, av := range allowList {
+			allowListData = append(allowListData,
+				&types.AllowBlockData{
+					Wxid:     &av.Wxid,
+					Nickname: &av.Nickname,
+				})
+		}
+		resp.Data.AllowList = allowListData
+	}
+
+	if data.GroupAllowList != nil {
+		groupAllowList, err := l.svcCtx.DB.Contact.Query().Where(contact.WxWxidEQ(wxid), contact.WxidIn(data.GroupAllowList...)).All(l.ctx)
+
+		if err != nil {
+			return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
+		}
+		// 将 allowList 转换为[]*ContactInfo
+		groupAllowListData := make([]*types.AllowBlockData, 0)
+		for _, av := range groupAllowList {
+			groupAllowListData = append(groupAllowListData,
+				&types.AllowBlockData{
+					Wxid:     &av.Wxid,
+					Nickname: &av.Nickname,
+				})
+		}
+		resp.Data.GroupAllowList = groupAllowListData
+	}
+
+	if data.BlockList != nil {
+		blockList, err := l.svcCtx.DB.Contact.Query().Where(contact.WxWxidEQ(wxid), contact.WxidIn(data.BlockList...)).All(l.ctx)
+
+		if err != nil {
+			return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
+		}
+		// 将 allowList 转换为[]*ContactInfo
+		blockListData := make([]*types.AllowBlockData, 0)
+		for _, av := range blockList {
+			blockListData = append(blockListData,
+				&types.AllowBlockData{
+					Wxid:     &av.Wxid,
+					Nickname: &av.Nickname,
+				})
+		}
+		resp.Data.BlockList = blockListData
+	}
+
+	if data.GroupBlockList != nil {
+		groupBlockList, err := l.svcCtx.DB.Contact.Query().Where(contact.WxWxidEQ(wxid), contact.WxidIn(data.GroupBlockList...)).All(l.ctx)
+
+		if err != nil {
+			return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
+		}
+		groupBlockListData := make([]*types.AllowBlockData, 0)
+		for _, av := range groupBlockList {
+			groupBlockListData = append(groupBlockListData,
+				&types.AllowBlockData{
+					Wxid:     &av.Wxid,
+					Nickname: &av.Nickname,
+				})
+		}
+		resp.Data.GroupBlockList = groupBlockListData
+	}
+
+	return resp, nil
+}

+ 53 - 0
internal/logic/Wx/update_block_and_allow_list_logic.go

@@ -0,0 +1,53 @@
+package Wx
+
+import (
+	"context"
+	"fmt"
+	"github.com/suyuan32/simple-admin-common/msg/errormsg"
+	"wechat-api/ent/wx"
+	"wechat-api/internal/utils/dberrorhandler"
+
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type UpdateBlockAndAllowListLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewUpdateBlockAndAllowListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateBlockAndAllowListLogic {
+	return &UpdateBlockAndAllowListLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx}
+}
+
+func (l *UpdateBlockAndAllowListLogic) UpdateBlockAndAllowList(req *types.UpdateBlockAndAllowListReq) (resp *types.BaseMsgResp, err error) {
+	err = l.svcCtx.DB.Wx.UpdateOneID(*req.Id).
+		SetNotNilAllowList(req.AllowList).
+		SetNotNilGroupAllowList(req.GroupAllowList).
+		SetNotNilBlockList(req.BlockList).
+		SetNotNilGroupBlockList(req.GroupBlockList).
+		Exec(l.ctx)
+
+	if err != nil {
+		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
+	}
+
+	wxinfo, err := l.svcCtx.DB.Wx.Query().
+		Where(
+			wx.IDEQ(*req.Id),
+		).
+		WithAgent().
+		Only(l.ctx)
+	if err != nil {
+		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
+	}
+	fmt.Printf("------------------------wxinfo.Wxid------------------------: %+v\n", wxinfo.Wxid)
+	l.svcCtx.Rds.HDel(l.ctx, "wx_info", wxinfo.Wxid)
+	return &types.BaseMsgResp{Msg: errormsg.UpdateSuccess}, nil
+}

+ 161 - 112
internal/types/types.go

@@ -325,6 +325,27 @@ type WxInfo struct {
 	ApiBase *string `json:"apiBase,optional"`
 	// 大模型服务密钥
 	ApiKey *string `json:"apiKey,optional"`
+	// 白名单
+	AllowList []ContactInfo `json:"allowList,optional"`
+	// 群白名单
+	GroupAllowList []ContactInfo `json:"groupAllowList,optional"`
+	// 黑名单
+	BlockList []ContactInfo `json:"blockList,optional"`
+	// 群黑名单
+	GroupBlockList []ContactInfo `json:"groupBlockList,optional"`
+}
+
+// swagger:model UpdateBlockAndAllowListReq
+type UpdateBlockAndAllowListReq struct {
+	BaseIDInfo
+	// 白名单
+	AllowList []string `json:"allowList,optional"`
+	// 群白名单
+	GroupAllowList []string `json:"groupAllowList,optional"`
+	// 黑名单
+	BlockList []string `json:"blockList,optional"`
+	// 群黑名单
+	GroupBlockList []string `json:"groupBlockList,optional"`
 }
 
 // The response data of wx list | Wx列表数据
@@ -369,6 +390,34 @@ type WxInfoResp struct {
 	Data WxInfo `json:"data"`
 }
 
+// 获取黑白名单列表返回体
+// swagger:model AllowBlockListResp
+type AllowBlockListResp struct {
+	BaseDataInfo
+	// Wx information | Wx数据
+	Data AllowBlockListRespData `json:"data"`
+}
+
+// AllowBlockListRespData
+type AllowBlockListRespData struct {
+	// 白名单
+	AllowList []*AllowBlockData `json:"allowList,optional"`
+	// 群白名单
+	GroupAllowList []*AllowBlockData `json:"groupAllowList,optional"`
+	// 黑名单
+	BlockList []*AllowBlockData `json:"blockList,optional"`
+	// 群黑名单
+	GroupBlockList []*AllowBlockData `json:"groupBlockList,optional"`
+}
+
+// AllowBlockData
+type AllowBlockData struct {
+	// 微信id 公众号微信ID
+	Wxid *string `json:"wxid,optional"`
+	// 微信昵称 群备注名称
+	Nickname *string `json:"nickname,optional"`
+}
+
 // The data of agent information | Agent信息
 // swagger:model AgentInfo
 type AgentInfo struct {
@@ -653,118 +702,6 @@ type DeleteDataReq struct {
 	ID *string `json:"id" validate:"required"`
 }
 
-type LoginQRStatus struct {
-	// 登陆二维码
-	QRCode string `json:"qRCode,optional"`
-	// 登陆二维码状态
-	Status string `json:"status,optional"`
-	// 登陆二维码状态描述
-	StatusDesc string `json:"statusDesc,optional"`
-}
-
-// 刷新登陆二维码请求参数
-// swagger:model RefreshLoginQRReq
-type RefreshLoginQRReq struct {
-	// 服务器id
-	ServerId *uint64 `json:"serverId,optional"`
-	// 端口号
-	Port *string `json:"port,optional"`
-	// 回调地址
-	Callback *string `json:"callback,optional"`
-}
-
-// 刷新登陆二维码返回参数
-// swagger:model RefreshLoginQRResp
-type RefreshLoginQRResp struct {
-	BaseDataInfo
-	// 二维码Base64
-	Data LoginQRStatus `json:"data,optional"`
-}
-
-// 发送微信文本消息请求参数
-// swagger:model SendTextMsgReq
-type SendTextMsgReq struct {
-	// 属主微信id
-	WxWxid *string `json:"senderWxId"`
-	// 微信id 公众号微信ID
-	Wxid *string `json:"receiverWxId"`
-	// 微信文本消息内容
-	Msg *string `json:"msg"`
-}
-
-// 发送微信图片消息请求参数
-// swagger:model SendPicMsgReq
-type SendPicMsgReq struct {
-	// 属主微信id
-	WxWxid *string `json:"wxWxid"`
-	// 微信id 公众号微信ID
-	Wxid *string `json:"wxid"`
-	// 微信图片路径(本地或网络,本地需要上传操作,如:C:\\x.jpg)
-	Picpath *string `json:"picpath"`
-	// 微信图片自定义名称(此属性只有网络图片有)
-	Diyfilename *string `json:"diyfilename,optional"`
-}
-
-// 发送微信图片(本地)请求参数
-// swagger:model SendPicMsgLocalReq
-type SendPicMsgLocalReq struct {
-	// 属主微信id
-	WxWxid *string `json:"wxWxid"`
-	// 微信id 公众号微信ID
-	Wxid *string `json:"wxid"`
-	// 微信图片路径(本地或网络,本地需要上传操作,如:C:\\x.jpg)
-	Picpath *string `json:"picpath"`
-}
-
-// The response data of contact list | Contact列表数据
-// swagger:model ContactListResp
-type ContactListResp struct {
-	BaseDataInfo
-	// Contact list data | Contact列表数据
-	Data ContactListInfo `json:"data"`
-}
-
-// Contact list data | Contact列表数据
-// swagger:model ContactListInfo
-type ContactListInfo struct {
-	BaseListInfo
-	// The API list data | Contact列表数据
-	Data []ContactInfo `json:"data"`
-}
-
-// Get contact list request params | Contact列表请求参数
-// swagger:model ContactListReq
-type ContactListReq struct {
-	PageInfo
-	// Label ID list | 标签ID列表
-	LabelIDs []uint64 `json:"labelIDs,optional"`
-	// 属主微信id
-	WxWxid *string `json:"wxWxid,optional"`
-	// 微信id 公众号微信ID
-	Wxid *string `json:"wxid,optional"`
-	// 微信账号
-	Account *string `json:"account,optional"`
-	// 联系人类型:1好友,2群组,3公众号,4企业微信联系人
-	Type *int `json:"type,optional"`
-}
-
-// Contact information response | Contact信息返回体
-// swagger:model ContactInfoResp
-type ContactInfoResp struct {
-	BaseDataInfo
-	// Contact information | Contact数据
-	Data ContactInfo `json:"data"`
-}
-
-// swagger:model AddNewFriendReq
-type AddNewFriendReq struct {
-	OwnerWxid string `json:"ownerWxid"`
-	Wxid      string `json:"wxid"`
-	Gid       string `json:"gid"`
-	Desc      string `json:"desc"`
-	AddType   string `json:"addType"`
-}
-
 // ContactLabelList | Contact标签列表
 type ContactLabelList struct {
 	// label
@@ -907,6 +844,118 @@ type LabelRelationshipInfoResp struct {
 	Data LabelRelationshipInfo `json:"data"`
 }
 
+type LoginQRStatus struct {
+	// 登陆二维码
+	QRCode string `json:"qRCode,optional"`
+	// 登陆二维码状态
+	Status string `json:"status,optional"`
+	// 登陆二维码状态描述
+	StatusDesc string `json:"statusDesc,optional"`
+}
+
+// 刷新登陆二维码请求参数
+// swagger:model RefreshLoginQRReq
+type RefreshLoginQRReq struct {
+	// 服务器id
+	ServerId *uint64 `json:"serverId,optional"`
+	// 端口号
+	Port *string `json:"port,optional"`
+	// 回调地址
+	Callback *string `json:"callback,optional"`
+}
+
+// 刷新登陆二维码返回参数
+// swagger:model RefreshLoginQRResp
+type RefreshLoginQRResp struct {
+	BaseDataInfo
+	// 二维码Base64
+	Data LoginQRStatus `json:"data,optional"`
+}
+
+// 发送微信文本消息请求参数
+// swagger:model SendTextMsgReq
+type SendTextMsgReq struct {
+	// 属主微信id
+	WxWxid *string `json:"senderWxId"`
+	// 微信id 公众号微信ID
+	Wxid *string `json:"receiverWxId"`
+	// 微信文本消息内容
+	Msg *string `json:"msg"`
+}
+
+// 发送微信图片消息请求参数
+// swagger:model SendPicMsgReq
+type SendPicMsgReq struct {
+	// 属主微信id
+	WxWxid *string `json:"wxWxid"`
+	// 微信id 公众号微信ID
+	Wxid *string `json:"wxid"`
+	// 微信图片路径(本地或网络,本地需要上传操作,如:C:\\x.jpg)
+	Picpath *string `json:"picpath"`
+	// 微信图片自定义名称(此属性只有网络图片有)
+	Diyfilename *string `json:"diyfilename,optional"`
+}
+
+// 发送微信图片(本地)请求参数
+// swagger:model SendPicMsgLocalReq
+type SendPicMsgLocalReq struct {
+	// 属主微信id
+	WxWxid *string `json:"wxWxid"`
+	// 微信id 公众号微信ID
+	Wxid *string `json:"wxid"`
+	// 微信图片路径(本地或网络,本地需要上传操作,如:C:\\x.jpg)
+	Picpath *string `json:"picpath"`
+}
+
+// The response data of contact list | Contact列表数据
+// swagger:model ContactListResp
+type ContactListResp struct {
+	BaseDataInfo
+	// Contact list data | Contact列表数据
+	Data ContactListInfo `json:"data"`
+}
+
+// Contact list data | Contact列表数据
+// swagger:model ContactListInfo
+type ContactListInfo struct {
+	BaseListInfo
+	// The API list data | Contact列表数据
+	Data []ContactInfo `json:"data"`
+}
+
+// Get contact list request params | Contact列表请求参数
+// swagger:model ContactListReq
+type ContactListReq struct {
+	PageInfo
+	// Label ID list | 标签ID列表
+	LabelIDs []uint64 `json:"labelIDs,optional"`
+	// 属主微信id
+	WxWxid *string `json:"wxWxid,optional"`
+	// 微信id 公众号微信ID
+	Wxid *string `json:"wxid,optional"`
+	// 微信账号
+	Account *string `json:"account,optional"`
+	// 联系人类型:1好友,2群组,3公众号,4企业微信联系人
+	Type *int `json:"type,optional"`
+}
+
+// Contact information response | Contact信息返回体
+// swagger:model ContactInfoResp
+type ContactInfoResp struct {
+	BaseDataInfo
+	// Contact information | Contact数据
+	Data ContactInfo `json:"data"`
+}
+
+// swagger:model AddNewFriendReq
+type AddNewFriendReq struct {
+	OwnerWxid string `json:"ownerWxid"`
+	Wxid      string `json:"wxid"`
+	Gid       string `json:"gid"`
+	Desc      string `json:"desc"`
+	AddType   string `json:"addType"`
+}
+
 // The response data of message information | Message信息
 // swagger:model MessageInfo
 type MessageInfo struct {