|
@@ -3,9 +3,13 @@ package add_friend
|
|
|
import (
|
|
|
"context"
|
|
|
|
|
|
+ "wechat-api/internal/logic/chat"
|
|
|
+ "wechat-api/internal/service/addfriend"
|
|
|
"wechat-api/internal/svc"
|
|
|
"wechat-api/internal/types"
|
|
|
|
|
|
+ "github.com/suyuan32/simple-admin-common/enum/errorcode"
|
|
|
+ "github.com/suyuan32/simple-admin-common/msg/errormsg"
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
)
|
|
|
|
|
@@ -22,8 +26,52 @@ func NewAddFriendByPhoneLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
|
|
|
svcCtx: svcCtx}
|
|
|
}
|
|
|
|
|
|
+/*
|
|
|
+func getWeChatIds(ids any) []string {
|
|
|
+ nids := []string{}
|
|
|
+ switch rv := ids.(type) {
|
|
|
+ case []string:
|
|
|
+ nids = rv
|
|
|
+ case string:
|
|
|
+ nids = append(nids, rv)
|
|
|
+ }
|
|
|
+ return nids
|
|
|
+}
|
|
|
+*/
|
|
|
+
|
|
|
func (l *AddFriendByPhoneLogic) AddFriendByPhone(req *types.AddWechatFriendLogInfo) (resp *types.BaseMsgResp, err error) {
|
|
|
// todo: add your logic here and delete this line
|
|
|
|
|
|
- return
|
|
|
+ if req.Type != 2 {
|
|
|
+ req.Type = 1
|
|
|
+ }
|
|
|
+ if len(req.WeChatIds) == 0 {
|
|
|
+ req.WeChatIds = append(req.WeChatIds, "")
|
|
|
+ }
|
|
|
+ for _, wechatId := range req.WeChatIds {
|
|
|
+ nreq := &types.AddFriendByPhoneReq{Type: req.Type, WeChatId: wechatId, Phone: req.Phone, Message: req.Message}
|
|
|
+ //fmt.Println(typekit.PrettyPrint(nreq))
|
|
|
+ id, err := chat.AppendWechaFriendAddLog(l.ctx, l.svcCtx, nreq)
|
|
|
+ if err != nil {
|
|
|
+ logx.Errorf("chat.AppendWechaFriendAddLog err : %s", err)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ logx.Infof("chat.AppendWechaFriendAddLog succ,get id:%d",
|
|
|
+ id)
|
|
|
+
|
|
|
+ if req.Type != 1 {
|
|
|
+ continue //企微忽略后面
|
|
|
+ }
|
|
|
+ ret := addfriend.NewAddWechatFriendService(l.ctx, l.svcCtx).
|
|
|
+ FindFriendByContent(wechatId, req.Phone)
|
|
|
+ if ret {
|
|
|
+ logx.Infof("call addfriend.NewAddWechatFriendService.FindFriendByContent('%s','%s') maybe succ", wechatId, req.Phone)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resp = &types.BaseMsgResp{
|
|
|
+ Msg: errormsg.Success,
|
|
|
+ Code: errorcode.OK,
|
|
|
+ }
|
|
|
+
|
|
|
+ return resp, nil
|
|
|
}
|