From 530fed8ec225453572d57b15c200ab062c335457 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期三, 01 十一月 2023 19:20:21 +0800
Subject: [PATCH] 公海member_id使用0

---
 service/user.go |   46 ++++++++++------------------------------------
 1 files changed, 10 insertions(+), 36 deletions(-)

diff --git a/service/user.go b/service/user.go
index ad83ad2..923ccc2 100644
--- a/service/user.go
+++ b/service/user.go
@@ -1,19 +1,12 @@
 package service
 
 import (
-	"aps_crm/conf"
 	"aps_crm/constvar"
 	"aps_crm/model"
 	"aps_crm/pkg/ecode"
 	"aps_crm/pkg/encrypt"
-	"aps_crm/pkg/logx"
-	"aps_crm/proto/user"
-	"context"
 	"errors"
-	"google.golang.org/grpc"
-	"google.golang.org/grpc/credentials/insecure"
 	"gorm.io/gorm"
-	"time"
 )
 
 type UserService struct{}
@@ -97,39 +90,20 @@
 	})
 }
 
-func (userService *UserService) GetUserList() (userList []*model.User, err error) {
-	return model.NewUserSearch(nil).FindAll()
+func (userService *UserService) GetUserList(userIds []int) (userList []*model.User, err error) {
+	return model.NewUserSearch(nil).SetUserIds(userIds).FindAll()
 }
 
-var (
-	userConn *grpc.ClientConn
-)
-
-func InitUserConn() {
-	var err error
-	userConn, err = grpc.Dial(conf.Conf.GrpcServiceAddr.Aps, grpc.WithTransportCredentials(insecure.NewCredentials()))
+func (userService *UserService) UUID2CrmUserId(uuids []string) (crmUserIds []int, m map[string]int, err error) {
+	idPairs, err := model.NewUserSearch(nil).UUID2CrmUserId(uuids)
 	if err != nil {
-		logx.Errorf("grpc dial user service error: %v", err.Error())
 		return
 	}
-	defer userConn.Close()
-}
-
-func (userService *UserService) SyncUserInfo() (err error) {
-	cli := user.NewUserServiceClient(userConn)
-
-	users := []*user.User{
-		// ... fetched users
+	crmUserIds = make([]int, 0, len(idPairs))
+	m = make(map[string]int, len(idPairs))
+	for _, idPair := range idPairs {
+		crmUserIds = append(crmUserIds, idPair.ID)
+		m[idPair.UUID] = idPair.ID
 	}
-
-	ctx, cancel := context.WithTimeout(context.Background(), time.Second)
-	defer cancel()
-	r, err := cli.SyncUser(ctx, &user.UserRequest{Users: users})
-	if err != nil {
-		logx.Fatalf("could not sync users: %v", err)
-	}
-
-	logx.Infof("Synced: %v, Message: %s", r.List, r.Message)
-
-	return nil
+	return
 }

--
Gitblit v1.8.0