package service import ( "context" "encoding/json" "errors" user "git.echinacities.com/mogfee/protoc-gen-kit/proto/v1" "git.echinacities.com/mogfee/protoc-gen-kit/xerrors" ) type UserService struct { user.UnimplementedUserServer } func (*UserService) Login(ctx context.Context, req *user.LoginRequest) (*user.LoginResponse, error) { return nil, xerrors.BadRequest("BadRequest", "B") b, _ := json.Marshal(req) return &user.LoginResponse{Token: string(b)}, nil } func (*UserService) List(ctx context.Context, req *user.LoginRequest) (*user.LoginResponse, error) { //fmt.Println(ctx.Value("userId")) //return nil, xerrors.InternalServer("InternalServer", "B") //b, _ := json.Marshal(req) return &user.LoginResponse{Token: ""}, nil } func (*UserService) Delete(ctx context.Context, req *user.LoginRequest) (*user.LoginResponse, error) { return nil, errors.New("bad err") b, _ := json.Marshal(req) return &user.LoginResponse{Token: string(b)}, nil }