3 커밋 80acd48ad3 ... 9fd38c8fba

작성자 SHA1 메시지 날짜
  jimmyyem 9fd38c8fba Merge branch 'master' into yhg_250224 1 일 전
  jimmyyem 2d007df205 fix:修改stop stop 1 일 전
  jimmyyem 68e6ebe8a1 fix:调试 1 일 전

+ 5 - 5
crontask/send_msg.go

@@ -21,7 +21,7 @@ func (l *CronTask) sendMsg() {
 	batchList, err := l.svcCtx.DB.BatchMsg.Query().Where(
 		batchmsg.StartTimeLT(time.Now()),
 		batchmsg.StatusIn(0, 1),
-		batchmsg.Ctype(1),
+		batchmsg.CtypeIn(1, 3),
 	).All(l.ctx)
 	if err != nil {
 		l.Logger.Errorf("batchList err: %v", err)
@@ -61,7 +61,7 @@ func (l *CronTask) sendMsg() {
 				userList, err = l.svcCtx.DB.Contact.Query().Where(
 					contact.WxWxid(batch.Fromwxid),
 					contact.TypeIn(1, 2),
-					contact.Ctype(1),
+					contact.CtypeIn(1, 3),
 				).All(l.ctx)
 				if err != nil {
 					l.Logger.Errorf("userlist err: %v", err)
@@ -73,7 +73,7 @@ func (l *CronTask) sendMsg() {
 					userList, err = l.svcCtx.DB.Contact.Query().Where(
 						contact.WxWxid(batch.Fromwxid),
 						contact.TypeEQ(1),
-						contact.Ctype(1),
+						contact.CtypeIn(1, 3),
 					).All(l.ctx)
 					if err != nil {
 						l.Logger.Errorf("userList err: %v", err)
@@ -92,7 +92,7 @@ func (l *CronTask) sendMsg() {
 					groupList, err = l.svcCtx.DB.Contact.Query().Where(
 						contact.WxWxid(batch.Fromwxid),
 						contact.TypeEQ(2),
-						contact.Ctype(1),
+						contact.CtypeIn(1, 3),
 					).All(l.ctx)
 					if err != nil {
 						l.Logger.Errorf("groupList err: %v", err)
@@ -310,7 +310,7 @@ func (l *CronTask) getContactList(labels []uint64, fromWxId string, stype int) (
 			contact.WxWxid(fromWxId),
 			contact.IDIn(contact_ids...),
 			contact.TypeEQ(stype),
-			contact.Ctype(1),
+			contact.CtypeIn(1, 3),
 		).All(l.ctx)
 		if err != nil {
 			return nil, dberrorhandler.DefaultEntError(l.Logger, err, nil)

+ 1 - 1
crontask/send_wx.go

@@ -104,7 +104,7 @@ func (l *CronTask) sendWx() {
 		contactInfo, _ := l.svcCtx.DB.Contact.Query().Where(
 			contact.WxWxidEQ(botwxid),
 			contact.WxidEQ(wxid),
-			contact.Ctype(1),
+			contact.CtypeIn(1, 3),
 		).First(l.ctx)
 
 		return contactInfo, nil

+ 1 - 1
crontask/send_wx_on_timeout.go

@@ -144,7 +144,7 @@ func (l *CronTask) sendWxOnTimeout() {
 								contactInfo, _ := l.svcCtx.DB.Contact.Query().Where(
 									contact.WxWxidEQ(s.BotWxid),
 									contact.WxidEQ(s.ContactWxid),
-									contact.Ctype(1),
+									contact.CtypeIn(1, 3),
 								).First(l.ctx)
 								content := varReplace(message.Content, contactInfo)
 								_, _ = l.svcCtx.DB.MessageRecords.Create().

+ 3 - 0
desc/wechat/contact.api

@@ -39,6 +39,9 @@ type (
 
         // 联系人类型:1好友,2群组,3公众号,4企业微信联系人
         Type  *int `json:"type,optional"`
+
+		// 内容类型:1-个微 2-企微
+		Ctype *uint64 `json:"ctype,optional"`
     }
 
     // Contact information response | Contact信息返回体

+ 3 - 0
desc/wechat/workphone.api

@@ -16,4 +16,7 @@ info(
 service Wechat {
     @handler wxRefresh // TODO: replace handler name and delete this comment
     post /workphone/wxaccount/refresh returns(BaseMsgResp)
+
+	@handler QxRefresh // TODO: replace handler name and delete this comment
+	post /workphone/Qxaccount/refresh returns(BaseMsgResp)
 }

+ 10 - 0
desc/wechat/wx.api

@@ -72,6 +72,8 @@ type (
 
         // 使用token总数
         TotalTokens *uint64 `json:"totalTokens,optional"`
+
+		Ctype *uint64 `json:"ctype,optional"`
     }
 
     UpdateBlockAndAllowListReq {
@@ -127,12 +129,18 @@ type (
 
         // 回调地址 
         Callback  *string `json:"callback,optional"`
+
+		// 账号类型 1-个微 2-企微
+		Ctype *uint64 `json:"ctype,optional"`
     }
 
     // Get wx list request params | Wx列表请求参数
     WxSelectListReq {
         // 租户id
         OrganizationId  *uint64 `json:"organizationId,optional"`
+
+		// 账号类型 1-个微 2-企微
+		Ctype *uint64 `json:"ctype,optional"`
     }
 
     // The response data of wx list | Wx列表数据
@@ -151,6 +159,8 @@ type (
 
         // 微信昵称
         Nickname  *string `json:"nickname,optional"`
+
+		Ctype *uint64 `json:"ctype,optional"`
     }
 
     // Wx information response | Wx信息返回体

+ 5 - 4
ent/migrate/schema.go

@@ -1220,6 +1220,7 @@ var (
 		{Name: "group_allow_list", Type: field.TypeJSON, Comment: "群白名单"},
 		{Name: "block_list", Type: field.TypeJSON, Comment: "黑名单"},
 		{Name: "group_block_list", Type: field.TypeJSON, Comment: "群黑名单"},
+		{Name: "ctype", Type: field.TypeUint64, Nullable: true, Comment: "账号类型:1-个微 2-企微", Default: 1},
 		{Name: "agent_id", Type: field.TypeUint64, Comment: "模式ID", Default: 0},
 		{Name: "agent_base_wx_agent", Type: field.TypeString, Nullable: true},
 		{Name: "server_id", Type: field.TypeUint64, Nullable: true, Comment: "服务器id", Default: 0},
@@ -1232,19 +1233,19 @@ var (
 		ForeignKeys: []*schema.ForeignKey{
 			{
 				Symbol:     "wx_agent_wx_agent",
-				Columns:    []*schema.Column{WxColumns[20]},
+				Columns:    []*schema.Column{WxColumns[21]},
 				RefColumns: []*schema.Column{AgentColumns[0]},
 				OnDelete:   schema.NoAction,
 			},
 			{
 				Symbol:     "wx_agent_base_wx_agent",
-				Columns:    []*schema.Column{WxColumns[21]},
+				Columns:    []*schema.Column{WxColumns[22]},
 				RefColumns: []*schema.Column{AgentBaseColumns[0]},
 				OnDelete:   schema.SetNull,
 			},
 			{
 				Symbol:     "wx_server_wxs",
-				Columns:    []*schema.Column{WxColumns[22]},
+				Columns:    []*schema.Column{WxColumns[23]},
 				RefColumns: []*schema.Column{ServerColumns[0]},
 				OnDelete:   schema.SetNull,
 			},
@@ -1253,7 +1254,7 @@ var (
 			{
 				Name:    "wx_server_id_port",
 				Unique:  true,
-				Columns: []*schema.Column{WxColumns[22], WxColumns[5]},
+				Columns: []*schema.Column{WxColumns[23], WxColumns[5]},
 			},
 			{
 				Name:    "wx_wxid",

+ 108 - 1
ent/mutation.go

@@ -43662,6 +43662,8 @@ type WxMutation struct {
 	appendblock_list       []string
 	group_block_list       *[]string
 	appendgroup_block_list []string
+	ctype                  *uint64
+	addctype               *int64
 	clearedFields          map[string]struct{}
 	server                 *uint64
 	clearedserver          bool
@@ -44712,6 +44714,76 @@ func (m *WxMutation) ResetGroupBlockList() {
 	m.appendgroup_block_list = nil
 }
 
+// SetCtype sets the "ctype" field.
+func (m *WxMutation) SetCtype(u uint64) {
+	m.ctype = &u
+	m.addctype = nil
+}
+
+// Ctype returns the value of the "ctype" field in the mutation.
+func (m *WxMutation) Ctype() (r uint64, exists bool) {
+	v := m.ctype
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// OldCtype returns the old "ctype" 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) OldCtype(ctx context.Context) (v uint64, err error) {
+	if !m.op.Is(OpUpdateOne) {
+		return v, errors.New("OldCtype is only allowed on UpdateOne operations")
+	}
+	if m.id == nil || m.oldValue == nil {
+		return v, errors.New("OldCtype requires an ID field in the mutation")
+	}
+	oldValue, err := m.oldValue(ctx)
+	if err != nil {
+		return v, fmt.Errorf("querying old value for OldCtype: %w", err)
+	}
+	return oldValue.Ctype, nil
+}
+
+// AddCtype adds u to the "ctype" field.
+func (m *WxMutation) AddCtype(u int64) {
+	if m.addctype != nil {
+		*m.addctype += u
+	} else {
+		m.addctype = &u
+	}
+}
+
+// AddedCtype returns the value that was added to the "ctype" field in this mutation.
+func (m *WxMutation) AddedCtype() (r int64, exists bool) {
+	v := m.addctype
+	if v == nil {
+		return
+	}
+	return *v, true
+}
+
+// ClearCtype clears the value of the "ctype" field.
+func (m *WxMutation) ClearCtype() {
+	m.ctype = nil
+	m.addctype = nil
+	m.clearedFields[wx.FieldCtype] = struct{}{}
+}
+
+// CtypeCleared returns if the "ctype" field was cleared in this mutation.
+func (m *WxMutation) CtypeCleared() bool {
+	_, ok := m.clearedFields[wx.FieldCtype]
+	return ok
+}
+
+// ResetCtype resets all changes to the "ctype" field.
+func (m *WxMutation) ResetCtype() {
+	m.ctype = nil
+	m.addctype = nil
+	delete(m.clearedFields, wx.FieldCtype)
+}
+
 // ClearServer clears the "server" edge to the Server entity.
 func (m *WxMutation) ClearServer() {
 	m.clearedserver = true
@@ -44800,7 +44872,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, 21)
+	fields := make([]string, 0, 22)
 	if m.created_at != nil {
 		fields = append(fields, wx.FieldCreatedAt)
 	}
@@ -44864,6 +44936,9 @@ func (m *WxMutation) Fields() []string {
 	if m.group_block_list != nil {
 		fields = append(fields, wx.FieldGroupBlockList)
 	}
+	if m.ctype != nil {
+		fields = append(fields, wx.FieldCtype)
+	}
 	return fields
 }
 
@@ -44914,6 +44989,8 @@ func (m *WxMutation) Field(name string) (ent.Value, bool) {
 		return m.BlockList()
 	case wx.FieldGroupBlockList:
 		return m.GroupBlockList()
+	case wx.FieldCtype:
+		return m.Ctype()
 	}
 	return nil, false
 }
@@ -44965,6 +45042,8 @@ func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, erro
 		return m.OldBlockList(ctx)
 	case wx.FieldGroupBlockList:
 		return m.OldGroupBlockList(ctx)
+	case wx.FieldCtype:
+		return m.OldCtype(ctx)
 	}
 	return nil, fmt.Errorf("unknown Wx field %s", name)
 }
@@ -45121,6 +45200,13 @@ func (m *WxMutation) SetField(name string, value ent.Value) error {
 		}
 		m.SetGroupBlockList(v)
 		return nil
+	case wx.FieldCtype:
+		v, ok := value.(uint64)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.SetCtype(v)
+		return nil
 	}
 	return fmt.Errorf("unknown Wx field %s", name)
 }
@@ -45135,6 +45221,9 @@ func (m *WxMutation) AddedFields() []string {
 	if m.addorganization_id != nil {
 		fields = append(fields, wx.FieldOrganizationID)
 	}
+	if m.addctype != nil {
+		fields = append(fields, wx.FieldCtype)
+	}
 	return fields
 }
 
@@ -45147,6 +45236,8 @@ func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
 		return m.AddedStatus()
 	case wx.FieldOrganizationID:
 		return m.AddedOrganizationID()
+	case wx.FieldCtype:
+		return m.AddedCtype()
 	}
 	return nil, false
 }
@@ -45170,6 +45261,13 @@ func (m *WxMutation) AddField(name string, value ent.Value) error {
 		}
 		m.AddOrganizationID(v)
 		return nil
+	case wx.FieldCtype:
+		v, ok := value.(int64)
+		if !ok {
+			return fmt.Errorf("unexpected type %T for field %s", value, name)
+		}
+		m.AddCtype(v)
+		return nil
 	}
 	return fmt.Errorf("unknown Wx numeric field %s", name)
 }
@@ -45196,6 +45294,9 @@ func (m *WxMutation) ClearedFields() []string {
 	if m.FieldCleared(wx.FieldAPIKey) {
 		fields = append(fields, wx.FieldAPIKey)
 	}
+	if m.FieldCleared(wx.FieldCtype) {
+		fields = append(fields, wx.FieldCtype)
+	}
 	return fields
 }
 
@@ -45228,6 +45329,9 @@ func (m *WxMutation) ClearField(name string) error {
 	case wx.FieldAPIKey:
 		m.ClearAPIKey()
 		return nil
+	case wx.FieldCtype:
+		m.ClearCtype()
+		return nil
 	}
 	return fmt.Errorf("unknown Wx nullable field %s", name)
 }
@@ -45299,6 +45403,9 @@ func (m *WxMutation) ResetField(name string) error {
 	case wx.FieldGroupBlockList:
 		m.ResetGroupBlockList()
 		return nil
+	case wx.FieldCtype:
+		m.ResetCtype()
+		return nil
 	}
 	return fmt.Errorf("unknown Wx field %s", name)
 }

+ 4 - 0
ent/runtime/runtime.go

@@ -1632,6 +1632,10 @@ func init() {
 	wxDescAPIKey := wxFields[12].Descriptor()
 	// wx.DefaultAPIKey holds the default value on creation for the api_key field.
 	wx.DefaultAPIKey = wxDescAPIKey.Default.(string)
+	// wxDescCtype is the schema descriptor for ctype field.
+	wxDescCtype := wxFields[17].Descriptor()
+	// wx.DefaultCtype holds the default value on creation for the ctype field.
+	wx.DefaultCtype = wxDescCtype.Default.(uint64)
 	wxcardMixin := schema.WxCard{}.Mixin()
 	wxcardMixinHooks1 := wxcardMixin[1].Hooks()
 	wxcard.Hooks[0] = wxcardMixinHooks1[0]

+ 3 - 0
ent/schema/wx.go

@@ -70,6 +70,9 @@ func (Wx) Fields() []ent.Field {
 		field.JSON("group_block_list", []string{}).
 			Annotations(entsql.WithComments(true)).
 			Comment("群黑名单"),
+		field.Uint64("ctype").Default(1).Optional().
+			Annotations(entsql.WithComments(true)).
+			Comment("账号类型:1-个微 2-企微"),
 	}
 }
 

+ 24 - 0
ent/set_not_nil.go

@@ -9944,6 +9944,30 @@ func (w *WxCreate) SetNotNilGroupBlockList(value []string) *WxCreate {
 }
 
 // set field if value's pointer is not nil.
+func (w *WxUpdate) SetNotNilCtype(value *uint64) *WxUpdate {
+	if value != nil {
+		return w.SetCtype(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WxUpdateOne) SetNotNilCtype(value *uint64) *WxUpdateOne {
+	if value != nil {
+		return w.SetCtype(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
+func (w *WxCreate) SetNotNilCtype(value *uint64) *WxCreate {
+	if value != nil {
+		return w.SetCtype(*value)
+	}
+	return w
+}
+
+// set field if value's pointer is not nil.
 func (wc *WxCardUpdate) SetNotNilUpdatedAt(value *time.Time) *WxCardUpdate {
 	if value != nil {
 		return wc.SetUpdatedAt(*value)

+ 12 - 1
ent/wx.go

@@ -62,6 +62,8 @@ type Wx struct {
 	BlockList []string `json:"block_list,omitempty"`
 	// 群黑名单
 	GroupBlockList []string `json:"group_block_list,omitempty"`
+	// 账号类型:1-个微 2-企微
+	Ctype uint64 `json:"ctype,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"`
@@ -109,7 +111,7 @@ func (*Wx) scanValues(columns []string) ([]any, error) {
 		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:
+		case wx.FieldID, wx.FieldStatus, wx.FieldServerID, wx.FieldOrganizationID, wx.FieldAgentID, wx.FieldCtype:
 			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:
 			values[i] = new(sql.NullString)
@@ -272,6 +274,12 @@ func (w *Wx) assignValues(columns []string, values []any) error {
 					return fmt.Errorf("unmarshal field group_block_list: %w", err)
 				}
 			}
+		case wx.FieldCtype:
+			if value, ok := values[i].(*sql.NullInt64); !ok {
+				return fmt.Errorf("unexpected type %T for field ctype", values[i])
+			} else if value.Valid {
+				w.Ctype = uint64(value.Int64)
+			}
 		case wx.ForeignKeys[0]:
 			if value, ok := values[i].(*sql.NullString); !ok {
 				return fmt.Errorf("unexpected type %T for field agent_base_wx_agent", values[i])
@@ -387,6 +395,9 @@ func (w *Wx) String() string {
 	builder.WriteString(", ")
 	builder.WriteString("group_block_list=")
 	builder.WriteString(fmt.Sprintf("%v", w.GroupBlockList))
+	builder.WriteString(", ")
+	builder.WriteString("ctype=")
+	builder.WriteString(fmt.Sprintf("%v", w.Ctype))
 	builder.WriteByte(')')
 	return builder.String()
 }

+ 55 - 0
ent/wx/where.go

@@ -140,6 +140,11 @@ func APIKey(v string) predicate.Wx {
 	return predicate.Wx(sql.FieldEQ(FieldAPIKey, v))
 }
 
+// Ctype applies equality check predicate on the "ctype" field. It's identical to CtypeEQ.
+func Ctype(v uint64) predicate.Wx {
+	return predicate.Wx(sql.FieldEQ(FieldCtype, v))
+}
+
 // CreatedAtEQ applies the EQ predicate on the "created_at" field.
 func CreatedAtEQ(v time.Time) predicate.Wx {
 	return predicate.Wx(sql.FieldEQ(FieldCreatedAt, v))
@@ -1090,6 +1095,56 @@ func APIKeyContainsFold(v string) predicate.Wx {
 	return predicate.Wx(sql.FieldContainsFold(FieldAPIKey, v))
 }
 
+// CtypeEQ applies the EQ predicate on the "ctype" field.
+func CtypeEQ(v uint64) predicate.Wx {
+	return predicate.Wx(sql.FieldEQ(FieldCtype, v))
+}
+
+// CtypeNEQ applies the NEQ predicate on the "ctype" field.
+func CtypeNEQ(v uint64) predicate.Wx {
+	return predicate.Wx(sql.FieldNEQ(FieldCtype, v))
+}
+
+// CtypeIn applies the In predicate on the "ctype" field.
+func CtypeIn(vs ...uint64) predicate.Wx {
+	return predicate.Wx(sql.FieldIn(FieldCtype, vs...))
+}
+
+// CtypeNotIn applies the NotIn predicate on the "ctype" field.
+func CtypeNotIn(vs ...uint64) predicate.Wx {
+	return predicate.Wx(sql.FieldNotIn(FieldCtype, vs...))
+}
+
+// CtypeGT applies the GT predicate on the "ctype" field.
+func CtypeGT(v uint64) predicate.Wx {
+	return predicate.Wx(sql.FieldGT(FieldCtype, v))
+}
+
+// CtypeGTE applies the GTE predicate on the "ctype" field.
+func CtypeGTE(v uint64) predicate.Wx {
+	return predicate.Wx(sql.FieldGTE(FieldCtype, v))
+}
+
+// CtypeLT applies the LT predicate on the "ctype" field.
+func CtypeLT(v uint64) predicate.Wx {
+	return predicate.Wx(sql.FieldLT(FieldCtype, v))
+}
+
+// CtypeLTE applies the LTE predicate on the "ctype" field.
+func CtypeLTE(v uint64) predicate.Wx {
+	return predicate.Wx(sql.FieldLTE(FieldCtype, v))
+}
+
+// CtypeIsNil applies the IsNil predicate on the "ctype" field.
+func CtypeIsNil() predicate.Wx {
+	return predicate.Wx(sql.FieldIsNull(FieldCtype))
+}
+
+// CtypeNotNil applies the NotNil predicate on the "ctype" field.
+func CtypeNotNil() predicate.Wx {
+	return predicate.Wx(sql.FieldNotNull(FieldCtype))
+}
+
 // HasServer applies the HasEdge predicate on the "server" edge.
 func HasServer() predicate.Wx {
 	return predicate.Wx(func(s *sql.Selector) {

+ 10 - 0
ent/wx/wx.go

@@ -57,6 +57,8 @@ const (
 	FieldBlockList = "block_list"
 	// FieldGroupBlockList holds the string denoting the group_block_list field in the database.
 	FieldGroupBlockList = "group_block_list"
+	// FieldCtype holds the string denoting the ctype field in the database.
+	FieldCtype = "ctype"
 	// EdgeServer holds the string denoting the server edge name in mutations.
 	EdgeServer = "server"
 	// EdgeAgent holds the string denoting the agent edge name in mutations.
@@ -103,6 +105,7 @@ var Columns = []string{
 	FieldGroupAllowList,
 	FieldBlockList,
 	FieldGroupBlockList,
+	FieldCtype,
 }
 
 // ForeignKeys holds the SQL foreign-keys that are owned by the "wx"
@@ -168,6 +171,8 @@ var (
 	DefaultAPIBase string
 	// DefaultAPIKey holds the default value on creation for the "api_key" field.
 	DefaultAPIKey string
+	// DefaultCtype holds the default value on creation for the "ctype" field.
+	DefaultCtype uint64
 )
 
 // OrderOption defines the ordering options for the Wx queries.
@@ -263,6 +268,11 @@ func ByAPIKey(opts ...sql.OrderTermOption) OrderOption {
 	return sql.OrderByField(FieldAPIKey, opts...).ToFunc()
 }
 
+// ByCtype orders the results by the ctype field.
+func ByCtype(opts ...sql.OrderTermOption) OrderOption {
+	return sql.OrderByField(FieldCtype, opts...).ToFunc()
+}
+
 // ByServerField orders the results by server field.
 func ByServerField(field string, opts ...sql.OrderTermOption) OrderOption {
 	return func(s *sql.Selector) {

+ 102 - 0
ent/wx_create.go

@@ -286,6 +286,20 @@ func (wc *WxCreate) SetGroupBlockList(s []string) *WxCreate {
 	return wc
 }
 
+// SetCtype sets the "ctype" field.
+func (wc *WxCreate) SetCtype(u uint64) *WxCreate {
+	wc.mutation.SetCtype(u)
+	return wc
+}
+
+// SetNillableCtype sets the "ctype" field if the given value is not nil.
+func (wc *WxCreate) SetNillableCtype(u *uint64) *WxCreate {
+	if u != nil {
+		wc.SetCtype(*u)
+	}
+	return wc
+}
+
 // SetID sets the "id" field.
 func (wc *WxCreate) SetID(u uint64) *WxCreate {
 	wc.mutation.SetID(u)
@@ -409,6 +423,10 @@ func (wc *WxCreate) defaults() error {
 		v := wx.DefaultAPIKey
 		wc.mutation.SetAPIKey(v)
 	}
+	if _, ok := wc.mutation.Ctype(); !ok {
+		v := wx.DefaultCtype
+		wc.mutation.SetCtype(v)
+	}
 	return nil
 }
 
@@ -571,6 +589,10 @@ func (wc *WxCreate) createSpec() (*Wx, *sqlgraph.CreateSpec) {
 		_spec.SetField(wx.FieldGroupBlockList, field.TypeJSON, value)
 		_node.GroupBlockList = value
 	}
+	if value, ok := wc.mutation.Ctype(); ok {
+		_spec.SetField(wx.FieldCtype, field.TypeUint64, value)
+		_node.Ctype = value
+	}
 	if nodes := wc.mutation.ServerIDs(); len(nodes) > 0 {
 		edge := &sqlgraph.EdgeSpec{
 			Rel:     sqlgraph.M2O,
@@ -945,6 +967,30 @@ func (u *WxUpsert) UpdateGroupBlockList() *WxUpsert {
 	return u
 }
 
+// SetCtype sets the "ctype" field.
+func (u *WxUpsert) SetCtype(v uint64) *WxUpsert {
+	u.Set(wx.FieldCtype, v)
+	return u
+}
+
+// UpdateCtype sets the "ctype" field to the value that was provided on create.
+func (u *WxUpsert) UpdateCtype() *WxUpsert {
+	u.SetExcluded(wx.FieldCtype)
+	return u
+}
+
+// AddCtype adds v to the "ctype" field.
+func (u *WxUpsert) AddCtype(v uint64) *WxUpsert {
+	u.Add(wx.FieldCtype, v)
+	return u
+}
+
+// ClearCtype clears the value of the "ctype" field.
+func (u *WxUpsert) ClearCtype() *WxUpsert {
+	u.SetNull(wx.FieldCtype)
+	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:
 //
@@ -1332,6 +1378,34 @@ func (u *WxUpsertOne) UpdateGroupBlockList() *WxUpsertOne {
 	})
 }
 
+// SetCtype sets the "ctype" field.
+func (u *WxUpsertOne) SetCtype(v uint64) *WxUpsertOne {
+	return u.Update(func(s *WxUpsert) {
+		s.SetCtype(v)
+	})
+}
+
+// AddCtype adds v to the "ctype" field.
+func (u *WxUpsertOne) AddCtype(v uint64) *WxUpsertOne {
+	return u.Update(func(s *WxUpsert) {
+		s.AddCtype(v)
+	})
+}
+
+// UpdateCtype sets the "ctype" field to the value that was provided on create.
+func (u *WxUpsertOne) UpdateCtype() *WxUpsertOne {
+	return u.Update(func(s *WxUpsert) {
+		s.UpdateCtype()
+	})
+}
+
+// ClearCtype clears the value of the "ctype" field.
+func (u *WxUpsertOne) ClearCtype() *WxUpsertOne {
+	return u.Update(func(s *WxUpsert) {
+		s.ClearCtype()
+	})
+}
+
 // Exec executes the query.
 func (u *WxUpsertOne) Exec(ctx context.Context) error {
 	if len(u.create.conflict) == 0 {
@@ -1885,6 +1959,34 @@ func (u *WxUpsertBulk) UpdateGroupBlockList() *WxUpsertBulk {
 	})
 }
 
+// SetCtype sets the "ctype" field.
+func (u *WxUpsertBulk) SetCtype(v uint64) *WxUpsertBulk {
+	return u.Update(func(s *WxUpsert) {
+		s.SetCtype(v)
+	})
+}
+
+// AddCtype adds v to the "ctype" field.
+func (u *WxUpsertBulk) AddCtype(v uint64) *WxUpsertBulk {
+	return u.Update(func(s *WxUpsert) {
+		s.AddCtype(v)
+	})
+}
+
+// UpdateCtype sets the "ctype" field to the value that was provided on create.
+func (u *WxUpsertBulk) UpdateCtype() *WxUpsertBulk {
+	return u.Update(func(s *WxUpsert) {
+		s.UpdateCtype()
+	})
+}
+
+// ClearCtype clears the value of the "ctype" field.
+func (u *WxUpsertBulk) ClearCtype() *WxUpsertBulk {
+	return u.Update(func(s *WxUpsert) {
+		s.ClearCtype()
+	})
+}
+
 // Exec executes the query.
 func (u *WxUpsertBulk) Exec(ctx context.Context) error {
 	if u.create.err != nil {

+ 72 - 0
ent/wx_update.go

@@ -345,6 +345,33 @@ func (wu *WxUpdate) AppendGroupBlockList(s []string) *WxUpdate {
 	return wu
 }
 
+// SetCtype sets the "ctype" field.
+func (wu *WxUpdate) SetCtype(u uint64) *WxUpdate {
+	wu.mutation.ResetCtype()
+	wu.mutation.SetCtype(u)
+	return wu
+}
+
+// SetNillableCtype sets the "ctype" field if the given value is not nil.
+func (wu *WxUpdate) SetNillableCtype(u *uint64) *WxUpdate {
+	if u != nil {
+		wu.SetCtype(*u)
+	}
+	return wu
+}
+
+// AddCtype adds u to the "ctype" field.
+func (wu *WxUpdate) AddCtype(u int64) *WxUpdate {
+	wu.mutation.AddCtype(u)
+	return wu
+}
+
+// ClearCtype clears the value of the "ctype" field.
+func (wu *WxUpdate) ClearCtype() *WxUpdate {
+	wu.mutation.ClearCtype()
+	return wu
+}
+
 // SetServer sets the "server" edge to the Server entity.
 func (wu *WxUpdate) SetServer(s *Server) *WxUpdate {
 	return wu.SetServerID(s.ID)
@@ -529,6 +556,15 @@ func (wu *WxUpdate) sqlSave(ctx context.Context) (n int, err error) {
 			sqljson.Append(u, wx.FieldGroupBlockList, value)
 		})
 	}
+	if value, ok := wu.mutation.Ctype(); ok {
+		_spec.SetField(wx.FieldCtype, field.TypeUint64, value)
+	}
+	if value, ok := wu.mutation.AddedCtype(); ok {
+		_spec.AddField(wx.FieldCtype, field.TypeUint64, value)
+	}
+	if wu.mutation.CtypeCleared() {
+		_spec.ClearField(wx.FieldCtype, field.TypeUint64)
+	}
 	if wu.mutation.ServerCleared() {
 		edge := &sqlgraph.EdgeSpec{
 			Rel:     sqlgraph.M2O,
@@ -921,6 +957,33 @@ func (wuo *WxUpdateOne) AppendGroupBlockList(s []string) *WxUpdateOne {
 	return wuo
 }
 
+// SetCtype sets the "ctype" field.
+func (wuo *WxUpdateOne) SetCtype(u uint64) *WxUpdateOne {
+	wuo.mutation.ResetCtype()
+	wuo.mutation.SetCtype(u)
+	return wuo
+}
+
+// SetNillableCtype sets the "ctype" field if the given value is not nil.
+func (wuo *WxUpdateOne) SetNillableCtype(u *uint64) *WxUpdateOne {
+	if u != nil {
+		wuo.SetCtype(*u)
+	}
+	return wuo
+}
+
+// AddCtype adds u to the "ctype" field.
+func (wuo *WxUpdateOne) AddCtype(u int64) *WxUpdateOne {
+	wuo.mutation.AddCtype(u)
+	return wuo
+}
+
+// ClearCtype clears the value of the "ctype" field.
+func (wuo *WxUpdateOne) ClearCtype() *WxUpdateOne {
+	wuo.mutation.ClearCtype()
+	return wuo
+}
+
 // SetServer sets the "server" edge to the Server entity.
 func (wuo *WxUpdateOne) SetServer(s *Server) *WxUpdateOne {
 	return wuo.SetServerID(s.ID)
@@ -1135,6 +1198,15 @@ func (wuo *WxUpdateOne) sqlSave(ctx context.Context) (_node *Wx, err error) {
 			sqljson.Append(u, wx.FieldGroupBlockList, value)
 		})
 	}
+	if value, ok := wuo.mutation.Ctype(); ok {
+		_spec.SetField(wx.FieldCtype, field.TypeUint64, value)
+	}
+	if value, ok := wuo.mutation.AddedCtype(); ok {
+		_spec.AddField(wx.FieldCtype, field.TypeUint64, value)
+	}
+	if wuo.mutation.CtypeCleared() {
+		_spec.ClearField(wx.FieldCtype, field.TypeUint64)
+	}
 	if wuo.mutation.ServerCleared() {
 		edge := &sqlgraph.EdgeSpec{
 			Rel:     sqlgraph.M2O,

+ 31 - 0
internal/handler/WorkPhone/qx_refresh_handler.go

@@ -0,0 +1,31 @@
+package WorkPhone
+
+import (
+	"net/http"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
+
+	"wechat-api/internal/logic/WorkPhone"
+	"wechat-api/internal/svc"
+)
+
+// swagger:route post /workphone/Qxaccount/refresh WorkPhone QxRefresh
+//
+
+//
+
+//
+// Responses:
+//  200: BaseMsgResp
+
+func QxRefreshHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		l := WorkPhone.NewQxRefreshLogic(r.Context(), svcCtx)
+		resp, err := l.QxRefresh()
+		if err != nil {
+			httpx.ErrorCtx(r.Context(), w, err)
+		} else {
+			httpx.OkJsonCtx(r.Context(), w, resp)
+		}
+	}
+}

+ 5 - 0
internal/handler/routes.go

@@ -1627,6 +1627,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 					Path:    "/workphone/wxaccount/refresh",
 					Handler: WorkPhone.WxRefreshHandler(serverCtx),
 				},
+				{
+					Method:  http.MethodPost,
+					Path:    "/workphone/Qxaccount/refresh",
+					Handler: WorkPhone.QxRefreshHandler(serverCtx),
+				},
 			}...,
 		),
 		rest.WithJwt(serverCtx.Config.Auth.AccessSecret),

+ 45 - 0
internal/logic/WorkPhone/qx_refresh_logic.go

@@ -0,0 +1,45 @@
+package WorkPhone
+
+import (
+	"context"
+	"fmt"
+	"github.com/imroc/req/v3"
+	"github.com/suyuan32/simple-admin-common/msg/errormsg"
+	"time"
+	"wechat-api/internal/svc"
+	"wechat-api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type QxRefreshLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewQxRefreshLogic(ctx context.Context, svcCtx *svc.ServiceContext) *QxRefreshLogic {
+	return &QxRefreshLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx}
+}
+
+func (l *QxRefreshLogic) QxRefresh() (resp *types.BaseMsgResp, err error) {
+	var result types.WorkPhoneGetWeChatsResp
+	client := req.C().DevMode()
+	client.SetCommonRetryCount(2).
+		SetCommonRetryBackoffInterval(1*time.Second, 5*time.Second).
+		SetCommonRetryFixedInterval(2 * time.Second).SetTimeout(30 * time.Second)
+	res, err := client.R().SetSuccessResult(&result).Post("http://chat.gkscrm.com:15086/pc/GetWeChatsReq?id=13")
+
+	if err != nil {
+		return
+	}
+	if !res.IsSuccessState() {
+		err = fmt.Errorf("GetWeChats failed with status code %d", res.StatusCode)
+		return
+	}
+
+	return &types.BaseMsgResp{Msg: errormsg.Success}, nil
+}

+ 1 - 0
internal/logic/Wx/create_wx_logic.go

@@ -78,6 +78,7 @@ func (l *CreateWxLogic) CreateWx(req *types.WxInfo) (*types.BaseMsgResp, error)
 			SetNotNilAPIKey(req.ApiKey).
 			SetWxid(wxid).
 			SetStatus(0).
+			SetNotNilCtype(req.Ctype).
 			SetAllowList(stringSlice).
 			SetGroupAllowList(stringSlice).
 			SetBlockList(stringSlice).

+ 6 - 0
internal/logic/Wx/get_select_wx_list_logic.go

@@ -32,6 +32,11 @@ func (l *GetSelectWxListLogic) GetSelectWxList(req *types.WxSelectListReq) (resp
 	organizationId := l.ctx.Value("organizationId").(uint64)
 	isAdmin := l.ctx.Value("isAdmin").(bool)
 	var predicates []predicate.Wx
+	var ctype uint64 = 1
+	if req.Ctype != nil && *req.Ctype > 0 {
+		ctype = *req.Ctype
+	}
+	predicates = append(predicates, wx.Ctype(ctype))
 	if !isAdmin {
 		predicates = append(predicates, wx.OrganizationIDEQ(organizationId))
 	} else {
@@ -57,6 +62,7 @@ func (l *GetSelectWxListLogic) GetSelectWxList(req *types.WxSelectListReq) (resp
 					},
 					Wxid:     &wxid,
 					Nickname: &v.Nickname,
+					Ctype:    &v.Ctype,
 				})
 		}
 	}

+ 1 - 0
internal/logic/Wx/get_wx_by_id_logic.go

@@ -90,6 +90,7 @@ func (l *GetWxByIdLogic) GetWxById(req *types.IDReq) (resp *types.WxInfoResp, er
 			OrganizationId: &data.OrganizationID,
 			AgentId:        &data.AgentID,
 			AgentInfo:      &agent,
+			Ctype:          &data.Ctype,
 		},
 	}, nil
 }

+ 5 - 0
internal/logic/Wx/get_wx_list_logic.go

@@ -50,6 +50,10 @@ func (l *GetWxListLogic) GetWxList(req *types.WxListReq) (*types.WxListResp, err
 	}
 
 	var predicates []predicate.Wx
+	if req.Ctype != nil && *req.Ctype > 0 {
+		predicates = append(predicates, wx.Ctype(*req.Ctype))
+	}
+
 	if !isAdmin {
 		predicates = append(predicates, wx.OrganizationIDEQ(organizationId))
 	} else {
@@ -235,6 +239,7 @@ func (l *GetWxListLogic) GetWxList(req *types.WxListReq) (*types.WxListResp, err
 				ApiBase:          &v.APIBase,
 				ApiKey:           &v.APIKey,
 				TotalTokens:      &totalTokens,
+				Ctype:            &v.Ctype,
 			})
 	}
 

+ 7 - 1
internal/logic/contact/get_contact_list_logic.go

@@ -53,7 +53,12 @@ func (l *GetContactListLogic) GetContactList(req *types.ContactListReq) (*types.
 	organizationId := l.ctx.Value("organizationId").(uint64)
 	var predicates []predicate.Contact
 	predicates = append(predicates, contact.OrganizationIDEQ(organizationId))
-	predicates = append(predicates, contact.Ctype(1))
+
+	var ctype uint64 = 1
+	if req.Ctype != nil {
+		ctype = *req.Ctype
+	}
+	predicates = append(predicates, contact.Ctype(ctype))
 	if len(req.LabelIDs) > 0 {
 		predicates = append(predicates, contact.HasContactRelationshipsWith(
 			labelrelationship.HasLabelsWith(
@@ -78,6 +83,7 @@ func (l *GetContactListLogic) GetContactList(req *types.ContactListReq) (*types.
 	} else {
 		predicates = append(predicates, contact.Or(contact.TypeEQ(1), contact.TypeEQ(2)))
 	}
+
 	data, err := l.svcCtx.DB.Contact.Query().Where(predicates...).WithContactRelationships(func(query *ent.LabelRelationshipQuery) {
 		query.WithLabels()
 	}).Page(l.ctx, req.Page, req.PageSize)

+ 1 - 0
internal/logic/sop_task/sop_task_stop_logic.go

@@ -42,6 +42,7 @@ func (l *SopTaskStopLogic) SopTaskStop(req *types.IDReq) (resp *types.BaseMsgRes
 			soptask.IDEQ(req.Id),                   // Filter by ID
 			soptask.OrganizationID(organizationId), // Additional filter by organizationId
 		).
+		WithTaskStages().
 		Only(l.ctx)
 	if err != nil {
 		return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)

+ 8 - 0
internal/types/types.go

@@ -340,6 +340,7 @@ type WxInfo struct {
 	GroupBlockList []ContactInfo `json:"groupBlockList,optional"`
 	// 使用token总数
 	TotalTokens *uint64 `json:"totalTokens,optional"`
+	Ctype       *uint64 `json:"ctype,optional"`
 }
 
 // swagger:model UpdateBlockAndAllowListReq
@@ -387,6 +388,8 @@ type WxListReq struct {
 	ProcessId *string `json:"processId,optional"`
 	// 回调地址
 	Callback *string `json:"callback,optional"`
+	// 账号类型 1-个微 2-企微
+	Ctype *uint64 `json:"ctype,optional"`
 }
 
 // Get wx list request params | Wx列表请求参数
@@ -394,6 +397,8 @@ type WxListReq struct {
 type WxSelectListReq struct {
 	// 租户id
 	OrganizationId *uint64 `json:"organizationId,optional"`
+	// 账号类型 1-个微 2-企微
+	Ctype *uint64 `json:"ctype,optional"`
 }
 
 // The response data of wx list | Wx列表数据
@@ -411,6 +416,7 @@ type WxSelectListInfo struct {
 	Wxid *string `json:"wxid,optional"`
 	// 微信昵称
 	Nickname *string `json:"nickname,optional"`
+	Ctype    *uint64 `json:"ctype,optional"`
 }
 
 // Wx information response | Wx信息返回体
@@ -995,6 +1001,8 @@ type ContactListReq struct {
 	Nickname *string `json:"nickname,optional"`
 	// 联系人类型:1好友,2群组,3公众号,4企业微信联系人
 	Type *int `json:"type,optional"`
+	// 内容类型:1-个微 2-企微
+	Ctype *uint64 `json:"ctype,optional"`
 }
 
 // Contact information response | Contact信息返回体