diff --git a/go.mod b/go.mod index 2fc8159..ebe8cba 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.22.2 require ( github.com/go-sql-driver/mysql v1.8.1 github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 - github.com/pkusunjy/openai-server-proto v1.1.10 + github.com/pkusunjy/openai-server-proto v1.1.11 github.com/wechatpay-apiv3/wechatpay-go v0.2.18 google.golang.org/grpc v1.65.0 gopkg.in/natefinch/lumberjack.v2 v2.2.1 diff --git a/go.sum b/go.sum index b2c7faa..88631e9 100644 --- a/go.sum +++ b/go.sum @@ -16,8 +16,8 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/pkusunjy/openai-server-proto v1.1.10 h1:jcMMbrRsm/ycZSbXFJS054HdxhDMk5DhKtYM/7I6UR8= -github.com/pkusunjy/openai-server-proto v1.1.10/go.mod h1:Wy8DZHkU9TDe5/NvBxukAWoDfzclahb1y3B7+b+DaBI= +github.com/pkusunjy/openai-server-proto v1.1.11 h1:PUabIi+bBWhtxmkjKGFt69Mo0JgKimhg44g6M4GGa8s= +github.com/pkusunjy/openai-server-proto v1.1.11/go.mod h1:Wy8DZHkU9TDe5/NvBxukAWoDfzclahb1y3B7+b+DaBI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= diff --git a/service/auth/auth.go b/service/auth/auth.go index 6c20648..f6e8e3f 100644 --- a/service/auth/auth.go +++ b/service/auth/auth.go @@ -66,7 +66,7 @@ func (server AuthServiceImpl) GetOssToken(ctx context.Context, req *auth.AuthReq return &resp, nil } -func (server AuthServiceImpl) Jscode2Session(ctx context.Context, req *auth.AuthRequest) (*auth.AuthResponse, error) { +func (server AuthServiceImpl) Jscode2Session(ctx context.Context, req *auth.Code2SessionRequest) (*auth.Code2SessionResponse, error) { url := fmt.Sprintf(code2SessionUrl, server.WxAppID, server.WxSecret, req.Code) grpclog.Infof("code2session gen url: %s", url) code2SessionResp, err := http.DefaultClient.Get(url) @@ -75,17 +75,12 @@ func (server AuthServiceImpl) Jscode2Session(ctx context.Context, req *auth.Auth return nil, err } defer code2SessionResp.Body.Close() - var wxMap map[string]string - err = json.NewDecoder(code2SessionResp.Body).Decode(&wxMap) + resp := auth.Code2SessionResponse{} + err = json.NewDecoder(code2SessionResp.Body).Decode(&resp) if err != nil { grpclog.Errorf("code2session json decode fail, err:%v", err) return nil, err } - grpclog.Infof("code2session wxMap:%+v", wxMap) - resp := auth.AuthResponse{ - Openid: wxMap["openid"], - SessionKey: wxMap["session_key"], - Unionid: wxMap["unionid"], - } + grpclog.Infof("code2session resp:%+v", &resp) return &resp, nil }