| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- 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 GenVerifyImage(height, width int32) (id, imageBase64 string) {
- r, err := getClient().GenVerifyImage(ctx(), &pb.GenVerifyImageRequest{
- Height: int32(height),
- Width: int32(width),
- })
- if err != nil {
- panic(err)
- }
- id = r.CodeId
- imageBase64 = r.ImageBase64
- return
- }
- func SignInUserCodePassword(userCode, password, ip, ClientInfo, codeId, verifyCode string) (token string, userId int) {
- r, err := getClient().SignInUserCode(ctx(), &pb.SignInPasswordRequest{
- Credential: userCode,
- Password: password,
- ExpirationSec: global.TokenExpireSec,
- Ip: ip,
- ClientInfo: ClientInfo,
- CodeId: codeId,
- VerifyCode: verifyCode,
- })
- if err != nil {
- panic(err)
- }
- token = r.Token
- userId = int(r.UserId)
- return
- }
- func RegisterServiceList(servicePathList []string) {
- request := &pb.SaveServiceListRequest{}
- for _, p := range servicePathList {
- request.List = append(request.List, &pb.Service{
- Path: p,
- Memo: "自动添加",
- })
- }
- _, err := getClient().SubServiceSaveList(ctx(), request)
- if err != nil {
- panic(err)
- }
- }
|