Selaa lähdekoodia

Merge branch 'master' into debug

* master:
  优化
  将端口号 pc 开头的账号显示为本地版
  修复
  no message
boweniac 3 kuukautta sitten
vanhempi
commit
70adc6a4c4

+ 7 - 2
internal/logic/Wx/get_wx_list_logic.go

@@ -5,6 +5,7 @@ import (
 	"fmt"
 	reqv3 "github.com/imroc/req/v3"
 	"github.com/suyuan32/simple-admin-core/rpc/types/core"
+	"strings"
 	"wechat-api/ent"
 	"wechat-api/ent/predicate"
 	"wechat-api/ent/usagetotal"
@@ -105,7 +106,10 @@ func (l *GetWxListLogic) GetWxList(req *types.WxListReq) (*types.WxListResp, err
 	for _, v := range data.List {
 		// 创建 hookClient 客户端
 		serverInfo := serverSet[v.ServerID]
-
+		serverName := serverInfo.Name
+		if strings.HasPrefix(strings.ToUpper(v.Port), "PC-") {
+			serverName = "本地版"
+		}
 		var loginStatus uint8 = 0
 		hookClient := hook.NewHook(serverInfo.PrivateIP, serverInfo.AdminPort, v.Port)
 		if v.ServerID > 0 {
@@ -205,6 +209,7 @@ func (l *GetWxListLogic) GetWxList(req *types.WxListReq) (*types.WxListResp, err
 				Examples:   &v.Edges.Agent.Examples,
 			}
 		}
+
 		resp.Data.Data = append(resp.Data.Data,
 			types.WxInfo{
 				BaseIDInfo: types.BaseIDInfo{
@@ -214,7 +219,7 @@ func (l *GetWxListLogic) GetWxList(req *types.WxListReq) (*types.WxListResp, err
 				},
 				Status:           &loginStatus,
 				ServerId:         &v.ServerID,
-				ServerName:       &serverInfo.Name,
+				ServerName:       &serverName,
 				Port:             &v.Port,
 				ProcessId:        &processID,
 				Callback:         &v.Callback,

+ 4 - 1
internal/logic/Wxhook/get_friends_and_groups_logic.go

@@ -95,9 +95,9 @@ func (l *GetFriendsAndGroupsLogic) GetFriendsAndGroups(req *types.IDReq) (resp *
 					SetDontseeme(cast.ToInt(friend.Dontseeme)).
 					SetLag(friend.Lag).
 					SetV3(friend.V3).
+					SetOrganizationID(organizationId).
 					OnConflict().
 					UpdateNewValues().
-					SetOrganizationID(organizationId).
 					ID(l.ctx)
 				if err == nil {
 					lags := splitStringToIntArray(friend.Lag)
@@ -175,6 +175,7 @@ func (l *GetFriendsAndGroupsLogic) GetFriendsAndGroups(req *types.IDReq) (resp *
 					SetGname(chatroom.Gname).
 					SetMarkname(chatroom.Markname).
 					SetV3(chatroom.V3).
+					SetOrganizationID(organizationId).
 					OnConflict().
 					UpdateNewValues().
 					ID(l.ctx)
@@ -192,6 +193,7 @@ func (l *GetFriendsAndGroupsLogic) GetFriendsAndGroups(req *types.IDReq) (resp *
 					SetNickname(gh.Nickname).
 					SetMarkname(gh.Markname).
 					SetV3(gh.V3).
+					SetOrganizationID(organizationId).
 					OnConflict().
 					UpdateNewValues().
 					ID(l.ctx)
@@ -228,6 +230,7 @@ func (l *GetFriendsAndGroupsLogic) GetFriendsAndGroups(req *types.IDReq) (resp *
 				SetNickname(friend.Nickname).
 				SetHeadimg(friend.Avatar).
 				SetSex(cast.ToInt(friend.Gender)).
+				SetOrganizationID(organizationId).
 				OnConflict().
 				UpdateNewValues().
 				SetOrganizationID(organizationId).

+ 8 - 1
internal/logic/contact/add_new_friend_logic.go

@@ -2,6 +2,7 @@ package contact
 
 import (
 	"context"
+	"wechat-api/ent/predicate"
 	"wechat-api/hook"
 
 	"wechat-api/ent/wx"
@@ -27,7 +28,13 @@ func NewAddNewFriendLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddN
 
 func (l *AddNewFriendLogic) AddNewFriend(req *types.AddNewFriendReq) (*types.BaseMsgResp, error) {
 	organizationId := l.ctx.Value("organizationId").(uint64)
-	wxInfo, err := l.svcCtx.DB.Wx.Query().Where(wx.Wxid(req.OwnerWxid), wx.OrganizationIDEQ(organizationId)).First(l.ctx)
+	isAdmin := l.ctx.Value("isAdmin").(bool)
+	var predicates []predicate.Wx
+	predicates = append(predicates, wx.Wxid(req.OwnerWxid))
+	if !isAdmin {
+		predicates = append(predicates, wx.OrganizationIDEQ(organizationId))
+	}
+	wxInfo, err := l.svcCtx.DB.Wx.Query().Where(predicates...).First(l.ctx)
 	if err != nil {
 		l.Error("查询微信信息失败", err)
 		return nil, err

+ 2 - 0
internal/logic/contact/get_contact_list_logic.go

@@ -75,6 +75,8 @@ func (l *GetContactListLogic) GetContactList(req *types.ContactListReq) (*types.
 	}
 	if req.Type != nil {
 		predicates = append(predicates, contact.TypeEQ(*req.Type))
+	} 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()