package im import ( "context" "git.beswell.com/gframe/application" "google.golang.org/grpc/metadata" "sportfitness/base/global" pb "sportfitness/base/repository/grpc/bsw/im/im" ) func getClient() pb.ApiClient { conn, err := application.GetServiceGrpcConn("bsw/im") if err != nil { panic(err) } client := pb.NewApiClient(conn) return client } func ctx() context.Context { md := metadata.Pairs("sys_token", global.SysToken) return metadata.NewOutgoingContext(context.Background(), md) } func SignUpUserCode(params *pb.SignUpRequest) (userId int64) { r, err := getClient().SignUpUserCode(ctx(), params) if err != nil { panic(err) } userId = r.GetId() return } func SignInUserCodePassword(userCode, password, ip, ClientInfo string) (token string, userId int) { r, err := getClient().SignInUserCode(ctx(), &pb.SignInPasswordRequest{ Credential: userCode, Password: password, ExpirationSec: global.TokenExpireSec, Ip: ip, ClientInfo: ClientInfo, }) if err != nil { panic(err) } token = r.Token userId = int(r.UserId) return }