You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
783 B

package service
import (
"context"
"github.com/go-kratos/kratos/v2/errors"
"map/internal/biz"
pb "map/api/mapService"
)
type MapServiceService struct {
pb.UnimplementedMapServiceServer
msbiz *biz.MapServiceBiz
}
func NewMapServiceService(mz *biz.MapServiceBiz) *MapServiceService {
return &MapServiceService{
msbiz: mz,
}
}
func (this *MapServiceService) GetDrivingInfo(ctx context.Context, req *pb.GetDrivingInfoReq) (*pb.GetDrivingInfoReply, error) {
distance, duration, err := this.msbiz.GetDriverInfo(req.Origin, req.Destination)
if err != nil {
return nil, errors.New(200, "LBS_ERROR", "lbs api error")
}
return &pb.GetDrivingInfoReply{
Origin: req.Origin,
Destination: req.Destination,
Distance: distance,
Duration: duration,
}, nil
}