|
@@ -3,6 +3,7 @@ package Wxhook
|
|
|
import (
|
|
|
"context"
|
|
|
"github.com/zeromicro/go-zero/core/errorx"
|
|
|
+ "wechat-api/ent/wx"
|
|
|
"wechat-api/hook"
|
|
|
|
|
|
"wechat-api/internal/svc"
|
|
@@ -26,6 +27,11 @@ func NewRefreshLoginQRLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Re
|
|
|
}
|
|
|
|
|
|
func (l *RefreshLoginQRLogic) RefreshLoginQR(req *types.RefreshLoginQRReq) (resp *types.RefreshLoginQRResp, err error) {
|
|
|
+ wxInfo, err := l.svcCtx.DB.Wx.Query().Where(wx.ServerIDEQ(*req.ServerId)).Where(wx.PortEQ(*req.Port)).Limit(1).Only(l.ctx)
|
|
|
+ if err != nil {
|
|
|
+ l.Error("查询微信信息失败", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
// 获取服务器信息
|
|
|
server, err := l.svcCtx.DB.Server.Get(l.ctx, *req.ServerId)
|
|
@@ -34,7 +40,7 @@ func (l *RefreshLoginQRLogic) RefreshLoginQR(req *types.RefreshLoginQRReq) (resp
|
|
|
return
|
|
|
}
|
|
|
hookClient := hook.NewHook(server.PrivateIP, server.AdminPort, *req.Port)
|
|
|
-
|
|
|
+ _, _ = hookClient.TerminateThisWeChat(wxInfo.ProcessID)
|
|
|
// 如端口未被占用则启动微信
|
|
|
portOccupied, err := hookClient.GetPortOccupiedInfo(*req.Port)
|
|
|
if err != nil {
|